Ben Hutchings | 7c95a9d | 2015-02-24 02:32:07 +0000 | [diff] [blame^] | 1 | #! /bin/sh |
| 2 | |
| 3 | #modprobe pktgen |
| 4 | |
| 5 | |
| 6 | function pgset() { |
| 7 | local result |
| 8 | |
| 9 | echo $1 > $PGDEV |
| 10 | |
| 11 | result=`cat $PGDEV | fgrep "Result: OK:"` |
| 12 | if [ "$result" = "" ]; then |
| 13 | cat $PGDEV | fgrep Result: |
| 14 | fi |
| 15 | } |
| 16 | |
| 17 | function pg() { |
| 18 | echo inject > $PGDEV |
| 19 | cat $PGDEV |
| 20 | } |
| 21 | |
| 22 | # Config Start Here ----------------------------------------------------------- |
| 23 | |
| 24 | |
| 25 | # thread config |
| 26 | # Each CPU has own thread. Two CPU exammple. We add eth1, eth2 respectivly. |
| 27 | # IPv6. Note increase in minimal packet length |
| 28 | |
| 29 | PGDEV=/proc/net/pktgen/kpktgend_0 |
| 30 | echo "Removing all devices" |
| 31 | pgset "rem_device_all" |
| 32 | echo "Adding eth1" |
| 33 | pgset "add_device eth1" |
| 34 | echo "Setting max_before_softirq 10000" |
| 35 | pgset "max_before_softirq 10000" |
| 36 | |
| 37 | |
| 38 | # device config |
| 39 | # delay 0 |
| 40 | |
| 41 | CLONE_SKB="clone_skb 1000000" |
| 42 | # NIC adds 4 bytes CRC |
| 43 | PKT_SIZE="pkt_size 66" |
| 44 | |
| 45 | # COUNT 0 means forever |
| 46 | #COUNT="count 0" |
| 47 | COUNT="count 10000000" |
| 48 | DELAY="delay 0" |
| 49 | |
| 50 | PGDEV=/proc/net/pktgen/eth1 |
| 51 | echo "Configuring $PGDEV" |
| 52 | pgset "$COUNT" |
| 53 | pgset "$CLONE_SKB" |
| 54 | pgset "$PKT_SIZE" |
| 55 | pgset "$DELAY" |
| 56 | pgset "dst6 fec0::1" |
| 57 | pgset "src6 fec0::2" |
| 58 | pgset "dst_mac 00:04:23:08:91:dc" |
| 59 | |
| 60 | # Time to run |
| 61 | PGDEV=/proc/net/pktgen/pgctrl |
| 62 | |
| 63 | echo "Running... ctrl^C to stop" |
| 64 | pgset "start" |
| 65 | echo "Done" |
| 66 | |
| 67 | # Result can be vieved in /proc/net/pktgen/eth1 |