Giter Site home page Giter Site logo

luizluca / speedtest-shell Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 1.0 30 KB

This is an unofficial speedtest (ookla) client, written in shell script and compatible with most basic systems, including OpenWrt routers

License: GNU General Public License v3.0

Shell 100.00%
openwrt speedtest speedtest-cli speedtests ookla

speedtest-shell's Introduction

speedtest-shell

This is an unofficial speedtest (ookla) client, compatible with most basic systems, including OpenWrt routers.

It is a very simple but useful speedtest, designed to be executed from a OpenWrt router, but possibly compatible with most UNIX systems with minor changes.

Usage speedtest-cli.sh [ -4 | -6 ] [ -c ( nc | netcat | socat ) ] [ -d bytes ] [ -i times ]
      [-I device] [ -p port ] [ -s server] [ -u bytes ]

Runs a speedtest 

Options:
 -4     Connect only to IPv4 servers. Default is IPv6 or IPv4.
 -6     Connect only to IPv6 servers Default is IPv6 or IPv4.
 -c     Define the netcat client. By default, it tries, socat, netcat and nc
 -d     Define the download payload size in bytes. Default is 52428800
 -i     Define number of times a PING command is issued. Default is 10
 -I     Bind to interface (only works with socat)
 -l     List close servers
 -s     Define the server address (name or ip address) with port. IPv6 addresses
        needs to use braces, like in URL. Default is to look for the fastest server.
 -u     Define the upload payload size in bytes; Default is 20971520
 -v     Be verbose

If not server was provided, it will look for the best one at:
 https://www.speedtest.net/speedtest-servers-static.php

It requires a web client (curl or wget), a tcp client (socat, netcat or nc) and a POSIX shell (tested with ash and bash). It also requires some basic unix tools like sed, awk, dd, tr, grep, cut, nslookup, ip

If no server is specified, it gets a list of servers from https://www.speedtest.net/speedtest-servers-static.php, choose the closest one (based on the server answers) and run a test. The standard est is executed through a TCP connection. First, it pings the server (through the TCP connection) and then download 50M and upload 20M.

As a shell script, this client has its limitations. I could not test anything over 170 Mbps but I cannot garantee this is the connection, target server or script limit. For slow CPU devices, like many OpenWrt routers, that limit would be even lower. If the script detects the CPU is at 100%, it will give you a warning ("CPU is struggling... expect worse measures"). With slow CPUs, the socat seems to be the best option.

It uses either /proc/timer_list or /proc/uptime to measue time, although uptime resolution is in cs (1/100s). For very close servers and the time in cs, expect strange things like 0ms RTT.

I cannot garantee the acuracy of this client but there is a good confidence that the real speed is equal or faster than the reported by the script, not slower.

Some runs:

# Internet 120 Mbps/12 Mbps
root@router-slow:~# speedtest-cli.sh
ping.rtt_min = 0 ms
ping.rtt_mean = 6 ms
ping.rtt_max = 10 ms
ping.rtt_stddev = 4 ms
CPU is struggling... expect worse measures
download.payload = 50.0000 MiB 52.4288 MB
download.duration = 7.340000 s
download.speed = 6.8120 MiB/s 7.1429 MB/s
download.speed = 54.4959 Mib/s 57.1431 Mb/s
upload.payload = 20.0000 MiB 20.9715 MB
upload.duration = 5.740000 s
upload.speed = 3.4843 MiB/s 3.6536 MB/s
upload.speed = 27.8746 Mib/s 29.2286 Mb/s

# Internet 300 Mbps/300 Mbps
root@router-fast:~# speedtest-cli.sh
ping.rtt_min = 0 ms
ping.rtt_mean = 3 ms
ping.rtt_max = 10 ms
ping.rtt_stddev = 4 ms
download.payload = 50.0000 MiB 52.4288 MB
download.duration = 2.330000 s
download.speed = 21.4592 MiB/s 22.5016 MB/s
download.speed = 171.6738 Mib/s 180.0130 Mb/s
upload.payload = 20.0000 MiB 20.9715 MB
upload.duration = 0.880000 s
upload.speed = 22.7273 MiB/s 23.8313 MB/s
upload.speed = 181.8180 Mib/s 190.6500 Mb/s

# Internet 120 Mbps/12 Mbps
user@linux-desktop:~# speedtest-cli.sh
ping.rtt_min = 10 ms
ping.rtt_mean = 16 ms
ping.rtt_max = 30 ms
ping.rtt_stddev = 6 ms
download.payload = 50.0000 MiB 52.4288 MB
download.duration = 3.400000 s
download.speed = 14.7058 MiB/s 15.4202 MB/s
download.speed = 117.6472 Mib/s 123.3620 Mb/s
upload.payload = 20.0000 MiB 20.9715 MB
upload.duration = 16.040000 s
upload.speed = 1.2469 MiB/s 1.3075 MB/s
upload.speed = 9.9751 Mib/s 10.4596 Mb/s

speedtest-shell's People

Contributors

luizluca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mantheman

speedtest-shell's Issues

getent not found

sh speedtest-cli.sh

getent not found. Using ping instead.
iptables v1.4.10: option -d' requires an argument Try iptables -h' or 'iptables --help' for more information.
rm: can't remove '/var/speedtest_output_dl_json_result_default': No such file or directory
No servers found at 'https://www.speedtest.net/speedtest-servers-static.php'

sh speedtest-cli.sh -s speedtest.turk.net:8080

getent not found. Using ping instead.
Timeout waiting HI answer with 'speedtest.turk.net'

uname -a

Linux VMG3625-T50B 3.18.21 #1 SMP Wed Nov 23 12:23:41 CST 2022 mips GNU/Linux

busybox

BusyBox v1.20.1 (2022-11-23 11:48:55 CST) multi-call binary.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.