From e36812903b516700ccd98e4ab0c34b1b3f86c95d Mon Sep 17 00:00:00 2001 From: Aidan Harris Date: Sun, 15 Nov 2020 12:32:22 +0000 Subject: [PATCH] Make sure ping uses ipv4 when $TESTPROTO equals -4 The ping command on some systems will default to using ipv6 if a hostname resolves to both ipv4 and ipv6 addresses. --- betterspeedtest.sh | 9 +++++++-- idlelatency.sh | 9 +++++++-- netperfrunner.sh | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/betterspeedtest.sh b/betterspeedtest.sh index afb4e2d..8f124eb 100755 --- a/betterspeedtest.sh +++ b/betterspeedtest.sh @@ -114,9 +114,9 @@ start_pings() { # Start Ping if [ $TESTPROTO -eq "-4" ] then - ping $PINGHOST > $PINGFILE & + "${PING4}" $PINGHOST > $PINGFILE & else - ping6 $PINGHOST > $PINGFILE & + "${PING6}" $PINGHOST > $PINGFILE & fi ping_pid=$! # echo "Ping PID: $ping_pid" @@ -186,6 +186,11 @@ measure_direction() { # set an initial values for defaults TESTHOST="netperf.bufferbloat.net" TESTDUR="60" + +PING4=ping +command -v ping4 > /dev/null 2>&1 && PING4=ping4 +PING6=ping6 + PINGHOST="gstatic.com" MAXSESSIONS="5" TESTPROTO="-4" diff --git a/idlelatency.sh b/idlelatency.sh index a47cd20..4367dd5 100644 --- a/idlelatency.sh +++ b/idlelatency.sh @@ -108,9 +108,9 @@ start_pings() { # Start Ping if [ $TESTPROTO -eq "-4" ] then - ping $PINGHOST > $PINGFILE & + "${PING4}" $PINGHOST > $PINGFILE & else - ping6 $PINGHOST > $PINGFILE & + "${PING6}" $PINGHOST > $PINGFILE & fi ping_pid=$! # echo "Ping PID: $ping_pid" @@ -127,6 +127,11 @@ start_pings() { # set an initial values for defaults TESTDUR="60" + +PING4=ping +command -v ping4 > /dev/null 2>&1 && PING4=ping4 +PING6=ping6 + PINGHOST="gstatic.com" TESTPROTO="-4" diff --git a/netperfrunner.sh b/netperfrunner.sh index 5c3fa8f..d1c74be 100755 --- a/netperfrunner.sh +++ b/netperfrunner.sh @@ -72,6 +72,11 @@ summarize_pings() { # set an initial values for defaults TESTHOST="netperf.bufferbloat.net" TESTDUR="60" + +PING4=ping +command -v ping4 > /dev/null 2>&1 && PING4=ping4 +PING6=ping6 + PINGHOST="gstatic.com" MAXSESSIONS=4 TESTPROTO=-4 @@ -132,9 +137,9 @@ echo "$DATE Testing $TESTHOST ($PROTO) with $MAXSESSIONS streams down and up whi # Start Ping if [ $TESTPROTO -eq "-4" ] then - ping $PINGHOST > $PINGFILE & + "${PING4}" $PINGHOST > $PINGFILE & else - ping6 $PINGHOST > $PINGFILE & + "${PING6}" $PINGHOST > $PINGFILE & fi ping_pid=$! # echo "Ping PID: $ping_pid"