1

I have read that one would need to send a WOL (wake on lan) magic packet on port 7 or 9 of the target machine (with WOL enabled in H/W) for it to work.

Is this correct? If not, then how is the WOL packet processed?

3

The magic packet is necessarily not a packet at all, it must consist of a Frame, so it just needs a valid payload that contains the magic string. you can put a packet and a segment in it, but they are not actually processed by the IP and TCP/UDP layers.

From https://en.wikipedia.org/wiki/Wake-on-LAN#Magic_packet:

The magic packet is a broadcast frame containing anywhere within its payload 6 bytes of all 255 (FF FF FF FF FF FF in hexadecimal), followed by sixteen repetitions of the target computer's 48-bit MAC address, for a total of 102 bytes.

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 any network- and transport-layer protocol, although it is typically sent as a UDP datagram to port 7 or 9, or directly over Ethernet as EtherType 0x0842.

so the answers to your questions are no and yes respectively. you do not need to use an upper layer protocol at all, the IP paccket need not be addressed to the target machine, and the ports don't actually listen or recieve the WOL datagram at all; the Datalink layer scans the payload for the magic string, and if found does not pass the payload up to the Network layer for processing at all. Many implementations use UDP\7 (Echo) and UDP\9 (Discard), probably so that systems which do not support WOL do not process the packet in a potentially unsafe way. On those systems the upper layers would receive the segment.

Note however that while WOL is implemented 100% in hardware and drivers, its compliance varies from vendor to vendor and device to device, so it is often finicky.

  • the Datalink layer scans the payload for the magic string, and if found does not pass the payload up to the Network layer for processing at all. it can not just "drop" packages, if them contains magic string, because it absolutely valid for upper layer protocol to have that sequence of bytes as part of payload. – PetSerAl Mar 15 '15 at 21:43
  • @PetSerAl, feel free to argue your point over at wikipedia if you like. I'm guessing your concern is likley why many implementations make it point to the UDP Echo port (7), or the UDP "Discard" port (9), or even better using a raw frame directed at LLC 0x0842, but those upper layer ports do nothing with the data, and do nothing in themselves to support WOL. I am thinking they do this so that WOL traffic to non-WOL capable systems is non-disruptive. Like the Frame, the IP datagram would be a LAN broadcast. – Frank Thomas Mar 15 '15 at 23:04
  • First, I does not find at Wikipedia anything that support your claim (if found does not pass the payload up to the Network layer for processing at all.). Second, when computer sleep, no Network layer processing should be going, so no packets passed to Network layer regardless of have them correct WoL pattern or not. Third, on my WoL capable and configured computer, I am able to receive packets that have correct WoL pattern, so them are not dropped by Datalink layer. – PetSerAl Mar 15 '15 at 23:47
  • ummm, that's what Since the magic packet is only scanned for the string above, and not actually parsed by a full protocol stack means. Look into sleep states. sleep is not like hibernate, and leaves the computer able to wake itself on a schedule, and on events like receiving a frame. WOL is a standard, and yes some implementers may do it differently, but the intention of the protocol is to handle everything at Layer 2, and not involve higher layers of the network stack. – Frank Thomas Mar 16 '15 at 4:14
  • @FrankThomas you mentioned in your answer that it needs a broadcast frame. The application I was using to generate the WOL packet was asking me if I want to broadcast or to use specific destination of my hibernating PC. I was always putting the specific (not broadcast) router ip address where I port forward the WOL packets to my sleeping pc. And as mentioned in question I actually do receive the packet. So was the problem the fact that I didn't send a broadcast frame? – Kam Mar 17 '15 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.