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 | |
Ben Hutchings | 7c95a9d | 2015-02-24 02:32:07 +0000 | [diff] [blame] | 17 | # Config Start Here ----------------------------------------------------------- |
| 18 | |
| 19 | |
| 20 | # thread config |
Ben Hutchings | 2ad1cdf | 2015-02-24 02:32:37 +0000 | [diff] [blame^] | 21 | # Each CPU has its own thread. One CPU example. We add eth1. |
Ben Hutchings | 7c95a9d | 2015-02-24 02:32:07 +0000 | [diff] [blame] | 22 | |
| 23 | PGDEV=/proc/net/pktgen/kpktgend_0 |
| 24 | echo "Removing all devices" |
| 25 | pgset "rem_device_all" |
| 26 | echo "Adding eth1" |
| 27 | pgset "add_device eth1" |
| 28 | echo "Setting max_before_softirq 10000" |
| 29 | pgset "max_before_softirq 10000" |
| 30 | |
| 31 | |
| 32 | # device config |
| 33 | # delay 0 |
| 34 | |
| 35 | # We need to do alloc for every skb since we cannot clone here. |
| 36 | |
| 37 | CLONE_SKB="clone_skb 0" |
| 38 | # NIC adds 4 bytes CRC |
| 39 | PKT_SIZE="pkt_size 60" |
| 40 | |
| 41 | # COUNT 0 means forever |
| 42 | #COUNT="count 0" |
| 43 | COUNT="count 10000000" |
| 44 | DELAY="delay 0" |
| 45 | |
| 46 | PGDEV=/proc/net/pktgen/eth1 |
| 47 | echo "Configuring $PGDEV" |
| 48 | pgset "$COUNT" |
| 49 | pgset "$CLONE_SKB" |
| 50 | pgset "$PKT_SIZE" |
| 51 | pgset "$DELAY" |
| 52 | # Random address with in the min-max range |
| 53 | pgset "flag IPDST_RND" |
| 54 | pgset "dst_min 10.0.0.0" |
| 55 | pgset "dst_max 10.255.255.255" |
| 56 | |
| 57 | pgset "dst_mac 00:04:23:08:91:dc" |
| 58 | |
| 59 | # Time to run |
| 60 | PGDEV=/proc/net/pktgen/pgctrl |
| 61 | |
| 62 | echo "Running... ctrl^C to stop" |
| 63 | pgset "start" |
| 64 | echo "Done" |
| 65 | |
| 66 | # Result can be vieved in /proc/net/pktgen/eth1 |