aboutsummaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorJesper Dangaard Brouer <brouer@redhat.com>2015-05-21 06:17:33 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-22 23:59:17 -0400
commit6f09479758be247fef02188a275383ebaddbe291 (patch)
tree833f7db1b84e0093905532b87845539b964950c6 /samples
parentb64b0d1e64959691c1f4067a05fdb541d453ed6a (diff)
pktgen: add sample script pktgen_sample01_simple.sh
Add the first basic pktgen samples script pktgen_sample01_simple.sh, which demonstrates the a simple use of the helper functions. Removing pktgen.conf-1-1 as that example should be covered now. The naming scheme pktgen_sampleNN, where NN is a number, should encourage reading the samples in a specific order. Script cause pktgen sending with a single thread and single interface, and introduce flow variation via random UDP source port. Usage example and help: ./pktgen_sample01_simple.sh -i eth4 -m 00:1B:21:3C:9D:F8 -d 192.168.8.2 Usage: ./pktgen_sample01_simple.sh [-vx] -i ethX -i : ($DEV) output interface/device (required) -s : ($PKT_SIZE) packet size -d : ($DEST_IP) destination IP -m : ($DST_MAC) destination MAC-addr -c : ($SKB_CLONE) SKB clones send before alloc new SKB -v : ($VERBOSE) verbose -x : ($DEBUG) debug Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples')
-rwxr-xr-xsamples/pktgen/pktgen.conf-1-159
-rwxr-xr-xsamples/pktgen/pktgen_sample01_simple.sh71
2 files changed, 71 insertions, 59 deletions
diff --git a/samples/pktgen/pktgen.conf-1-1 b/samples/pktgen/pktgen.conf-1-1
deleted file mode 100755
index f91daad9e916..000000000000
--- a/samples/pktgen/pktgen.conf-1-1
+++ /dev/null
@@ -1,59 +0,0 @@
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
diff --git a/samples/pktgen/pktgen_sample01_simple.sh b/samples/pktgen/pktgen_sample01_simple.sh
new file mode 100755
index 000000000000..8c9d318c221b
--- /dev/null
+++ b/samples/pktgen/pktgen_sample01_simple.sh
@@ -0,0 +1,71 @@
1#!/bin/bash
2#
3# Simple example:
4# * pktgen sending with single thread and single interface
5# * flow variation via random UDP source port
6#
7basedir=`dirname $0`
8source ${basedir}/functions.sh
9root_check_run_with_sudo "$@"
10
11# Parameter parsing via include
12# - go look in parameters.sh to see which setting are avail
13# - required param is the interface "-i" stored in $DEV
14source ${basedir}/parameters.sh
15#
16# Set some default params, if they didn't get set
17[ -z "$DEST_IP" ] && DEST_IP="198.18.0.42"
18[ -z "$CLONE_SKB" ] && CLONE_SKB="0"
19# Example enforce param "-m" for dst_mac
20[ -z "$DST_MAC" ] && usage && err 2 "Must specify -m dst_mac"
21
22# Base Config
23DELAY="0" # Zero means max speed
24COUNT="100000" # Zero means indefinitely
25
26# Flow variation random source port between min and max
27UDP_MIN=9
28UDP_MAX=109
29
30# General cleanup everything since last run
31# (especially important if other threads were configured by other scripts)
32pg_ctrl "reset"
33
34# Add remove all other devices and add_device $DEV to thread 0
35thread=0
36pg_thread $thread "rem_device_all"
37pg_thread $thread "add_device" $DEV
38
39# How many packets to send (zero means indefinitely)
40pg_set $DEV "count $COUNT"
41
42# Reduce alloc cost by sending same SKB many times
43# - this obviously affects the randomness within the packet
44pg_set $DEV "clone_skb $CLONE_SKB"
45
46# Set packet size
47pg_set $DEV "pkt_size $PKT_SIZE"
48
49# Delay between packets (zero means max speed)
50pg_set $DEV "delay $DELAY"
51
52# Flag example disabling timestamping
53pg_set $DEV "flag NO_TIMESTAMP"
54
55# Destination
56pg_set $DEV "dst_mac $DST_MAC"
57pg_set $DEV "dst $DEST_IP"
58
59# Setup random UDP port src range
60pg_set $DEV "flag UDPSRC_RND"
61pg_set $DEV "udp_src_min $UDP_MIN"
62pg_set $DEV "udp_src_max $UDP_MAX"
63
64# start_run
65echo "Running... ctrl^C to stop" >&2
66pg_ctrl "start"
67echo "Done" >&2
68
69# Print results
70echo "Result device: $DEV"
71cat /proc/net/pktgen/$DEV