Enable WoWLAN ( Wake on Wireless LAN ) on Windows 8.1

October 26, 2014

Share

Tags

C# windows

What is WoWLAN?

WoWLAN or Wake on Wireless LAN provides network enabled devices the ability to be brought out of sleep by other devices on the network. WOL or Wake On Lan has been around for a while and used in many different scenarios. WoWLAN really just adds WOL functionality to wireless interfaces instead of just hard wired ethernet connections.

Who uses WoWLAN?

The first time I was asked about WoWLAN was at work, when a customer wanted to wake up their Mac Mini with iRule. Mac Mini’s are used a fair amount as HTPC’s and keeping them awake isn’t a very big deal, but allowing it to sleep is the default functionality.

I know this article is about setting up WoWLAN on Windows 8.1, but this was one of the reason's I started looking into it. The walkthrough will not show you how to set it up on a Mac Mini.

The previous scenario was a long time ago and I hadn’t really thought about it much until recently. I am on my computer a lot, at my desk, on the couch, and anywhere else you can take a computer. I have a desktop computer and a Macbook Pro. I remote desktop into my desktop often, but you can’t remote desktop unless the computer is awake. So, I started poking around to get WoWLAN to work the way I want.

I’m sure there are other scenarios where this could and will be useful.

Setting up WoWLAN

Open Device Manager, find your wireless interface, and open the Preferences

Device Manager

Wireless Interface Advanced Properties

Wireless Interface Power Management Properties

Get the Devices MAC Address by running ipconfig /all. The output should contain a Physical Address for each interface you have.

IPCONFIG output

Sending the Packet

There are multiple tools that I have seen out there to send out WOL or Magic Packets. Since I am a developer, I decided to just whip something up real quick to help me send out the packet.

I have a project on Github with the source code for the wakeup utility I wrote to send out the WOL packets.

From my macbook pro, I use mono to execute the program.

mono /path/to/exe/wakeup.exe 0C-8B-FD-24-1A-8B

The Code

using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

public class Program
{
    public static void Main(String[] args)
    {
        if(args.Length != 1)
        {
            Console.WriteLine("Usage: wakeup.exe [mac address]");
            System.Environment.Exit(-1);
        }
            
        // strip non-hex characters
        var macAddress = new Regex("[^a-fA-F0-9]").Replace(args[0], "");  

        // build magic packet
        string hexMagicPacket = String.Concat(Enumerable.Repeat("FF", 6)) +
                                String.Concat(Enumerable.Repeat(macAddress, 16));
        
        // hex string to byte array
        byte[] magicPacket = Enumerable.Range(0, hexMagicPacket.Length)
                     .Where(x => x % 2 == 0)
                     .Select(x => Convert.ToByte(hexMagicPacket.Substring(x, 2), 16))
                     .ToArray();

        // send packet to broadcast address at port 9
        UdpClient udpClient = new UdpClient();
        udpClient.Connect(IPAddress.Broadcast, 9);
        udpClient.Send(magicPacket, magicPacket.Length);

        Console.WriteLine("Magic Packet Sent");
    }
}