Refactor iperf3 function in runtest.sh for improved argument handling and readability
This commit is contained in:
parent
e3c3647a7e
commit
50000ac5c2
1 changed files with 15 additions and 11 deletions
20
runtest.sh
20
runtest.sh
|
@ -109,23 +109,27 @@ while [ "$COUNTER" -lt "$NUM_TESTS" ]; do
|
||||||
|
|
||||||
# iperf3 function
|
# iperf3 function
|
||||||
run_iperf() {
|
run_iperf() {
|
||||||
local target=$1
|
local target="$1"
|
||||||
local mode=$2 # tcp or udp
|
local mode="$2"
|
||||||
local direction=$3 # up or down
|
local direction="$3"
|
||||||
|
local args=("-c" "$target" "-J" "-t" "10")
|
||||||
|
|
||||||
local args="-c $target -J -t $IPERF_DURATION"
|
if [ "$mode" = "udp" ]; then
|
||||||
[ "$mode" = "udp" ] && args="$args -u -b 10M"
|
args+=("-u")
|
||||||
|
fi
|
||||||
|
|
||||||
[ "$direction" = "down" ] && args="$args -R"
|
if [ "$direction" = "down" ]; then
|
||||||
|
args+=("--reverse")
|
||||||
|
fi
|
||||||
|
|
||||||
iperf3 $args 2>/dev/null | jq -r '
|
iperf3 "${args[@]}" 2>/dev/null | jq -r '
|
||||||
if .error then "0" else
|
if .error then "0" else
|
||||||
if .end then
|
if .end then
|
||||||
if .end.sum_received then .end.sum_received.bits_per_second
|
if .end.sum_received then .end.sum_received.bits_per_second
|
||||||
elif .end.sum then .end.sum.bits_per_second
|
elif .end.sum then .end.sum.bits_per_second
|
||||||
else "0" end
|
else "0" end
|
||||||
else "0" end
|
else "0" end
|
||||||
end'
|
end' || echo "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
echo " Running iperf3 tests..."
|
echo " Running iperf3 tests..."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue