* [dts] [PATCH V1]used tcpdump replace scapy get packet
@ 2015-11-13 6:09 xu,huilong
2015-11-13 9:21 ` Liu, Yong
0 siblings, 1 reply; 2+ messages in thread
From: xu,huilong @ 2015-11-13 6:09 UTC (permalink / raw)
To: dts
sometime used scapy get packet, the pcaket payload will loss. so used tcpdump get packet.
Signed-off-by: xu,huilong <huilongx.xu@intel.com>
---
tests/TestSuite_scatter.py | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/tests/TestSuite_scatter.py b/tests/TestSuite_scatter.py
index 7a49b53..7f39d8a 100644
--- a/tests/TestSuite_scatter.py
+++ b/tests/TestSuite_scatter.py
@@ -61,6 +61,14 @@ class TestScatter(TestCase):
else:
self.mbsize = 1024
+ def start_tcpdump(self, tester_rx_intf):
+ self.tester.send_expect("rm -rf ./scatter.cap", "#")
+ self.tester.send_expect("tcpdump -i %s -x -w ./scatter.cap 2>/dev/null &" % tester_rx_intf, "#")
+
+ def get_tcpdump_packet(self):
+ self.tester.send_expect("killall tcpdump", "#")
+ return self.tester.send_expect("tcpdump -nn -x -r ./scatter.cap", "#")
+
def scatter_pktgen_send_packet(self, sPortid, rPortid, pktsize, num=1):
"""
Functional test for scatter packets.
@@ -73,21 +81,17 @@ class TestScatter(TestCase):
rintf = self.tester.get_interface(rport)
self.tester.send_expect("ifconfig %s mtu 9000" % sintf, "#")
self.tester.send_expect("ifconfig %s mtu 9000" % rintf, "#")
-
- self.tester.scapy_background()
- self.tester.scapy_append(
- 'p = sniff(filter="ip",iface="%s", count=%d)' % (rintf, num))
- self.tester.scapy_append('RESULT = str(p)')
+ self.start_tcpdump(rintf)
pktlen = pktsize - 18
padding = pktlen - 20
- self.tester.scapy_foreground()
self.tester.scapy_append(
'sendp([Ether(src="%s",dst="%s")/IP(len=%s)/Raw(load="\x50"*%s)], iface="%s")' % (smac, dmac,pktlen, padding, sintf))
self.tester.scapy_execute()
- time.sleep(5)
- res = self.tester.scapy_get_result()
+ time.sleep(5) #wait for scapy capture subprocess exit
+ res = self.get_tcpdump_packet()
+
self.tester.send_expect("ifconfig %s mtu 1500" % sintf, "#")
self.tester.send_expect("ifconfig %s mtu 1500" % sintf, "#")
return res
@@ -118,7 +122,7 @@ class TestScatter(TestCase):
for offset in [-1, 0, 1, 4, 5]:
ret = self.scatter_pktgen_send_packet(
dutPorts[0], dutPorts[1], self.mbsize + offset)
- self.verify("load='P" in ret, "packet receive error")
+ self.verify("5050 5050 5050 5050 5050 5050 5050" in ret, "packet receive error")
self.dut.send_expect("stop", "testpmd> ")
self.dut.send_expect("quit", "# ", 30)
--
1.9.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dts] [PATCH V1]used tcpdump replace scapy get packet
2015-11-13 6:09 [dts] [PATCH V1]used tcpdump replace scapy get packet xu,huilong
@ 2015-11-13 9:21 ` Liu, Yong
0 siblings, 0 replies; 2+ messages in thread
From: Liu, Yong @ 2015-11-13 9:21 UTC (permalink / raw)
To: xu,huilong, dts
Applied with comment optimized. Thanks.
On 11/13/2015 02:09 PM, xu,huilong wrote:
> sometime used scapy get packet, the pcaket payload will loss. so used tcpdump get packet.
>
> Signed-off-by: xu,huilong <huilongx.xu@intel.com>
> ---
> tests/TestSuite_scatter.py | 22 +++++++++++++---------
> 1 file changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/tests/TestSuite_scatter.py b/tests/TestSuite_scatter.py
> index 7a49b53..7f39d8a 100644
> --- a/tests/TestSuite_scatter.py
> +++ b/tests/TestSuite_scatter.py
> @@ -61,6 +61,14 @@ class TestScatter(TestCase):
> else:
> self.mbsize = 1024
>
> + def start_tcpdump(self, tester_rx_intf):
> + self.tester.send_expect("rm -rf ./scatter.cap", "#")
> + self.tester.send_expect("tcpdump -i %s -x -w ./scatter.cap 2>/dev/null &" % tester_rx_intf, "#")
> +
> + def get_tcpdump_packet(self):
> + self.tester.send_expect("killall tcpdump", "#")
> + return self.tester.send_expect("tcpdump -nn -x -r ./scatter.cap", "#")
> +
> def scatter_pktgen_send_packet(self, sPortid, rPortid, pktsize, num=1):
> """
> Functional test for scatter packets.
> @@ -73,21 +81,17 @@ class TestScatter(TestCase):
> rintf = self.tester.get_interface(rport)
> self.tester.send_expect("ifconfig %s mtu 9000" % sintf, "#")
> self.tester.send_expect("ifconfig %s mtu 9000" % rintf, "#")
> -
> - self.tester.scapy_background()
> - self.tester.scapy_append(
> - 'p = sniff(filter="ip",iface="%s", count=%d)' % (rintf, num))
> - self.tester.scapy_append('RESULT = str(p)')
> + self.start_tcpdump(rintf)
>
> pktlen = pktsize - 18
> padding = pktlen - 20
>
> - self.tester.scapy_foreground()
> self.tester.scapy_append(
> 'sendp([Ether(src="%s",dst="%s")/IP(len=%s)/Raw(load="\x50"*%s)], iface="%s")' % (smac, dmac,pktlen, padding, sintf))
> self.tester.scapy_execute()
> - time.sleep(5)
> - res = self.tester.scapy_get_result()
> + time.sleep(5) #wait for scapy capture subprocess exit
> + res = self.get_tcpdump_packet()
> +
> self.tester.send_expect("ifconfig %s mtu 1500" % sintf, "#")
> self.tester.send_expect("ifconfig %s mtu 1500" % sintf, "#")
> return res
> @@ -118,7 +122,7 @@ class TestScatter(TestCase):
> for offset in [-1, 0, 1, 4, 5]:
> ret = self.scatter_pktgen_send_packet(
> dutPorts[0], dutPorts[1], self.mbsize + offset)
> - self.verify("load='P" in ret, "packet receive error")
> + self.verify("5050 5050 5050 5050 5050 5050 5050" in ret, "packet receive error")
>
> self.dut.send_expect("stop", "testpmd> ")
> self.dut.send_expect("quit", "# ", 30)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-13 9:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-13 6:09 [dts] [PATCH V1]used tcpdump replace scapy get packet xu,huilong
2015-11-13 9:21 ` Liu, Yong
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).