Logo - Japanese Zodiac Sign

OpenBSD

Some projects I made with or for my favourite operating system OpenBSD.

de en

Wake On LAN

Via Wake On LAN, from now on called WOL, it is possible to power on or wake up a computer. This is mostly used for administrative purposes.

To wake up the computer a so called "Magic Packet" must be sent to the network interface. A computer that is powered off can't use the ip protocol but the network interface is usually supplied with current (at least in the ATX specification which apply to most of the currently sold personal computers) so the card can read the traffic reaching it. It is sufficient if the "Magic Packet" is somewhere in a frame reaching the network interface. The content of the "Magic Packet" must be like this:

6 Bytes with the value 255 (0xff Hex)
16 times the MAC-Address of the target computer

In an environment with switched ethernet the destination address of the ethernet frame must have a broadcast address (this means ff:ff:ff:ff:ff:ff). The content of the "Magic Packet" is wrapped inside a UDP packet. UDP because it is connectionless. A broadcast address is choosen for the ip destination. This is usually 255.255.255.255.

Such a broadcast will not be routed and therefore the packet must be sent from a box inside the same network segment the computer that is to be woken up is in. The sending box can have multiple interfaces (for example it could be a router) and so the right interface must be picked. From this interface the ethernet source address and the ip source address are taken. The complete UDP paket could look like this example:

VersionIHLType of ServicePacket Length
0x045 (5 * 32bit = 20 Byte)0x10102
IdentificationFlagsFragment Offset
24200
Time to LiveProtocolHeader Checksum
1UDP (6)calculated by libnet
Source Address
First ip address of the interface
Destination Address
Broadcast address 255.255.255.255
Magic Packet, total 17 * 6 = 102 Byte (see the description above)

Because none of my experiments to generate a Magic Packet with existing software was successful I decided to write a program managing this task. This program is now fit to my requirements. I called it wakeup. It uses libnet for a simple way of creating network packages. The source should be compileable and installable via make. If it is not working I would like to see a short description of the problem so that I can fix it.

What is the relation to OpenBSD? Well, most already available solutions I found were Linux centered programs. The ports tree from OpenBSD includes a perl module that should generate such a Magic Packet. But I could not get it to work with my system. wakeup is only tested on my OpenBSD system. Reports about other working operating systems or bug reports are welcome...

Using the newer libnet-1.1

I did a rewrite of the original wakeup which depended on libnet-1.0 for the newer libnet-1.1. The source of version 0.2 should compile on unix like systems, a port for OpenBSD can be found here.

New wake command in -current

As from 28th January 2009 mbalmer@ commitet a wake on lan program to the base system of OpenBSD. This comes without any third party dependencies and will be in the release 4.5. The command has been removed again and the wake on lan function was implemented into the arp command.