Pages: 1 [2] 3   Go Down
Author Topic: Arduino Network causing severe battery drain on WiFi connected devices.  (Read 2828 times)
0 Members and 1 Guest are viewing this topic.
Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 148
Posts: 6103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My bad. I downloaded the wrong manual. I have the correct one now. I would go into the router settings and check your LAN settings. What ip/subnet does it show? It should be 192.168.1.1.

I would also check the dhcp server settings for your LAN. Avoid using any (add: static) ips in that range.

edit: Try dhcp on the ethernet shield. Does it pick up an ip?
« Last Edit: February 05, 2013, 06:47:17 am by SurferTim » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using 192.168.0.0/24 (but that's OK obviously). DHCP is off (I prefer static IPs). There's no way to specify independent IP ranges for the LAN and WLAN in the settings.

However, this isn't a WLAN / LAN / IP / Subnet type issue - it's an ARP Broadcast issue. It wouldn't matter what IP or subnet I was using because the broadcasts are sent to FF:FF:FF:FF:FF:FF, so they hit every device on the same network segment. As I only have one router the entire LAN/WLAN is the same segment. The only thing my router is blocking broadcasts from/to is the WAN.

The only way to prevent broadcasts spreading too far is to add a segment to the network by adding another router as routers don't normally allow broadcasts to pass through. I could, for example, add another WiFi Access Point router and put all my mobile devices on that. But again that's additional hardware that I'd like to avoid.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 148
Posts: 6103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That is odd. I haven't checked my network for that. When I get a chance, I will. Mine might be doing that, but I do not see any noticeable indication yet.

edit: I probably wouldn't see anything on my wireless network. My wireless and ethernet are separate networks, so I wouldn't see the effect on my mobile devices.
« Last Edit: February 05, 2013, 07:22:14 am by SurferTim » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can see broadcasts on Wireshark if you want to look for it. Just download it, install it, run it, and set a filter for "eth.dst == ff:ff:ff:ff:ff:ff".

It's normal for every device on the network to send out the ARP "Who has <ip>" requests the first time they try to communicate with that IP. It's a bit like the way DNS works, in that when you enter "google.com" as an address, a DNS server will look up that IP address for that domain name and you'll use the IP address. A MAC is looked up by IP address by asking every device on the network "Who has <ip>". The device that has that IP will respond with its MAC address and then the two devices can then communicate.

For example, if you reboot your PC, the first time it tries to connect to the internet it will send out a "Who has 192.168.1.1" broadcast (assuming 192.168.1.1 is your gateway's IP and you have that IP set as the default gateway on your PC). Whichever device has that IP address will respond back with its MAC address. Then your PC will know what MAC address to send stuff to when communicating with your gateway.

What is meant to happen, however, is that the MAC address for a given IP address is meant to be stored in the device's ARP table. You can see the ARP table on Windows by opening a command prompt and doing "arp -a". This table prevents the need to ask all the devices on your network who has a given IP address every time you want to talk to that IP because the device already knows that information and has remembered it. You can also add MAC addresses manually and permanently (until you manually delete them) with something like "arp -s 192.168.1.1 00-aa-bb-cc-dd-ee".

So the problem with the Arduino Ethernet is that these ARP entries are not being cached and it's asking the entire network who has the gateway's IP address every time it sends stuff. Ideally it should cache the IP to MAC address entries, but I'm guessing with limited memory on the Ethernet card this isn't possible. Also it would be nice if you could tell it in code what the MAC address of an IP is(i.e. the same as "arp -s"), as it's not very often my router changes MAC addresses.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 148
Posts: 6103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, but I think I have that part down.  smiley-wink

I just have never checked the ARP broadcast before. Like I said, my wireless and ethernet ports are separate networks. I can bridge them, but I don't. When I do my send every 30 seconds, I am not likely to notice one extra pre-send ARP broadcast unless I was looking.

I do use the DNS thing with the w5100 tho. Instead of using a domain for each send, which does a dns lookup for every send, I do one dns request, then use that ip for a while. That really speeds up things.

edit: I think I see what you are saying now. You think that extra ARP broadcast is causing the mobile device "wake-on-lan" to activate?
« Last Edit: February 05, 2013, 08:19:19 am by SurferTim » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not quite... Wake-On-Lan is to remotely turn on a device (such as a laptop or PC that's turned off / hibernated / suspended). They would normally completely ignore all network traffic, including ARP broadcasts, unless it received a "Magic Packet": http://en.wikipedia.org/wiki/Wake-on-LAN#Magic_packet

What I'm talking about is a bit different. When a modern mobile device, such as an Android phone or iPhone, isn't doing anything, it goes into a low power state - essentially dropping the CPU clock speed down to something very small, turning off circuits that aren't needed, reducing the RAM refresh, etc.

When they receive an ARP broadcast though, they will go to full speed so that they can deal with it. It is normally advantageous for the device to stay at full speed for a while so that other processes can catch up and not immediately require it to wake up again (as powering up everything causes a reasonably battery hit on its own). So it'll normally stay awake for a few seconds, then go back into a power save mode. I can't speak for all devices, but on my phone it'll stay awake for at least a few seconds when woken up. So, sending frequent broadcasts to the device that require it to wake up can cause it to stay fully awake forever.

This is exactly what's happening with me based on the following evidence:
  • The logs show that its being woken up constantly due to receiving stuff on the WiFi.
  • The log entries are timed at exactly the same frequency that my Arduino is sending stuff.
  • Wireshark shows the Arduino sending those ARP broadcasts at the same frequency and times that my phone is being woken up.
  • If I disconnect the Arduino from the network, the battery lasts around around 20x longer. When it's disconnected the remaining WiFi RX wakelocks account for almost no power use (under 2% of total battery use).
  • If I reconnect the Arduino the battery life sucks again.
  • It's not just my phone, but several mobile devices in the household that exhibit exactly the same behaviour.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 148
Posts: 6103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That is what I meant. I didn't know exactly what the term would be for that. It must be a "wake-on-something" tho. How about "wake-on-arp"?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

From the device's perspective they're called "Wakelocks". Or specifically in this case WLAN_RX_WAKE Kernel Wakelocks. The device is in full power mode while a Kernel Wakelock is held. You can also have Partial Wakelocks which can be held by applications.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 148
Posts: 6103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll go with that. "Wakelock" appears to be specifically an Android term, but it sounds good. Almost all Google search items involved Android.

So it seems your alternative is to isolate your wireless devices from the ethernet devices. I'm not sure how to stop the w5100 from doing the ARP broadcast, but I will take a look.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It comes down to 4 choices (in order of my preference):
  • Fix / Improve the Arduino Ethernet module so that it caches ARP entries. This would be the way most devices work.
  • Find some way to add a static ARP entry on the Arduino Ethernet so it never has to send out the broadcast.
  • Add another router to make a network segment that I can put all the misbehaving network devices on.
  • "Isolate" my WiFi so that WiFi devices can only access the internet and not the LAN.

Buying a router costs me money and uses up more space, power sockets, cabling.

Isolating my WiFi is a no good for me as my WiFi devices need access to the LAN (e.g. printers, remote desktop, NAS, etc).

So I'm hoping for one of the top 2. I've failed to find anything myself though. smiley-sad
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 148
Posts: 6103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm experienced with the w5100 and w5200 versions of the ethernet library, and I do not see where the arduino or wiznet library code is involved with an arp broadcast. I think that is done by the w5100 firmware internally when it establishes the connection.

The w5100 doesn't have a bunch of internal SRAM. Most is taken by the 4 socket buffers. It doesn't leave much for arp lists.  smiley-sad
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 111
Posts: 5225
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You told you can log into your router by telnet and have a linux environment there? Do you have root access then? If yes, you probably can segment your WLAN from your LAN without loosing connectivity. You just have to remove the (software) bridge between the interfaces and enable ip_forward on the router. Configure two subnets and you're fine.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It seems to be root access. While I'm very familiar with Linux, I've never had to do that kind of stuff on it before. However, I'm also chatting to a guy who makes one of the more popular custom firmwares for it to see if he can help.

I wonder if an iptables rule could filter it...
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 111
Posts: 5225
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You probably don't need iptables for that. Does the router have the "ip" command? Can you post the output of "ip ro sh"?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You'll understand if I blank out some of the IPs smiley

So it's obviously bridged the relevant devices (giving br0). At this point I'm getting scared to bugger around with it smiley-grin

admin@RT-N66U:/tmp/home/root# ip ro sh
217.X.X.X dev ppp0  proto kernel  scope link  src VincentMcKenzie'sWAN-IP
192.168.0.0/24 dev br0  proto kernel  scope link  src 192.168.0.1
169.254.0.0/16 dev eth0  proto kernel  scope link  src 169.254.128.143
127.0.0.0/8 dev lo  scope link
default via 217.X.X.X dev ppp0
Logged

Pages: 1 [2] 3   Go Up
Jump to: