#! /bin/sh #modprobe pktgen function pgset() { local result echo $1 > $PGDEV result=`cat $PGDEV | fgrep "Result: OK:"` if [ "$result" = "" ]; then cat $PGDEV | fgrep Result: fi } function pg() { echo inject > $PGDEV cat $PGDEV } # Config Start Here ----------------------------------------------------------- remove_all() { # thread config PGDEV=/proc/net/pktgen/kpktgend_0 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_1 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_2 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_3 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_4 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_5 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_6 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_7 pgset "rem_device_all" } remove_all PGDEV=/proc/net/pktgen/kpktgend_0 pgset "add_device eth2@0" PGDEV=/proc/net/pktgen/kpktgend_1 pgset "add_device eth2@1" PGDEV=/proc/net/pktgen/kpktgend_2 pgset "add_device eth2@2" PGDEV=/proc/net/pktgen/kpktgend_3 pgset "add_device eth2@3" # device config # # Sending a mix of pkt sizes of 64, 576 and 1500 # CLONE_SKB="clone_skb 1" PKT_SIZE="pkt_size 60" COUNT="count 000000" DELAY="delay 0000" #MAC="00:21:28:08:40:EE" #MAC="00:21:28:08:40:EF" #MAC="00:1B:21:17:C1:CD" #MAC="00:14:4F:DA:8C:66" #MAC="00:14:4F:6B:CD:E8" #MAC="00:1B:21:4A:FE:A8" MAC="00:1B:21:54:B3:BC" #MAC="00:1B:21:4B:09:C8" PGDEV=/proc/net/pktgen/eth2@0 echo "Configuring $PGDEV" pgset "$COUNT" pgset "$CLONE_SKB" pgset "pkt_size 1496" pgset "$DELAY" pgset "flag QUEUE_MAP_CPU" pgset "flag IPDST_RND" pgset "flag FLOW_SEQ" pgset "dst_min 11.0.0.0" pgset "dst_max 11.255.255.255" pgset "flows 2048" pgset "flowlen 30" pgset "dst_mac $MAC" PGDEV=/proc/net/pktgen/eth2@1 echo "Configuring $PGDEV" pgset "$COUNT" pgset "$CLONE_SKB" pgset "pkt_size 576" pgset "$DELAY" pgset "flag QUEUE_MAP_CPU" pgset "flag IPDST_RND" pgset "flag FLOW_SEQ" pgset "dst_min 11.0.0.0" pgset "dst_max 11.255.255.255" pgset "flows 2048" pgset "flowlen 30" pgset "dst_mac $MAC" PGDEV=/proc/net/pktgen/eth2@2 echo "Configuring $PGDEV" pgset "$COUNT" pgset "$CLONE_SKB" pgset "$DELAY" pgset "pkt_size 60" pgset "flag QUEUE_MAP_CPU" pgset "flag IPDST_RND" pgset "flag FLOW_SEQ" pgset "dst_min 11.0.0.0" pgset "dst_max 11.255.255.255" pgset "flows 2048" pgset "flowlen 30" pgset "dst_mac $MAC" PGDEV=/proc/net/pktgen/eth2@3 echo "Configuring $PGDEV" pgset "$COUNT" pgset "$CLONE_SKB" pgset "pkt_size 1496" pgset "$DELAY" pgset "flag QUEUE_MAP_CPU" pgset "flag IPDST_RND" pgset "flag FLOW_SEQ" pgset "dst_min 11.0.0.0" pgset "dst_max 11.255.255.255" pgset "flows 2048" pgset "flowlen 30" pgset "dst_mac $MAC" # Time to run PGDEV=/proc/net/pktgen/pgctrl echo "Running... ctrl^C to stop" pgset "start" echo "Done" grep pps /proc/net/pktgen/*