diff options
-rw-r--r-- | Documentation/networking/pktgen.txt | 12 | ||||
-rwxr-xr-x | samples/pktgen/pktgen.conf-1-1 | 66 | ||||
-rwxr-xr-x | samples/pktgen/pktgen.conf-1-1-flows | 74 | ||||
-rwxr-xr-x | samples/pktgen/pktgen.conf-1-1-ip6 | 67 | ||||
-rwxr-xr-x | samples/pktgen/pktgen.conf-1-1-ip6-rdos | 70 | ||||
-rwxr-xr-x | samples/pktgen/pktgen.conf-1-1-rdos | 71 | ||||
-rwxr-xr-x | samples/pktgen/pktgen.conf-1-2 | 76 | ||||
-rwxr-xr-x | samples/pktgen/pktgen.conf-2-1 | 72 | ||||
-rwxr-xr-x | samples/pktgen/pktgen.conf-2-2 | 82 |
9 files changed, 584 insertions, 6 deletions
diff --git a/Documentation/networking/pktgen.txt b/Documentation/networking/pktgen.txt index fa0ad87e6597..24c6dc100e02 100644 --- a/Documentation/networking/pktgen.txt +++ b/Documentation/networking/pktgen.txt | |||
@@ -92,8 +92,8 @@ Result: OK: 13101142(c12220741+d880401) usec, 10000000 (60byte,0frags) | |||
92 | 92 | ||
93 | Configuring threads and devices | 93 | Configuring threads and devices |
94 | ================================ | 94 | ================================ |
95 | This is done via the /proc interface, and most easily done via pgset in | 95 | This is done via the /proc interface, and most easily done via pgset |
96 | the scripts. | 96 | as defined in the sample scripts. |
97 | 97 | ||
98 | Examples: | 98 | Examples: |
99 | 99 | ||
@@ -192,11 +192,11 @@ Examples: | |||
192 | pgset "rate 300M" set rate to 300 Mb/s | 192 | pgset "rate 300M" set rate to 300 Mb/s |
193 | pgset "ratep 1000000" set rate to 1Mpps | 193 | pgset "ratep 1000000" set rate to 1Mpps |
194 | 194 | ||
195 | Example scripts | 195 | Sample scripts |
196 | =============== | 196 | ============== |
197 | 197 | ||
198 | A collection of small tutorial scripts for pktgen is in the examples | 198 | A collection of small tutorial scripts for pktgen is in the |
199 | directory: | 199 | samples/pktgen directory: |
200 | 200 | ||
201 | pktgen.conf-1-1 # 1 CPU 1 dev | 201 | pktgen.conf-1-1 # 1 CPU 1 dev |
202 | pktgen.conf-1-2 # 1 CPU 2 dev | 202 | pktgen.conf-1-2 # 1 CPU 2 dev |
diff --git a/samples/pktgen/pktgen.conf-1-1 b/samples/pktgen/pktgen.conf-1-1 new file mode 100755 index 000000000000..5d30f836ca3e --- /dev/null +++ b/samples/pktgen/pktgen.conf-1-1 | |||
@@ -0,0 +1,66 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | #modprobe pktgen | ||
4 | |||
5 | |||
6 | function 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 | function 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 | |||
28 | PGDEV=/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 means maximum speed. | ||
39 | |||
40 | CLONE_SKB="clone_skb 1000000" | ||
41 | # NIC adds 4 bytes CRC | ||
42 | PKT_SIZE="pkt_size 60" | ||
43 | |||
44 | # COUNT 0 means forever | ||
45 | #COUNT="count 0" | ||
46 | COUNT="count 10000000" | ||
47 | DELAY="delay 0" | ||
48 | |||
49 | PGDEV=/proc/net/pktgen/eth1 | ||
50 | echo "Configuring $PGDEV" | ||
51 | pgset "$COUNT" | ||
52 | pgset "$CLONE_SKB" | ||
53 | pgset "$PKT_SIZE" | ||
54 | pgset "$DELAY" | ||
55 | pgset "dst 10.10.11.2" | ||
56 | pgset "dst_mac 00:04:23:08:91:dc" | ||
57 | |||
58 | |||
59 | # Time to run | ||
60 | PGDEV=/proc/net/pktgen/pgctrl | ||
61 | |||
62 | echo "Running... ctrl^C to stop" | ||
63 | pgset "start" | ||
64 | echo "Done" | ||
65 | |||
66 | # Result can be vieved in /proc/net/pktgen/eth1 | ||
diff --git a/samples/pktgen/pktgen.conf-1-1-flows b/samples/pktgen/pktgen.conf-1-1-flows new file mode 100755 index 000000000000..88a01b7d3531 --- /dev/null +++ b/samples/pktgen/pktgen.conf-1-1-flows | |||
@@ -0,0 +1,74 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | #modprobe pktgen | ||
4 | |||
5 | |||
6 | function 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 | function 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 | |||
28 | PGDEV=/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 | # We need to do alloc for every skb since we cannot clone here. | ||
40 | |||
41 | CLONE_SKB="clone_skb 0" | ||
42 | # NIC adds 4 bytes CRC | ||
43 | PKT_SIZE="pkt_size 60" | ||
44 | |||
45 | # COUNT 0 means forever | ||
46 | #COUNT="count 0" | ||
47 | COUNT="count 10000000" | ||
48 | DELAY="delay 0" | ||
49 | |||
50 | PGDEV=/proc/net/pktgen/eth1 | ||
51 | echo "Configuring $PGDEV" | ||
52 | pgset "$COUNT" | ||
53 | pgset "$CLONE_SKB" | ||
54 | pgset "$PKT_SIZE" | ||
55 | pgset "$DELAY" | ||
56 | # Random address with in the min-max range | ||
57 | pgset "flag IPDST_RND" | ||
58 | pgset "dst_min 10.0.0.0" | ||
59 | pgset "dst_max 10.255.255.255" | ||
60 | |||
61 | # 8k Concurrent flows at 4 pkts | ||
62 | pgset "flows 8192" | ||
63 | pgset "flowlen 4" | ||
64 | |||
65 | pgset "dst_mac 00:04:23:08:91:dc" | ||
66 | |||
67 | # Time to run | ||
68 | PGDEV=/proc/net/pktgen/pgctrl | ||
69 | |||
70 | echo "Running... ctrl^C to stop" | ||
71 | pgset "start" | ||
72 | echo "Done" | ||
73 | |||
74 | # Result can be vieved in /proc/net/pktgen/eth1 | ||
diff --git a/samples/pktgen/pktgen.conf-1-1-ip6 b/samples/pktgen/pktgen.conf-1-1-ip6 new file mode 100755 index 000000000000..752f112bd9e6 --- /dev/null +++ b/samples/pktgen/pktgen.conf-1-1-ip6 | |||
@@ -0,0 +1,67 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | #modprobe pktgen | ||
4 | |||
5 | |||
6 | function 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 | function 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 | # IPv6. Note increase in minimal packet length | ||
28 | |||
29 | PGDEV=/proc/net/pktgen/kpktgend_0 | ||
30 | echo "Removing all devices" | ||
31 | pgset "rem_device_all" | ||
32 | echo "Adding eth1" | ||
33 | pgset "add_device eth1" | ||
34 | echo "Setting max_before_softirq 10000" | ||
35 | pgset "max_before_softirq 10000" | ||
36 | |||
37 | |||
38 | # device config | ||
39 | # delay 0 | ||
40 | |||
41 | CLONE_SKB="clone_skb 1000000" | ||
42 | # NIC adds 4 bytes CRC | ||
43 | PKT_SIZE="pkt_size 66" | ||
44 | |||
45 | # COUNT 0 means forever | ||
46 | #COUNT="count 0" | ||
47 | COUNT="count 10000000" | ||
48 | DELAY="delay 0" | ||
49 | |||
50 | PGDEV=/proc/net/pktgen/eth1 | ||
51 | echo "Configuring $PGDEV" | ||
52 | pgset "$COUNT" | ||
53 | pgset "$CLONE_SKB" | ||
54 | pgset "$PKT_SIZE" | ||
55 | pgset "$DELAY" | ||
56 | pgset "dst6 fec0::1" | ||
57 | pgset "src6 fec0::2" | ||
58 | pgset "dst_mac 00:04:23:08:91:dc" | ||
59 | |||
60 | # Time to run | ||
61 | PGDEV=/proc/net/pktgen/pgctrl | ||
62 | |||
63 | echo "Running... ctrl^C to stop" | ||
64 | pgset "start" | ||
65 | echo "Done" | ||
66 | |||
67 | # Result can be vieved in /proc/net/pktgen/eth1 | ||
diff --git a/samples/pktgen/pktgen.conf-1-1-ip6-rdos b/samples/pktgen/pktgen.conf-1-1-ip6-rdos new file mode 100755 index 000000000000..fd364277e43f --- /dev/null +++ b/samples/pktgen/pktgen.conf-1-1-ip6-rdos | |||
@@ -0,0 +1,70 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | #modprobe pktgen | ||
4 | |||
5 | |||
6 | function 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 | function 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 | # IPv6. Note increase in minimal packet length | ||
28 | |||
29 | PGDEV=/proc/net/pktgen/kpktgend_0 | ||
30 | echo "Removing all devices" | ||
31 | pgset "rem_device_all" | ||
32 | echo "Adding eth1" | ||
33 | pgset "add_device eth1" | ||
34 | echo "Setting max_before_softirq 10000" | ||
35 | pgset "max_before_softirq 10000" | ||
36 | |||
37 | |||
38 | # device config | ||
39 | # delay 0 means maximum speed. | ||
40 | |||
41 | # We need to do alloc for every skb since we cannot clone here. | ||
42 | CLONE_SKB="clone_skb 0" | ||
43 | |||
44 | # NIC adds 4 bytes CRC | ||
45 | PKT_SIZE="pkt_size 66" | ||
46 | |||
47 | # COUNT 0 means forever | ||
48 | #COUNT="count 0" | ||
49 | COUNT="count 10000000" | ||
50 | DELAY="delay 0" | ||
51 | |||
52 | PGDEV=/proc/net/pktgen/eth1 | ||
53 | echo "Configuring $PGDEV" | ||
54 | pgset "$COUNT" | ||
55 | pgset "$CLONE_SKB" | ||
56 | pgset "$PKT_SIZE" | ||
57 | pgset "$DELAY" | ||
58 | pgset "dst6_min fec0::1" | ||
59 | pgset "dst6_max fec0::FFFF:FFFF" | ||
60 | |||
61 | pgset "dst_mac 00:04:23:08:91:dc" | ||
62 | |||
63 | # Time to run | ||
64 | PGDEV=/proc/net/pktgen/pgctrl | ||
65 | |||
66 | echo "Running... ctrl^C to stop" | ||
67 | pgset "start" | ||
68 | echo "Done" | ||
69 | |||
70 | # Result can be vieved in /proc/net/pktgen/eth1 | ||
diff --git a/samples/pktgen/pktgen.conf-1-1-rdos b/samples/pktgen/pktgen.conf-1-1-rdos new file mode 100755 index 000000000000..bc81fa319243 --- /dev/null +++ b/samples/pktgen/pktgen.conf-1-1-rdos | |||
@@ -0,0 +1,71 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | #modprobe pktgen | ||
4 | |||
5 | |||
6 | function 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 | function 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 | |||
28 | PGDEV=/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 | |||
42 | CLONE_SKB="clone_skb 0" | ||
43 | # NIC adds 4 bytes CRC | ||
44 | PKT_SIZE="pkt_size 60" | ||
45 | |||
46 | # COUNT 0 means forever | ||
47 | #COUNT="count 0" | ||
48 | COUNT="count 10000000" | ||
49 | DELAY="delay 0" | ||
50 | |||
51 | PGDEV=/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 | ||
65 | PGDEV=/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 | ||
diff --git a/samples/pktgen/pktgen.conf-1-2 b/samples/pktgen/pktgen.conf-1-2 new file mode 100755 index 000000000000..f99b88673860 --- /dev/null +++ b/samples/pktgen/pktgen.conf-1-2 | |||
@@ -0,0 +1,76 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | #modprobe pktgen | ||
4 | |||
5 | |||
6 | function 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 | function pg() { | ||
18 | echo inject > $PGDEV | ||
19 | cat $PGDEV | ||
20 | } | ||
21 | |||
22 | # Config Start Here ----------------------------------------------------------- | ||
23 | |||
24 | |||
25 | # thread config | ||
26 | # One CPU means one thread. One CPU exammple. We add eth1, eth2 respectivly. | ||
27 | |||
28 | PGDEV=/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 "Adding eth2" | ||
34 | pgset "add_device eth2" | ||
35 | echo "Setting max_before_softirq 10000" | ||
36 | pgset "max_before_softirq 10000" | ||
37 | |||
38 | |||
39 | # device config | ||
40 | # delay 0 means maximum speed. | ||
41 | |||
42 | CLONE_SKB="clone_skb 1000000" | ||
43 | # NIC adds 4 bytes CRC | ||
44 | PKT_SIZE="pkt_size 60" | ||
45 | |||
46 | # COUNT 0 means forever | ||
47 | #COUNT="count 0" | ||
48 | COUNT="count 10000000" | ||
49 | DELAY="delay 0" | ||
50 | |||
51 | PGDEV=/proc/net/pktgen/eth1 | ||
52 | echo "Configuring $PGDEV" | ||
53 | pgset "$COUNT" | ||
54 | pgset "$CLONE_SKB" | ||
55 | pgset "$PKT_SIZE" | ||
56 | pgset "$DELAY" | ||
57 | pgset "dst 10.10.11.2" | ||
58 | pgset "dst_mac 00:04:23:08:91:dc" | ||
59 | |||
60 | PGDEV=/proc/net/pktgen/eth2 | ||
61 | echo "Configuring $PGDEV" | ||
62 | pgset "$COUNT" | ||
63 | pgset "$CLONE_SKB" | ||
64 | pgset "$PKT_SIZE" | ||
65 | pgset "$DELAY" | ||
66 | pgset "dst 192.168.2.2" | ||
67 | pgset "dst_mac 00:04:23:08:91:de" | ||
68 | |||
69 | # Time to run | ||
70 | PGDEV=/proc/net/pktgen/pgctrl | ||
71 | |||
72 | echo "Running... ctrl^C to stop" | ||
73 | pgset "start" | ||
74 | echo "Done" | ||
75 | |||
76 | # Result can be vieved in /proc/net/pktgen/eth[1,2] | ||
diff --git a/samples/pktgen/pktgen.conf-2-1 b/samples/pktgen/pktgen.conf-2-1 new file mode 100755 index 000000000000..845d7bf1609a --- /dev/null +++ b/samples/pktgen/pktgen.conf-2-1 | |||
@@ -0,0 +1,72 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | #modprobe pktgen | ||
4 | |||
5 | |||
6 | function 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 | function 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 | |||
28 | PGDEV=/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 | # We need to remove old config since we dont use this thread. We can only | ||
37 | # one NIC on one CPU due to affinity reasons. | ||
38 | |||
39 | PGDEV=/proc/net/pktgen/kpktgend_1 | ||
40 | echo "Removing all devices" | ||
41 | pgset "rem_device_all" | ||
42 | |||
43 | # device config | ||
44 | # delay 0 means maximum speed. | ||
45 | |||
46 | CLONE_SKB="clone_skb 1000000" | ||
47 | # NIC adds 4 bytes CRC | ||
48 | PKT_SIZE="pkt_size 60" | ||
49 | |||
50 | # COUNT 0 means forever | ||
51 | #COUNT="count 0" | ||
52 | COUNT="count 10000000" | ||
53 | DELAY="delay 0" | ||
54 | |||
55 | PGDEV=/proc/net/pktgen/eth1 | ||
56 | echo "Configuring $PGDEV" | ||
57 | pgset "$COUNT" | ||
58 | pgset "$CLONE_SKB" | ||
59 | pgset "$PKT_SIZE" | ||
60 | pgset "$DELAY" | ||
61 | pgset "dst 10.10.11.2" | ||
62 | pgset "dst_mac 00:04:23:08:91:dc" | ||
63 | |||
64 | |||
65 | # Time to run | ||
66 | PGDEV=/proc/net/pktgen/pgctrl | ||
67 | |||
68 | echo "Running... ctrl^C to stop" | ||
69 | pgset "start" | ||
70 | echo "Done" | ||
71 | |||
72 | # Result can be vieved in /proc/net/pktgen/eth1 | ||
diff --git a/samples/pktgen/pktgen.conf-2-2 b/samples/pktgen/pktgen.conf-2-2 new file mode 100755 index 000000000000..7ce86470a3a9 --- /dev/null +++ b/samples/pktgen/pktgen.conf-2-2 | |||
@@ -0,0 +1,82 @@ | |||
1 | #! /bin/sh | ||
2 | |||
3 | #modprobe pktgen | ||
4 | |||
5 | |||
6 | function 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 | function 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 | |||
28 | PGDEV=/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 | PGDEV=/proc/net/pktgen/kpktgend_1 | ||
37 | echo "Removing all devices" | ||
38 | pgset "rem_device_all" | ||
39 | echo "Adding eth2" | ||
40 | pgset "add_device eth2" | ||
41 | echo "Setting max_before_softirq 10000" | ||
42 | pgset "max_before_softirq 10000" | ||
43 | |||
44 | |||
45 | # device config | ||
46 | # delay 0 means maximum speed. | ||
47 | |||
48 | CLONE_SKB="clone_skb 1000000" | ||
49 | # NIC adds 4 bytes CRC | ||
50 | PKT_SIZE="pkt_size 60" | ||
51 | |||
52 | # COUNT 0 means forever | ||
53 | #COUNT="count 0" | ||
54 | COUNT="count 10000000" | ||
55 | DELAY="delay 0" | ||
56 | |||
57 | PGDEV=/proc/net/pktgen/eth1 | ||
58 | echo "Configuring $PGDEV" | ||
59 | pgset "$COUNT" | ||
60 | pgset "$CLONE_SKB" | ||
61 | pgset "$PKT_SIZE" | ||
62 | pgset "$DELAY" | ||
63 | pgset "dst 10.10.11.2" | ||
64 | pgset "dst_mac 00:04:23:08:91:dc" | ||
65 | |||
66 | PGDEV=/proc/net/pktgen/eth2 | ||
67 | echo "Configuring $PGDEV" | ||
68 | pgset "$COUNT" | ||
69 | pgset "$CLONE_SKB" | ||
70 | pgset "$PKT_SIZE" | ||
71 | pgset "$DELAY" | ||
72 | pgset "dst 192.168.2.2" | ||
73 | pgset "dst_mac 00:04:23:08:91:de" | ||
74 | |||
75 | # Time to run | ||
76 | PGDEV=/proc/net/pktgen/pgctrl | ||
77 | |||
78 | echo "Running... ctrl^C to stop" | ||
79 | pgset "start" | ||
80 | echo "Done" | ||
81 | |||
82 | # Result can be vieved in /proc/net/pktgen/eth[1,2] | ||