Last active
March 17, 2020 08:38
-
-
Save lyekumchew/6dca6f27c80b96d0a62392c886198851 to your computer and use it in GitHub Desktop.
iperf3
This file contains 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 | |
function calc() { | |
res=0 | |
for file in $(ls $3/single_$1_*$2*); do | |
tmp=$(tac $file | sed -n 4p | awk '{print $7}') | |
res=$(echo "${res}+${tmp}"|bc) | |
done | |
echo "time:" $i "threads:" $j "result:" $res | |
} | |
for i in 10 20; do | |
for j in 1 32 64 128; do | |
calc $j $i $1 | |
done | |
done |
This file contains 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 | |
function calc() { | |
res_2=0 | |
i_2=0 | |
res_3=0 | |
i_3=0 | |
for file in $(find $3/ -size +1 | grep $1 | grep $2); do | |
# 丢包率 | |
tmp_2=$(tac $file | sed -n 4p | awk '{print $12}' | sed 's/(//g' | sed 's/\%)//g') | |
i_2=$(echo "${i_2}+1"|bc) | |
res_2=$(echo "${res_2}+${tmp_2}"|bc) | |
# 延迟 | |
tmp_3=$(tac $file | sed -n 4p | awk '{print $9}') | |
i_3=$(echo "${i_3}+1"|bc) | |
res_3=$(echo "${res_3}+${tmp_3}"|bc) | |
done | |
res_2=$(echo "scale=4; ${res_2}/${i_2}"|bc) | |
res_3=$(echo "scale=4; ${res_3}/${i_3}"|bc) | |
echo "time:" $i "threads:" $j "lat:" $res_3 "," "loss:" $res_2 | |
} | |
for i in 10 20; do | |
for j in 1 32 64 128; do | |
calc $j $i $1 | |
done | |
done |
This file contains 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 | |
# time = 10s | |
for threads in 1 32 64 128; do | |
echo "boot ${threads} thread(s)" | |
numactl -N 0-3 ./iperf3_client.sh 6000 172.26.0.2 $threads 10 double -f g -w 400M -b 100G -B 172.26.0.4 $* | |
numactl -N 0-3 ./iperf3_client.sh 7000 172.26.0.3 $threads 10 double -f g -w 400M -b 100G -B 172.26.0.5 $* | |
sleep 18 | |
done | |
# time = 20s | |
for threads in 1 32 64 128; do | |
echo "boot ${threads} thread(s)" | |
numactl -N 0-3 ./iperf3_client.sh 6000 172.26.0.2 $threads 20 double -f g -w 400M -b 100G -B 172.26.0.4 $* | |
numactl -N 0-3 ./iperf3_client.sh 7000 172.26.0.3 $threads 20 double -f g -w 400M -b 100G -B 172.26.0.5 $* | |
sleep 28 | |
done |
This file contains 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 | |
pkill iperf3 | |
numactl -N 0-3 ./iperf3_server.sh 6000 128 server_report -f g -B 172.26.0.2 | |
numactl -N 0-3 ./iperf3_server.sh 7000 128 server_report -f g -B 172.26.0.3 |
This file contains 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 | |
# Assumes the port numbers used by the servers start at 5001 and increase | |
# e.g. 5001, 5002, 5003, ... | |
# If you want something different, then change the following parameter value | |
# to be: firstport - 1 | |
base_port=$1 | |
shift | |
# Command line input: server IP address | |
# E.g. 1.1.1.1 | |
server_ip=$1 | |
shift | |
# Command line input: number of clients to start | |
# E.g. 5 | |
num_clients=$1 | |
shift | |
# Command line input: test duration | |
# E.g. 60 | |
test_duration=$1 | |
shift | |
# Command line input: base report file name | |
# E.g. report | |
report_base=$1 | |
shift | |
# Optional command line input: other iperf options | |
# E.g. -u -b 10M | |
iperf_options="$*" | |
# Run iperf multiple times | |
for i in `seq 1 $num_clients`; do | |
# Set server port | |
server_port=$(($base_port+$i)); | |
# Report file includes server ip, server port and test duration | |
report_file=${report_base}_${num_clients}_${server_ip}_${server_port}_${test_duration}.txt | |
# Run iperf | |
iperf3 -A `expr $i - 1 ` -c $server_ip -p $server_port -t $test_duration $iperf_options &> $report_file & | |
done |
This file contains 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 | |
# Assumes the port numbers used by the servers start at 5001 and increase | |
# e.g. 5001, 5002, 5003, ... | |
# If you want something different, then change the following parameter value | |
# to be: firstport - 1 | |
base_port=$1 | |
shift | |
# Command line input: number of servers | |
# E.g. 5 | |
num_servers=$1 | |
shift | |
# Command line input: base report file name | |
# E.g. report | |
report_base=$1 | |
shift | |
# Optional command line input: other iperf options | |
# E.g. -u | |
iperf_options="$*" | |
#pkill iperf3 | |
# Run iperf multiple times | |
for i in `seq 1 $num_servers`; do | |
# Set server port | |
server_port=$(($base_port+$i)); | |
# Report file includes server port | |
report_file=${report_base}_${server_port}.txt | |
# Run iperf | |
iperf3 -A `expr $i - 1 ` -s -p $server_port $iperf_options &> $report_file & | |
done |
This file contains 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 | |
# time = 10s | |
for threads in 1 32 64 128; do | |
echo "boot ${threads} thread(s)" | |
numactl -N 0-3 ./iperf3_client.sh 6000 172.26.0.2 $threads 10 single -f g -w 400M -b 100G $* | |
sleep 15 | |
done | |
# time = 20s | |
for threads in 1 32 64 128; do | |
echo "boot ${threads} thread(s)" | |
numactl -N 0-3 ./iperf3_client.sh 6000 172.26.0.2 $threads 20 single -f g -w 400M -b 100G $* | |
sleep 25 | |
done |
This file contains 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
# 测试服务器服务端 | |
# iperf3 服务器模式同时启动 tcp 和 udp | |
bash double_port_server.sh | |
# 测试服务器客户端 | |
# tcp 单端口单路/双路 | |
bash single_port_client.sh | |
bash single_port_client.sh --bidir | |
# udp 单端口单路/双路 | |
bash single_port_client.sh -u | |
bash single_port_client.sh -u --bidir | |
# tcp 双端口单路/双路 | |
bash double_port_client.sh | |
bash double_port_client.sh --bidir | |
# udp 双端口单路/双路 | |
bash double_port_client.sh -u | |
bash double_port_client.sh -u --bidir | |
# tcp/udp 结果统计输出 | |
# 先将生成的所有日志文件放入一个目录 | |
bash calc.sh <dir> | |
bash calc_udp.sh <dir> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment