test suite reviews and discussions
 help / color / mirror / Atom feed
From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH 2/6] framework packet: only sniff coming packet when tcpdump support
Date: Mon, 11 Jan 2016 15:05:36 +0800	[thread overview]
Message-ID: <1452495940-9681-2-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1452495940-9681-1-git-send-email-yong.liu@intel.com>

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 <yong.liu@intel.com>

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

  reply	other threads:[~2016-01-11  7:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11  7:05 [dts] [PATCH 1/6] framework tester: NIC object get from net_device module Yong Liu
2016-01-11  7:05 ` Yong Liu [this message]
2016-01-11  7:05 ` [dts] [PATCH 3/6] framework pmd_output: support quit command of testpmd Yong Liu
2016-01-11  7:05 ` [dts] [PATCH 4/6] tests vf_vlan: add VF vlan test plan Yong Liu
2016-01-18  1:30   ` Xu, Qian Q
2016-01-18  7:48     ` Liu, Yong
2016-01-11  7:05 ` [dts] [PATCH 5/6] tests vf_vlan: add test suite for VF vlan validation Yong Liu
2016-01-18  1:37   ` Xu, Qian Q
2016-01-11  7:05 ` [dts] [PATCH 6/6] conf vf_vlan: add configuration file for VF vlan Yong Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452495940-9681-2-git-send-email-yong.liu@intel.com \
    --to=yong.liu@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).