#!/bin/bash #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" PGDEV=/proc/net/pktgen/kpktgend_8 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_9 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_10 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_11 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_12 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_13 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_14 pgset "rem_device_all" PGDEV=/proc/net/pktgen/kpktgend_15 pgset "rem_device_all" } remove_all i=0 c=9 while [ $i -lt 10 ]; do PGDEV=/proc/net/pktgen/kpktgend_$c pgset "add_device eth$i@$c " i=$[ i+1 ] c=$[ c-1 ] done if false; then PGDEV=/proc/net/pktgen/kpktgend_8 pgset "add_device eth8@12" PGDEV=/proc/net/pktgen/kpktgend_9 pgset "add_device eth9@13" fi # device config # # Sending a mix of pkt sizes of 64, 576 and 1500 # CLONE_SKB="clone_skb 1000000" PKT_SIZE="pkt_size 1496" #COUNT="count 100000000" COUNT="count 000000000" DELAY="delay 0000" MAC="00:1B:21:54:B3:BC" echo Configuring i=0 c=0 while [ 11 -lt 10 ]; do PGDEV=/proc/net/pktgen/eth$i@$c echo -n " eth$i" pgset "$COUNT" pgset "flag NODE_ALLOC" pgset "$CLONE_SKB" pgset "$PKT_SIZE" pgset "$DELAY" pgset "dst 11.0.0.0" i=$[ i+1 ] c=$[ c+1 ] done echo if false; then PGDEV=/proc/net/pktgen/eth8@12 pgset "$COUNT" pgset "flag NODE_ALLOC" pgset "$CLONE_SKB" pgset "$PKT_SIZE" pgset "$DELAY" pgset "dst 11.0.0.0" PGDEV=/proc/net/pktgen/eth9@13 pgset "$COUNT" pgset "flag NODE_ALLOC" pgset "$CLONE_SKB" pgset "$PKT_SIZE" pgset "$DELAY" pgset "dst 11.0.0.0" fi fn() { i=$1 #ifname c=$2 #queue / cpu core n=$3 # numa node PGDEV=/proc/net/pktgen/kpktgend_$c pgset "add_device eth$i@$c " PGDEV=/proc/net/pktgen/eth$i@$c pgset "node $n" pgset "$COUNT" pgset "flag NODE_ALLOC" pgset "$CLONE_SKB" pgset "$PKT_SIZE" pgset "$DELAY" pgset "dst 11.0.0.0" } remove_all fn 0 0 1 fn 1 1 1 fn 2 2 1 fn 3 3 1 fn 4 4 0 fn 5 5 0 fn 6 6 0 fn 7 7 0 fn 8 12 0 fn 9 13 0 # Time to run PGDEV=/proc/net/pktgen/pgctrl echo "Running... ctrl^C to stop" pgset "start" echo "Done" grep pps /proc/net/pktgen/*