pktgen使用文档

2020-02-21 02:52

使用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 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:856589260 (816.9 MiB) TX bytes:899925597 (858.2 MiB) [root@localhost pktgen]# ethtool -s eth1 autoneg off speed 1000 duplex full [root@localhost pktgen]# ethtool -s eth2 autoneg off speed 1000 duplex full [root@localhost pktgen]# ethtool eth1 Settings foreth5: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supports auto-negotiation: Yes Advertised link modes: 1000baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on MDI-X: Unknown Supports Wake-on: d Wake-on: d Current message level: 0x00000007 (7) Link detected: yes 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 [root@localhost pktgen]# ethtool eth2 Settings foreth6: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supports auto-negotiation: Yes Advertised link modes: 1000baseT/Full Advertised pause frame use: No Advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on MDI-X: Unknown Supports Wake-on: d Wake-on: d Current message level: 0x00000007 (7) Link detected: yes [root@localhost pktgen]# 步骤2 ) 查看两个网口的中断号,并把eth1/eth2做亲和性绑定到特定的cpu.

注意:先关闭系统的irqbalance服务

[root@localhost ~]# cat /proc/interrupts | grep eth 16: 2586 540 1351588 4172554 IO-APIC-fasteoi Ensoniq AudioPCI, eth1 19: 5117 1949714 6098060 40 IO-APIC-fasteoi eth4, eth2 #说明:16和19 表示的是eth1和eth2的中断号 [root@localhost ~]# /etc/init.d/irqbalance stop Stopping irqbalance: [ OK ] #使用上面的命令停止irqbalance服务后,下面的语句就是绑定特定的cpu了: 注意: cpu的值对应关系如下: Binary Hex CPU 0 00000001 1 CPU 1 00000010 2 CPU 2 00000100 4 CPU 3 00001000 8 1 2 3 4 5 6 7 8 9 10 11 12 例如:如果我想把 IRQ 绑定到 CPU2 上就是 00000100=4: [root@localhost ~]# echo 4 > /proc/irq/19/smp_affinity [root@localhost ~]# echo 8 > /proc/irq/16/smp_affinity [root@localhost ~]# cat /proc/irq/19/smp_affinity 04 [root@localhost ~]# cat /proc/irq/16/smp_affinity 08

步骤3)在PC机上运行pktgen测试脚本:

脚本1:

2个网口(eth1/eth2))双向对发脚本. (即GWN7000的LAN1和LAN5之间双向对发数据测试) 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 #! /bin/sh # FileName: pktgen-eth1-eth2.conf # modprobe pktgen pgset() { local result echo $1 > $PGDEV result=`cat $PGDEV | fgrep \ if [ \ cat $PGDEV | fgrep Result: fi } pg() { echo inject > $PGDEV cat $PGDEV } # Config Start Here ----------------------------------------------------------- # thread config # Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 PGDEV=/proc/net/pktgen/kpktgend_2 echo \ pgset \ echo \ pgset \ PGDEV=/proc/net/pktgen/kpktgend_3 echo \ pgset \ echo \ pgset \ # device config # delay 0 means maximum speed. CLONE_SKB=\# NIC adds 4 bytes CRC PKT_SIZE=\ # COUNT 0 means forever #COUNT=\COUNT=\DELAY=\ PGDEV=/proc/net/pktgen/eth1 echo \ pgset \ pgset \ pgset \ pgset \ pgset \ pgset \ PGDEV=/proc/net/pktgen/eth2 echo \ pgset \ pgset \ pgset \ pgset \ pgset \ pgset \


pktgen使用文档.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:高考语文复习质量检测

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: