License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-2.6/btrfs-unstable.git] / samples / pktgen / pktgen_sample04_many_flows.sh
blob4df92b7176da8241e7b1099c14b471dc675adf81
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # Script example for many flows testing
6 # Number of simultaneous flows limited by variable $FLOWS
7 # and number of packets per flow controlled by variable $FLOWLEN
9 basedir=`dirname $0`
10 source ${basedir}/functions.sh
11 root_check_run_with_sudo "$@"
13 # Parameter parsing via include
14 source ${basedir}/parameters.sh
15 # Set some default params, if they didn't get set
16 [ -z "$DEST_IP" ] && DEST_IP="198.18.0.42"
17 [ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff"
18 [ -z "$CLONE_SKB" ] && CLONE_SKB="0"
19 [ -z "$COUNT" ] && COUNT="0" # Zero means indefinitely
21 # NOTICE: Script specific settings
22 # =======
23 # Limiting the number of concurrent flows ($FLOWS)
24 # and also set how many packets each flow contains ($FLOWLEN)
26 [ -z "$FLOWS" ] && FLOWS="8000"
27 [ -z "$FLOWLEN" ] && FLOWLEN="10"
29 # Base Config
30 DELAY="0" # Zero means max speed
32 if [[ -n "$BURST" ]]; then
33 err 1 "Bursting not supported for this mode"
36 # General cleanup everything since last run
37 pg_ctrl "reset"
39 # Threads are specified with parameter -t value in $THREADS
40 for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
41 dev=${DEV}@${thread}
43 # Add remove all other devices and add_device $dev to thread
44 pg_thread $thread "rem_device_all"
45 pg_thread $thread "add_device" $dev
47 # Base config
48 pg_set $dev "flag QUEUE_MAP_CPU"
49 pg_set $dev "count $COUNT"
50 pg_set $dev "clone_skb $CLONE_SKB"
51 pg_set $dev "pkt_size $PKT_SIZE"
52 pg_set $dev "delay $DELAY"
53 pg_set $dev "flag NO_TIMESTAMP"
55 # Single destination
56 pg_set $dev "dst_mac $DST_MAC"
57 pg_set $dev "dst $DEST_IP"
59 # Randomize source IP-addresses
60 pg_set $dev "flag IPSRC_RND"
61 pg_set $dev "src_min 198.18.0.0"
62 pg_set $dev "src_max 198.19.255.255"
64 # Limit number of flows (max 65535)
65 pg_set $dev "flows $FLOWS"
67 # How many packets a flow will send, before flow "entry" is
68 # re-generated/setup.
69 pg_set $dev "flowlen $FLOWLEN"
71 # Flag FLOW_SEQ will cause $FLOWLEN packets from the same flow
72 # being send back-to-back, before next flow is selected
73 # incrementally. This helps lookup caches, and is more realistic.
75 pg_set $dev "flag FLOW_SEQ"
77 done
79 # Run if user hits control-c
80 function print_result() {
81 # Print results
82 for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
83 dev=${DEV}@${thread}
84 echo "Device: $dev"
85 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
86 done
88 # trap keyboard interrupt (Ctrl-C)
89 trap true SIGINT
91 echo "Running... ctrl^C to stop" >&2
92 pg_ctrl "start"
94 print_result