←back to thread

189 points thunderbong | 3 comments | | HN request time: 0.001s | source
Show context
redbell ◴[] No.41412932[source]
Speaking about LAN, today, I encountered an unexpected event I had never imagined or experienced before.

I was working on a simple HTML/CSS game in VS Code, with Live Server running on port 5500 to serve the site. Feeling a bit tired, I decided to take a break. I put my Windows PC to sleep and moved to another room in my house. There, I spotted my Android tablet and thought it would be interesting to see how the game would perform on a tablet.

I unlocked the tablet, opened Chrome, entered my PC's local IP address and port, and hit 'Go'. To my surprise, the loading spinner appeared and spun for about 3-4 seconds. I was puzzled as to why the request was taking so long to get a response, and then it hit me—my PC was supposed to be sleeping.

Yet, just as I was processing this realization, the game’s web page loaded on the tablet. I was stunned, thinking, "Wait a minute—didn't I put my PC to sleep?" I went back to check my PC, and sure enough, it was awake but showing the lock screen. Out of curiosity, I repeated the experiment: I put the PC to sleep again, then accessed the webpage from my phone, and, once again, my PC awoke in response to the request. It was an eye-opening moment to see how the network request could wake my PC from sleep!

I googled this behavior and turned out to be called Wake on LAN or, WOL for short [1].

__________________

1. https://learn.microsoft.com/en-us/troubleshoot/windows-clien...

replies(3): >>41413057 #>>41413078 #>>41414533 #
1. kijiki ◴[] No.41413078[source]
WoL relies on a special magic Ethernet frame being sent to the MAC of the sleeping computer. A normal ARP or TCP SYN from an incoming HTTP request won't do it. The wikipedia article has the exact frame format: https://en.wikipedia.org/wiki/Wake-on-LAN

I've seen setups where the router is configured to send the magic WoL packet when it sees an ARP for the IP of a computer it knows is sleeping, but you'd almost certainly know if you had an exotic configuration like that on your network.

replies(2): >>41413213 #>>41413283 #
2. jcrawfordor ◴[] No.41413213[source]
The terminology here can be a little confusing, because WoL isn't a precisely standardized term but rather sort of a general label for a family of behaviors, the most common of which is the "Magic Packet" that originated with AMD. For some time a magic packet was mostly the only thing that could wake a computer, because the NIC had to originate a power-on event and most NICs were only capable of doing so in response to a magic packet. There were, though, particularly in more "enterprise" contexts, NICs that could be configured to wake the machine on other types of traffic. This kind of thing went in the option ROM of high-end NICs.

Today, though, with various low-power states and "hybrid sleep," packets received while in a low-power state can actually be delivered to the operating system to make a decision on waking. That's made WoL a lot more complex: with a supported network adapter and power state, Windows will wake up in response to pretty much any network traffic directed at the sleeping computer. That detection is surprisingly sophisticated, unicast packets addressed to a computer will wake it, but so will certain recognized discovery protocols sent to broadcast when they specify the computer's hostname.

One the one hand, it's pretty neat that e.g. attempting to connect to an SMB share on a Windows computer will wake it. On the other hand, it means that "nuisance" WoL has become an occasional irritation. For that reason you can configure Windows back to the original behavior of only waking on a magic packet specifically. To be fair, the whole idea came about in part because of all the implementation limitations with magic packets that made them very flaky.

Microsoft refers to all of this functionality with the term "WoL," while Apple seems to have decided to avoid the confusion by calling the entire concept "Wake on Demand" instead.

3. emmelaich ◴[] No.41413283[source]
Some cards seem to allow any packet, not just the WoL magic packet to wake the machine. This is referenced in the Wikipedia article as "Wake on Link"

You can change this. From memory it was directly in the Control Panel for Windows. And ethtool or similar in Linux.