All About Performance

and other stuff by Taras Glek

Router-Assisted Automatic Wake-on-LAN + Suspend

The problem

My new computer uses 10-46W of power while on, 1W while suspended. It replaced my softbricked (ArchLinux can burn in hell) arm computer where power consumption ranged from 4-7W.

The new computer is a backup target for my eyefi (via iiid), Android phone (via rsync/ssh), laptop (via rsync).

For fun I decided to try to use suspend-to-RAM + Wake-on-LAN to minimize power usage to get this beefy x86 to use less power than the old ARM NAS (which could not unsuspend successfully).

By default WOL is a pain. The eye-fi card uploads photos when the SLR camera is on. Android phone is configured to rsync stuff when it is plugged while connected to home wifi. It’s not convenient to navigate some UI to send a WOL packet (or push a power button) every time I need to perform a backup. Manually deciding when to suspend the machine is also no fun.

Automatic WOL

In an ideal world WOL would support waking up on IP traffic directed at the machine in question. Typically WOL either wakes up in response to WOL magic packets or ANY ethernet traffic(ugh!). Update: Turns out my nic supports directed wakeups, but the e1000e driver on Linux does not implement them.

Luckily, ARP who has x.x.x.x queries are broadcast to whole network segment. So my Tomato router can help.

This works as follows:

1
2
3
Android-phone: ARP: Who has 192.168.1.149
router: *sends WOL packet to NAS*
Server Unsuspend Script: 192.168.1.149 is at A:B:C:D:E:F

I wrote an arpwol program for this, I run it via

1
arpwake.mips br0 192.168.1.149 4C:72:B9:42:EA:97

It listens for arp looking for 192.168.1.149 and fires of a WOL.

It takes 5 seconds for an ssh roundtrip to a sleeping server.

Auto-suspend

Once the server is awake, it is annoying to have to put it to sleep manually. I wrote a script to monitor /var/log/auth.log and auto-suspend when active ssh-session count reaches 0.

Conclusion

It great to have an x86 box idle at 1W while unused. Suspend to disk introduces extra latency without saving much more power (due to keeping WOL on).

Please checkout the code on github. WOL magic happens in arpwake.c and auto-suspend in autosleep.py.

Comments