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发的包
手机扫一扫
移动阅读更方便
你可能感兴趣的文章