Tips & Tricks![]()
EthernetThe 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.
Side effectsHaving 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.
Turning off WOLSometimes, 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.
ethtool eth0This 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 GigabitThe 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.
Going to a lower speedTo 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.
ethtool -s eth0 autoneg off speed 100 This command will do two things:
Going back to gigabit speedIf 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
Interrupt mitigationOne 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.
|