The Linux Page

Discovering the speed of your Ethernet connection

Stylish Motorbike Speedometer

Situation

I had some problems (and may still have some problems) with a computer which at times drops its transfer speed to 100Mb instead of running at full speed (1Gb).

I think that one possible problem is that the card detects a "weak" cable, probably because it's a very long one.

Today I was surprised that it ran at full speed, though. I really thought that the network card was dead for good, especially because I tested with a MS-Windows laptop which would get the 1Gb transfer rate as expected.

Linux

Discovering Connections

Under Linux, you first need to discover your available connections. In my case, one of the connections doesn't make it on that computer and that's one of the main reasons I thought that the network card is broken. It could also be that the BIOS decides to hide that connector altogether. I could not see anything in the setup that would indicate that it should be disabled, though.

The discovery is important because even though the default name of an Ethernet interface has been eth0, now a day, many computers will change that name and use some sort of row name instead. Frankly, I'm not too sure why they do that, there must be a reason... I also run some servers at DigitalOcean and they have the same situation, but their developers actually tweaked the system to force a rename of the ports to eth0, eth1, etc.

The list of names can be obtained with the following command:

ifconfig

It may write multiple pages of interfaces if you have many ports or added various software that add virtual ports such as tun.

You will have to sort out through the cluter and possibly test a few things to make sure you get the correct port. If you know the IP address, then it will be quick and easy.

There is an example:

p4p1 Link encap:Ethernet  HWaddr 12:34:56:78:9a:bc 
     inet addr:192.168.2.17  Bcast:192.168.2.255  Mask:255.255.255.0
     inet6 addr: fe80::225:90ff:fe79:7768/64 Scope:Link
     UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
     RX packets:141495 errors:0 dropped:2 overruns:0 frame:0
     TX packets:51759 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1000
     RX bytes:208587673 (208.5 MB)  TX bytes:3992634 (3.9 MB)
     Interrupt:16 Memory:f7200000-f7220000

And here you can see the name of the port is not eth0. Instead, I have a port named p4p1. On my other computer, where both ports work as expected, the second port is p5p1.

The line that says UP, BROADCAST, RUNNING, MULTICAST gives you valuable information about this port. In this case, that it is UP and that it supports BROADCAST and MULTICAST.

As I mentioned, you can find a port from its IP address, here it is the inet addr or inet6 addr, depending on whether you use IPv4 or IPv6 for your network. In my case, this is a computer on the LAN so I use an IPv4. It's much easier to deal with (as many tools still don't support IPv6 correctly.)

Discovering the Connection Speed

Now that we have the name of the port (p4p1 for me), we can check its speed. Obviously, you can check the speed of all your ports.

Note that virtual ports such as lo and tun are likely to not tell you anything about a speed. Instead they will go as fast as it can be on your computer.

The command you use to check the speed is the Ethernet tool:

sudo ethtool p4p1

Include the name of the port to be checked and you get a couple of pages of output. To be complete, you want to use sudo, but it's not mandatory. Without sudo you will be missing some checks such as determining whether the port supports wake-on-lan or not.

There is an example of output:

Settings for p4p1:
    Supported ports: [ TP ]
    Supported link modes:   10baseT/Half 10baseT/Full
                            100baseT/Half 100baseT/Full
                            1000baseT/Full
    Supported pause frame use: No
    Supports auto-negotiation: Yes
    Advertised link modes:  10baseT/Half 10baseT/Full
                            100baseT/Half 100baseT/Full
                            1000baseT/Full
    Advertised pause frame use: No
    Advertised auto-negotiation: Yes
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 1
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: off (auto)
    Supports Wake-on: pumbg
    Wake-on: g
    Current message level: 0x00000007 (7)
                   drv probe link
    Link detected: yes

As we can see, there is one line that says "Speed: ..." and in this case it is 1000Mb/s, so a 1Gbps port.