awein / SleepProxyClient

A SleepProxyClient implementation
GNU General Public License v3.0
57 stars 14 forks source link

Cannot get clients to wake up #6

Closed martinjo closed 11 years ago

martinjo commented 11 years ago

I've been trying to get SleepProxyClient to work on my UnRaid-box this weekend, but without succeeding.

First I had to modify the script with a fixed IP of my time capsule, or it would always choose the the "169.X.X.X" ip-address, as was discussed in another issue. I also hardcoded the script to only send updates for my first ethernet interface 'eth0'.

Now it seems to be registering my services with the proxy, but I still cant get my client to wake up (it works when I manually send a WOL package).

When I browse my bonjour services with BonjourBrowser, I can see my service advertised with the correct IP, but it's missing the MAC-address (it seems all other services have a mac-address assigned to them). A screenshot is attached.

Any help would be appreciated. I'm not really sure how to debug this any further...

bonjourbrowser

Below is the debug output from SleepProxyClient.py root@UNRAID:/boot/config/scripts/SleepProxyClient# python sleepproxyclient.py --debug Interfaces: lo, eth0, eth1 -sendUpdateForInterface: eth0 -sendUpdateForInterface: IPs: 192.168.1.130 -sendUpdateForInterface: HW-Addr: 00:25:90:93:f2:28 -discoverSleepProxyForInterface: Interface: eth0 -discoverSleepProxyForInterface: selected proxy: {'ip': '169.254.145.227', 'name': 'Martins-Time-Capsule.local', 'port': '51527'} with properties: 50-34-10-70\032Martins\032Time\032Capsule -sendUpdateForInterface: Host: UNRAID.local -discoverServices: IPs: 192.168.1.130 -discoverServices: discovered Services: [['_http._tcp', '80', ''], ['_workstation._tcp', '9', ''], ['_device-info._tcp', '0', 'model=Xserve'], ['_smb._tcp', '445', '']] -sendUpdateForInterface: request: id 27501 opcode UPDATE rcode NOERROR flags edns 0 eflags payload 1280 ;ZONE . IN SOA ;PREREQ ;UPDATE 130.1.168.192.in-addr.arpa. 120 IN PTR UNRAID.local UNRAID.local 120 IN A 192.168.1.130 UNRAID._http._tcp.local 4500 IN TXT "\000" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _http._tcp.local _http._tcp.local 4500 IN PTR UNRAID._http._tcp.local UNRAID._http._tcp.local 120 IN SRV 0 0 80 UNRAID.local UNRAID._workstation._tcp.local 4500 IN TXT "\000" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _workstation._tcp.local _workstation._tcp.local 4500 IN PTR UNRAID._workstation._tcp.local UNRAID._workstation._tcp.local 120 IN SRV 0 0 9 UNRAID.local UNRAID._device-info._tcp.local 4500 IN TXT "model=Xserve" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _device-info._tcp.local _device-info._tcp.local 4500 IN PTR UNRAID._device-info._tcp.local UNRAID._device-info._tcp.local 120 IN SRV 0 0 0 UNRAID.local UNRAID._smb._tcp.local 4500 IN TXT "\000" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _smb._tcp.local _smb._tcp.local 4500 IN PTR UNRAID._smb._tcp.local UNRAID._smb._tcp.local 120 IN SRV 0 0 445 UNRAID.local ;ADDITIONAL -sendUpdateForInterface: sending update to 169.254.145.227 -sendUpdateForInterface: response: id 27501 opcode UPDATE rcode NOERROR flags QR edns 0 eflags payload 1440 ;ZONE ;PREREQ ;UPDATE ;ADDITIONAL

awein commented 11 years ago

Hi, thanks for using SPC and trying to get it running with unRAID. Would be great to get some setup instructions from you to be able to share this with other users via wiki.

some remarks first:

Have you tried to access UNRAID.local? (It should not be case-sensitify due to it's based on DNS - but you should try it just to be safe)

It seems the SPC (time capsule) does not recognize the service access correctly The only way to debug this issue is to record the network traffic via Wireshark/tcpdump and try to find the issue. If you need some instructions on how to dump the network traffic just send me a mail to dev[at]weinlein.info

martinjo commented 11 years ago

Once I get it working I'll add some instructions to the wiki on how to set everything up. It seems from the UnRaid forums that others got it to work, so I'm still hopeful :)

I downloaded the master branch, so I guess (hope) it's 0.7 that I'm using.

the unraid.local address is working, it resolves to 192.168.1.130. Do I need to access my server through this address to get it to wake up?

As soon as I have the time I'll try to set WireShark up and log the traffic. I just need to figure out how to forward the packets to/from my TimeCapsule to the monitoring computer...

Thanks for your help! :)

awein commented 11 years ago

Take a look at your arp-table too - 192.168.1.130 should point to the TimeCapsule after the unraid is sleeping. The unraid should get WOL packages if the TimeCapsule detects packages matching the announced IP and port. (For example 192.168.1.130:80). Maybe the WOL is not working as it should. Do you send a multicast or unicast WOL package to wake it up by hand?

martinjo commented 11 years ago

I'm unsure about whether the WOL utility I use sends uni- or multicast (can't check anything now since I'm at work, but I will tonight or tomorrow). I have not changed any settings in my router to get WOL working, if that is any clue?

Another thing that perhaps could affect this issue is that my UnRaid server has a static IP-address. That was because of some other issue I had when installing it. Could the static IP be a problem?

awein commented 11 years ago

Could the static IP be a problem?

No.

martinjo commented 11 years ago

I've checked the ARP table, and it appears as my UnRaid server gets the MAC of my time capsule after I've run sleepproxyclient.py. I've never used the arp command before, so if there is anything specific that I should check, please tell me (I'm using a router with DD-WRT).

For some reason I still have to hard code the IP of my time capsule in the script or I get an error that the response came from the wrong IP.

What do you suggest checking next? Could there be something preventing the WOL packet from my time capsule to reach the (sleeping) server? When waking up the server manually I use the WakeUp utility from http://archive.org/details/tucows_305250_WakeUp

Output from script now:

root@UNRAID:/boot/config/scripts/SleepProxyClient# python2.7 sleepproxyclient.py --interfaces eth0 --debug Interfaces: eth0 -sendUpdateForInterface: eth0 -sendUpdateForInterface: IPs: 192.168.1.130 -sendUpdateForInterface: HW-Addr: 00:25:90:93:f2:28 -discoverSleepProxyForInterface: Interface: eth0 -discoverSleepProxyForInterface: selected proxy: {'ip': '192.168.1.128', 'name': 'Martins-Time-Capsule.local', 'port': '51527'} with properties: 50-34-10-70\032Martins\032Time\032Capsule -sendUpdateForInterface: Host: UNRAID.local -discoverServices: IPs: 192.168.1.130 -discoverServices: discovered Services: [['_http._tcp', '80', ''], ['_smb._tcp', '445', ''], ['_device-info._tcp', '0', 'model=Xserve'], ['_workstation._tcp', '9', '']] -sendUpdateForInterface: request: id 65144 opcode UPDATE rcode NOERROR flags edns 0 eflags payload 1280 ;ZONE . IN SOA ;PREREQ ;UPDATE 130.1.168.192.in-addr.arpa. 120 IN PTR UNRAID.local UNRAID.local 120 IN A 192.168.1.130 UNRAID._http._tcp.local 4500 IN TXT "\000" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _http._tcp.local _http._tcp.local 4500 IN PTR UNRAID._http._tcp.local UNRAID._http._tcp.local 120 IN SRV 0 0 80 UNRAID.local UNRAID._smb._tcp.local 4500 IN TXT "\000" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _smb._tcp.local _smb._tcp.local 4500 IN PTR UNRAID._smb._tcp.local UNRAID._smb._tcp.local 120 IN SRV 0 0 445 UNRAID.local UNRAID._device-info._tcp.local 4500 IN TXT "model=Xserve" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _device-info._tcp.local _device-info._tcp.local 4500 IN PTR UNRAID._device-info._tcp.local UNRAID._device-info._tcp.local 120 IN SRV 0 0 0 UNRAID.local UNRAID._workstation._tcp.local 4500 IN TXT "\000" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _workstation._tcp.local _workstation._tcp.local 4500 IN PTR UNRAID._workstation._tcp.local UNRAID._workstation._tcp.local 120 IN SRV 0 0 9 UNRAID.local ;ADDITIONAL -sendUpdateForInterface: sending update to 192.168.1.128 -sendUpdateForInterface: response: id 65144 opcode UPDATE rcode NOERROR flags QR edns 0 eflags payload 1440 ;ZONE ;PREREQ ;UPDATE ;ADDITIONAL

awein commented 11 years ago

For some reason I still have to hard code the IP of my time capsule in the script or I get an error that the response came from the wrong IP.

This error can be ignored (I'm almost sure). I've added some more debug output to investigate the IP-selection in more detail. Please update your script to get some more details.

I'm using a router with DD-WRT

it may be easy to record the traffic via tcpdump on your DD-WRT router. There should be prebuilt binaries available from the openwrt project.

What do you suggest checking next?

Maybe there is a WOL or networking issue. But it seems I need some network traffic to investigate this in more detail.

martinjo commented 11 years ago

I'm still struggling to get this to work. I've downloaded the updated script and the output is below.

Also trying to capture the traffic, but so far it seems tcpdump doesn't capture the traffic to my sleep proxies. I'll update here when I get something...

root@UNRAID:/boot/config/scripts/SleepProxyClient# python2.7 sleepproxyclient.py --interfaces eth0 --debug Interfaces: eth0 -sendUpdateForInterface: eth0 -sendUpdateForInterface: IPs: 192.168.1.130 -sendUpdateForInterface: HW-Addr: 00:25:90:93:f2:28 -discoverSleepProxyForInterface: Interface: eth0 -discoverSleepProxyForInterface: available proxy: {'ip': '169.254.145.227', 'name': 'Martins-Time-Capsule.local', 'port': '52955'} with properties: 50-34-10-70\032Martins\032Time\032Capsule -discoverSleepProxyForInterface: available proxy: {'ip': '169.254.78.252', 'name': 'Sovjnet-APE.local', 'port': '64146'} with properties: 50-35-10-70.1\032Sovjnet\032APE -discoverSleepProxyForInterface: selected proxy: {'ip': '169.254.78.252', 'name': 'Sovjnet-APE.local', 'port': '64146'} with properties: 50-35-10-70.1\032Sovjnet\032APE -sendUpdateForInterface: Host: UNRAID.local -discoverServices: IPs: 192.168.1.130 -discoverServices: discovered Services: [['_http._tcp', '80', 'SPC_STATE=sleeping', 'SPC_STATE=sleeping'], ['_http._tcp', '80', ''], ['_workstation._tcp', '9', ''], ['_device-info._tcp', '0', 'model=Xserve'], ['_smb._tcp', '445', ''], ['_workstation._tcp', '9', 'SPC_STATE=sleeping', 'SPC_STATE=sleeping'], ['_device-info._tcp', '0', 'SPC_STATE=sleeping', 'model=Xserve', 'SPC_STATE=sleeping'], ['_smb._tcp', '445', 'SPC_STATE=sleeping', 'SPC_STATE=sleeping']] -sendUpdateForInterface: request: id 39491 opcode UPDATE rcode NOERROR flags edns 0 eflags payload 1280 ;ZONE . IN SOA ;PREREQ ;UPDATE 130.1.168.192.in-addr.arpa. 120 IN PTR UNRAID.local UNRAID.local 120 IN A 192.168.1.130 UNRAID._http._tcp.local 4500 IN TXT "SPC_STATE=sleeping" "SPC_STATE=sleeping" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _http._tcp.local _http._tcp.local 4500 IN PTR UNRAID._http._tcp.local UNRAID._http._tcp.local 120 IN SRV 0 0 80 UNRAID.local UNRAID._http._tcp.local 4500 IN TXT "\000" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _http._tcp.local _http._tcp.local 4500 IN PTR UNRAID._http._tcp.local UNRAID._http._tcp.local 120 IN SRV 0 0 80 UNRAID.local UNRAID._workstation._tcp.local 4500 IN TXT "\000" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _workstation._tcp.local _workstation._tcp.local 4500 IN PTR UNRAID._workstation._tcp.local UNRAID._workstation._tcp.local 120 IN SRV 0 0 9 UNRAID.local UNRAID._device-info._tcp.local 4500 IN TXT "model=Xserve" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _device-info._tcp.local _device-info._tcp.local 4500 IN PTR UNRAID._device-info._tcp.local UNRAID._device-info._tcp.local 120 IN SRV 0 0 0 UNRAID.local UNRAID._smb._tcp.local 4500 IN TXT "\000" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _smb._tcp.local _smb._tcp.local 4500 IN PTR UNRAID._smb._tcp.local UNRAID._smb._tcp.local 120 IN SRV 0 0 445 UNRAID.local UNRAID._workstation._tcp.local 4500 IN TXT "SPC_STATE=sleeping" "SPC_STATE=sleeping" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _workstation._tcp.local _workstation._tcp.local 4500 IN PTR UNRAID._workstation._tcp.local UNRAID._workstation._tcp.local 120 IN SRV 0 0 9 UNRAID.local UNRAID._device-info._tcp.local 4500 IN TXT "SPC_STATE=sleeping" "model=Xserve" "SPC_STATE=sleeping" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _device-info._tcp.local _device-info._tcp.local 4500 IN PTR UNRAID._device-info._tcp.local UNRAID._device-info._tcp.local 120 IN SRV 0 0 0 UNRAID.local UNRAID._smb._tcp.local 4500 IN TXT "SPC_STATE=sleeping" "SPC_STATE=sleeping" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _smb._tcp.local _smb._tcp.local 4500 IN PTR UNRAID._smb._tcp.local UNRAID._smb._tcp.local 120 IN SRV 0 0 445 UNRAID.local ;ADDITIONAL -sendUpdateForInterface: sending update to 169.254.78.252 Unable to register with SleepProxy Sovjnet-APE.local (169.254.78.252:64146) <class 'dns.query.UnexpectedSource'> got a response from ('192.168.1.104', 64146) instead of ('169.254.78.252', 64146)

martinjo commented 11 years ago

I think I managed to capture the relevant packages. But the destination address was a multicast address (224.0.0.251), so that's why I didn't find them at first. Hope this can give some clues :)

https://dl.dropbox.com/u/24442350/sleepproxycapture.pcap

awein commented 11 years ago

@martinjo sorry - the captured traffic just shows the mdns name resolution. I need more traffic (including the wol traffic) to be able to find the issue. If you don't wan't to upload your full traffic, you can send me the file via mail too: mail to dev[at]weinlein.info

martinjo commented 11 years ago

Hi again!

I think I've managed to capture two packets that might be of interest now. They are in the file linked below. If you like I can send you the complete capture, but it seems it doesn't contain anything else of interest. I'm not completely sure that my setup with DD-WRT allows me to capture all packets, so I will borrow a hub from a friend within a few days... the

The capture: https://dl.dropbox.com/u/24442350/sleepproxy2.pcapng

And the debug output from sleepproxyclient.py

Hope this can be of some help to figure out what's wrong :-)

root@UNRAID:/boot/config/scripts/SleepProxyClient# python2.7 sleepproxyclient.py --interfaces eth0 --debug Interfaces: eth0 -sendUpdateForInterface: eth0 -sendUpdateForInterface: IPs: 192.168.1.130 -sendUpdateForInterface: HW-Addr: 00:25:90:93:f2:28 -discoverSleepProxyForInterface: Interface: eth0 -discoverSleepProxyForInterface: available proxy: {'ip': '169.254.145.227', 'name': 'Martins-Time-Capsule.local', 'port': '52955'} with properties: 50-34-10-70\032Martins\032Time\032Capsule -discoverSleepProxyForInterface: available proxy: {'ip': '169.254.78.252', 'name': 'Sovjnet-APE.local', 'port': '60621'} with properties: 50-35-10-70.1\032Sovjnet\032APE -discoverSleepProxyForInterface: selected proxy: {'ip': '169.254.78.252', 'name': 'Sovjnet-APE.local', 'port': '60621'} with properties: 50-35-10-70.1\032Sovjnet\032APE -sendUpdateForInterface: Host: UNRAID.local -discoverServices: IPs: 192.168.1.130 -discoverServices: discovered Services: [['_http._tcp', '80', 'SPC_STATE=sleeping', 'SPC_STATE=sleeping'], ['_http._tcp', '80', ''], ['_workstation._tcp', '9', 'SPC_STATE=sleeping', 'SPC_STATE=sleeping'], ['_workstation._tcp', '9', ''], ['_smb._tcp', '445', 'SPC_STATE=sleeping', 'SPC_STATE=sleeping'], ['_smb._tcp', '445', ''], ['_device-info._tcp', '0', 'SPC_STATE=sleeping', 'model=Xserve', 'SPC_STATE=sleeping'], ['_device-info._tcp', '0', 'model=Xserve']] -sendUpdateForInterface: request: id 28503 opcode UPDATE rcode NOERROR flags edns 0 eflags payload 1280 ;ZONE . IN SOA ;PREREQ ;UPDATE 130.1.168.192.in-addr.arpa. 120 IN PTR UNRAID.local UNRAID.local 120 IN A 192.168.1.130 UNRAID._http._tcp.local 4500 IN TXT "SPC_STATE=sleeping" "SPC_STATE=sleeping" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _http._tcp.local _http._tcp.local 4500 IN PTR UNRAID._http._tcp.local UNRAID._http._tcp.local 120 IN SRV 0 0 80 UNRAID.local UNRAID._http._tcp.local 4500 IN TXT "\000" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _http._tcp.local _http._tcp.local 4500 IN PTR UNRAID._http._tcp.local UNRAID._http._tcp.local 120 IN SRV 0 0 80 UNRAID.local UNRAID._workstation._tcp.local 4500 IN TXT "SPC_STATE=sleeping" "SPC_STATE=sleeping" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _workstation._tcp.local _workstation._tcp.local 4500 IN PTR UNRAID._workstation._tcp.local UNRAID._workstation._tcp.local 120 IN SRV 0 0 9 UNRAID.local UNRAID._workstation._tcp.local 4500 IN TXT "\000" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _workstation._tcp.local _workstation._tcp.local 4500 IN PTR UNRAID._workstation._tcp.local UNRAID._workstation._tcp.local 120 IN SRV 0 0 9 UNRAID.local UNRAID._smb._tcp.local 4500 IN TXT "SPC_STATE=sleeping" "SPC_STATE=sleeping" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _smb._tcp.local _smb._tcp.local 4500 IN PTR UNRAID._smb._tcp.local UNRAID._smb._tcp.local 120 IN SRV 0 0 445 UNRAID.local UNRAID._smb._tcp.local 4500 IN TXT "\000" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _smb._tcp.local _smb._tcp.local 4500 IN PTR UNRAID._smb._tcp.local UNRAID._smb._tcp.local 120 IN SRV 0 0 445 UNRAID.local UNRAID._device-info._tcp.local 4500 IN TXT "SPC_STATE=sleeping" "model=Xserve" "SPC_STATE=sleeping" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _device-info._tcp.local _device-info._tcp.local 4500 IN PTR UNRAID._device-info._tcp.local UNRAID._device-info._tcp.local 120 IN SRV 0 0 0 UNRAID.local UNRAID._device-info._tcp.local 4500 IN TXT "model=Xserve" "SPC_STATE=sleeping" _services._dns-sd._udp.local 4500 IN PTR _device-info._tcp.local _device-info._tcp.local 4500 IN PTR UNRAID._device-info._tcp.local UNRAID._device-info._tcp.local 120 IN SRV 0 0 0 UNRAID.local ;ADDITIONAL -sendUpdateForInterface: sending update to 169.254.78.252 Unable to register with SleepProxy Sovjnet-APE.local (169.254.78.252:60621) <class 'dns.exception.Timeout'>

awein commented 11 years ago

Sorry - this is still just resolution and registration/update traffic. Since registration is fine (Service resolution is possible after putting the SPC to sleep) the problem seems to be the wakeup process. Thus wakeup-traffic is needed to be able to analyze this in more detail.

martinjo commented 11 years ago

Ok, I've managed to capture the WOL packets now. There is a WOL packet sent from my airport express, but it is different from my manually sent WOL packets (the last ones in the capture). I guess this could be a problem with my network card not recognizing the kind of WOL packet that the airport express generates?

https://dl.dropbox.com/u/24442350/wolcap.pcapng

awein commented 11 years ago

Hi - thanks, thats the information I've searched for. You network dump confirms: This is not a SleepProxyClient issue.

It seems the Time Capsule will send plain Ethernet WOL packages (without a UDP/IP Broadcast to Port 9). Thus either your NAS is not on the same subnet or (more unlikely) your network card won't recognize plain ethernet WOL packages (maybe there is a BIOS setting?). It seems it's not possible to force the TC to send UDP WOL packages... but maybe google knows some secret trick...

awein commented 11 years ago

@martinjo Is your problem solved now?

martinjo commented 11 years ago

Sorry for my slow response. I've not had much time to test things yet. But a quick test seems to show that it was my motherboard that prevented the wakeup. My motherboard is a Supermicro X7SPA-HF-D525 with a IPMI interface. When the IPMI is enabled broadcast WOL does not work. When disabling the IPMI (via jumper and BIOS) it does work. I'm still struggling with some details of how to integrate sleep proxy client with Unraid, but when I've sorted those out I'll write some notes on the wiki. Thanks for the support! :D