Ticket #296 (new enhancement)

Opened 2 years ago

Last modified 13 months ago

Implement Sleep Proxy Service (Wake on Demand)

Reported by: ajmas Owned by: lennart
Milestone: Component: avahi-core
Keywords: Cc: sascha-web-avahi.org@…

Description

With the release of MacOS X 10.6 (Snow Leopard) it is now possible, with the combination of an Apple Airport Extreme, to wake a computer from sleep based on a request to its IP address. This technology is described in the following two links:

http://support.apple.com/kb/HT3774 http://en.wikipedia.org/wiki/Sleep_Proxy_Service

While WoL and WoW are available, these both require use of the MAC address. This solution described in this enhancement ticket simplifies this by simply requiring an IP address.

Attachments

sleep-proxy.py (3.5 kB) - added by ajmas 20 months ago.
Python file for testing fucntionality

Change History

  Changed 20 months ago by ajmas

  • summary changed from Implement Sleep Proxy Service to Implement Sleep Proxy Service (Wake on Demand)

From what I can see it is simply a registered mDNS entry to let the router know than the computer is interested in being woken on demand. There doesn't seem to be much functionality beyond that.

Changed 20 months ago by ajmas

Python file for testing fucntionality

  Changed 20 months ago by ajmas

I have attached a file that should allow the computer to recognised by the "Apple Airport" for being available for "Wake on Demand". At this point I have not been able to test this with a standalone Linux machine (was using a VM), so if anyone can test this it would be cool. This is essentially a slightly tweaked version of the python example provided on this site.

  Changed 19 months ago by dlmh

I have tried your script, but it didn't work. I read through it and assumed it's nothing more than an easy way to add a service to Avahi.

So I created a sleepproxy.service file, with the port and service name provided by the script. I put the machine to S3 sleep (with WoL [pumbg] enabled) and tried to wake it up using one of the many services it's running (FTP/HTTP/SSH): still doesn't work.

Was I right to assume it's nothing more than a service that needs to be registered by Avahi? Once registered by Avahi and published on the network, my Airport Extreme should pick this up, right?

follow-ups: ↓ 6 ↓ 7   Changed 19 months ago by ajmas

It is possible I have misunderstood how it works exactly, but from my understanding the sleep proxy advertisement should tell the router (Apple Airport in this case), that it is available for being woken up, but only for one of the other services already registered via Bonjour, for that computer. My script is based more on theory than previous experience.

The way I would see the test scenario go:

  • Test that WoL works by itself, by trying to send a magic packet from another computer.
  • If that works, then activate a service advertisement, via Bonjor/mDNs, such as for HTTP or SSH
  • Activate the Sleep proxy advertisement
  • Put the computer to sleep and then try accessing the other computer, both with its mDNs name and also separately its IP address.

  Changed 19 months ago by andrewtj

In so far as I understand a sleep proxy client must send the records it wants advertised to the sleep proxy just prior to it going to sleep. The sleep proxy then issues ARP requests to take over the IP addresses of the client. A wake packet is only sent to the client when a connection is attempted to the pseudo services the sleep proxy is offering.

The mDNSResponder source code is probably the best place to get the specifics on this process.

in reply to: ↑ 4   Changed 19 months ago by dlmh

Replying to ajmas:

It is possible I have misunderstood how it works exactly, but from my understanding the sleep proxy advertisement should tell the router (Apple Airport in this case), that it is available for being woken up, but only for one of the other services already registered via Bonjour, for that computer. My script is based more on theory than previous experience. The way I would see the test scenario go: - Test that WoL works by itself, by trying to send a magic packet from another computer. - If that works, then activate a service advertisement, via Bonjor/mDNs, such as for HTTP or SSH - Activate the Sleep proxy advertisement - Put the computer to sleep and then try accessing the other computer, both with its mDNs name and also separately its IP address.

WoL is working, as it did before ;)

The problem I had when trying your script is that is unable to find the 'dbus' module. I've installed the dbus package and it should be running, but lsmod confirms that error (although I'm not sure if it should show up there).

So I created a separate service for the sleep-proxy, assuming this was the only thing necessary, that looks like this:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<service-group>
	<name replace-wildcards="yes">%h</name>
	<service>
		<type>_sleep-proxy._udp</type>
		<port>1234</port>
		<txt-record>model=Xserve</txt-record>
	</service>
</service-group>

But if it works like andrewtj says, I should add the service to every other service I have announced over Avahi, like this?

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<service-group>
    <name replace-wildcards="yes">%h</name>
    <service>
        <type>_smb._tcp</type>
        <port>139</port>
    </service>
    <service>
         <type>_device-info._tcp</type>
         <port>0</port>
         <txt-record>model=Xserve</txt-record>
    </service
    <service>
		<type>_sleep-proxy._udp</type>
		<port>1234</port>
		<txt-record>model=Xserve</txt-record>
	</service>
</service-group>

in reply to: ↑ 4   Changed 19 months ago by dlmh

Replying to ajmas:

It is possible I have misunderstood how it works exactly, but from my understanding the sleep proxy advertisement should tell the router (Apple Airport in this case), that it is available for being woken up, but only for one of the other services already registered via Bonjour, for that computer. My script is based more on theory than previous experience. The way I would see the test scenario go: - Test that WoL works by itself, by trying to send a magic packet from another computer. - If that works, then activate a service advertisement, via Bonjor/mDNs, such as for HTTP or SSH - Activate the Sleep proxy advertisement - Put the computer to sleep and then try accessing the other computer, both with its mDNs name and also separately its IP address.

WoL is working, as it did before ;)

The problem I had when trying your script is that is unable to find the 'dbus' module. I've installed the dbus package and it should be running, but lsmod confirms that error (although I'm not sure if it should show up there).

So I created a separate service for the sleep-proxy, assuming this was the only thing necessary, that looks like this:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<service-group>
	<name replace-wildcards="yes">%h</name>
	<service>
		<type>_sleep-proxy._udp</type>
		<port>1234</port>
		<txt-record>model=Xserve</txt-record>
	</service>
</service-group>

But if it works like andrewtj says, I should add the service to every other service I have announced over Avahi? Like this?

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">

<service-group>
    <name replace-wildcards="yes">%h</name>
    <service>
        <type>_smb._tcp</type>
        <port>139</port>
    </service>
    <service>
         <type>_device-info._tcp</type>
         <port>0</port>
         <txt-record>model=Xserve</txt-record>
    </service
    <service>
		<type>_sleep-proxy._udp</type>
		<port>1234</port>
		<txt-record>model=Xserve</txt-record>
	</service>
</service-group>

follow-up: ↓ 9   Changed 19 months ago by andrewtj

There's more to it than advertising a service. The message format and much of the semantics are described in: http://tools.ietf.org/id/draft-cheshire-edns0-owner-option-00.txt

in reply to: ↑ 8   Changed 19 months ago by dlmh

Replying to andrewtj:

There's more to it than advertising a service. The message format and much of the semantics are described in: http://tools.ietf.org/id/draft-cheshire-edns0-owner-option-00.txt

Ah, I see... that's a bit more complicated than I bargained for :P

  Changed 13 months ago by sascha_silbe

  • cc sascha-web-avahi.org@… added
Note: See TracTickets for help on using tickets.