blob: c7553be49b80f449159f9538894518109cc12b88 [file] [log] [blame]
Ben Hutchingsdb72aba2015-02-24 02:32:59 +00001#!/bin/bash
Ben Hutchings7c95a9d2015-02-24 02:32:07 +00002
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# Each CPU has its own thread. One CPU example. We add eth1.
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"
Ben Hutchings7c95a9d2015-02-24 02:32:07 +000028
29
30# device config
31# delay 0
32
33# We need to do alloc for every skb since we cannot clone here.
34
35CLONE_SKB="clone_skb 0"
36# NIC adds 4 bytes CRC
37PKT_SIZE="pkt_size 60"
38
39# COUNT 0 means forever
40#COUNT="count 0"
41COUNT="count 10000000"
42DELAY="delay 0"
43
44PGDEV=/proc/net/pktgen/eth1
45 echo "Configuring $PGDEV"
46 pgset "$COUNT"
47 pgset "$CLONE_SKB"
48 pgset "$PKT_SIZE"
49 pgset "$DELAY"
50 # Random address with in the min-max range
51 pgset "flag IPDST_RND"
52 pgset "dst_min 10.0.0.0"
53 pgset "dst_max 10.255.255.255"
54
55 pgset "dst_mac 00:04:23:08:91:dc"
56
57# Time to run
58PGDEV=/proc/net/pktgen/pgctrl
59
60 echo "Running... ctrl^C to stop"
Ben Hutchings16b5d0c2015-02-24 02:33:08 +000061 trap true INT
Ben Hutchings7c95a9d2015-02-24 02:32:07 +000062 pgset "start"
63 echo "Done"
Ben Hutchings4062bd22015-02-24 02:33:20 +000064 cat /proc/net/pktgen/eth1