App::SpeedTest - Command-line interface to speedtest.net
$ speedtest [ --no-geo | --country=NL ] [ --list | --ping ] [ options ] $ speedtest --list $ speedtest --ping --country=BE $ speedtest $ speedtest -s 4358 $ speedtest --url=http://ookla.extraip.net $ speedtest -q --no-download $ speedtest -Q --no-upload
The provided perl script is a command-line interface to the speedtest.net infrastructure so that flash is not required
It was written to feature the functionality that speedtest.net offers without the overhead of flash or java and the need of a browser.
The tool is there to give you a quick indication of the achievable throughput of your current network. That can drop dramatically if you are behind (several) firewalls or badly configured networks (or network parts like switches, hubs and routers).
It was inspired by speedtest-cli, a project written in python. But I neither like python, nor did I like the default behavior of that script. I also think it does not take the right decisions in choosing the server based on distance instead of speed. That does matter if one has fiber lines. I prefer speed over distance.
Show all available options and then exit.
Show program version and exit.
Show the builtin manual using pod2man and nroff.
pod2man
nroff
Show the builtin manual using pod2text.
pod2text
Set verbose level. Default value is 1. A plain -v without value will set the level to 2.
An alias for -v0
-v0
No (default) filtering on available servers. Useful when finding servers outside of the country of your own location.
Use GEO-IP service to find the country your ISP is located. The default is true. If disable (--no-geo), the server to use will be based on distance instead of on latency.
--no-geo
Pass the ISO country code to select the servers
$ speedtest -c NL ... $ speedtest --cc=B ... $ speedtest --country=D ...
Fetch the server list and then show the list of countries the servers are located with their country code and server count
$ speedtest --list-cc AD Andorra 1 AE United Arab Emirates 4 : ZW Zimbabwe 6
You can then use that code to list the servers in the chosen country, as described below.
This option will show all servers in the selection with the distance in kilometers to the server.
$ speedtest --list --country=IS 1: 10661 - Tengir hf Akureyri 1980.02 km 2: 21605 - Premis ehf Reykjav�k 2039.16 km 3: 3684 - Nova Reykjavik 2039.16 km 4: 6471 - Gagnaveita Reykjavikur Reykjavik 2039.16 km 5: 10650 - Nova VIP Reykjavik 2039.16 km 6: 16148 - Hringidan Reykjavik 2039.16 km 7: 4818 - Siminn Reykjavik 2039.16 km 8: 17455 - Hringdu Reykjav�k 2039.16 km 9: 4141 - Vodafone Reykjav�k 2039.16 km 10: 3644 - Snerpa Isafjordur 2192.27 km
Show a list of servers in the selection with their latency in ms. Be very patient if running this with "--all".
$ speedtest --ping --cc=BE 1: 10986 - Proximus Schaarbeek 169.72 km 58 ms 2: 4812 - Universite Catholiq… Louvain-La-Neuve 186.05 km 66 ms 3: 12627 - Proximus Brussels 172.22 km 67 ms 4: 12306 - VOO Li�ge 185.52 km 79 ms 5: 21086 - ASP Brussels 172.22 km 91 ms 6: 4319 - Orange Belgium Brussels 172.22 km 127 ms 7: 4320 - EDPnet Sint-Niklaas 147.26 km 489 ms 8: 2955 - Nucleus BVBA Antwerp 132.91 km 4000000 ms 9: 2848 - Cu.be Solutions Diegem 165.51 km 4000000 ms 10: 5151 - Combell Brussels 172.22 km 4000000 ms
If a server does not respond, a very high latency is used as default.
Generate a very short report easy to paste in e.g. IRC channels.
$ speedtest -1Qv0 DL: 40.721 Mbit/s, UL: 30.307 Mbit/s
Report throughput in Mbyte/s instead of Mbit/s
Generate the measurements in CSV format. The data can be collected in a file (by a cron job) to be able to follow internet speed over time.
The reported fields are
- A timestam (the time the tests are finished) - The server ID - The latency in ms - The number of tests executed in this measurement - The direction of the test (D = Down, U = Up) - The measure avarage speed in Mbit/s - The minimum speed measured in one of the test in Mbit/s - The maximum speed measured in one of the test in Mbit/s $ speedtest -Cs4358 "2015-01-24 17:15:09",4358,63.97,40,D,93.45,30.39,136.93 "2015-01-24 17:15:14",4358,63.97,40,U,92.67,31.10,143.06
Skip reporting measurements that have no speed recordings at all. The default is to report these as 0.00 .. 999999999.999.
0.00
999999999.999
Generate the measurements in XML suited for PRTG
$ speedtest -P <?xml version="1.0" encoding="UTF-8" ?> <prtg> <text>Testing from My ISP (10.20.30.40)</text> <result> <channel>Ping</channel> <customUnit>ms</customUnit> <float>1</float> <value>56.40</value> </result> <result> <channel>Download</channel> <customUnit>Mbit/s</customUnit> <float>1</float> <value>38.34</value> </result> <result> <channel>Upload</channel> <customUnit>Mbit/s</customUnit> <float>1</float> <value>35.89</value> </result> </prtg>
Use the top # (based on lowest latency or shortest distance) from the list to do all required tests.
$ speedtest -T3 -c NL -Q2 Testing for 80.x.y.z : XS4ALL Internet BV (NL) Using 13218: 26.52 km 25 ms XS4ALL Internet BV Test download .. Download 31.807 Mbit/s Test upload .. Upload 86.587 Mbit/s Using 15850: 26.09 km 25 ms QTS Data Centers Test download .. Download 80.763 Mbit/s Test upload .. Upload 77.122 Mbit/s Using 11365: 26.09 km 27 ms Vancis Test download .. Download 106.022 Mbit/s Test upload .. Upload 82.891 Mbit/s Rank 01: Server: 11365 26.09 km 27 ms, DL: 106.022 UL: 82.891 Rank 02: Server: 15850 26.09 km 25 ms, DL: 80.763 UL: 77.122 Rank 03: Server: 13218 26.52 km 25 ms, DL: 31.807 UL: 86.587 $ speedtest -1v0 -T5 DL: 200.014 Mbit/s, UL: 159.347 Mbit/s, SRV: 13218 DL: 203.599 Mbit/s, UL: 166.247 Mbit/s, SRV: 15850 DL: 207.249 Mbit/s, UL: 134.957 Mbit/s, SRV: 11365 DL: 195.490 Mbit/s, UL: 172.109 Mbit/s, SRV: 5972 DL: 179.413 Mbit/s, UL: 160.309 Mbit/s, SRV: 2042 Rank 01: Server: 15850 26.09 km 30 ms, DL: 203.599 UL: 166.247 Rank 02: Server: 5972 26.09 km 32 ms, DL: 195.490 UL: 172.109 Rank 03: Server: 13218 26.52 km 23 ms, DL: 200.014 UL: 159.347 Rank 04: Server: 11365 26.09 km 31 ms, DL: 207.249 UL: 134.957 Rank 05: Server: 2042 51.41 km 33 ms, DL: 179.413 UL: 160.309
Specify the ID of the server to test against. This ID can be taken from the output of "--list" or "--ping". Using this option prevents fetching the complete server list and calculation of distances. It also enables you to always test against the same server.
$ speedtest -1s4358 Testing for 80.x.y.z : XS4ALL Internet BV () Using 4358: 52.33 km 64 ms KPN Test download ........................................Download: 92.633 Mbit/s Test upload ........................................Upload: 92.552 Mbit/s DL: 92.633 Mbit/s, UL: 92.552 Mbit/s
If you pass a filename, it is expected to reflect a server-like structure as received from the speedtest server-list, possibly completed with upload- and download URL's:
{ cc => "NL", country => "Netherlands", host => "unlisted.host.amsterdam:8080", id => 9999, lat => "52.37316", lon => "4.89122", name => "Amsterdam", ping => 20.0, sponsor => "Dam tot Damloop", url => "http://unlisted.host.amsterdam/speedtest/speedtest/upload.php", url2 => "http://unlisted.host.amsterdam/speedtest/speedtest/upload.php", dl_list => [ "http://unlisted.host.amsterdam/files/128.bin", "http://unlisted.host.amsterdam/files/256.bin", # 40 URL's pointing to files in increasing size "http://unlisted.host.amsterdam/files/2G.bin", ], ul_list => [ # 40 URL's ], }
Specify the maximum timeout in seconds.
Run the download tests. This is default unless "--upload" is passed.
Run the upload tests. This is default unless "--download" is passed.
Don't run the full test. The default test runs 40 tests, sorting on increasing test size (and thus test duration). Long(er) tests may take too long on slow connections without adding value. The default value for -q is 20 but any value between 1 and 40 is allowed.
-q
Don't run the full test. The default test runs 40 tests, sorting on increasing test size (and thus test duration). Long(er) tests may take too long on slow connections without adding value. The default value for -Q is 10 but any value between 1 and 40 is allowed.
-Q
Run the speedtest on a speedtest mini server.
NYI - mentioned for speedtest-cli compatibility
See "SYNOPSIS" and Command-line arguments
...
Due to language implementation, it may report speeds that are not consistent with the speeds reported by the web interface or other speed-test tools. Likewise for reported latencies, which are not to be compared to those reported by tools like ping.
What did I miss?
XML::Simple is not the recommended XML parser, but it sufficed on startup. All other API's are more complex.
As Perl has been ported to a plethora of operating systems, this CLI will work fine on all systems that fulfill the requirement as listed in Makefile.PL (or the various META files).
The script has been tested on Linux, HP-UX, AIX, and Windows 7.
Debian wheezy will run with just two additional packages:
# apt-get install libxml-simple-perl libdata-peek-perl
As an alternative to speedtest.net, you could consider http://compari.tech/speed.
The speedtest-cli project that inspired me to improve a broken CLI written in python into our beloved language Perl.
I am always open to improvements and suggestions. Use issues at github issues.
I will never accept pull request that do not strictly conform to my style, however you might hate it. You can read the reasoning behind my preferences here.
I really don't care about mixed spaces and tabs in (leading) whitespace
This tool is by no means a guarantee to show the correc6t speeds. It is only to be used as an indication of the throughput of your internet connection. The values shown cannot be used in a legal debate.
H.Merijn Brand <h.m.brand@xs4all.nl> wrote this for his own personal use, but was asked to make it publicly available as application.
Copyright (C) 2014-2019 H.Merijn Brand
This software is free; you can redistribute it and/or modify it under the same terms as Perl itself.
To install App::SpeedTest, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::SpeedTest
CPAN shell
perl -MCPAN -e shell install App::SpeedTest
For more information on module installation, please visit the detailed CPAN module installation guide.