Chuck's Code Blog

Assorted solutions and musings

Wake On LAN (WOL)

In the process of learning about the new Wake on Wireless technologies, I found myself adding some Wake On LAN (WOL) functionality to my kiosk application, I thought I would perhaps post some of that code and info here.  One of these days I will sit down and do a proper publication, but for now WordPress is still new to me and I haven’t the time that I would like to do this correctly.

Certain network cards also support a security feature called “SecureON password”. This feature allows users to set a Magic Packet password. The password is 6 bytes like the MAC address. Still, only a few NIC and router manufacturers seem to support such security features.

What do I need to use WOL?

• A network card that can support WOL with its cable to the motherboard properly installed.

• In the BIOS Power Management, you must enable the LAN Wakeup option. The option might also be named:

o Wake On LAN,                                                     o Resume on LAN,
o MAC Resume From S3/S4,                            o Resume on LAN/PME#,
o MACPME Power Up Control,                        o Wake on LAN from S5,
o Power On By Onboard LAN,                          o Wake Up On LAN,
o Power Up By Onboard LAN,                          o Wake Up by Onboard LAN,
o Resume by LAN,                                                 o WOL (PME#) From Soft-Off
o Resume By WOL,

• Then take a look at your network card settings, (right click mouse on “My Computer” icon on your desktop, select Manage -> “Device Manager”) in “Device Manager” open the properties of your “Network Card” and select “Power Management” tab. Wakeup should be also enabled as shown below.


Power Management Settings


Wake from Shutdown = On; Wake-Up Capabilities = Magic Packet.

Some network cards support additional options to wake up from shutdown.

After completing these settings, check that the “Good Connection” light (typically green led) on the back of the network card is lit when the machine is off.

Most implementations send the “magic packet” via UDP over either port 7 or port 9 .  So you’ll have to make sure that port is forwarded by your firewall/router to the IP broadcast address.


Magic packet

The magic packet is a broadcast frame containing anywhere within its payload: 6 bytes of ones (resulting in hexadecimal FF FF FF FF FF FF), followed by sixteen repetitions of the target computer’s MAC address.

Since the magic packet is only scanned for the string above, and not actually parsed by a full protocol stack, it may be sent as a broadcast packet of any network- and transport-layer protocol. It is typically sent as a UDP datagram to port 0, 7 or 9, or, in former times, as an IPX packet.



using System;
using System.Net;
using System.Net.Sockets;
namespace WakeOnLan
    class Program
        static void Main(string[] args)
            byte[] mac = new byte[] {0x00, 0x0F, 0x1F, 0x20, 0x2D, 0x35};
        /// <summary>
        /// Sends a Wake-On-Lan packet to the specified MAC address.
        /// </summary>
        /// <param name="mac">Physical MAC address to send WOL packet to.</param>
        private static void WakeUp(byte[] mac)
            // WOL packet is sent over UDP
            UdpClient client = new UdpClient();
            client.Connect(IPAddress.Broadcast, 40000);
            // WOL packet contains a 6-bytes trailer and
            // 16 times a 6-bytes sequence containing the MAC address.
            byte[] packet = new byte[17 * 6];
            // Trailer of 6 times 0xFF.
            for (int i = 0; i < 6; i++)
                packet[i] = 0xFF;
            // Body of magic packet contains 16 times the MAC address.
            for (int i = 1; i <= 16; i++)
                for (int j = 0; j < 6; j++)
                    packet[i * 6 + j] = mac[j];
            // Submit WOL packet.
            client.Send(packet, packet.Length);


November 11, 2009 - Posted by | UMPC | ,


  1. […] Wake On LAN (WOL) ( […]

    Pingback by Wake On LAN Setup For Windows 7 | EssayBoard | April 8, 2012 | Reply

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: