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/4] Add vxlan protocal support in etgen module
Date: Mon,  8 Jun 2015 10:21:26 +0800	[thread overview]
Message-ID: <1433730088-5601-3-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1433730088-5601-1-git-send-email-yong.liu@intel.com>

From: Marvin Liu <yong.liu@intel.com>

Inner packets can not be handled like normal packet. Now parse_pcap function
will strip vxlan inner packet and convert it to hex string. This hex string
will be configured to dataBytes of protocolPad.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/etgen.py b/framework/etgen.py
index 8270f24..fc64b70 100644
--- a/framework/etgen.py
+++ b/framework/etgen.py
@@ -189,11 +189,34 @@ class IxiaPacketGenerator(SSHConnection):
         self.send_expect("clearOwnershipAndLogout", "% ")
 
     def parse_pcap(self, fpcap):
-        """
-        Parse packet in pcap file and convert it into tcl commands.
-        """
-        self.send_expect("echo {print [i.command() for i in rdpcap('%s', -1)]; exit()} > dumppcap.py" %
-                         fpcap, "% ")
+        dump_str1 = "cmds = []\n"
+        dump_str2 = "for i in rdpcap('%s', -1):\n" % fpcap
+        dump_str3 = "    if 'Vxlan' in i.command():\n" + \
+                    "        vxlan_str = ''\n" + \
+                    "        l = len(i[Vxlan])\n" + \
+                    "        vxlan = str(i[Vxlan])\n" + \
+                    "        first = True\n" + \
+                    "        for j in range(l):\n" + \
+                    "            if first:\n" + \
+                    "                vxlan_str += \"Vxlan(hexval='%02X\" %ord(vxlan[j])\n" + \
+                    "                first = False\n" + \
+                    "            else:\n" + \
+                    "                vxlan_str += \" %02X\" %ord(vxlan[j])\n" + \
+                    "        vxlan_str += \"\')\"\n" + \
+                    "        command = re.sub(r\"Vxlan(.*)\", vxlan_str, i.command())\n" + \
+                    "    else:\n" + \
+                    "        command = i.command()\n" + \
+                    "    cmds.append(command)\n" + \
+                    "print cmds\n" + \
+                    "exit()"
+
+        f = open("dumppcap.py", "w")
+        f.write(dump_str1)
+        f.write(dump_str2)
+        f.write(dump_str3)
+        f.close()
+
+        self.session.copy_file_to("dumppcap.py")
         out = self.send_expect("scapy -c dumppcap.py 2>/dev/null", "% ", 120)
         flows = eval(out)
         return flows
@@ -254,7 +277,15 @@ class IxiaPacketGenerator(SSHConnection):
         self.add_tcl_cmd("udp config -sourcePort %d" % sport)
         self.add_tcl_cmd("udp config -destPort %d" % dport)
         self.add_tcl_cmd("udp config -length %d" % len)
-        self.add_tcl_cmd("udp set %d %d %d" % (self.chasId, port['card'], port['port']))
+        self.add_tcl_cmd("udp set %d %d %d" %
+                         (self.chasId, port['card'], port['port']))
+
+    def vxlan(self, port, hexval):
+        self.add_tcl_cmd("protocolPad setDefault")
+        self.add_tcl_cmd("protocol config -enableProtocolPad true")
+        self.add_tcl_cmd("protocolPad config -dataBytes \"%s\"" % hexval)
+        self.add_tcl_cmd("protocolPad set %d %d %d" %
+                         (self.chasId, port['card'], port['port']))
 
     def tcp(self, port, sport, dport, seq, ack, dataofs, reserved, flags, window, chksum, urgptr, options=None):
         """
@@ -297,6 +328,10 @@ class IxiaPacketGenerator(SSHConnection):
                 match = pat.match(header)
                 params = eval('dict(%s)' % match.group(2))
                 method_name = match.group(1)
+                if method_name == 'Vxlan':
+                    method = getattr(self, method_name.lower())
+                    method(txport, **params)
+                    break
                 if method_name in SCAPY2IXIA:
                     method = getattr(self, method_name.lower())
                     method(txport, **params)
diff --git a/framework/settings.py b/framework/settings.py
index 2eccc64..19ebe6b 100644
--- a/framework/settings.py
+++ b/framework/settings.py
@@ -124,7 +124,8 @@ HEADER_SIZE = {
     'ip': 20,
     'ipv6': 40,
     'udp': 8,
-    'tcp': 20
+    'tcp': 20,
+    'vxlan': 8,
 }
 
 
-- 
1.9.3

  parent reply	other threads:[~2015-06-08  2:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-08  2:21 [dts] [PATCH 0/4] Add vxlan function and performance suite Yong Liu
2015-06-08  2:21 ` [dts] [PATCH 1/4] Optimize get core list function for Haswell cpu Yong Liu
2015-06-08  2:21 ` Yong Liu [this message]
2015-06-08  2:21 ` [dts] [PATCH 3/4] Add vxlan test plan Yong Liu
2015-06-08  2:21 ` [dts] [PATCH 4/4] Add vxlan test suite Yong Liu
2015-06-09  6:38 ` [dts] [PATCH] Enhance vxlan checksum offload performance test case 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=1433730088-5601-3-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).