Created
April 5, 2019 14:15
-
-
Save maesoser/6237828840656917b5ee3a55b8ac90a4 to your computer and use it in GitHub Desktop.
Iperf scripts designed to perform throughput tests on ovs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Run multiple parallel instances of iperf client | |
| # Assumes iperf servers have been started, e.g. | |
| # iperf -s -p PORT | |
| # Examples: | |
| # Run 5 clients for 60 seconds to server 1.1.1.1 | |
| # iperf-multiple-clients 1.1.1.1 5 60 report | |
| # 5 files will be created, report-1.1.1.1-5001-60.txt, ... | |
| # | |
| # Run 7 clients for 20 seconds with UDP | |
| # iperf-multipleclients 1.1.1.1 7 20 report-udp -u -b 10M | |
| function() textSum { | |
| total=0 | |
| for i in ${1[@]}; do | |
| number=$(echo $i | cut -d: -f1) | |
| unit=$(echo $i | cut -d: -f2) | |
| if [ "$unit" == "Gbytes" || "$unit" == "Gbits/sec" ]; then | |
| multiplier=1000000000 | |
| elif [ "$unit" == "Mbytes" || "$unit" == "Mbits/sec" ]; then | |
| multiplier=1000000 | |
| elif [ "$unit" == "Kbytes" || "$unit" == "Kbits/sec" ]; then | |
| multiplier=1000 | |
| else | |
| multiplier=1 | |
| fi | |
| #echo "·i - $number - $unit - $multiplier - $total" | |
| let total+=($number*$multiplier) | |
| done | |
| echo $total | |
| } | |
| function() toMb { | |
| echo $(let $1/1000000) | |
| } | |
| if [ $# -eq 0 ] | |
| then | |
| echo "Usage: " | |
| echo -e "\t$0 [server_ip] [#clients] [duration] [report_name] [options]" | |
| exit | |
| fi | |
| base_port=5000 | |
| server_ip=$1 | |
| shift | |
| num_clients=$1 | |
| shift | |
| duration=$1 | |
| shift | |
| report_base=$1 | |
| shift | |
| iperf_options="$*" | |
| echo -e "Server: $server_ip\tDuration: $duration secs" | |
| echo "Report: $report_base" | |
| echo "Options: $iperf_options" | |
| for i in `seq 1 $num_clients`; do | |
| server_port=$(($base_port+$i)); | |
| report_file=${report_base}-${server_ip}-${server_port}-${test_duration}.log | |
| iperf3 -c $server_ip -p $server_port -t $duration $iperf_options 2>&1 > $report_file & | |
| pids[${i}]=$! | |
| done | |
| echo "Testing..." | |
| for pid in ${pids[*]}; do | |
| wait $pid | |
| done | |
| echo -e "Test done.\nSummary:" | |
| bytesRX_arr=$(grep "receiver" ${report_base}-${server_ip}*.log | awk '{print $5":"$6}') | |
| bytesRX=$(textSum $bytesRX_arr) | |
| mBytesRX=$(toMb $bytesRX) | |
| bytesTX_arr=$(grep "sender" ${report_base}-${server_ip}*.log | awk '{print $5":"$6}') | |
| bytesTX=$(textSum $bytesTX_arr) | |
| mBytesTX=$(toMb $bytesTX) | |
| bpsRX_arr=$(grep "receiver" ${report_base}-${server_ip}*.log | awk '{print $7":"$8}') | |
| bpsRX=$(textSum $bpsRX_arr) | |
| mbpsRX=$(toMb $bpsRX) | |
| bpsTX_arr=$(grep "sender" ${report_base}-${server_ip}*.log | awk '{print $7":"$8}') | |
| bpsTX=$(textSum $bpsTX_arr) | |
| mbpsTX=$(toMb $bpsTX) | |
| DATE=`date '+%Y-%m-%d %H:%M:%S'` | |
| echo -e "\tDate: $date" | |
| echo -e "\tTX Throughput: $mbpsTX Mbits/sec" | |
| echo -e "\tRX Throughput: $mbpsRX Mbist/sec\n" | |
| echo -e "\tTX Total: $mBytesTX Mbytes" | |
| echo -e "\tRX Total: $mBytesRX Mbytes" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Run multiple parallel instances of iperf servers | |
| if [ $# -eq 0 ] | |
| then | |
| echo "Usage: " | |
| echo -e "\t$0 start [servers] [report_name] [extra_options]" | |
| echo -e "\t$0 stop" | |
| echo -e "\t$0 status" | |
| exit | |
| fi | |
| if [ "$1" == "start" ]; then | |
| num_servers=$2 | |
| report_base=$3 | |
| shift && shift && shift | |
| iperf_options="$*" | |
| echo "Servers: $num_servers" | |
| echo "Report: $report_base" | |
| echo "Options: $iperf_options" | |
| for i in `seq 1 $num_servers`; do | |
| server_port=$(($base_port+$i)); | |
| report_file=${report_base}-${server_port}.log | |
| # echo "Running <iperf3 -s -p $server_port $iperf_options>" | |
| iperf3 -s -p $server_port $iperf_options 2>&1 > $report_file & | |
| done | |
| elif [ "$1" == "stop" ]; then | |
| iperf_pids=$(ps aux | grep "iperf" | awk '{print $1 }' | grep -E '[0-9]') | |
| for i in "${iperf_pids[@]}"; do | |
| kill -9 $i | |
| done | |
| elif [ "$1" == "status" ]; then | |
| ps aux | grep "iperf" | |
| else | |
| echo "Argument \"$1\" not known." | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment