#! /bin/sh # Might change this later. . $1 echo "Usage - runs 10 million packets at a range of packet sizes" 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 ----------------------------------------------------------- # thread config # Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. PGDEV=/proc/net/pktgen/kpktgend_0 echo "Removing all devices" pgset "rem_device_all" echo "Adding $DEV" pgset "add_device $DEV" echo "Setting max_before_softirq 10000" pgset "max_before_softirq 10000" # device config # delay 0 means maximum speed. CLONE_SKB="clone_skb 1000" # NIC adds 4 bytes CRC PKT_SIZE=60 # COUNT 0 means forever #COUNT="count 0" COUNT="count 10000000" DELAY="delay 0" for PKT_SIZE in 60 124 252 508 1020 1496 1500 4096 do PGDEV=/proc/net/pktgen/$DEV echo "Configuring $PGDEV packet size $PKT_SIZE" pgset "$COUNT" pgset "$CLONE_SKB" pgset "min_pkt_size 60" pgset "max_pkt_size $PKT_SIZE" pgset "$DELAY" pgset "dst $D_ADDR" pgset "dst_mac $D_MAC" cat $PGDEV # Time to run PGDEV=/proc/net/pktgen/pgctrl echo "Running... ctrl^C to stop" pgset "start" echo "Done" echo "Check errors" ethtool -S eth1 | grep error | grep -v 'errors: 0' echo "Check remote machine" ssh $TARGET ethtool -S $DEV | grep error done # Result can be vieved in /proc/net/pktgen/eth1 echo "Mileage may vary" cat /proc/net/pktgen/$DEV