pktgen使用文档 下载本文

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]# cat /proc/net/pktgen/eth6 Params: count 0 min_pkt_size: 60 max_pkt_size: 60 frags: 0 delay: 0 clone_skb: 1000000 ifname: eth6 flows: 0 flowlen: 0 queue_map_min: 0 queue_map_max: 0 dst_min: 192.168.1.95 dst_max: src_min: src_max: src_mac: 00:0c:29:97:9b:be dst_mac: 00:0c:29:97:9b:b4 udp_src_min: 9 udp_src_max: 9 udp_dst_min: 9 udp_dst_max: 9 src_mac_count: 0 dst_mac_count: 0 Flags: Current: pkts-sofar: 2846965 errors: 0 started: 2423223982us stopped: 2570673243us idle: 45963us seq_num: 2846966 cur_dst_mac_offset: 0 cur_src_mac_offset: 0 cur_saddr: 0x6001a8c0 cur_daddr: 0x5f01a8c0 cur_udp_dst: 9 cur_udp_src: 9 cur_queue_map: 0 flows: 0 Result: OK: 147449261(c147403297+d45963) usec, 2846965 (60byte,0frags) 19308pps 9Mb/sec (9267840bps) errors: 0 [root@localhost pktgen]# 1.2 测试Nat模式下的包转发率

测试1: LAN->WAN发包

即PC机上的eth2口通过GWN7000的LAN1口向接在eth2口发包.

步骤1) 运行modprobe pktgen 命令,加载pktgen模块. 具体方法见链接. 步骤2) 并把eth1/eth2做亲和性绑定到特定的cpu. 具体方法见链接. 步骤3) 在linux PC上执行脚本:

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 #! /bin/sh # FileName: pktgen-eth5-eth6.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. PGDEV=/proc/net/pktgen/kpktgend_2 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=\45 46 47 48 49 50 51 52 53 DELAY=\ PGDEV=/proc/net/pktgen/eth2 echo \ pgset \ pgset \ pgset \ pgset \ pgset \ pgset \##This MAC is GWN7000 eth0’s MAC # Time to run PGDEV=/proc/net/pktgen/pgctrl echo \ pgset \ echo \ # Result can be vieved in /proc/net/pktgen/eth[5,6] 步骤4) 测试脚本的同时查看发送包数.具体方法见链接.

测试2: WAN->LAN发包

即PC机上的eth1口通过wan口向接在LAN1口下的eth2口发包.

测试步骤:

步骤0) PC(Linux)上,将eth1的网口设置成静态IP 172.16.1.54, 将网关设置成GWN7000 wan口的IP 172.16.1.84.

步骤1)在GWN7000上,设置端口转发, 将wan口上所有收到的包都转发到内网IP 192.168.1.166.

步骤2) 运行modprobe pktgen 命令,加载pktgen模块. 具体方法见链接. 步骤3) 并把eth1/eth2做亲和性绑定到特定的cpu. 具体方法见链接.

步骤4) 在linux PC上执行脚本: 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 #! /bin/sh # FileName: pktgen-eth5-eth6.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. PGDEV=/proc/net/pktgen/kpktgend_0 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=\