From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 6BBDEBB0A for ; Wed, 26 Oct 2016 09:00:55 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP; 26 Oct 2016 00:00:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,549,1473145200"; d="scan'208";a="183935039" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga004.fm.intel.com with ESMTP; 26 Oct 2016 00:00:53 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id u9Q70p0N015608; Wed, 26 Oct 2016 15:00:51 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id u9Q70nEZ017883; Wed, 26 Oct 2016 15:00:51 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id u9Q70nj7017879; Wed, 26 Oct 2016 15:00:49 +0800 From: Marvin Liu To: dts@dpdk.org Date: Wed, 26 Oct 2016 15:00:41 +0800 Message-Id: <1477465241-17826-4-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1477465241-17826-1-git-send-email-yong.liu@intel.com> References: <1477465241-17826-1-git-send-email-yong.liu@intel.com> Subject: [dts] [PATCH 3/3] framework tester: workaround random packet check issue X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Oct 2016 07:00:56 -0000 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 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