From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH] framework tester: fix promisc and enhance random check function
Date: Thu, 28 Jan 2016 15:56:59 +0800 [thread overview]
Message-ID: <1453967819-22027-1-git-send-email-yong.liu@intel.com> (raw)
NetDevice should not use any more, all network object should get from
net_device module.
Show helpful message in packet random check function, transmit/sniff
pcap will saved for later compare.
Signed-off-by: Marvin Liu <yong.liu@intel.com>
diff --git a/framework/tester.py b/framework/tester.py
index 2a18712..5184d73 100644
--- a/framework/tester.py
+++ b/framework/tester.py
@@ -42,6 +42,7 @@ from net_device import GetNicObj
from etgen import IxiaPacketGenerator, SoftwarePacketGenerator
from settings import IXIA
import random
+from utils import GREEN
class Tester(Crb):
@@ -216,7 +217,7 @@ class Tester(Crb):
try:
for (pci_bus, pci_id) in self.pci_devices_info:
addr_array = pci_bus.split(':')
- port = NetDevice(self, addr_array[0], addr_array[1])
+ port = GetNicObj(self, addr_array[0], addr_array[1])
itf = port.get_interface_name()
self.enable_promisc(itf)
except Exception as e:
@@ -483,6 +484,8 @@ class Tester(Crb):
sniff_f = getattr(module, "sniff_packets")
load_f = getattr(module, "load_sniff_packets")
compare_f = getattr(module, "compare_pktload")
+ strip_f = getattr(module, "strip_pktload")
+ save_f = getattr(module, "save_packets")
pkts = []
# packet type random between tcp/udp/ipv6
random_type = ['TCP', 'UDP', 'IPv6_TCP', 'IPv6_UDP']
@@ -492,6 +495,7 @@ class Tester(Crb):
for txport, rxport in portList:
txIntf = self.get_interface(txport)
rxIntf = self.get_interface(rxport)
+ print GREEN("Preparing transmit packets, please wait few minutes...")
for num in range(pktnum):
# chose random packet
pkt_type = random.choice(random_type)
@@ -511,6 +515,7 @@ class Tester(Crb):
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)
send_f(intf=txIntf, pkts=pkts, interval=interval)
recv_pkts = load_f(inst)
@@ -523,11 +528,14 @@ class Tester(Crb):
return False
# check each received packet content
+ print GREEN("Comparing sniff packets, please wait few minutes...")
for idx in range(len(recv_pkts)):
t_idx = recv_pkts[idx].strip_element_layer4('src')
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)
+ print "Sent: %s" % strip_f(pkts[t_idx], "L4")
+ print "Recv: %s" % strip_f(recv_pkts[idx], "L4")
return False
return True
--
1.8.4.2
reply other threads:[~2016-01-28 7:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1453967819-22027-1-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).