Contributing to development

Posted on
Wed Jul 23, 2014 10:08 pm
PottedPorkProduct offline
User avatar
Posts: 13
Joined: Jun 29, 2014
Location: San Diego, CA, USA

Contributing to development

Hi,

I have an ASUS RT-956U set up in access point point that has a better idea of what devices are on the network than my router does, but it's not available via syslog or NTP. There's a really simple way to get this listing via an HTTP call.

Do you have the source code up on something like Github? Would you be amenable to code contributions?

Posted on
Thu Jul 24, 2014 6:15 am
kw123 offline
User avatar
Posts: 5388
Joined: May 12, 2013
Location: Dallas, TX

Re: Contributing to development

try FING on you mac. its pretty good

Posted on
Thu Jul 24, 2014 8:07 am
PottedPorkProduct offline
User avatar
Posts: 13
Joined: Jun 29, 2014
Location: San Diego, CA, USA

Re: Contributing to development

Fing seems like a nice tool, but it's just a wrapper for classic UNIX networking tools like arpping, ping, and nmap - programs that will find your device, but only if it's actually awake and on the network.

I'm afraid it's the wrong approach here. Just pinging or ARP-pinging the IP address or MAC of my iPhone is pretty unreliable. The phone only wakes up the radios every once in a while, and it's really easy to miss this window with a periodic poll. I've let a continuous ping run for 5 minutes before with my phone sitting on the desk next to me, and it didn't once wake up the WiFi radio.

However, it will stay associated with my wireless AP even with the radios in sleep mode. I've verified that even when the phone can't be pinged from my Mac (and thus doesn't show up in the arp queue), it's still in the list of stations associated with the AP.

I've dug into the code for this plugin, and it looks like it will be pretty trivial to add an HTTP polling engine similar to the SNMP polling engine used for the Airport mode.

Posted on
Thu Jul 24, 2014 8:13 am
kw123 offline
User avatar
Posts: 5388
Joined: May 12, 2013
Location: Dallas, TX

Re: Contributing to development

If the device is not answering (wifi off to save power) there is no way of knowing that the device is still there. There is no magic other information available (to the router or any other device).
It is just a question if the router/FING keeps it in its tables and how does it list it (up/down/expired) and when is it removed.

Karl

Posted on
Thu Jul 24, 2014 8:24 pm
PottedPorkProduct offline
User avatar
Posts: 13
Joined: Jun 29, 2014
Location: San Diego, CA, USA

Re: Contributing to development

I beg to differ. It still shows up in the list of associated systems according to the wireless interface on the router (accessible via the web page), but I can't ping it except sporadically. It's MAC address ends in CE:48, and it's in the 2.4Ghz radio's listing of associated stations (edited to sanitize MAC addresses):

Code: Select all
MAC address   : XX:XX:XX:XX:56:64
OP Mode      : AP
Phy Mode   : 11b/g/n
Channel      : 3

Stations List            
----------------------------------------
MAC               PSM PhyMode BW  MCS SGI STBC Rate Connect Time
XX:XX:XX:XX:9E:25 Yes HTMIX   20M   7 NO  Yes   65M 01:14:35
XX:XX:XX:XX:D6:6E Yes HTMIX   20M   7 NO  Yes   65M 371:20:22
XX:XX:XX:XX:21:E4 Yes HTMIX   20M   7 NO  NO    65M 82:21:42
XX:XX:XX:XX:9F:29 Yes HTMIX   20M   7 NO  NO    65M 602:26:16
XX:XX:XX:XX:CE:48 Yes HTMIX   20M   7 NO  NO    65M 00:17:02
XX:XX:XX:XX:58:86 Yes HTMIX   20M   7 NO  NO    65M 01:11:47
XX:XX:XX:XX:0D:CB NO  OFDM    20M   7 NO  NO    54M 176:25:16
XX:XX:XX:XX:E5:0A Yes HTMIX   20M   7 NO  NO    65M 00:53:00

MAC address   : XX:XX:XX:XX:56:65
OP Mode      : AP
Phy Mode   : 11a/n
Channel      : 36

Stations List            
----------------------------------------
MAC               PSM PhyMode BW  MCS SGI STBC Rate Connect Time
XX:XX:XX:XX:18:09 NO  HTMIX   40M  15 NO  NO   270M 00:23:16
XX:XX:XX:XX:36:6B Yes HTMIX   40M   4 NO  NO    81M 299:03:54
XX:XX:XX:XX:F4:E0 Yes HTMIX   40M  15 NO  NO   270M 00:15:08


Code: Select all
Request timeout for icmp_seq 384
Request timeout for icmp_seq 385
Request timeout for icmp_seq 386
Request timeout for icmp_seq 387
Request timeout for icmp_seq 388
Request timeout for icmp_seq 389
Request timeout for icmp_seq 390
Request timeout for icmp_seq 391
Request timeout for icmp_seq 392
Request timeout for icmp_seq 393
Request timeout for icmp_seq 394
Request timeout for icmp_seq 395
Request timeout for icmp_seq 396
Request timeout for icmp_seq 397


And most importantly, when I turn off the wireless interface on the phone completely, that mac address disappears completely from the table.

Code: Select all
MAC address   : XX:XX:XX:XX:56:64
OP Mode      : AP
Phy Mode   : 11b/g/n
Channel      : 3

Stations List            
----------------------------------------
MAC               PSM PhyMode BW  MCS SGI STBC Rate Connect Time
XX:XX:XX:XX:9E:25 Yes HTMIX   20M   7 NO  Yes   65M 01:29:10
XX:XX:XX:XX:D6:6E Yes HTMIX   20M   7 NO  Yes   65M 371:34:57
XX:XX:XX:XX:21:E4 NO  HTMIX   20M   7 NO  NO    65M 82:36:17
XX:XX:XX:XX:9F:29 Yes HTMIX   20M   7 NO  NO    65M 602:40:51
XX:XX:XX:XX:58:86 Yes HTMIX   20M   7 NO  NO    65M 01:26:22
XX:XX:XX:XX:0D:CB NO  OFDM    20M   7 NO  NO    54M 176:39:51
XX:XX:XX:XX:E5:0A Yes HTMIX   20M   7 NO  NO    65M 01:07:35

MAC address   : XX:XX:XX:XX:56:65
OP Mode      : AP
Phy Mode   : 11a/n
Channel      : 36

Stations List            
----------------------------------------
MAC               PSM PhyMode BW  MCS SGI STBC Rate Connect Time
XX:XX:XX:XX:18:09 NO  HTMIX   40M  15 NO  NO   270M 00:37:51
XX:XX:XX:XX:36:6B Yes HTMIX   40M   4 NO  NO    81M 299:18:29


So, as you can see, it's a pretty darn good indication of whether or not my phone is home, and it's a lot more reliable than relying on a periodic ping. I get near instantaneous notification when the phone leaves the range of the network.

Posted on
Fri Jul 25, 2014 3:23 pm
kw123 offline
User avatar
Posts: 5388
Joined: May 12, 2013
Location: Dallas, TX

Re: Contributing to development

cool,

Let me play this back:

1. the router has a table of mac numbers + status + assigned ip number +...
2. the mac number disappears when the wifi radio is turned off. --- Q: after what time? how long is the DHCP lease time set?
3. after mac number disappears from the tables and the wifi radio is switched on again, how fast does the phone-mac appears again in the tables?

To stretch my knowledge of networking here is my understanding how things work:
1. when a wifi device enters a new wifi network it negotiates with the router to get access (passwords etc) during that phase some network traffic gets generated that can be listen to by all devices on the network (if the network is flat ) - no pings involved here. Any devices connected to the network can create a table of devices this way.
2. then any device can ping any other device and confirm the device list.
2.a if the wifi device then happens to be asleep it naturally does not answer to pings
2.b every 5 to 30 minutes depending on power setting of the wifi device the device reconnects to the network and sends out some broadcasts (this where I am not sure what broadcasts are send) and how long the device is up
3. the device will be removed from the tables once some timeouts have expired (no later than DHCP expiration time).

My question is:
- does the router have more information about the wifi-devices than other nodes/devices participating in the network, i.e. during wake-up is there traffic ONLY between wifi-device and router?
- is there another wifi state (a little bit on) where the phone just wakes up for 1/10 of a seconds and sends out "alive" packages to the router?
if yes then I understand, if not I do not understand how more information is created. If a device is off or asleep should be the same information outside the wifi-device.

Interesting discussion..


Karl

Posted on
Fri Jul 25, 2014 4:36 pm
FlyingDiver offline
Posts: 2194
Joined: Jun 07, 2014
Location: Cape Coral, FL

Re: Contributing to development

A couple of things to consider -

The router will know more about the devices on the network than any other device can learn, because most ethernet connection devices are switches, not hubs. And the switches will only send info between specific devices, unless it's a broadcast message. Traffic between the device and the access point will be visible to other wireless devices with the right software. Not so much between the access point and the router (if they're different devices).

I think the reason the MAC address is disappearing from the router's tables is because the device is releasing it's IP address as part of the process of shutting off the Wifi. That's not the same as going out of range. To test that, you're going to need to actually take it out of range, or put in a shield box or bag.

The "keep alive" that the device is doing is renewing it's DHCP lease. Most clients try to renew their lease when it's half expired. That is, if the router is giving out an 8 hour lease, it will try to renew it at 4 hours left. But I don't think that's required by the spec, so clients can do it differently.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Jul 25, 2014 4:59 pm
kw123 offline
User avatar
Posts: 5388
Joined: May 12, 2013
Location: Dallas, TX

Re: Contributing to development

I will definitely try the wifi off vs the out of range. I understand the difference between router switch repeater -- designed some MANY years ago. So how does the router know it is out of range vs asleep?


Sent from my iPhone using Tapatalk

Posted on
Fri Jul 25, 2014 5:01 pm
FlyingDiver offline
Posts: 2194
Joined: Jun 07, 2014
Location: Cape Coral, FL

Re: Contributing to development

kw123 wrote:
So how does the router know it is out of range vs asleep?


I don't think it does, which is why you need to test that. It knows when a device has "signed off" the network (by releasing it's IP address), but it can't know if it's not there or just not talking.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Jul 25, 2014 8:06 pm
RogueProeliator online
User avatar
Posts: 1900
Joined: Nov 13, 2012
Location: Baton Rouge, LA

Re: Contributing to development

So how does the router know it is out of range vs asleep?

For a wireless connection, the router usually DOES know this -- your phone (or other wireless device) generally goes into a special lower-power mode where in the wireless does not just "shut off" as you are thinking. Your phone will issue a special sleep command to the router telling it "I am going to low-power sleep mode". When it awakes to check traffic it does not have to fully reestablish a connection like a full break (i.e. does not to a full negotiation again). Routers which support sleep mode can queue up some broadcasts destined for the sleeping device and send them upon wakeup.

Unfortunately, that right there just pretty much exhausted my knowledge of the sleep status. It is, however, a part of the 802.11 standard, so a google search could bring up far more detail than anyone is likely willing to read (sorry electrical engineers out there, nobody else cares that much as long as it works! ;-))

A total guess, but the router may know the device is in this sleep state, but I am guessing FING and the other protocols outside the router are working a level or two up the networking stack, so there would be no requirement that the phone check in to these services when it awakes to see if it needs to process traffic.

Adam

Posted on
Sat Jul 26, 2014 12:31 am
PottedPorkProduct offline
User avatar
Posts: 13
Joined: Jun 29, 2014
Location: San Diego, CA, USA

Re: Contributing to development

Adam, you're thoughts are similar to mine. The 802.11a/b/g/n standards are basically (physical) layer 1 in the old OSI 7 layer burrito model, though it blurs the lines a little. The ARP tables which allow you to are solidly layer 2. IP stuff like ping happens at layer 3.

The low power radio modes that allow the iPhone to stay associated with the access point are most likely something at the layer 1 level. The phone is still sending out keep-alive frames saying it's associated with the access point from time to time, but otherwise it's shut itself down and isn't responding to layer 3 stuff like IP pings. This is basically how the Access Point knows that the phone is still in range and just asleep. (I'm using AP here instead of router since my router is a separate box).

Interestingly enough, the WiFi Access Point (or some other device on the network playing proxy arp) is responding to ARP queries on behalf of the iPhone if I ping the IP address of my iPhone (even if pings aren't returned). I currently don't have a static mapping for the phone so that's not something I want to rely on.

Additionally, the AP itself seems to have a split-brained view of what's connected to it - the view on the home page of it's admin interface (/update_clients.asp) doesn't have my phone listed except when it's actively transmitting on it's WiFi radios, but that second page that dumps the list of associated stations (/Main_WStatus_Content.asp) does have it at all times while my phone is nearby.

I haven't done a full test where I put the phone in some faraday cage to simulate going out of range - guess I'll get out a bunch of tin foil and try it out and make myself a sweet hat while I'm at it. Regardless, the behavior I want - sensing that the phone is associated with the AP but asleep, is visible through the /Main_WStatus_Content.asp web page on my ASUS RT-N56U

Posted on
Sat Jul 26, 2014 5:54 am
kw123 offline
User avatar
Posts: 5388
Joined: May 12, 2013
Location: Dallas, TX

Re: Contributing to development

I read up on the 802.11 power save mode. It's actually complicated. There are different sleep modes. But all of then buffer messages at the router and still send them to the device. The time OFF is measured in number beacon interval time. That's milliseconds. So the device's wifi is off for x times beacon interval time and then reconnects. An iPhone theoretically will still receive emails while in sleep mode. A ping should still succeed. But sometimes it does not. When I am back home I will do some testing.


Sent from my iPhone using Tapatalk

Posted on
Sat Jul 26, 2014 3:37 pm
PottedPorkProduct offline
User avatar
Posts: 13
Joined: Jun 29, 2014
Location: San Diego, CA, USA

Re: Contributing to development

I've got the HTTP poller working on my system at home, and it seems to work great. My roommate walked out the door during my debug runs and the plugin correctly detected him leaving.

Travis, since I don't have any info from you regarding licensing, I'm not going to put this up on the net unless you give me an OK.

Everyone else: Let me know if you want to try this out on your systems and I'll give you a Zipfile to play with.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest