Speedtest: new package to measure network performance

I've tried several times with no results.

I put the script into debug mode and ran it again. Maybe there is a clue as to what may be happening in the output.

root@lede:~# speedtest.sh
+ TESTHOST=netperf.bufferbloat.net
+ TESTDUR=60
+ PINGHOST=gstatic.com
+ MAXSESSIONS=5
+ TESTPROTO=-4
+ TESTSEQ=1
+ '[' 0 -gt 0 ]
+ date '+%Y-%m-%d %H:%M:%S'
+ DATE='2018-11-08 07:19:05'
+ echo '2018-11-08 07:19:05 Starting speedtest for 60 seconds per transfer session.'
2018-11-08 07:19:05 Starting speedtest for 60 seconds per transfer session.
+ echo 'Measure speed to netperf.bufferbloat.net (IPv4) while pinging gstatic.com.'
Measure speed to netperf.bufferbloat.net (IPv4) while pinging gstatic.com.
+ echo -n 'Download and upload sessions are '
Download and upload sessions are + '[' '1 ' -eq 1 ]
+ echo -n sequential,
sequential,+ echo ' each with 5 simultaneous streams.'
 each with 5 simultaneous streams.
+ trap kill_background_and_exit HUP INT TERM
+ '[' 1 -eq 1 ]
+ measure_direction Download
+ mktemp /tmp/netperfUL.XXXXXX
+ ULFILE=/tmp/netperfUL.pBCDEJ
+ mktemp /tmp/netperfDL.XXXXXX
+ DLFILE=/tmp/netperfDL.PcBAao
+ mktemp /tmp/measurepings.XXXXXX
+ PINGFILE=/tmp/measurepings.EMeaka
+ mktemp /tmp/measureload.XXXXXX
+ LOADFILE=/tmp/measureload.OafFaP
+ DIRECTION=Download
+ dots_pid=3881
+ '[' -4 -eq -4 ]
+ + ping_pid=3882
print_dots
+ + load_pid=3883
+ '[' Download '=' Bidirectional ]
+ spd_test=TCP_MAERTS
+ start_netperf TCP_MAERTS /tmp/netperfDL.PcBAao
:
+ printf .
+ seq 5
.+ sleep 1s
+ sample_load
+ cat /proc/3875/stat
+ wait_netperf
+ ping gstatic.com
+ + + netperf -4+ netperf -4 -H netperf.bufferbloat.net -t TCP_MAERTS -l 60 -v 0 -P 0
 -H netperf.bufferbloat.net -tpgrep TCP_MAERTS+  -l -P 60 3875 -v netperf 0
 -P 0
netperf+ netperf -4 -H netperf.bufferbloat.net -t TCP_MAERTS -l 60 -v 0 -P 0
+ :
+ sleep 1s
 -4 -H netperf.bufferbloat.net -t TCP_MAERTS -l 60 -v 0 -P 0
netperf -4 -H netperf.bufferbloat.net -t TCP_MAERTS -l 60 -v 0 -P 0
+ wait 3886
+ wait 3887
+ wait 3889
+ wait 3890
+ wait 3891
+ kill_load
+ kill -9 3883
+ wait 3883
+ load_pid=0
+ kill_pings
+ kill -9 3882
+ wait 3882
+ ping_pid=0
+ kill_dots
+ kill -9 3881
+ wait 3881
+ dots_pid=0
+ echo

+ '[' Download '=' Bidirectional ]
+ summarize_speed Download /tmp/netperfDL.PcBAao
+ awk '{s+=$1} END {print s}' /tmp/netperfDL.PcBAao
+ printf '%9s: %6.2f Mbps\n' Download 0
 Download:   0.00 Mbps
+ summarize_pings /tmp/measurepings.EMeaka
+ grep -v PING
+ sort -n
+ awk '
BEGIN {numdrops=0; numrows=0;}
{
        if ( $0 ~ /timeout/ ) {
                numdrops += 1;
        } else {
                numrows += 1;
                arr[numrows]=$1; sum+=$1;
        }
}
END {
        pc10="-"; pc90="-"; med="-";
        if (numrows == 0) {numrows=1}
        if (numrows>=10) {
                ix=int(numrows/10); pc10=arr[ix]; ix=int(numrows*9/10);pc90=arr[ix];
                if (numrows%2==1) med=arr[(numrows+1)/2]; else med=(arr[numrows/2]);
        }
        pktloss = numdrops/(numdrops+numrows) * 100;
        printf("  Latency: (in msec, %d pings, %4.2f%% packet loss)\n      Min: %4.3f \n    10pct: %4.3f \n   Median: %4.3f \n      Avg: %4.3f \n    90pct: %4.3f \n      Max: %4.3f\n", numrows, pktloss, arr[1], pc10, med, sum/numrows, pc90, arr[numrows] )
}'+ sed 's/^.*time=\([^ ]*\) ms/\1/'

  Latency: (in msec, 1 pings, 0.00% packet loss)
      Min: 46.035
    10pct: 0.000
   Median: 0.000
      Avg: 46.035
    90pct: 0.000
      Max: 46.035
+ summarize_load /tmp/measureload.OafFaP
+ cat /tmp/measureload.OafFaP /proc/3875/stat+ awk '
# total CPU of speedtest processes
$1 !~ /cpu/ {
        tot=$16+$17
        if (init_proc_cpu=="") init_proc_cpu=tot
        proc_cpu=tot-init_proc_cpu
}
# track aggregate CPU stats
$1 == "cpu" {
        tot=0; for (f=2;f<=NF;f++) tot+=$f
        if (init_cpu=="") init_cpu=tot
        tot_cpu=tot-init_cpu
}
# track per-CPU stats
$1 ~ /cpu[0-9]+/ {
        tot=0; for (f=2;f<=NF;f++) tot+=$f
        usg = tot - $5
        if (init_tot[$1]=="") {
                init_tot[$1]=tot
                init_usg[$1]=usg
                cpus[num_cpus++]=$1
        }
        if (last_tot[$1]>0) {
                sum_usg_2[$1] += ((usg-last_usg[$1])/(tot-last_tot[$1]))^2
        }
        last_tot[$1]=tot
        last_usg[$1]=usg
}
END {
        num_samp=(NR-2)/(num_cpus+1)-1
        printf("Processor: (in %% busy, avg +/- stddev, %d samples)\n", num_samp)
        for (i=0;i<num_cpus;i++) {
                c=cpus[i]
                if (num_samp>0) {
                        avg_usg=(last_tot[c]-init_tot[c])
                        avg_usg=avg_usg>0 ? (last_usg[c]-init_usg[c])/avg_usg : 0
                        std_usg=sum_usg_2[c]/num_samp-avg_usg^2
                        std_usg=std_usg>0 ? sqrt(std_usg) : 0
                        printf("%9s: %2.f +/- %2.f\n", c, avg_usg*100, std_usg*100)
                }
        }
        printf(" Overhead: (in %% total CPU used)\n")
        printf("%9s: %2.f\n", "netperf", tot_cpu>0 ? proc_cpu/tot_cpu*100 : 0)
}'

Processor: (in % busy, avg +/- stddev, -1 samples)
 Overhead: (in % total CPU used)
  netperf:  0
+ rm -f /tmp/netperfDL.PcBAao
+ rm -f /tmp/netperfUL.pBCDEJ
+ rm -f /tmp/measurepings.EMeaka
+ rm -f /tmp/measureload.OafFaP
+ measure_direction Upload
+ mktemp /tmp/netperfUL.XXXXXX
+ ULFILE=/tmp/netperfUL.LaaFDo
+ mktemp /tmp/netperfDL.XXXXXX
+ DLFILE=/tmp/netperfDL.OCHbEp
+ mktemp /tmp/measurepings.XXXXXX
+ PINGFILE=/tmp/measurepings.PFafBN
+ mktemp /tmp/measureload.XXXXXX
+ LOADFILE=/tmp/measureload.HDkBkj
+ DIRECTION=Upload
+ dots_pid=3909
+ '[' -4 -eq -4 ]
+ + ping_pid=3910
print_dots
+ load_pid=3911
+ '[' Upload '=' Bidirectional ]
+ spd_test=TCP_STREAM
+ start_netperf TCP_STREAM /tmp/netperfDL.OCHbEp
+ :
+ printf+ sample_load
+ cat /proc/3875/stat
 .
.+ sleep 1s+ ping gstatic.com

+ seq 5
+ wait_netperf
+ + :
+ sleep 1s
+ + netperf+ pgrep -P 3875 netperf
 -4netperf -H netperf.bufferbloat.net -4 -t -H TCP_STREAM -l 60 netperf.bufferbloat.net+ netperf -4 -H netperf.bufferbloat.net -t TCP_STREAM -l 60 -v 0 -P 0
 -v -t 0 TCP_STREAM -P -l 0 60
 -v 0 -P 0
netperf -4 -H netperf.bufferbloat.net -t TCP_STREAM -l 60 -v 0 -P 0
+ netperf -4 -H netperf.bufferbloat.net -t TCP_STREAM -l 60 -v 0 -P 0
+ wait 3915
+ wait 3916
+ wait 3917
+ wait 3918
+ wait 3919
+ kill_load
+ kill -9 3911
+ wait 3911
+ load_pid=0
+ kill_pings
+ kill -9 3910
+ wait 3910
+ ping_pid=0
+ kill_dots
+ kill -9 3909
+ wait 3909
+ dots_pid=0
+ echo

+ '[' Upload '=' Bidirectional ]
+ summarize_speed Upload /tmp/netperfDL.OCHbEp
+ awk '{s+=$1} END {print s}' /tmp/netperfDL.OCHbEp
+ printf '%9s: %6.2f Mbps\n' Upload 0
   Upload:   0.00 Mbps
+ summarize_pings /tmp/measurepings.PFafBN
+ grep -v PING
+ sort -n
+ awk '
BEGIN {numdrops=0; numrows=0;}
{
        if ( $0 ~ /timeout/ ) {
                numdrops += 1;
        } else {
                numrows += 1;
                arr[numrows]=$1; sum+=$1;
        }
}
END {
        pc10="-"; pc90="-"; med="-";
        if (numrows == 0) {numrows=1}
        if (numrows>=10) {
                ix=int(numrows/10); pc10=arr[ix]; ix=int(numrows*9/10);pc90=arr[ix];
                if (numrows%2==1) med=arr[(numrows+1)/2]; else med=(arr[numrows/2]);
        }
        pktloss = numdrops/(numdrops+numrows) * 100;
        printf("  Latency: (in msec, %d pings, %4.2f%% packet loss)\n      Min: %4.3f \n    10pct: %4.3f \n   Median: %4.3f \n      Avg: %4.3f \n    90pct: %4.3f \n      Max: %4.3f\n", numrows, pktloss, arr[1], pc10, med, sum/numrows, pc90, arr[numrows] )
}'
+ sed 's/^.*time=\([^ ]*\) ms/\1/'
  Latency: (in msec, 1 pings, 0.00% packet loss)
      Min: 62.481
    10pct: 0.000
   Median: 0.000
      Avg: 62.481
    90pct: 0.000
      Max: 62.481
+ summarize_load /tmp/measureload.HDkBkj
+ cat /tmp/measureload.HDkBkj /proc/3875/stat
+ awk '
# total CPU of speedtest processes
$1 !~ /cpu/ {
        tot=$16+$17
        if (init_proc_cpu=="") init_proc_cpu=tot
        proc_cpu=tot-init_proc_cpu
}
# track aggregate CPU stats
$1 == "cpu" {
        tot=0; for (f=2;f<=NF;f++) tot+=$f
        if (init_cpu=="") init_cpu=tot
        tot_cpu=tot-init_cpu
}
# track per-CPU stats
$1 ~ /cpu[0-9]+/ {
        tot=0; for (f=2;f<=NF;f++) tot+=$f
        usg = tot - $5
        if (init_tot[$1]=="") {
                init_tot[$1]=tot
                init_usg[$1]=usg
                cpus[num_cpus++]=$1
        }
        if (last_tot[$1]>0) {
                sum_usg_2[$1] += ((usg-last_usg[$1])/(tot-last_tot[$1]))^2
        }
        last_tot[$1]=tot
        last_usg[$1]=usg
}
END {
        num_samp=(NR-2)/(num_cpus+1)-1
        printf("Processor: (in %% busy, avg +/- stddev, %d samples)\n", num_samp)
        for (i=0;i<num_cpus;i++) {
                c=cpus[i]
                if (num_samp>0) {
                        avg_usg=(last_tot[c]-init_tot[c])
                        avg_usg=avg_usg>0 ? (last_usg[c]-init_usg[c])/avg_usg : 0
                        std_usg=sum_usg_2[c]/num_samp-avg_usg^2
                        std_usg=std_usg>0 ? sqrt(std_usg) : 0
                        printf("%9s: %2.f +/- %2.f\n", c, avg_usg*100, std_usg*100)
                }
        }
        printf(" Overhead: (in %% total CPU used)\n")
        printf("%9s: %2.f\n", "netperf", tot_cpu>0 ? proc_cpu/tot_cpu*100 : 0)
}'
Processor: (in % busy, avg +/- stddev, -1 samples)
 Overhead: (in % total CPU used)
  netperf:  0
+ rm -f /tmp/netperfDL.OCHbEp
+ rm -f /tmp/netperfUL.LaaFDo
+ rm -f /tmp/measurepings.PFafBN
+ rm -f /tmp/measureload.HDkBkj
1 Like