A trip through wake-on-wireless-LAN

For several months now I’ve been struggling with an issue that showed up after I managed to set up Wake on Wireless LAN (WoWLAN) on my desktop computer, and I thought the whole process it would make for a great blog post, so here we go!

Chapter 1: got it to work!

Getting WoWLAN to work wasn’t particularly hard, it basically boiled down to two things:

  • Make sure the BIOS would allow it.
  • Configure the wireless NIC settings in Windows.

The first step was about looking for the appropriate settings in my BIOS, and setting them to the correct values. Some people might not be able to complete this if their motherboard/NIC/BIOS doesn’t support WoWLAN, and in that case there’s not much to be done other than changing hardware (or making sure it’s not just a missing BIOS update, which it probably isn’t). In my case, the only relevant setting (and maybe not even that, since I only use WoWLAN with state S3 (sleep), not S4 (hibernate) nor S5 (soft-off)) was S4/S5 Wake on LAN.

BIOS options

For the second step I went to Device Manager, double-clicked my wireless card under “Network Adapters”, and made sure that Wake on Magic Packet and Wake on Pattern Match were set to Enabled in the Advanced Settings tab; and that “Allow this device to wake up the computer” and “Only allow a magic packet to wake up the computer” were checked in the Power Management tab.

NIC settings

NIC settings - power management

And voilà! I was immediately able to put my computer to sleep, and wake it up with a Wake-on-LAN packet sent through the WiFi.

Chapter 2: an issue shows up

Things were great until I noticed that my computer was waking up on its own every night after I went to bed and put it to sleep.

I first went to Windows’ Event Viewer and found this sequence of events (the first one has the wrong time because Windows still thinks it’s the same moment as when the computer went to sleep, and the second event fixes that by syncing the OS clock with the hardware clock):

Wakeup Event 1

Wakeup Event 2

And a couple of entries later, this one:

Wakeup Event 3

It was clear that the NIC was responsible for waking up the computer, and sure enough, if I disabled its “Allow this device to wake up the computer” setting in Device Manager, the problem went away. But that setting is needed for WoWLAN to work, so I started looking for a solution.

Playing around with the other settings in Device Manager didn’t help. Intel provides some documentation on those that was pretty useful. For obvious reasons, of particular interest were NS offloading for WoWLAN, ARP offloading for WoWLAN, GTK rekeying for WoWLAN, and Sleep on WoWLAN disconnect. The first two let the OS “delegate” some work to the NIC when it is sleeping, so that some things can happen without it waking up. They are enabled by default, and it sounds like that’s the way it should be. The documentation for GTK rekeying for WoWLAN is not clear on what it does, but some additional research shows that it’s related to the PMWiFiRekeyOffload standard keyword for power management, which says “A value that describes whether the device should be enabled to offload group temporal key (GTK) rekeying for wake-on-wireless-LAN (WOL) when the computer enters a sleep state.” So just like the previous two, we want that enabled.

Finally, I just can’t wrap my head around what Sleep on WoWLAN disconnect is. The documentation says “Sleep on WoWLAN Disconnect is the ability to put the device to sleep/drop connection when WoWLAN is disconnected.” but I don’t understand what “WoWLAN is disconnected” means. I think of WoWLAN as an event, not a persistent connection. So I didn’t really mess around with this one. Maybe it’s supposed to say “disabled” instead of “disconnected”, and it lets the NIC go to sleep if WoWLAN is disabled…

I don’t remember what else I did to try and fix this, but if there was anything else, it didn’t work. After a while, I resigned myself and didn’t even try to put my computer to sleep before bed.

Chapter 3: a second attempt

Some time later I came back to the issue and this time my research first led me to the powercfg utility.

powercfg /lastwake didn’t give me any new information, it also said that it was the NIC waking up the computer:

powercfg lastwake

powercfg /waketimers (which needs to run in an elevated command prompt) said there were no active wake timers on my system, so nothing to do there:

powercfg waketimers

Just to be sure, I also went through all the tasks in Task Scheduler, trying to figure out if a scheduled action was the culprit. A couple of them seemed like potential candidates but few of them could wake up the computer, and they were disabled or had schedules that didn’t match the symptoms I was seeing.

Chapter 4: found the root cause!

Fast forward another month or so, and I found a new clue: the wake up from sleep didn’t happen only during the night, the time of day didn’t matter! My computer is usually on all day, so I hadn’t noticed that before. But putting it to sleep at any time during the day resulted in the same wake-up-on-its-own behavior after some time. And more importantly, the computer always woke up on the 41st minute of the hour.

Knowing that, I did some more research and found this question in the Intel forums, with a superbly documented reddit post by someone having the exact same problem.

The author of that post did A LOT of research and troubleshooting, and found out that his issue was related to the Group Key Update feature of WPA2, and concluded that the GTK rekeying for WoWLAN setting in the NIC probably had a bug, since it should have offloaded handling of the appropriate network packets to the NIC, without having to wake up the computer.

I wanted to really soak up all the information there and make sure I understood what was happening, so I followed the research on that post and applied it to my scenario.

My starting point was this document from Microsoft regarding WoWLAN on Windows and which specific things can wake up the computer. Besides receiving a WOL packet or WOL magic pattern, 4 things can do that:

  • AP Association Lost: i.e. the NIC loses its connection to the AP. My AP wasn’t restarting or anything similar, so that couldn’t be it.
  • GTK Handshake Error: (here I had to go and research what “GTK” was. It’s not super relevant to this post, but here I found a great explanation) I’m not sure what could cause an error of this sort, probably something like changing the WiFi pre-shared key on the AP? I wasn’t seeing any errors in my AP/Router’s log, and besides the wake-up issue, my WiFi worked fine, so I guessed it was probably not this.
  • 802.1x EAP-Request/Identity Packet Received: this only applies to WPA2-Enterprise, and since I’m using WPA2-Personal, it couldn’t be it.
  • Four-way Handshake Request Received: thanks to all the reading I had done up to this point I knew that 4-way handshake is the process by which the AP and a wireless client establish keys (PTK and GTK) to encrypt the packets sent between them, and that my AP was configured to update the GTK every hour. And my computer was restarting every hour. So… We probably have a winner!

I confirmed that this is probably the culprit by changing the GTK rekeying interval (referred to in my settings as “Group Key Update”) in my router. After that, the minute when my computer woke up changed to match the time of the AP restart, so I’m pretty confident that this is it.

Chapter 5: …but it still doesn’t work

Yet, just like for that other person having this issue, having GTK rekeying for WoWLAN enabled wasn’t helping, so I’m inclined to agree that there’s a bug somewhere in Windows or the NIC driver.

Speaking of which… I looked for updates to my NIC driver, and there was one but it didn’t help things.

A workaround for those that can do this, is to increase the GTK rekey interval in the router. I was going to set it to 12 hours (at 9am/pm) so it didn’t happen while I was asleep, but my router only allows up to 2 hours.

Conclusion

So I’m still leaving my computer on when I go to bed because I know it will wake up on its own not long after. I’ll keep my eye out for updates to the NIC driver and see if they help.

In any case, I got a lot out of this ordeal. I learned about low-level details of WiFi connections like the Beacon Frame, the Beacon Interval and DTIM, plus some other things mentioned above. So even if the problem hasn’t gone away, trying to solve it has been a very productive endeavor.

13 thoughts on “A trip through wake-on-wireless-LAN

  1. Simone

    I don’t know if you are ever going to read this, as the original post is very old, but I hope that you may find this useful. I read your post and the thing regarding the GTK offloading pointed me in the right direction (and I have hopefully solved the problem both of us had).
    So, after looking for a while I was able to find this post on the MSDN: https://support.microsoft.com/en-in/help/3050405/gtk-offloading-fails-when-the-only-allow-a-magic-packet-to-wake-the-co. (Premise: I am on Windows 10 and have a Aorus x570 Ultra with integrated Wi-Fi and the post refers to Windows 7).
    There is also another article which explains some of the things that may be happening: https://support.microsoft.com/en-in/help/2957147/gtk-rekey-fails-when-the-wake-on-pattern-match-method-is-disabled-for
    Reading the second article on the MSDN I noticed that even though I didn’t have the “Wake on pattern match” option at all in my network settings, I still had the “Only allow a magic packet to wake the computer”.
    If I understood this correctly (and this is a huge IF), the second article is basically saying that disabling pattern match will also make the GTK rekeying not working. For some reason, I also believe that enabling the “only allow magic packet to wake up the PC” also disables pattern matching. I tried to give it a shot and disabled the “only allow magic packet to wake up the PC” (by not touching the GTK rekeying options to enabled) and still I had the same issue. However, after disabling GTK rekeying, rebooting, and then re-enabling the GTK, my PC stopped starting by itself and I could wake up it anytime I wanted. I believe that the GTK Rekeying flag was set to disabled (even though I could see it as enabled) and that re-enabling while having the “Only allow the magic packet flag to wake up” disabled fixed this issue.
    I don’t know if this could solve also your issue. I made a lot of tests so I could be in a not-clean situation (meaning that this may be not the only option needed to make it work) however it’s worth a shot.
    I will have some more test, but first I will make a DD copy of my disk, just to be sure.
    Let me know if this helped!

    Reply
    1. alexvy86 Post author

      Awesome! Thanks for the info, I’ll give this a shot (hopefully tonight) and report my findings.

      Reply
      1. Simone

        Did you manage to make it work? I did a couple more of checks and it looks like that the “Wake on pattern match” was literally translated with google translate and I couldn’t find it. In the end, I have the following options for the wireless adapter:
        *In Advanced Options*
        – Wake on Magic Packet: Enabled
        – Wake on Pattern Match: Enabled
        – GTK Rekeying: Enabled

        *In Power Management*
        – Allow the computer to turn off…: Checked
        – Allow this device to wake the computer: Checked
        – Only allow a magic packet to wake the computer: NOT CHECKED

        Even with the last option left uncheked, only a magic packet containing the MAC address of the adapter will actually wake the machine.

        I had a couple of wake up which were caused by the task scheduler, but checking the event viewer you can see if that was the case (you can check this if you need it: https://www.tenforums.com/general-support/133361-pc-waking-up-itself-sleep.html). Now I have the problem that I have to send the magic packet a bunch of times to wake up the PC, but I believe that it is caused by the wireless adapter reducing the transmission power after a while, so there is actually a packet loss, but I will try to troubleshoot it.

        In case you need any help, let me know!

        Reply
        1. alexvy86 Post author

          I made the changes you suggested and things definitely improved, I don’t see wake-ups every hour anymore, but I did see one instance of my computer waking up due to the NIC (plus several others due to scheduled tasks, like yours). I’d like to test it for a bit longer before claiming victory, but your findings were definitely on track.

          My current network adapter settings are the same as yours:
          *In Advanced Options*
          – Wake on Magic Packet: Enabled
          – Wake on Pattern Match: Enabled
          – GTK Rekeying: Enabled

          *In Power Management*
          – Allow the computer to turn off…: Checked
          – Allow this device to wake the computer: Checked
          – Only allow a magic packet to wake the computer: NOT CHECKED

          I’ve only tried to wake up my computer wirelessly once and it worked (I use the WOL feature on the custom firmware I installed on my router). I’ll have to make more tests around that to see if I also start having to send the wake up packet several times, maybe after prolonged sleep periods.

          Reply
          1. Simone

            I figured out that the problem regarding the PC not waking up unless I send multiple requests is related to Teamviewer (which I was using to wake it up) and not to some sort of power saving which I initially thought was the cuplrit.

            On my PC I have different network adapters and Teamviewer does not allow to specify the MAC address of the adapter, so it sends multiple packets with different MAC address (in my case 3 packets every time I tried to wake it up). In this case, even if the correct MAC address is sent, it did not wake up, possibly because only the first one received was elaborated. By using a different tool to wake it up and by sending only 1 packet it works flawlessly.

          2. Simone

            So, it appears that setting “Only allow a magic packet to wake the computer” to unchecked may be a little too aggressive, as ANY packet will wake up the PC… However if you do check it then you have that the GTK rekeying will fail and it will wake up anyway. I didn’t notice the problem until I enabled the “monitoring” on one of the tools that I use to wake up the PC from android. That tool just tries to connect to a set of ports (the most commons, 21, 22, etc) to get if the system is enabled, and it did wake up the PC even if those ports are close (I was on the same network, so no firewall or whatever).

            At this point I don’t think there is any way to make it work as it should, even though it seems strange to me that you have to uncheck “only allow…” otherwise the GTK rekeying fails, as the post was very old… But it seems the case…

  2. RyzaJr

    I’m trying to figure WoWLAN myself. I don’t know where the weak link is in my setup though as I can’t even get it to work.

    I believe my wireless card is not even powered during sleep mode, as the LED light on it turns off. Tried messing around the BIOS but still haven’t managed to keep it up.

    Reply
    1. alexvy86 Post author

      The first two things that I’d point to are: did you see any specific setting in the BIOS related to WOL/WoWOL? And how do the settings for the wireless card look like, in Device Manager (assuming you’re running Windows)?

      Reply
      1. RyzaJr

        For the BIOS, I assume it’s this setting:
        Allow the system to be waked up by a PCI device and enable wake on LAN: Enabled.
        Since it’s a wireless network card that connects by PCI.

        As for the device manager settings, it has all the usual stuff like “allow this device to wake the computer” etc. enabled.

        But for whatever reason, the card isn’t staying on (LED goes off) after the PC goes into sleep mode.

        Reply
        1. alexvy86 Post author

          Yeah, the BIOS setting sounds right. I’m not sure if the LEDs turning off is expected, I haven’t looked into that on my computer (the wireless card is inside the case). I imagine you already confirmed that your wireless card supports WoWLAN?

          Reply
          1. RyzaJr

            Actually, that might be it. It’s a TP-Link AC1300. I can’t find any documentation on it that says it supports WOL. I did find the following in its properties though. Regardless, I may have to get a new one that supports WOL.

  3. marcelulrich3870

    This thread ended hours of trial and error for me, unchecking “Only allow a magic packet to wake the computer” did the trick and stopped my PC from constantly waking up, thanks a lot!

    Reply

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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