1#!/bin/bash
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
17# Config Start Here -----------------------------------------------------------
18
19
20# thread config
21# Each CPU has its own thread. One CPU example. We add eth1.
22
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
29
30# device config
31# delay 0 means maximum speed.
32
33CLONE_SKB="clone_skb 1000000"
34# NIC adds 4 bytes CRC
35PKT_SIZE="pkt_size 60"
36
37# COUNT 0 means forever
38#COUNT="count 0"
39COUNT="count 10000000"
40DELAY="delay 0"
41
42PGDEV=/proc/net/pktgen/eth1
43  echo "Configuring $PGDEV"
44 pgset "$COUNT"
45 pgset "$CLONE_SKB"
46 pgset "$PKT_SIZE"
47 pgset "$DELAY"
48 pgset "dst 10.10.11.2"
49 pgset "dst_mac  00:04:23:08:91:dc"
50
51
52# Time to run
53PGDEV=/proc/net/pktgen/pgctrl
54
55 echo "Running... ctrl^C to stop"
56 trap true INT
57 pgset "start"
58 echo "Done"
59 cat /proc/net/pktgen/eth1
60