Merge tag 'iio-fixes-for-5.8a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23...
[linux/fpc-iii.git] / samples / pktgen / pktgen_sample04_many_flows.sh
blob2cd6b701400de5cee39d9fe518c74f68846fcf71
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
20 if [ -n "$DEST_IP" ]; then
21 validate_addr $DEST_IP
22 read -r DST_MIN DST_MAX <<< $(parse_addr $DEST_IP)
24 if [ -n "$DST_PORT" ]; then
25 read -r UDP_DST_MIN UDP_DST_MAX <<< $(parse_ports $DST_PORT)
26 validate_ports $UDP_DST_MIN $UDP_DST_MAX
29 # NOTICE: Script specific settings
30 # =======
31 # Limiting the number of concurrent flows ($FLOWS)
32 # and also set how many packets each flow contains ($FLOWLEN)
34 [ -z "$FLOWS" ] && FLOWS="8000"
35 [ -z "$FLOWLEN" ] && FLOWLEN="10"
37 # Base Config
38 DELAY="0" # Zero means max speed
40 if [[ -n "$BURST" ]]; then
41 err 1 "Bursting not supported for this mode"
44 # 198.18.0.0 / 198.19.255.255
45 read -r SRC_MIN SRC_MAX <<< $(parse_addr 198.18.0.0/15)
47 # General cleanup everything since last run
48 pg_ctrl "reset"
50 # Threads are specified with parameter -t value in $THREADS
51 for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
52 dev=${DEV}@${thread}
54 # Add remove all other devices and add_device $dev to thread
55 pg_thread $thread "rem_device_all"
56 pg_thread $thread "add_device" $dev
58 # Base config
59 pg_set $dev "flag QUEUE_MAP_CPU"
60 pg_set $dev "count $COUNT"
61 pg_set $dev "clone_skb $CLONE_SKB"
62 pg_set $dev "pkt_size $PKT_SIZE"
63 pg_set $dev "delay $DELAY"
64 pg_set $dev "flag NO_TIMESTAMP"
66 # Single destination
67 pg_set $dev "dst_mac $DST_MAC"
68 pg_set $dev "dst_min $DST_MIN"
69 pg_set $dev "dst_max $DST_MAX"
71 if [ -n "$DST_PORT" ]; then
72 # Single destination port or random port range
73 pg_set $dev "flag UDPDST_RND"
74 pg_set $dev "udp_dst_min $UDP_DST_MIN"
75 pg_set $dev "udp_dst_max $UDP_DST_MAX"
78 # Randomize source IP-addresses
79 pg_set $dev "flag IPSRC_RND"
80 pg_set $dev "src_min $SRC_MIN"
81 pg_set $dev "src_max $SRC_MAX"
83 # Limit number of flows (max 65535)
84 pg_set $dev "flows $FLOWS"
86 # How many packets a flow will send, before flow "entry" is
87 # re-generated/setup.
88 pg_set $dev "flowlen $FLOWLEN"
90 # Flag FLOW_SEQ will cause $FLOWLEN packets from the same flow
91 # being send back-to-back, before next flow is selected
92 # incrementally. This helps lookup caches, and is more realistic.
94 pg_set $dev "flag FLOW_SEQ"
96 done
98 # Run if user hits control-c
99 function print_result() {
100 # Print results
101 for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
102 dev=${DEV}@${thread}
103 echo "Device: $dev"
104 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
105 done
107 # trap keyboard interrupt (Ctrl-C)
108 trap true SIGINT
110 echo "Running... ctrl^C to stop" >&2
111 pg_ctrl "start"
113 print_result