command line junkie – speed test

Graphical operating systems really does make it easier to multi-task, especially for people who are not comfortable on the command line.  It is really easy to switch between your spreadsheet, web browsers and photo viewer programs in this type of environment.

I suppose a tabbed browser is a logical extension of that metaphor and it does make it easy to open up quite a few pages at the same time.  I probably even open too many sites and periodically my connection seems overly slow.  This would explain why from time to time my browsing comes to a standstill.  It could be that I am overwhelming my bandwidth or someone else in our household is watching you-tube or perhaps even downloading a Linux distribution without my knowledge.

In the true fashion of the user, it is easier to blame your ISP than to investigate the real source of the problem.  As that is usually the position I usually take, my first step is usually to check my connection.

Google will return quite a number of different speed tests that you can use to test the connection from your browser.  I actually find the command line a quicker and easier to check as there is always one open and especially because I never bother to bookmark a speed test.

Debian has a package which will allow me to perform my own speed test without a browser.  It is easy enough to install it using apt-get.

# apt-get install speedtest-cli
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
speedtest-cli
0 upgraded, 1 newly installed, 0 to remove and 26 not upgraded.
Need to get 12.3 kB of archives.
After this operation, 91.1 kB of additional disk space will be used.
Get:1 http://ftp.de.debian.org/debian/ jessie/main speedtest-cli all 0.3.1-1 [12.3 kB]
Fetched 12.3 kB in 0s (108 kB/s)
Selecting previously unselected package speedtest-cli.
(Reading database ... 124629 files and directories currently installed.)
Preparing to unpack .../speedtest-cli_0.3.1-1_all.deb ...
Unpacking speedtest-cli (0.3.1-1) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up speedtest-cli (0.3.1-1) ...

The command is great.  Simply type speedtest from the command prompt to find out about the upload and download speeds.

# speedtest
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Deutsche Telekom AG (79.243.68.175)...
Selecting best server based on latency...
Hosted by Base-Mail (Frankfurt) [6.98 km]: 27.114 ms
Testing download speed........................................
Download: 13.10 Mbits/s
Testing upload speed..................................................
Upload: 7.26 Mbits/s

Oddly enough this worked just fine for a few days but then ceased to work.  After some investigation, I cannot understand why this either worked briefly or why it stopped working at all.  Yet the fix is pretty simple I discovered it on one of the forums.

Just do a small change to the speedtest_cli.py in the /usr/lib/python2.7/dist-packages directory.  The fix is to change the name of the URL that is being called – the change is one line 345.

From

uh = urlopen(‘http://www.speedtest.net/speedtest-servers-static.php’)

To

uh = urlopen(‘http://c.speedtest.net/speedtest-servers-static.php’)

This is a convenient tool if you are concerned about checking your Internet throughput at a given time.

I haven’t needed to track my available throughput over the course of the day, but with this tool it wouldn’t be too much of a task to write up a small script which would run this command every five minutes and save the statistics to a file.

# speedtest | egrep "Download|Upload"
Download: 46.27 Mbits/s
Upload: 8.75 Mbits/s

Perhaps one of these days I will write up such a script.

This entry was posted in Command line, Setup From Scratch and tagged , . Bookmark the permalink.