基于我的环境,为了用tcpdump查看转发效果,对l2fwd进行了简单修改,如下图,修改后的l2fwd的整体流程如下:
(1)、pktgen产生测试报文由eth2发往eth3;
(2)、eth3端口由DPDK接管;
(3)、L2FWD为基于DPDK的APP,实现简单功能,从ETH3收报文,交换MAC地址、交换IP地址(可以不实现,为查看报文修改情景),从ETH3将报文发送出去;
(4)、在eth2用tcpdump监控报文收发情况,会收到从l2fwd返回的报文。
测试步骤:
1、报文生成,参考DPDK(五):发包工具------pktgen
2、使用setup.sh完成下面工作:插入UIO.KO,配置大叶内存,绑定eth3接口
3、运行l2fwd,运行参数 -c 0x1 -n 2 -- -q 1 -p 0x1,一个CPU、接管一个端口
可以查看到效果:只有一个端口,未出现丢包
Port statistics ====================================
Statistics for port 0 ------------------------------
Packets sent: 130180
Packets received: 130180
Packets dropped: 0
Aggregate statistics ===============================
Total packets sent: 130180
Total packets received: 130180
Total packets dropped: 0
====================================================
4、在tcpdump上查看结果
root@ubuntu:/home# tcpdump -c 10 -vv -i eth2
tcpdump: listening on eth2, link-type EN10MB (Ethernet), capture size 262144 bytes
06:47:24.739556 IP (tos 0x0, ttl 32, id 93, offset 0, flags [none], proto UDP (17), length 46)
192.168.19.128.discard > 192.168.19.129.discard: [no cksum] UDP, length 18 --------------------------IP地址进行了交换
06:47:24.739573 IP (tos 0x0, ttl 32, id 93, offset 0, flags [none], proto UDP (17), length 46)
192.168.19.128.discard > 192.168.19.129.discard: [no cksum] UDP, length 18
06:47:24.739578 IP (tos 0x0, ttl 32, id 93, offset 0, flags [none], proto UDP (17), length 46)
192.168.19.128.discard > 192.168.19.129.discard: [no cksum] UDP, length 18
06:47:24.739583 IP (tos 0x0, ttl 32, id 93, offset 0, flags [none], proto UDP (17), length 46)
192.168.19.128.discard > 192.168.19.129.discard: [no cksum] UDP, length 18
06:47:24.739588 IP (tos 0x0, ttl 32, id 93, offset 0, flags [none], proto UDP (17), length 46)
192.168.19.128.discard > 192.168.19.129.discard: [no cksum] UDP, length 18
06:47:24.739590 IP (tos 0x0, ttl 32, id 93, offset 0, flags [none], proto UDP (17), length 46)
192.168.19.128.discard > 192.168.19.129.discard: [no cksum] UDP, length 18
06:47:24.739593 IP (tos 0x0, ttl 32, id 93, offset 0, flags [none], proto UDP (17), length 46)
192.168.19.128.discard > 192.168.19.129.discard: [no cksum] UDP, length 18
06:47:24.835744 IP (tos 0x0, ttl 32, id 93, offset 0, flags [none], proto UDP (17), length 46)
192.168.19.128.discard > 192.168.19.129.discard: [no cksum] UDP, length 18
06:47:24.835794 IP (tos 0x0, ttl 32, id 93, offset 0, flags [none], proto UDP (17), length 46)
192.168.19.128.discard > 192.168.19.129.discard: [no cksum] UDP, length 18
06:47:24.835798 IP (tos 0x0, ttl 32, id 93, offset 0, flags [none], proto UDP (17), length 46)
192.168.19.128.discard > 192.168.19.129.discard: [no cksum] UDP, length 18
10 packets captured
871 packets received by filter
537 packets dropped by kernel
5、l2fwd的实现留到下一节分析。