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
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"
19 # NOTICE: Script specific settings
21 # Limiting the number of concurrent flows ($FLOWS)
22 # and also set how many packets each flow contains ($FLOWLEN)
24 [ -z "$FLOWS" ] && FLOWS
="8000"
25 [ -z "$FLOWLEN" ] && FLOWLEN
="10"
28 DELAY
="0" # Zero means max speed
29 COUNT
="0" # Zero means indefinitely
31 if [[ -n "$BURST" ]]; then
32 err
1 "Bursting not supported for this mode"
35 # General cleanup everything since last run
38 # Threads are specified with parameter -t value in $THREADS
39 for ((thread
= 0; thread
< $THREADS; thread
++)); do
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
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"
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
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"
78 # Run if user hits control-c
79 function print_result
() {
81 for ((thread
= 0; thread
< $THREADS; thread
++)); do
84 cat /proc
/net
/pktgen
/$dev |
grep -A2 "Result:"
87 # trap keyboard interrupt (Ctrl-C)
90 echo "Running... ctrl^C to stop" >&2