Cookie

Test connection speed with Linux

Published by TheJoe on

Estimated reading time: 4 minutes

There are several online tools to test your connection speed, one of them is the Speed ​​Test by Ookla and the Google speed test. Tools like the latter are certainly useful and fast if we need to test the speed of the network to which the computer we are working on is connected, but today I want to check the speed of a remote server to which I am connected in SSH. This is a headless installation, therefore we will not have the graphical interface available and we will have to work exclusively with the terminal.

Some of the utilities that we will see together in this article are the following:

  • speed test
  • fast
  • iPerf
  • iftop
  • wget
  • youtube-dl

Among the prerequisites for testing the tools listed are:

  • a Linux installation (any, but it better integrate a package manager)
  • root permissions / sudo
  • access to a terminal

Speedtest-cli

This is the same service already mentioned in the introduction: the famous Speed ​​Test by Ookla. The software is packaged for a large number of distributions, or you can use pip to install it with python.

# pip install speedtest-cli

To start it we type in the terminal speedtest.

~ $ speedtest
Retrieving speedtest.net configuration...
Testing from Telecom Italia Business (188.10.211.206)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Avelia (Verona) [107.07 km]: 13.87 ms
Testing download speed...................
Download: 47.87 Mbit/s
Testing upload speed.....................
Upload: 20.00 Mbit/s

Fast-cli

Fast is a lightweight CLI utility based on the speed test offered by fast.com. The test uses Netflix servers located globally to return the result.

Fast-cli is relatively simple to use, but it must be installed using NPM (Nodejs). Installing Node is not the subject of this article, each distribution has its own package manager / repository. After installing it, let's launch it:

~ $ npm install --global fast-cli

And we launch the program:

~ $ fast


  ⠼ 31 Mbps ↓

iPerf

The iPerf software allows you to configure various options to test the speed of the connection between two devices. The difference between this latest software and the previous ones is that we will necessarily have to have two PCs to carry out the test. We will install the program on both, but one will be the server and the other the client. iPerf is much more useful if you want to test the speed of two PCs connected locally.

Again, each distribution has its own package manager and repositories.

On the server we will run the command iperf3 -s, while on the client that will run the test we will launch iperf3 -c <IP del server>.

~ $ iperf3 -c 192.168.5.10
Connecting to host 192.168.5.10, port 5201
[  5] local 192.168.5.2 port 59472 connected to 192.168.5.10 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  2.12 MBytes  17.8 Mbits/sec   55   77.0 KBytes       
[  5]   1.00-2.00   sec  1.50 MBytes  12.6 Mbits/sec    0   94.3 KBytes       
[  5]   2.00-3.00   sec  1.25 MBytes  10.5 Mbits/sec    0    120 KBytes       
[  5]   3.00-4.00   sec   896 KBytes  7.34 Mbits/sec    6    128 KBytes       
[  5]   4.00-5.00   sec   896 KBytes  7.34 Mbits/sec   43   89.0 KBytes       
[  5]   5.00-6.00   sec   640 KBytes  5.24 Mbits/sec    1   62.4 KBytes       
[  5]   6.00-7.00   sec  0.00 Bytes   0.00  bits/sec   47   1.33 KBytes       
[  5]   7.00-8.00   sec   640 KBytes  5.24 Mbits/sec   55   69.1 KBytes       
[  5]   8.00-9.00   sec  1.50 MBytes  12.6 Mbits/sec    0   97.0 KBytes       
[  5]   9.00-10.00  sec  1.12 MBytes  9.42 Mbits/sec    0   91.6 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  10.5 MBytes  8.81 Mbits/sec  207        sender
[  5]   0.00-10.08  sec  10.0 MBytes  8.33 Mbits/sec             receiver

iperf Done.

The same report will be visible on the server before stopping iPerf.

Look here:  As I solved the problems with the disks "fsck"

iftop

Iftop allows you to control the traffic speed on a specific user-defined network interface. This program can also be easily installed via repository.

First we check what name has been assigned to the network interface we want to monitor. In my case the Wi-Fi card:

~ $ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: enp9s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether 70:54:d2:5b:1f:f8 brd ff:ff:ff:ff:ff:ff
3: wlp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 20:16:d8:5b:19:b3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.4/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp8s0
       valid_lft 68747sec preferred_lft 68747sec
    inet6 fe80::f123:5636:87bc:af11/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

The Wi-Fi card is indicated by the initial “in”: in my case “wlp8s0“. To launch it we use the argument “-i” and specify the network interface to monitor:

~ $ sudo iftop -i wlp8s0

Transmission statistics (TX) and reception (RX) they are at the bottom of the page.

wget

Wget is on this list, although its main function is certainly not to monitor the connection speed. In fact, it is a sophisticated and very long-lived download manager, which however also offers the information we are looking for about speed.

You need the address of a downloadable file… I'd say at least a few MB. I searched on Google “fotografia file type:pdf” hoping for some photographic brochures, instead I found a catalog of digital microscopes.

~ $ wget -O /dev/null -q --show-progress http://bio-plast.net/pdf/Catalogue/Optika/DIGITAL%202009_IT.pdf
/dev/null                 30%[=========>                        ] 899,54K   184KB/s    prev 13s 

With this command nothing will be saved because we are telling wget to put everything in /dev/null, but the download will take place anyway and from the last line we can see at what speed.

youtube-dl

Youtube-dl, come wget, it is another program that is not meant for our purpose. But equally there is no reason not to use it.

~ $ yt-dlp -f best --no-part --no-cache-dir -o /dev/null --newline <una qualsiasi URL di youtube>
[download] Destination: /dev/null
[download]   0.0% of   19.65MiB at  Unknown B/s ETA Unknown
[download]   0.0% of   19.65MiB at    1.44MiB/s ETA 00:13
[download]   0.0% of   19.65MiB at   81.41KiB/s ETA 04:07
[download]   0.1% of   19.65MiB at  171.64KiB/s ETA 01:57
[download]   0.2% of   19.65MiB at  171.12KiB/s ETA 01:57
[download]   0.3% of   19.65MiB at  202.58KiB/s ETA 01:39
[download]   0.6% of   19.65MiB at   71.21KiB/s ETA 04:40
[download]   0.8% of   19.65MiB at   95.49KiB/s ETA 03:28
[download]   1.3% of   19.65MiB at  144.05KiB/s ETA 02:17
[download]   2.1% of   19.65MiB at  198.62KiB/s ETA 01:39

Did I forgot something? Let me know in the comments.


TheJoe

I keep this blog as a hobby by 2009. I am passionate about graphic, technology, software Open Source. Among my articles will be easy to find music, and some personal thoughts, but I prefer the direct line of the blog mainly to technology. For more information contact me.

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.