diff options
| author | Jesper Dangaard Brouer <brouer@redhat.com> | 2016-07-13 16:06:04 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2016-07-14 18:19:51 -0400 |
| commit | 15f2cbbde4cff41904f5e87504ff45b36796b8d2 (patch) | |
| tree | 6b9f08746e2a07f4f2aaba2bae3dd9cfde44b342 /samples | |
| parent | 53d94892e27409bb2b48140207c0273b2ba65f61 (diff) | |
pktgen: add sample script pktgen_sample04_many_flows.sh
Adding a pktgen sample script that demonstrates how to use pktgen
for simulating flows. Script will generate a certain number of
concurrent flows ($FLOWS) and each flow will contain $FLOWLEN
packets, which will be send back-to-back, before switching to a
new flow, due to flag FLOW_SEQ.
This script obsoletes the old sample script 'pktgen.conf-1-1-flows',
which is removed.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples')
| -rwxr-xr-x | samples/pktgen/pktgen.conf-1-1-flows | 67 | ||||
| -rwxr-xr-x | samples/pktgen/pktgen_sample04_many_flows.sh | 93 |
2 files changed, 93 insertions, 67 deletions
diff --git a/samples/pktgen/pktgen.conf-1-1-flows b/samples/pktgen/pktgen.conf-1-1-flows deleted file mode 100755 index 081749c9707d..000000000000 --- a/samples/pktgen/pktgen.conf-1-1-flows +++ /dev/null | |||
| @@ -1,67 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 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 | # Config Start Here ----------------------------------------------------------- | ||
| 18 | |||
| 19 | |||
| 20 | # thread config | ||
| 21 | # Each CPU has its own thread. One CPU example. We add eth1. | ||
| 22 | |||
| 23 | PGDEV=/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 | ||
| 32 | # We need to do alloc for every skb since we cannot clone here. | ||
| 33 | |||
| 34 | CLONE_SKB="clone_skb 0" | ||
| 35 | # NIC adds 4 bytes CRC | ||
| 36 | PKT_SIZE="pkt_size 60" | ||
| 37 | |||
| 38 | # COUNT 0 means forever | ||
| 39 | #COUNT="count 0" | ||
| 40 | COUNT="count 10000000" | ||
| 41 | DELAY="delay 0" | ||
| 42 | |||
| 43 | PGDEV=/proc/net/pktgen/eth1 | ||
| 44 | echo "Configuring $PGDEV" | ||
| 45 | pgset "$COUNT" | ||
| 46 | pgset "$CLONE_SKB" | ||
| 47 | pgset "$PKT_SIZE" | ||
| 48 | pgset "$DELAY" | ||
| 49 | # Random address with in the min-max range | ||
| 50 | pgset "flag IPDST_RND" | ||
| 51 | pgset "dst_min 10.0.0.0" | ||
| 52 | pgset "dst_max 10.255.255.255" | ||
| 53 | |||
| 54 | # 8k Concurrent flows at 4 pkts | ||
| 55 | pgset "flows 8192" | ||
| 56 | pgset "flowlen 4" | ||
| 57 | |||
| 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 | trap true INT | ||
| 65 | pgset "start" | ||
| 66 | echo "Done" | ||
| 67 | cat /proc/net/pktgen/eth1 | ||
diff --git a/samples/pktgen/pktgen_sample04_many_flows.sh b/samples/pktgen/pktgen_sample04_many_flows.sh new file mode 100755 index 000000000000..f60412e445bb --- /dev/null +++ b/samples/pktgen/pktgen_sample04_many_flows.sh | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | # | ||
| 3 | # Script example for many flows testing | ||
| 4 | # | ||
| 5 | # Number of simultaneous flows limited by variable $FLOWS | ||
| 6 | # and number of packets per flow controlled by variable $FLOWLEN | ||
| 7 | # | ||
| 8 | basedir=`dirname $0` | ||
| 9 | source ${basedir}/functions.sh | ||
| 10 | root_check_run_with_sudo "$@" | ||
| 11 | |||
| 12 | # Parameter parsing via include | ||
| 13 | source ${basedir}/parameters.sh | ||
| 14 | # Set some default params, if they didn't get set | ||
| 15 | [ -z "$DEST_IP" ] && DEST_IP="198.18.0.42" | ||
| 16 | [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" | ||
| 17 | [ -z "$CLONE_SKB" ] && CLONE_SKB="0" | ||
| 18 | |||
| 19 | # NOTICE: Script specific settings | ||
| 20 | # ======= | ||
| 21 | # Limiting the number of concurrent flows ($FLOWS) | ||
| 22 | # and also set how many packets each flow contains ($FLOWLEN) | ||
| 23 | # | ||
| 24 | [ -z "$FLOWS" ] && FLOWS="8000" | ||
| 25 | [ -z "$FLOWLEN" ] && FLOWLEN="10" | ||
| 26 | |||
| 27 | # Base Config | ||
| 28 | DELAY="0" # Zero means max speed | ||
| 29 | COUNT="0" # Zero means indefinitely | ||
| 30 | |||
| 31 | if [[ -n "$BURST" ]]; then | ||
| 32 | err 1 "Bursting not supported for this mode" | ||
| 33 | fi | ||
| 34 | |||
| 35 | # General cleanup everything since last run | ||
| 36 | pg_ctrl "reset" | ||
| 37 | |||
| 38 | # Threads are specified with parameter -t value in $THREADS | ||
| 39 | for ((thread = 0; thread < $THREADS; thread++)); do | ||
| 40 | dev=${DEV}@${thread} | ||
| 41 | |||
| 42 | # Add remove all other devices and add_device $dev to thread | ||
| 43 | pg_thread $thread "rem_device_all" | ||
| 44 | pg_thread $thread "add_device" $dev | ||
| 45 | |||
| 46 | # Base config | ||
| 47 | pg_set $dev "flag QUEUE_MAP_CPU" | ||
| 48 | pg_set $dev "count $COUNT" | ||
| 49 | pg_set $dev "clone_skb $CLONE_SKB" | ||
| 50 | pg_set $dev "pkt_size $PKT_SIZE" | ||
| 51 | pg_set $dev "delay $DELAY" | ||
| 52 | pg_set $dev "flag NO_TIMESTAMP" | ||
| 53 | |||
| 54 | # Single destination | ||
| 55 | pg_set $dev "dst_mac $DST_MAC" | ||
| 56 | pg_set $dev "dst $DEST_IP" | ||
| 57 | |||
| 58 | # Randomize source IP-addresses | ||
| 59 | pg_set $dev "flag IPSRC_RND" | ||
| 60 | pg_set $dev "src_min 198.18.0.0" | ||
| 61 | pg_set $dev "src_max 198.19.255.255" | ||
| 62 | |||
| 63 | # Limit number of flows (max 65535) | ||
| 64 | pg_set $dev "flows $FLOWS" | ||
| 65 | # | ||
| 66 | # How many packets a flow will send, before flow "entry" is | ||
| 67 | # re-generated/setup. | ||
| 68 | pg_set $dev "flowlen $FLOWLEN" | ||
| 69 | # | ||
| 70 | # Flag FLOW_SEQ will cause $FLOWLEN packets from the same flow | ||
| 71 | # being send back-to-back, before next flow is selected | ||
| 72 | # incrementally. This helps lookup caches, and is more realistic. | ||
| 73 | # | ||
| 74 | pg_set $dev "flag FLOW_SEQ" | ||
| 75 | |||
| 76 | done | ||
| 77 | |||
| 78 | # Run if user hits control-c | ||
| 79 | function print_result() { | ||
| 80 | # Print results | ||
| 81 | for ((thread = 0; thread < $THREADS; thread++)); do | ||
| 82 | dev=${DEV}@${thread} | ||
| 83 | echo "Device: $dev" | ||
| 84 | cat /proc/net/pktgen/$dev | grep -A2 "Result:" | ||
| 85 | done | ||
| 86 | } | ||
| 87 | # trap keyboard interrupt (Ctrl-C) | ||
| 88 | trap true SIGINT | ||
| 89 | |||
| 90 | echo "Running... ctrl^C to stop" >&2 | ||
| 91 | pg_ctrl "start" | ||
| 92 | |||
| 93 | print_result | ||
