From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id A8A058E68 for ; Tue, 19 Jan 2016 02:38:28 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 18 Jan 2016 17:38:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,315,1449561600"; d="scan'208";a="635771403" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 18 Jan 2016 17:38:26 -0800 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id u0J1cPc5013728; Tue, 19 Jan 2016 09:38:25 +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 u0J1cNuD001675; Tue, 19 Jan 2016 09:38:25 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id u0J1cMbr001671; Tue, 19 Jan 2016 09:38:22 +0800 From: Yong Liu To: dts@dpdk.org Date: Tue, 19 Jan 2016 09:38:07 +0800 Message-Id: <1453167491-1632-2-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1453167491-1632-1-git-send-email-yong.liu@intel.com> References: <1453167491-1632-1-git-send-email-yong.liu@intel.com> Subject: [dts] [PATCH v2 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: Tue, 19 Jan 2016 01:38:29 -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