rxtx_callbacks.py
""" DPDK Test suite. Test Rxtx_Callbacks. """ import utils import string import time from test_case import TestCase from plotting import Plotting from settings import HEADER_SIZE from etgen import IxiaPacketGenerator from packet import Packet, sniff_packets, load_sniff_packets class TestRxtxCallbacks(TestCase): def set_up_all(self): """ Run at the start of each test suite. timer prerequistites """ self.dut_ports = self.dut.get_ports(self.nic) ''' self.nic = 'niantic' ; self.dut_ports = [0, 1, 2, 3] self.mac = '90:e2:ba:4a:53:28' ''' self.verify(len(self.dut_ports) >= 2, "Insufficient ports") cores = self.dut.get_core_list("1S/2C/1T") self.coremask = utils.create_mask(cores) self.mac = self.dut.get_mac_address(self.dut_ports[0]) self.path = "./examples/rxtx_callbacks/build/rxtx_callbacks" out = self.dut.build_dpdk_apps("./examples/rxtx_callbacks") self.verify("Error" not in out, "compilation error 1") self.verify("No such file" not in out, "compilation error 2") def set_up(self): """ Run before each test case. """ pass def test_rxtx_callbacks(self): cmd = self.path + " -c %s -n %d " % (self.coremask,self.dut.get_memory_channels()) self.dut.send_expect(cmd,"forwarding packets",60) self.iface_port0 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0])) self.iface_port1 = self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1])) ''' self.dut_ports[0] : 0 self.tester.get_local_port(self.dut_ports[0]) : 2 self.tester.get_interface(self.tester.get_local_port(self.dut_ports[0])) : 'ens261f0' self.dut_ports[1] : 1 self.tester.get_local_port(self.dut_ports[1]) : 3 self.tester.get_interface(self.tester.get_local_port(self.dut_ports[1])) : 'ens261f1' ''' self.inst_port1 = sniff_packets(self.iface_port1) #self.inst_port1 : '1539677920.09' self.scapy_send_packet(self.iface_port0) ''' tester: scapy tester: sendp([Ether(dst="90:e2:ba:4a:53:28")/IP()/UDP()/Raw('X'*18)], iface="ens261f0") tester: exit() ''' out_port1 = self.get_tcpdump_package(self.inst_port1) ''' 1 packet captured 1 packet received by filter 0 packets dropped by kernel ''' self.verify(self.mac in out_port1, "Wrong: can't get package at %s " % self.inst_port1) def scapy_send_packet(self,iface): """ Send a packet to port """ self.tester.scapy_append('sendp([Ether(dst="%s")/IP()/UDP()/Raw(\'X\'*18)], iface="%s")' % (self.mac, iface)) self.tester.scapy_execute() def get_tcpdump_package(self,inst): pkts = load_sniff_packets(inst) dsts = [] for packet in pkts: dst = packet.strip_element_layer2("dst") dsts.append(dst) #[''90:e2:ba:4a:53:28''] return dsts def tear_down(self): """ Run after each test case. """ self.dut.kill_all() time.sleep(2) def tear_down_all(self): """ Run after each test suite. """ pass
#测试的目的:
Send one packet on Port0,check the port1 receive packet.
It receive one packet that the port0 send.
TESTS_RESULT:PASS
1 packet captured
1 packet received by filter
0 packets dropped by kernel
Result FAILED: "Wrong: can't get package at 1530862720.26 "
0 packets captured
0 packets received by filter
0 packets dropped by kernel
pdb调试信息:
> /home/autoregression/changqing/tests/TestSuite_rxtx_callbacks.py(86)test_rxtx_callbacks()
-> self.verify(self.mac in out_port1, "Wrong: can't get package at %s " % self.inst_port1)
(Pdb) l
81
82 self.inst_port1 = sniff_packets(self.iface_port1)
83 self.scapy_send_packet(self.iface_port0)
84
85 out_port1 = self.get_tcpdump_package(self.inst_port1)
86 -> self.verify(self.mac in out_port1, "Wrong: can't get package at %s " % self.inst_port1)
87
88
89 def scapy_send_packet(self,iface):
90 """
91 Send a packet to port
(Pdb) p out_port1
['90:e2:ba:4a:53:28']
(Pdb) p self.iface_port0
'p5p1'
(Pdb) p self.iface_port1
'p5p2'
(Pdb) p self.mac
'90:e2:ba:4a:53:28'
(Pdb) p self.inst_port1
'1530861577.19'
dut-tests
dut: #测试前编译: [root@localhost dpdk-changqing]# rm -rf ./app/test/test_resource_c.res.o [root@localhost dpdk-changqing]# rm -rf ./app/test/test_resource_tar.res.o [root@localhost dpdk-changqing]# rm -rf ./app/test/test_pci_sysfs.res.o [root@localhost dpdk-changqing]# make -j 70 -C ./examples/rxtx_callbacks make: Entering directory '/root/dpdk-changqing/examples/rxtx_callbacks' CC main.o LD rxtx_callbacks INSTALL-APP rxtx_callbacks INSTALL-MAP rxtx_callbacks.map make: Leaving directory '/root/dpdk-changqing/examples/rxtx_callbacks' EAL 启动成功 [root@localhost dpdk-changqing]# ./examples/rxtx_callbacks/build/rxtx_callbacks -c 0x6 -n 4 EAL: Detected 72 lcore(s) EAL: Detected 2 NUMA nodes EAL: Multi-process socket /var/run/dpdk/rte/mp_socket EAL: Probing VFIO support... EAL: PCI device 0000:03:00.0 on NUMA socket 0 EAL: probe driver: 8086:1572 net_i40e EAL: PCI device 0000:03:00.1 on NUMA socket 0 EAL: probe driver: 8086:1572 net_i40e EAL: PCI device 0000:03:00.2 on NUMA socket 0 EAL: probe driver: 8086:1572 net_i40e EAL: PCI device 0000:03:00.3 on NUMA socket 0 EAL: probe driver: 8086:1572 net_i40e EAL: PCI device 0000:04:00.0 on NUMA socket 0 EAL: probe driver: 8086:10fb net_ixgbe EAL: PCI device 0000:04:00.1 on NUMA socket 0 EAL: probe driver: 8086:10fb net_ixgbe EAL: PCI device 0000:05:00.0 on NUMA socket 0 EAL: probe driver: 8086:1521 net_e1000_igb EAL: PCI device 0000:05:00.1 on NUMA socket 0 EAL: probe driver: 8086:1521 net_e1000_igb EAL: PCI device 0000:82:00.0 on NUMA socket 1 EAL: probe driver: 8086:10fb net_ixgbe EAL: PCI device 0000:82:00.1 on NUMA socket 1 EAL: probe driver: 8086:10fb net_ixgbe Port 0 MAC: 90 e2 ba 4a 53 28 Port 1 MAC: 90 e2 ba 4a 53 29 Port 2 MAC: 90 e2 ba 50 8d 68 Port 3 MAC: 90 e2 ba 50 8d 69 WARNING: Too much enabled lcores - App uses only 1 lcore WARNING, port 2 is on remote NUMA node to polling thread. Performance will not be optimal. WARNING, port 3 is on remote NUMA node to polling thread. Performance will not be optimal. Core 1 forwarding packets. [Ctrl+C to quit] #dut启动EAL,接口p5p2能够监听到p5p1发的包 tester: [root@dpdk-test37 ~]# scapy WARNING: No route found for IPv6 destination :: (no default route?) INFO: Can't import python-cryptography v1.7+. Disabled WEP decryption/encryption. INFO: Could not import python-cryptography.Computations for the "authenticator" field (RADIUS packets) and"Message-Authenticator" attribute value field are disabled. Welcome to Scapy (2.3.3.dev623) >>> sendp([Ether(dst="90:e2:ba:4a:53:28")/IP()/UDP()/Raw('X'*18)], iface="p5p1") . Sent 1 packets. [root@dpdk-test37 ~]# tcpdump -i p5p2 tcpdump: WARNING: p5p1: no IPv4 address assigned tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on p5p1, link-type EN10MB (Ethernet), capture size 65535 bytes 15:58:56.181060 IP localhost.domain > localhost.domain: 22616 updateDA% [b2&3=0x5858] [22616a] [22616q] [22616n] [22616au][|domain] #dut启动EAL,接口p5p1能够监听到p5p2发的包 [root@dpdk-test37 ~]# >>> sendp([Ether(dst="90:e2:ba:4a:53:28")/IP()/UDP()/Raw('X'*18)], iface="p5p2") [root@dpdk-test37 ~]# tcpdump -i p5p1 tcpdump: WARNING: p5p1: no IPv4 address assigned tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on p5p1, link-type EN10MB (Ethernet), capture size 65535 bytes 15:58:56.181060 IP localhost.domain > localhost.domain: 22616 updateDA% [b2&3=0x5858] [22616a] [22616q] [22616n] [22616au][|domain] #dut退出启动EAL,接口p5p1无法监听到p5p2发的包 dut: Ctrl+c to quit tester: >>> sendp([Ether(dst="90:e2:ba:4a:53:28")/IP()/UDP()/Raw('X'*18)], iface="p5p2") [root@dpdk-test37 ~]# tcpdump -i p5p1 tcpdump: WARNING: p5p1: no IPv4 address assigned tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on p5p1, link-type EN10MB (Ethernet), capture size 65535 bytes
总结:
#开启EAL:./examples/rxtx_callbacks/build/rxtx_callbacks -c 0x6 -n 4
接口p5p1能够监听到p5p2发的包,监听到p5p1发的包
接口p5p2能够监听到p5p1发的包,监听到p5p2发的包
#关闭EAL:Ctrl+c to quit
接口p5p1能够监听到p5p1发的包,无法监听到p5p2发的包
接口p5p2能够监听到p5p2发的包,无法监听到p5p1发的包