blob: 136e10caff636d41b8289daa99584da734a0f629 [file] [log] [blame]
Ben Hutchings7c95a9d2015-02-24 02:32:07 +00001#! /bin/sh
2
3#modprobe pktgen
4
5
6function 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 Hutchings7c95a9d2015-02-24 02:32:07 +000017# Config Start Here -----------------------------------------------------------
18
19
20# thread config
Ben Hutchings2ad1cdf2015-02-24 02:32:37 +000021# One CPU means one thread. One CPU example. We add eth1, eth2 respectivly.
Ben Hutchings7c95a9d2015-02-24 02:32:07 +000022
23PGDEV=/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 "Adding eth2"
29 pgset "add_device eth2"
30 echo "Setting max_before_softirq 10000"
31 pgset "max_before_softirq 10000"
32
33
34# device config
35# delay 0 means maximum speed.
36
37CLONE_SKB="clone_skb 1000000"
38# NIC adds 4 bytes CRC
39PKT_SIZE="pkt_size 60"
40
41# COUNT 0 means forever
42#COUNT="count 0"
43COUNT="count 10000000"
44DELAY="delay 0"
45
46PGDEV=/proc/net/pktgen/eth1
47 echo "Configuring $PGDEV"
48 pgset "$COUNT"
49 pgset "$CLONE_SKB"
50 pgset "$PKT_SIZE"
51 pgset "$DELAY"
52 pgset "dst 10.10.11.2"
53 pgset "dst_mac 00:04:23:08:91:dc"
54
55PGDEV=/proc/net/pktgen/eth2
56 echo "Configuring $PGDEV"
57 pgset "$COUNT"
58 pgset "$CLONE_SKB"
59 pgset "$PKT_SIZE"
60 pgset "$DELAY"
61 pgset "dst 192.168.2.2"
62 pgset "dst_mac 00:04:23:08:91:de"
63
64# Time to run
65PGDEV=/proc/net/pktgen/pgctrl
66
67 echo "Running... ctrl^C to stop"
68 pgset "start"
69 echo "Done"
70
71# Result can be vieved in /proc/net/pktgen/eth[1,2]