使用pktgen测试GWN7000包转发率
思博伦通信Smartbits测试设备,做为专业的发包仪器非常不错,但唯一的缺点就是太贵.还好Linux为我们提供了一个先进的发包pktgen,这个工具以内核模块的形式存在,理论上性能应该比同等运行在应用层的工具性能要好,而且还是所谓的多核支持.
1.1 测试Swich模式下的LAN口间的包转发率
测试环境:
测试步骤如下:
步骤1),首先加载pktgen.
在Linux PC上运行modprobe pktgen 命令.
加载成功后, 会有对应的/proc/net/pktgen接口,pktgen是每一个cpu绑定一个内核线程,如果PC机有4个cpu,所以这里可以看到4个kpktgend_*文件(假设PC机是4核的): 1 2 3 4 5 6 7 8 9 [root@localhost ~]#modprobe pktgen [root@localhost ~]# cat /proc/cpuinfo | grep processor processor : 0 processor : 1 processor : 2 processor : 3 [root@localhost ~]#ls /proc/net/pktgen/ kpktgend_0 kpktgend_1 kpktgend_2 kpktgend_3 pgctrl 假如PC机一共有3个网口,拿其中的2个网口(eth1/eth2)用于pktgen测试. 可以先使用ethtool工具查看eth1/eth2网口的速率.
如果网口速率没有协商成1000M, 也可以使用如下命令进行修改. ethtool -s eth1 autoneg off speed 1000 duplex full ethtool -s eth2 autoneg off speed 1000 duplex full
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 [root@localhost pktgen]#ifconfig eth1 eth5 Link encap:Ethernet HWaddr 00:0C:29:97:9B:B4 inet addr:192.168.1.95 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe97:9bb4/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:15044140 errors:0 dropped:0 overruns:0 frame:0 TX packets:14210498 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:903846363 (861.9 MiB) TX bytes:852636332 (813.1 MiB) [root@localhost pktgen]# ifconfig eth2 eth6 Link encap:Ethernet HWaddr 00:0C:29:97:9B:BE inet addr:192.168.1.96 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe97:9bbe/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:14256340 errors:0 dropped:0 overruns:0 frame:0 TX packets:14998657