Merge tag 'asoc-fix-v4.13-rc7' into asoc-linus
[linux-2.6/btrfs-unstable.git] / samples / pktgen / pktgen_sample04_many_flows.sh
blob497fb7520464c6b44153252e26b46a4202678f5f
1 #!/bin/bash
3 # Script example for many flows testing
5 # Number of simultaneous flows limited by variable $FLOWS
6 # and number of packets per flow controlled by variable $FLOWLEN
8 basedir=`dirname $0`
9 source ${basedir}/functions.sh
10 root_check_run_with_sudo "$@"
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 [ -z "$COUNT" ] && COUNT="0" # Zero means indefinitely
20 # NOTICE: Script specific settings
21 # =======
22 # Limiting the number of concurrent flows ($FLOWS)
23 # and also set how many packets each flow contains ($FLOWLEN)
25 [ -z "$FLOWS" ] && FLOWS="8000"
26 [ -z "$FLOWLEN" ] && FLOWLEN="10"
28 # Base Config
29 DELAY="0" # Zero means max speed
31 if [[ -n "$BURST" ]]; then
32 err 1 "Bursting not supported for this mode"
35 # General cleanup everything since last run
36 pg_ctrl "reset"
38 # Threads are specified with parameter -t value in $THREADS
39 for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
40 dev=${DEV}@${thread}
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
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"
54 # Single destination
55 pg_set $dev "dst_mac $DST_MAC"
56 pg_set $dev "dst $DEST_IP"
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"
63 # Limit number of flows (max 65535)
64 pg_set $dev "flows $FLOWS"
66 # How many packets a flow will send, before flow "entry" is
67 # re-generated/setup.
68 pg_set $dev "flowlen $FLOWLEN"
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.
74 pg_set $dev "flag FLOW_SEQ"
76 done
78 # Run if user hits control-c
79 function print_result() {
80 # Print results
81 for ((thread = $F_THREAD; thread <= $L_THREAD; thread++)); do
82 dev=${DEV}@${thread}
83 echo "Device: $dev"
84 cat /proc/net/pktgen/$dev | grep -A2 "Result:"
85 done
87 # trap keyboard interrupt (Ctrl-C)
88 trap true SIGINT
90 echo "Running... ctrl^C to stop" >&2
91 pg_ctrl "start"
93 print_result