forked from NetFPGA-NewNIC/test-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpktgen.sh
executable file
·67 lines (56 loc) · 1.23 KB
/
pktgen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
if [ "$count" = "" ]; then
count=1000000
fi
if [ "$delay" = "" ]; then
delay=0
fi
if [ $# -ne 2 ]; then
echo "Usage: [delay=$delay] [count=$count] $0 <netif> <packet size>"
exit
fi
netif=$1
pkt_size=$2
function pgset() {
local result
echo $1 > $PGDEV
result=`cat $PGDEV | grep "Result: OK:"`
if [ "$result" = "" ]; then
cat $PGDEV | grep Result:
fi
}
function pg() {
echo inject > $PGDEV
cat $PGDEV
}
if [[ ! "$(lsmod)" =~ pktgen ]]; then
modprobe pktgen
fi
PGDEV=/proc/net/pktgen/kpktgend_0
if [ ! -e $PGDEV ]; then
echo "Error: pktgen might not be loaded!"
exit
fi
echo "Removing all devices"
pgset "rem_device_all"
echo "Adding $netif"
pgset "add_device $netif"
echo "Setting max_before_softirq 10000"
pgset "max_before_softirq 10000"
PGDEV=/proc/net/pktgen/$netif
if [ ! -e $PGDEV ]; then
echo "Error: pktgen might not be loaded or $netif is not up now!"
exit
fi
pgset "count $count"
pgset "clone_skb $count"
pgset "pkt_size $pkt_size" # nic adds 4B CRC
pgset "delay $delay"
pgset "dst 10.10.0.3"
pgset "dst_mac 00:15:17:15:5d:74"
echo "$PGDEV is configured: pkt_size=$pkt_size w/ count=$count and delay=$delay"
PGDEV=/proc/net/pktgen/pgctrl
echo "Running..."
pgset "start"
echo "Done"
cat /proc/net/pktgen/$netif