1*d25692e4SJesper Dangaard Brouer#!/bin/bash 2*d25692e4SJesper Dangaard Brouer# 3*d25692e4SJesper Dangaard Brouer# Script will generate one flow per thread (-t N) 4*d25692e4SJesper Dangaard Brouer# - Same destination IP 5*d25692e4SJesper Dangaard Brouer# - Fake source IPs for each flow (fixed based on thread number) 6*d25692e4SJesper Dangaard Brouer# 7*d25692e4SJesper Dangaard Brouer# Useful for scale testing on receiver, to see whether silo'ing flows 8*d25692e4SJesper Dangaard Brouer# works and scales. For optimal scalability (on receiver) each 9*d25692e4SJesper Dangaard Brouer# separate-flow should not access shared variables/data. This script 10*d25692e4SJesper Dangaard Brouer# helps magnify any of these scaling issues by overloading the receiver. 11*d25692e4SJesper Dangaard Brouer# 12*d25692e4SJesper Dangaard Brouerbasedir=`dirname $0` 13*d25692e4SJesper Dangaard Brouersource ${basedir}/functions.sh 14*d25692e4SJesper Dangaard Brouerroot_check_run_with_sudo "$@" 15*d25692e4SJesper Dangaard Brouer 16*d25692e4SJesper Dangaard Brouer# Parameter parsing via include 17*d25692e4SJesper Dangaard Brouersource ${basedir}/parameters.sh 18*d25692e4SJesper Dangaard Brouer# Set some default params, if they didn't get set 19*d25692e4SJesper Dangaard Brouer[ -z "$DEST_IP" ] && DEST_IP="198.18.0.42" 20*d25692e4SJesper Dangaard Brouer[ -z "$DST_MAC" ] && DST_MAC="90:e2:ba:ff:ff:ff" 21*d25692e4SJesper Dangaard Brouer[ -z "$CLONE_SKB" ] && CLONE_SKB="0" 22*d25692e4SJesper Dangaard Brouer[ -z "$BURST" ] && BURST=32 23*d25692e4SJesper Dangaard Brouer 24*d25692e4SJesper Dangaard Brouer 25*d25692e4SJesper Dangaard Brouer# Base Config 26*d25692e4SJesper Dangaard BrouerDELAY="0" # Zero means max speed 27*d25692e4SJesper Dangaard BrouerCOUNT="0" # Zero means indefinitely 28*d25692e4SJesper Dangaard Brouer 29*d25692e4SJesper Dangaard Brouer# General cleanup everything since last run 30*d25692e4SJesper Dangaard Brouerpg_ctrl "reset" 31*d25692e4SJesper Dangaard Brouer 32*d25692e4SJesper Dangaard Brouer# Threads are specified with parameter -t value in $THREADS 33*d25692e4SJesper Dangaard Brouerfor ((thread = 0; thread < $THREADS; thread++)); do 34*d25692e4SJesper Dangaard Brouer dev=${DEV}@${thread} 35*d25692e4SJesper Dangaard Brouer 36*d25692e4SJesper Dangaard Brouer # Add remove all other devices and add_device $dev to thread 37*d25692e4SJesper Dangaard Brouer pg_thread $thread "rem_device_all" 38*d25692e4SJesper Dangaard Brouer pg_thread $thread "add_device" $dev 39*d25692e4SJesper Dangaard Brouer 40*d25692e4SJesper Dangaard Brouer # Base config 41*d25692e4SJesper Dangaard Brouer pg_set $dev "flag QUEUE_MAP_CPU" 42*d25692e4SJesper Dangaard Brouer pg_set $dev "count $COUNT" 43*d25692e4SJesper Dangaard Brouer pg_set $dev "clone_skb $CLONE_SKB" 44*d25692e4SJesper Dangaard Brouer pg_set $dev "pkt_size $PKT_SIZE" 45*d25692e4SJesper Dangaard Brouer pg_set $dev "delay $DELAY" 46*d25692e4SJesper Dangaard Brouer pg_set $dev "flag NO_TIMESTAMP" 47*d25692e4SJesper Dangaard Brouer 48*d25692e4SJesper Dangaard Brouer # Single destination 49*d25692e4SJesper Dangaard Brouer pg_set $dev "dst_mac $DST_MAC" 50*d25692e4SJesper Dangaard Brouer pg_set $dev "dst $DEST_IP" 51*d25692e4SJesper Dangaard Brouer 52*d25692e4SJesper Dangaard Brouer # Setup source IP-addresses based on thread number 53*d25692e4SJesper Dangaard Brouer pg_set $dev "src_min 198.18.$((thread+1)).1" 54*d25692e4SJesper Dangaard Brouer pg_set $dev "src_max 198.18.$((thread+1)).1" 55*d25692e4SJesper Dangaard Brouer 56*d25692e4SJesper Dangaard Brouer # Setup burst, for easy testing -b 0 disable bursting 57*d25692e4SJesper Dangaard Brouer # (internally in pktgen default and minimum burst=1) 58*d25692e4SJesper Dangaard Brouer if [[ ${BURST} -ne 0 ]]; then 59*d25692e4SJesper Dangaard Brouer pg_set $dev "burst $BURST" 60*d25692e4SJesper Dangaard Brouer else 61*d25692e4SJesper Dangaard Brouer info "$dev: Not using burst" 62*d25692e4SJesper Dangaard Brouer fi 63*d25692e4SJesper Dangaard Brouer 64*d25692e4SJesper Dangaard Brouerdone 65*d25692e4SJesper Dangaard Brouer 66*d25692e4SJesper Dangaard Brouer# Run if user hits control-c 67*d25692e4SJesper Dangaard Brouerfunction print_result() { 68*d25692e4SJesper Dangaard Brouer # Print results 69*d25692e4SJesper Dangaard Brouer for ((thread = 0; thread < $THREADS; thread++)); do 70*d25692e4SJesper Dangaard Brouer dev=${DEV}@${thread} 71*d25692e4SJesper Dangaard Brouer echo "Device: $dev" 72*d25692e4SJesper Dangaard Brouer cat /proc/net/pktgen/$dev | grep -A2 "Result:" 73*d25692e4SJesper Dangaard Brouer done 74*d25692e4SJesper Dangaard Brouer} 75*d25692e4SJesper Dangaard Brouer# trap keyboard interrupt (Ctrl-C) 76*d25692e4SJesper Dangaard Brouertrap true SIGINT 77*d25692e4SJesper Dangaard Brouer 78*d25692e4SJesper Dangaard Brouerecho "Running... ctrl^C to stop" >&2 79*d25692e4SJesper Dangaard Brouerpg_ctrl "start" 80*d25692e4SJesper Dangaard Brouer 81*d25692e4SJesper Dangaard Brouerprint_result 82