Tips & Tricks

line

Ethernet

The ethernet network controller is one of the pieces in a computer that has to transport signals of a long piece of cable, at a high speed. The analog part of the NIC, called a PHY, can take up several Watts just to do this task.

Wake On Lan (WOL)

Most ethernet controllers have a feature called "Wake On Lan" (WOL). WOL allows the administrator to send the computer, when it's turned off, a magic packet over ethernet that then powers the computer on.


WOL is a great feature if you regularly power up computers remotely. However, WOL also keeps the network card active, even when the computer is powered off.

Side effects

Having WOL enabled has an unexpected side-effect: if you have an ethernet port on your machine that you're not using, WOL will keep that ethernet port at least moderately active all the time. It does this to cover the situation where you power the computer down, and then plug in a network cable.


With servers with 2 or more network ports installed in the factory becoming more and more common, the scenario of having an unused ethernet port isn't just theoretical, it's actually quite common to connect only one ethernet cable to a server.

Turning off WOL

Sometimes, the BIOS of your machine offers a setting where you can enable or disable WOL. However, you can also control the WOL setting from Linux directly with the ethtool program.


For example, to check if the network interface eth0 has WOL enabled, issue the following command:

ethtool eth0
This can result in output like this:
# ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: umbg
        Wake-on: g
        Current message level: 0x00000007 (7)
        Link detected: yes
This output shows a whole list of settings for the network card, including the current WOL setting. In the example above, the current setting is g, which means WOL is enabled in the "Magic Packet" mode. If the line said Wake-on: d then Wake On Lan would be disabled. The ethtool program can also be used to change the WOL setting. For example, to disable Wake On Lan for the eth0 interface, use the following command:
ethtool -s eth0 wol d

Gigabit

The power required to transport a signal over a distance increases with higher bandwidth transmissions. In particular, with networking, the power a network adapter uses at 1 gigabit link speed is significantly higher (2 Watts or more) than the power used at 100 megabit link speed.


Gigabit ethernet is pretty much the de-facto standard for ethernet nowadays. Pretty much every server or even desktop or laptop computer has a gigabit ethernet network interface. When you're connected to a gigabit-capable network switch or router, or if you're connected using a cross over cable, the hardware will default to using gigabit link speed.


Not all servers or desktops actually need gigabit speeds. For example, if you're primarily using your computer to browse the web or serve web pages, it's very likely that your internet connection is significantly lower in bandwidth than the 1 gigabit your card can default to; in these scenarios you're pretty much never going to be using actual gigabit data transfers.


Another typical case is where gigabit speed is only used a portion of the day, with the rest of the day being much lower in terms of network traffic. Typical examples are servers where high speeds are only used during business hours or during the nightly backup window.

Going to a lower speed

To see what speed you are current using, you can again use the ethtool command. As shown in the example above (in the Turning off WOL setion), the "Speed: 100" entry shows that the adaptor in the example is operating at 1000 megabit (1 gigabit) per second speed.


To set your adapter to 100 megabit instead, you can use the following ethtool command:

ethtool -s eth0 autoneg off speed 100

This command will do two things:

  • turn off autonegotiation (this is the process where the network card and the switch fill find the highest speed automatically)
  • then manually set the speed to 100 megabit

Going back to gigabit speed

If you want to undo the change to a lower speed, you also need to turn autonegotiation back on. For example, you could use the following command:
ethtool -s eth0 autoneg on speed 1000

Usage suggestions

  • Cron job for business hours
  • Backup script

Interrupt mitigation

One of the things that modern ethernet cards have in common is a feature called "Interrupt mitigation". Rather than giving the processor an interrupt for every packet (which could be many many times per second at this high speed), the processor is woken up a certain amount of time after a packet is received, in the hope that multiple packets have been received since, so that there will be one interrupt for multiple packets. This is good for network throughput (the kernel can process the packets much more agressively) and power consumption (fewer and more spread out interrupts allow the rest of the system to be in low power modes longer). The downside is that this delay may create a bit of latency on the connection.


While a relatively low latency is a big deal when playing network games or when you're running a real time system controlling a laser operating robot, there are many situations where a little bit of latency is no problem at all. For example, if most of the users of a webserver are behind a link with a 30 millisecond ping time, adding 3 milliseconds of maximum latency isn't going to be noticable.


 About | ISN | Intel is a trademark of Intel Corporation in the U.S. and other countries. | * Other names / brands may be claimed as the property of others