Ben Hutchings | db72aba | 2015-02-24 02:32:59 +0000 | [diff] [blame] | 1 | #!/bin/bash |
Ben Hutchings | 7c95a9d | 2015-02-24 02:32:07 +0000 | [diff] [blame] | 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 | # IPv6. Note increase in minimal packet length |
| 23 | |
| 24 | PGDEV=/proc/net/pktgen/kpktgend_0 |
| 25 | echo "Removing all devices" |
| 26 | pgset "rem_device_all" |
| 27 | echo "Adding eth1" |
| 28 | pgset "add_device eth1" |
Ben Hutchings | 7c95a9d | 2015-02-24 02:32:07 +0000 | [diff] [blame] | 29 | |
| 30 | |
| 31 | # device config |
| 32 | # delay 0 |
| 33 | |
| 34 | CLONE_SKB="clone_skb 1000000" |
| 35 | # NIC adds 4 bytes CRC |
| 36 | PKT_SIZE="pkt_size 66" |
| 37 | |
| 38 | # COUNT 0 means forever |
| 39 | #COUNT="count 0" |
| 40 | COUNT="count 10000000" |
| 41 | DELAY="delay 0" |
| 42 | |
| 43 | PGDEV=/proc/net/pktgen/eth1 |
| 44 | echo "Configuring $PGDEV" |
| 45 | pgset "$COUNT" |
| 46 | pgset "$CLONE_SKB" |
| 47 | pgset "$PKT_SIZE" |
| 48 | pgset "$DELAY" |
| 49 | pgset "dst6 fec0::1" |
| 50 | pgset "src6 fec0::2" |
| 51 | pgset "dst_mac 00:04:23:08:91:dc" |
| 52 | |
| 53 | # Time to run |
| 54 | PGDEV=/proc/net/pktgen/pgctrl |
| 55 | |
| 56 | echo "Running... ctrl^C to stop" |
Ben Hutchings | 16b5d0c | 2015-02-24 02:33:08 +0000 | [diff] [blame^] | 57 | trap true INT |
Ben Hutchings | 7c95a9d | 2015-02-24 02:32:07 +0000 | [diff] [blame] | 58 | pgset "start" |
| 59 | echo "Done" |
| 60 | |
| 61 | # Result can be vieved in /proc/net/pktgen/eth1 |