blob: bc81fa31924333ab06efa8d5d8fad2d13855a868 [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
17function 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
28PGDEV=/proc/net/pktgen/kpktgend_0
29 echo "Removing all devices"
30 pgset "rem_device_all"
31 echo "Adding eth1"
32 pgset "add_device eth1"
33 echo "Setting max_before_softirq 10000"
34 pgset "max_before_softirq 10000"
35
36
37# device config
38# delay 0
39
40# We need to do alloc for every skb since we cannot clone here.
41
42CLONE_SKB="clone_skb 0"
43# NIC adds 4 bytes CRC
44PKT_SIZE="pkt_size 60"
45
46# COUNT 0 means forever
47#COUNT="count 0"
48COUNT="count 10000000"
49DELAY="delay 0"
50
51PGDEV=/proc/net/pktgen/eth1
52 echo "Configuring $PGDEV"
53 pgset "$COUNT"
54 pgset "$CLONE_SKB"
55 pgset "$PKT_SIZE"
56 pgset "$DELAY"
57 # Random address with in the min-max range
58 pgset "flag IPDST_RND"
59 pgset "dst_min 10.0.0.0"
60 pgset "dst_max 10.255.255.255"
61
62 pgset "dst_mac 00:04:23:08:91:dc"
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/eth1