Detect WOL possibility
I'd like to detect if Wake On Lan is possible.
On my 开发者_Go百科router (Tomato firmware) there is a table with info - when displays device "Active (In ARP)" - it's possible to turn this device by WOL (offline linux pc).
I wonder if it is achieved by router only function or I can do this in C# or C? Function SendArp can detect MAC adress and do "arping" but it is not what I would like to do.
Your router can't detect if your computer (or any other network device) supports Wake-On-Lan. All your router can do is send out a WOL package and hoping that it will wake up.
If the calling device respects the packet and wakes up must be configured at the device itself and there exists nothing within the OSI layers 4 to 1 which can tell you if a device supports WOL.
If you like to send a WOL packet from your PC using C#, you find plenty examples by using your favourite search engine. Here is one example from Bart de Smet.
Update
The message "Active (In ARP)" doesn't mean that your router detected that it is possible to send a WOL packet. It just tells you that within the routers ARP cache currently is a matching entry for this IP or MAC address. Such a cache has every network device (also your pc). In Windows just open the command line and enter arp -a
to see the cache of your windows machine. Here you'll get a list of the stored mac adresses for sending to an IP address. A black hat can try to manipulate this cache to redirect your ip communication. Further informations about this can be found at wikipedia.
So this message just tells you, that your router had recently an ip connection to this device. That's it. But it can't tell you if your device is currently able to handle a WOL packet (cause it is power connected or not).
You're probably best checking out http://msdn.microsoft.com/en-us/library/ff566341(VS.85).aspx
This will let you query boolean for power management and the device specific "wake enabled" state.
Given that it's WMI, you should be able to get to this remotely, but it does need a couple of registry keys set to expose the WMI class.
You get the info about whether a machine supports WOL from the BIOS.
If it is supported, make sure it's turned on. Many machines have the capability disabled by default.
To route WOL packets through the network you need to forward port 9 on the router to 255.255.255.255 (Brodcast-to-all) IP Address.
精彩评论