ʹÓÃ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.