From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id AA22CE62 for ; Mon, 11 Jan 2016 08:05:50 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 10 Jan 2016 23:05:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,551,1444719600"; d="scan'208";a="27175231" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga004.fm.intel.com with ESMTP; 10 Jan 2016 23:05:48 -0800 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id u0B75kZF013000; Mon, 11 Jan 2016 15:05:46 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id u0B75iHH009724; Mon, 11 Jan 2016 15:05:46 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id u0B75hP3009720; Mon, 11 Jan 2016 15:05:43 +0800 From: Yong Liu To: dts@dpdk.org Date: Mon, 11 Jan 2016 15:05:36 +0800 Message-Id: <1452495940-9681-2-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1452495940-9681-1-git-send-email-yong.liu@intel.com> References: <1452495940-9681-1-git-send-email-yong.liu@intel.com> Subject: [dts] [PATCH 2/6] framework packet: only sniff coming packet when tcpdump support X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jan 2016 07:05:51 -0000 Newer version tcpdump support capture packet by direction. This feature will help us distinguish coming packets and outgoing packets. And will be helpful when only one nic available on tester. Signed-off-by: Marvin Liu diff --git a/framework/packet.py b/framework/packet.py index 6d16a9e..aaa1dd0 100755 --- a/framework/packet.py +++ b/framework/packet.py @@ -639,8 +639,20 @@ def sniff_packets(intf, count=0, timeout=5): """ sniff all packets for certain port in certain seconds """ - sniff_cmd = 'tcpdump -i %(INTF)s -w %(FILE)s' - options = {'INTF': intf, 'COUNT': count, + param = "" + direct_param = r"(\s+)\[ -(\w) in\|out\|inout \]" + tcpdump_help = subprocess.check_output("tcpdump -h; echo 0", + stderr=subprocess.STDOUT, shell=True) + for line in tcpdump_help.split('\n'): + m = re.match(direct_param, line) + if m: + param = "-" + m.group(2) + " in" + + if len(param) == 0: + print "tcpdump not support direction chioce!!!" + + sniff_cmd = 'tcpdump -i %(INTF)s %(IN_PARAM)s -w %(FILE)s' + options = {'INTF': intf, 'COUNT': count, 'IN_PARAM': param, 'FILE': '/tmp/sniff_%s.pcap' % intf} if count: sniff_cmd += ' -c %(COUNT)d' -- 1.9.3