Closed akshay2000 closed 9 years ago
I'm currently trying to implement this feature. Waking up PCs works fine, only problem is: I don't know where to find out the right broadcast IP address the magic package needs to be sent to.
Possible solutions are:
I'm very new to this and haven't been able to setup WOL on my Windows machine yet. So, walk me through. But here are our options right now:
I don't have any reading material for you at the moment but let me try to explain the basics:
You create a "magic" package which contains 6 bytes of 0xFF and then 16 repetitions of the 6 byte long MAC address. This package is sent via an UDP (Datagram) Socket to the broadcast address in the network so all hosts (even those who are not turned on) receive the package. The always-on network card receives this package, compares it's MAC address and if it's correct, turns the machine on.
I knew about the magic packet part but had trouble understanding why would it be sent to broadcast address and why not specific IP address. Now it all makes sense. IP just isn't there for the host that is not alive. And we do need to extend the ConnectionItem
to accommodate for MAC address. Might as well throw in the IP too.
Now for our problem, first solution still sounds good. Second is confusing, like you said.
I'd love some explanation about the WAN IP though. Do you mean to wake up computer from outside the home network?
I will implement a prototype for the first solution, we'll see if it all works out.
You're quite right about the Wake-on-WAN thing, it is possible to wake your computer from outside your network, if everything is configured correctly. I doubt anyone will connect to their Kodi instance over the internet without VPN but anyway, this setup needs to be done:
I assume your network to be at 192.168.1.0/24
with WAN IP 11.12.13.14
.
x
to internal IP 192.168.1.254
(could be any unused IP) on port 9
(discard, best practice)FF:FF:FF:FF:FF:FF
(broadcast IP) on your router's network interface (here br0
) to 192.168.1.254
with the command arp -i br0 -s 192.168.1.254 FF:FF:FF:FF:FF:FF
11.12.13.14
on port x
. The router does a lookup for the package's destination MAC address and finds out, that is has to be broadcasted, since the MAC is set to FF:FF:FF:FF:FF:FF
. Done.As you see, in addition to the MAC address and subnet mask (which is useless here), the WAN IP and Port have to be given enable this feature.
I'm glad that I understood correctly. Now, let's take a step back. Waking up machines from outside the LAN is not the responsibility of Kodi Assist. There are other things (apps, websites, etc.) out there specialized for WOL scenarios. Adding this functionality to Kodi Assist is mere a matter of convenience of not having to use two different apps when you're on the couch and ready to watch a movie. Now, allowing remote wake up won't make sense. Let's say user woke a host up remotely, now what? Rest of the app still remains unusable. So, in essence, we're choosing to ignore the WAN scenario.
First implementation is now finished. Maybe you can create a branch "wake-on-lan" so I can make a pull request to that? Or will you just clone my repo locally to test it?
I think a branch will be easier to manage. I'll create one soon. Although, I'm not sure how to test it. I tried with different apps, but my machine won't just wake up from sleep. Not entirely sure what configuration I'm missing.
It's very hard to debug, as it requires configuration in the BIOS / UEFI as well as in your OS. Please refer to this guide. There is a packet sniffer linked at the bottom of that guide, that will help to analyze, if the packages come through. You can also use Wireshark, if you're familiar with that, it has far more possibilities to analyze the packages.
Problem is: If it fails, no errors or exceptions are thrown in the app at all, so no feedback for the user is possible.
I've followed that guide a few times. And frankly, going all WireShark seems like overkill to get a setup that I might never use. A thing for another time, perhaps. Thanks for the info, though. While we're at it, a branch has been created. Open a pull request against it. I'll test it for UX and just assume that the code works.
@brinox Apparently, the mac addresses starting with 0 are being truncated.
An empty stub has been added to
Helpers
namespace for WOL. The class needs to be completed with necessary code to achieve wake on LAN feature. If required, it is possible to obtain and store MAC id of the server intoConnectionItem
.