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 31FAF2C72 for ; Mon, 15 Feb 2016 02:55:44 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 14 Feb 2016 17:55:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,448,1449561600"; d="scan'208";a="746389022" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga003.jf.intel.com with ESMTP; 14 Feb 2016 17:55:42 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 14 Feb 2016 17:55:42 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.248.2; Sun, 14 Feb 2016 17:55:42 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.249]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.117]) with mapi id 14.03.0248.002; Mon, 15 Feb 2016 09:55:33 +0800 From: "Xu, HuilongX" To: "Xu, HuilongX" , "dts@dpdk.org" Thread-Topic: [DTS][PATCH V1 2/2] creat a pcap file include 2000 random packet, used scapy send the pcap, and check dut not loss packet Thread-Index: AQHRXvvk/4B6WBIv80y08krt5YV1S58saZXg Date: Mon, 15 Feb 2016 01:55:33 +0000 Message-ID: References: <1454556122-16292-1-git-send-email-huilongx.xu@intel.com> <1454556122-16292-2-git-send-email-huilongx.xu@intel.com> In-Reply-To: <1454556122-16292-2-git-send-email-huilongx.xu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [DTS][PATCH V1 2/2] creat a pcap file include 2000 random packet, used scapy send the pcap, and check dut not loss packet 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: Mon, 15 Feb 2016 01:55:44 -0000 Hi all, Could you have time, review this patch and give me some comments. Thanks a lot > -----Original Message----- > From: Xu, HuilongX > Sent: Thursday, February 04, 2016 11:22 AM > To: dts@dpdk.org > Cc: Xu, HuilongX > Subject: [DTS][PATCH V1 2/2] creat a pcap file include 2000 random packet= , > used scapy send the pcap, and check dut not loss packet >=20 > Signed-off-by: xu,huilong > --- > tests/TestSuite_pmd.py | 55 > +++++++++++++++++++++++++++++++++++++++++++++----- > 1 file changed, 50 insertions(+), 5 deletions(-) >=20 > diff --git a/tests/TestSuite_pmd.py b/tests/TestSuite_pmd.py > index eeec53f..7a8df89 100644 > --- a/tests/TestSuite_pmd.py > +++ b/tests/TestSuite_pmd.py > @@ -1,6 +1,6 @@ > # BSD LICENSE > # > -# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. > +# Copyright(c) 2010-2016 Intel Corporation. All rights reserved. > # All rights reserved. > # > # Redistribution and use in source and binary forms, with or without > @@ -37,12 +37,14 @@ Test userland 10Gb PMD > import dts > import re > import time > +import random > from test_case import TestCase > from plotting import Plotting > from time import sleep > from settings import HEADER_SIZE > from pmd_output import PmdOutput > from etgen import IxiaPacketGenerator > +from scapy.all import * >=20 > class TestPmd(TestCase,IxiaPacketGenerator): >=20 > @@ -81,6 +83,8 @@ class TestPmd(TestCase,IxiaPacketGenerator): > self.frame_sizes =3D [64, 65, 128, 256, 512, 1024, 1280, 1518] >=20 > self.rxfreet_values =3D [0, 8, 16, 32, 64, 128] > + > + self.total_packets =3D 2000 >=20 > self.test_cycles =3D [{'cores': '1S/1C/1T', 'Mpps': {}, 'pct': {= }}, > {'cores': '1S/2C/1T', 'Mpps': {}, 'pct': {}}= , > @@ -113,7 +117,37 @@ class TestPmd(TestCase,IxiaPacketGenerator): > Run before each test case. > """ > pass > - > + def random_ip(self, iptype): > + tmp =3D [] > + if 'ipv4' =3D=3D iptype: > + for i in range(4): > + tmp.append(str(random.randint(10, 254))) > + return '.'.join(tmp) > + if 'ipv6' =3D=3D iptype: > + for i in range(8): > + tmp.append(str(hex(random.randint(0, 65535)))[2:]) > + return ':'.join(tmp) > + else: > + self.logger.warning("invalid ip type: %s" % iptype) > + def creat_pcap(self, filename, dst_mac, tx_intf): > + packets =3D [] > + packet_type =3D [Ether(dst=3D"%s" % dst_mac, > src=3Dget_if_hwaddr(tx_intf))/IP(src=3D"%s" % self.random_ip("ipv4"), > dst=3D"%s" % self.random_ip("ipv4"))/("X"), #ipv4 packet > + Ether(dst=3D"%s" % dst_mac, > src=3Dget_if_hwaddr(tx_intf))/IP(src=3D"%s" % self.random_ip("ipv4"), > dst=3D"%s" % self.random_ip("ipv4"))/TCP()/("X"), #ipv4 tcp packet > + Ether(dst=3D"%s" % dst_mac, > src=3Dget_if_hwaddr(tx_intf))/IP(src=3D"%s" % self.random_ip("ipv4"), > dst=3D"%s" % self.random_ip("ipv4"))/UDP()/("X"), #ipv4 udp packet > + Ether(dst=3D"%s" % dst_mac, > src=3Dget_if_hwaddr(tx_intf))/IP(src=3D"%s" % self.random_ip("ipv4"), > dst=3D"%s" % self.random_ip("ipv4"))/SCTP(tag=3D1)/("X"),#ipv4 sctp packe= t > + Ether(dst=3D"%s" % dst_mac, > src=3Dget_if_hwaddr(tx_intf))/("X"), # l2 packet > + Ether(dst=3D"%s" % dst_mac, > src=3Dget_if_hwaddr(tx_intf))/IPv6(src=3D"%s" % self.random_ip("ipv6"), > dst=3D"%s" % self.random_ip("ipv6"))/("X"), # ipv6 packet > + Ether(dst=3D"%s" % dst_mac, > src=3Dget_if_hwaddr(tx_intf))/IPv6(src=3D"%s" % self.random_ip("ipv6"), > dst=3D"%s" % self.random_ip("ipv6"))/UDP()/("X"), #ipv6 udp packet > + Ether(dst=3D"%s" % dst_mac, > src=3Dget_if_hwaddr(tx_intf))/IPv6(src=3D"%s" % self.random_ip("ipv6"), > dst=3D"%s" % self.random_ip("ipv6"))/TCP()/("X"), # ipv6 tcp packet > + Ether(dst=3D"%s" % dst_mac, > src=3Dget_if_hwaddr(tx_intf))/IPv6(src=3D"%s" % self.random_ip("ipv6"), > dst=3D"%s" % self.random_ip("ipv6"))/SCTP(tag=3D1)/("X"), # ipv6 sctp pac= ket > + ] > + for packet in packet_type: > + for i in range(self.total_packets / len(packet_type)): > + packets.append(packet) > + for i in range(self.total_packets % len(packet_type)): > + packets.append(packet_type[random.randint(0, len(packet_type= ) > - 1)]) > + wrpcap(filename, packets) > + self.tester.session.copy_file_to(filename) > def test_perf_pmd_performance_4ports(self): > """ > PMD Performance Benchmarking with 4 ports. > @@ -322,11 +356,22 @@ class TestPmd(TestCase,IxiaPacketGenerator): > port_mask =3D dts.create_mask([self.dut_ports[0], > self.dut_ports[1]]) >=20 > self.pmdout.start_testpmd("1S/2C/1T", "--portmask=3D%s" % port_m= ask, > socket=3Dself.ports_socket) > + > + self.dut.send_expect("set fwd mac", "testpmd> ") > self.dut.send_expect("start", "testpmd> ") > - for size in self.frame_sizes: > - self.send_packet(size) > + interface =3D self.tester.get_interface( > + self.tester.get_local_port(self.dut_ports[0])) > + mac =3D self.dut.get_mac_address(self.dut_ports[0]) > + self.creat_pcap("random_packet.pcap", mac, interface) > + self.tester.scapy_append('pcap =3D rdpcap("random_packet.pcap")'= ) > + self.tester.scapy_append('sendp(pcap, iface=3D"%s")' % interface= ) > + self.tester.scapy_execute(120) > + > + #self.dut.send_expect("stop", "testpmd> ") > + dut_rxpackets =3D self.get_stats(self.dut_ports[0])['RX-packets'= ] > + dut_txpackets =3D self.get_stats(self.dut_ports[1])['TX-packets'= ] > + self.verify(dut_txpackets =3D=3D self.total_packets and dut_rxpa= ckets > =3D=3D dut_txpackets, "loss packets,tester send %d packets, dut rx packet= s %s, > dut tx packets %s" %(self.total_packets, dut_rxpackets, dut_txpackets) ) >=20 > - self.dut.send_expect("stop", "testpmd> ") > self.dut.send_expect("quit", "# ", 30) > sleep(5) >=20 > -- > 1.9.3