viernes, 23 de noviembre de 2012

Test Internet speed from the command line


Every time I need to measure my Internet speed I use the speedtest.net website. Its a very handy and easy tool, useful for knowing the upload and download speed of the internet link from where we are connecting.


To be able to use it, we just need a web browser. And there is the problem if we want to perform the test from the command line without a browser available (ie on a remote server),

Usually, in these cases the easy way would be to download a file (using wget or curl), and see the stats or make a simple calculation between filesize/time needed to finish the download.

There is also the lperf tool, to test the bandwith between two machines and could be useful too.

But it would be more interesting to have a tool like speedtest.net, capable of measuring the download and upload speeds, and be easy to use.

Looking for something like that I found this tool: testspeed, a python script available at https://github.com/Janhouse/tespeed.

It was developed by a programmer named Janis Jansons from Latvia, and it uses the speedtest.net service to perform the test, all that without leaving the beloved command line.

It can be downloaded from github:

$ wget https://github.com/Janhouse/tespeed/archive/master.zip
$ unzip master.zip

Before using it, the lxml python module must be installed:
$ sudo apt-get install python-lxml

And then we can run it:

$ cd tespeed-master/
$ ./tespeed.py 

As the browser version of speedtest, first the script will check the latency from geographically close servers, and select the best one; then will run the download and upload tests.

$ ./tespeed.py
Getting ready. Use parameter -h or --help to see available features.
Loading speedtest configuration...
IP: 198.74.62.154; Lat: 39.489900; Lon: -74.477300; ISP: Linode
Loading server list...
Looking for closest and best server...
Testing latency...
11 ms latency for http://sto-plfi-01.sys.comcast.net/speedtest/ (Comcast, Plainfield, NJ, United States) [37.08 km]
7 ms latency for http://speedtest.monmouth.com/speedtest/ (Monmouth Telecom, Red Bank, NJ, United States) [52.38 km]
3 ms latency for http://speed.fortressitx.com/speedtest/ (Fortress ITX, Clifton, NJ, United States) [54.77 km]
9 ms latency for http://nms.interserver.net/speedtest/speedtest/ (Interserver, inc, Secaucus, NJ, United States) [60.15 km]
2571 ms latency for http://newyork-speedtest.atlanticmetro.net/speedtest/speedtest/ (Atlantic Metro, New York, NY, United States) [64.06 km]
Best server with average latency 3ms - Fortress ITX, Clifton, NJ, United States
Download size: 3.93 MiB; Downloaded in 0.04 s                                              
Download speed: 112.11 Mbit/s
Download size: 16.18 MiB; Downloaded in 0.10 s                                            
Download speed: 164.61 Mbit/s
Download size: 35.78 MiB; Downloaded in 0.20 s                                            
Download speed: 180.54 Mbit/s
Download size: 63.56 MiB; Downloaded in 0.37 s                                            
Download speed: 170.40 Mbit/s
Download size: 142.98 MiB; Downloaded in 0.74 s                                            
Download speed: 194.10 Mbit/s
Download size: 253.05 MiB; Downloaded in 1.34 s                                            
Download speed: 188.53 Mbit/s
Download size: 379.57 MiB; Downloaded in 2.09 s                                            
Download speed: 181.30 Mbit/s
Download size: 595.58 MiB; Downloaded in 3.06 s                                            
Download speed: 194.95 Mbit/s
Download size: 855.21 MiB; Downloaded in 4.40 s                                            
Download speed: 194.54 Mbit/s
Download size: 1164.58 MiB; Downloaded in 6.05 s                                          
Download speed: 192.43 Mbit/s
Upload size: 2.10 MiB; Uploaded in 0.51 s                                                  
Upload speed: 4.09 Mbit/s
Upload size: 2.10 MiB; Uploaded in 0.26 s                                                  
Upload speed: 8.10 Mbit/s
Upload size: 4.19 MiB; Uploaded in 0.56 s                                                  
Upload speed: 7.54 Mbit/s
Upload size: 4.19 MiB; Uploaded in 0.56 s                                                  
Upload speed: 7.53 Mbit/s
Upload size: 16.78 MiB; Uploaded in 1.12 s                                                
Upload speed: 14.99 Mbit/s
Upload size: 16.78 MiB; Uploaded in 1.51 s                                                
Upload speed: 11.09 Mbit/s
Upload size: 134.22 MiB; Uploaded in 7.22 s                                                
Upload speed: 18.58 Mbit/s

Its a very handy script, and although its still in alpha version with some minor bugs, performs its task very well.

No hay comentarios.:

Publicar un comentario