From: Marvin Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH 3/3] framework tester: workaround random packet check issue
Date: Wed, 26 Oct 2016 15:00:41 +0800 [thread overview]
Message-ID: <1477465241-17826-4-git-send-email-yong.liu@intel.com> (raw)
In-Reply-To: <1477465241-17826-1-git-send-email-yong.liu@intel.com>
Random packet check maybe failed for scapy can't correct handle some
types of protocals. Make a workaround of this issue. Packet index will
be saved in source ip address. Source and destination ports will be hard
code to 65535.
Signed-off-by: Marvin Liu <yong.liu@intel.com>
diff --git a/framework/tester.py b/framework/tester.py
index b95cfc3..55395a8 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -42,7 +42,7 @@ from net_device import GetNicObj
from etgen import IxiaPacketGenerator, SoftwarePacketGenerator
from settings import IXIA
import random
-from utils import GREEN
+from utils import GREEN, convert_int2ip, convert_ip2int
from exception import ParameterInvalidException
@@ -557,16 +557,25 @@ class Tester(Crb):
for param in params:
layer, config = param
pkt.config_layer(layer, config)
- # sequence saved in layer4 source port
+ # hardcode src/dst port for some protocal may cause issue
if "TCP" in pkt_type:
- pkt.config_layer('tcp', {'src': num % 65536})
+ pkt.config_layer('tcp', {'src': 65535, 'dst': 65535})
else:
- pkt.config_layer('udp', {'src': num % 65536})
+ pkt.config_layer('udp', {'src': 65535, 'dst': 65535})
+ # sequence saved in layer3 source ip
+ if "IPv6" in pkt_type:
+ ip_str = convert_int2ip(num, 6)
+ pkt.config_layer('ipv6', {'src': ip_str})
+ else:
+ ip_str = convert_int2ip(num, 4)
+ pkt.config_layer('ipv4', {'src': ip_str})
+
pkts.append(pkt)
# send and sniff packets
save_f(pkts=pkts, filename="/tmp/%s_tx.pcap" % txIntf)
inst = sniff_f(intf=rxIntf, count=pktnum, timeout=timeout)
+ print GREEN("Transmitting and sniffing packets, please wait few minutes...")
send_f(intf=txIntf, pkts=pkts, interval=interval)
recv_pkts = load_f(inst)
@@ -578,9 +587,19 @@ class Tester(Crb):
return False
# check each received packet content
- print GREEN("Comparing sniff packets, please wait few minutes...")
+ print GREEN("Comparing sniffed packets, please wait few minutes...")
for idx in range(len(recv_pkts)):
- t_idx = recv_pkts[idx].strip_element_layer4('src')
+ l3_type = recv_pkts[idx].strip_element_layer2('type')
+ sip = recv_pkts[idx].strip_element_layer3('src')
+ # ipv4 packet
+ if l3_type == 2048:
+ t_idx = convert_ip2int(sip, 4)
+ # ipv6 packet
+ elif l3_type == 34525:
+ t_idx = convert_ip2int(sip, 6)
+ else:
+ continue
+
if compare_f(pkts[t_idx], recv_pkts[idx], "L4") is False:
print "Pkt recevied index %d not match original " \
"index %d" % (idx, t_idx)
--
1.9.3
prev parent reply other threads:[~2016-10-26 7:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-26 7:00 [dts] [PATCH 0/3] enable random packet check function Marvin Liu
2016-10-26 7:00 ` [dts] [PATCH 1/3] framework utils: add function to convert ipaddress Marvin Liu
2016-10-26 7:00 ` [dts] [PATCH 2/3] framework packet: support ip layer elements strip Marvin Liu
2016-10-26 7:00 ` Marvin Liu [this message]
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=1477465241-17826-4-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).