B.5. mii-tool

A key tool for determining if you are connected to the Ethernet, and if so, at what speed. The mii-tool program does not support all Ethernet devices, as some Ethernet devices have their own vendor-supplied tools to report the same information. The mii-tool source code is based on a tool called mii-diag which provides slightly more information but is less user friendly.

The information reported by mii-tool is quite terse. The following table should clarify the meaning of the speeds you'll encounter in output from mii-tool [43].

Table B.2. Ethernet Port Speed Abbreviations

Port SpeedDescription
10baseT-HD10 megabit half duplex
10baseT-FD10 megabit full duplex
100baseTx-HD100 megabit half duplex
100baseTx-FD100 megabit full duplex

The raw number indicates the number of bits which can be exchanged between two Ethernet devices over the wire. So 10 megabit Ethernet can support the transmission of ten million bits per second. The suffix to each identifier indicates whether both hosts can send and receive simultaneously or not. Half duplex means that each device can either send or receive in the same instant. Full duplex means that both devices can send and receive simultaneously.

The simplest use of mii-tool reports the link status of all Ethernet devices on a system. Any argument to mii-tool is interpreted as an interface name to query for link status.

Example B.21. Detecting link layer status with mii-tool

[root@tristan]# mii-tool
eth0: negotiated 100baseTx-FD, link ok
[root@tristan]# mii-tool -v
eth0: negotiated 100baseTx-FD, link ok
  product info: vendor 08:00:17, model 1 rev 0
  basic mode:   autonegotiation enabled
  basic status: autonegotiation complete, link ok
  capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  advertising:  100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control

In the above example, we can infer that tristan has only one Ethernet device (or no Ethernet drivers loaded for any other present Ethernet devices). The first Ethernet device has successfully negotiated a 100 megabit full duplex connection with the device to which it is connected.

Although a great rarity, you may have occasion to dictate to the Ethernet interface the speed at which it should talk to the switch or hub. mii-tool supports a mode of operation under which you indicate supported modes for autonegotiation. Normally, two connected devices will negotiate the fastest possible commonly shared speed. You can select what speeds you want to support on an Ethernet interface by using mii-tool.

Example B.22. Specifying Ethernet port speeds with mii-tool --advertise

[root@tristan]# mii-tool mii-tool --advertise 10baseT-HD,10baseT-FD
restarting autonegotiation...
[root@tristan]# mii-tool
eth0: negotiated 10baseT-FD, link ok

After we specified that we wished only to support 10baseT-HD and 10baseT-FD as acceptable speeds, mii-tool caused the Ethernet driver to renegotiate port speed with the attached device. Here we selected 10baseT-FD.

Example B.23. Forcing Ethernet port speed with mii-tool --force

[root@tristan]# mii-tool --force 10baseT-FD
[root@tristan]# mii-tool
eth0: 10 Mbit, full duplex, link ok
[root@tristan]# mii-tool --restart
restarting autonegotiation...
[root@tristan]# mii-tool
eth0: negotiated 100baseTx-FD, link ok

After manipulating the speed at which the Ethernet driver would communicate with the connected device on tristan, we chose to restart the autonegotiation process without forcing a particular speed or advertising a particular speed.

So, if you must know at what speed your linux machine is connected to another device, mii-tool comes to your rescue.

[43] There is a standard speed/Ethernet transmission style supported by mii-tool to which I have not referred. That is 100BaseT4. 100BaseT4 provides support for 100 megabit Ethernet networking over Category 3 rated cable. This is probably not a concern for most recently upgraded network infrastructure. The standard networking cable pulled in new construction and renovation is now Category 5 cable which supports 100Base-Tx-FD and possibly gigabit Ethernet. So, let's relegate 100BaseT4 to this footnote, and resume.