# Kernel Wakelock ("wlan_rx_wake")



## oz0ne

Is it possible that being connected to a particular wi-fi network would induce a kernel wakelock; but connected to a different wi-fi network would not? I have an issue with my GNex not entering the deep sleep state when connected to my apartment's wi-fi network. However, when connected to a standard home network router, the phone enters deep sleep fine. I have this narrowed down to the "wlan_rx_wake" kernel wakelock, as indicated by BetterBatteryStats and CPU Spy. This is occuring on the stock kernel. This happens when the screen is off, no matter what I set the Keep wifi on during sleep in settings. This happens on a clean install with nothing syncing in the background. Any thoughts? Thanks in advance.


----------



## abqnm

oz0ne said:


> Is it possible that being connected to a particular wi-fi network would induce a kernel wakelock; but connected to a different wi-fi network would not? I have an issue with my GNex not entering the deep sleep state when connected to my apartment's wi-fi network. However, when connected to a standard home network router, the phone enters deep sleep fine. I have this narrowed down to the "wlan_rx_wake" kernel wakelock, as indicated by BetterBatteryStats and CPU Spy. This is occuring on the stock kernel. This happens when the screen is off, no matter what I set the Keep wifi on during sleep in settings. This happens on a clean install with nothing syncing in the background. Any thoughts? Thanks in advance.


That particular wake lock is triggered any time the phone is awoken from deep sleep to send or receive data on wifi. If you are having issues with just one particular wifi network, that is likely DHCP/dynamic IP related. There are reports of issues with certain wifi routers that are using dynamic IP addresses causing DHCP queries to constantly wake the device. The only known work-around is to set a static IP address or use a different router. Since this is your apartment's wifi, you may not be able to do either of those, unfortunately.


----------



## oz0ne

abqnm said:


> That particular wake lock is triggered any time the phone is awoken from deep sleep to send or receive data on wifi. If you are having issues with just one particular wifi network, that is likely DHCP/dynamic IP related. There are reports of issues with certain wifi routers that are using dynamic IP addresses causing DHCP queries to constantly wake the device. The only known work-around is to set a static IP address or use a different router. Since this is your apartment's wifi, you may not be able to do either of those, unfortunately.


Correct, happens on just the one particular wifi network - the apartment's. I used Wireshark on my computer and Shark on my phone, and best I can tell, you are right. I see the constant queries. Unfortunately as you guessed, I don't have the capability to set a static IP or change the router. I can confirm that this network uses dynamic IPs. So if I understand, there's no way to stop the queries from waking the phone on my end? Thank you so much for your help.


----------



## abqnm

oz0ne said:


> Correct, happens on just the one particular wifi network - the apartment's. I used Wireshark on my computer and Shark on my phone, and best I can tell, you are right. I see the constant queries. Unfortunately as you guessed, I don't have the capability to set a static IP or change the router. I can confirm that this network uses dynamic IPs. So if I understand, there's no way to stop the queries from waking the phone on my end? Thank you so much for your help.


Unfortunately, I have not found a way.

You could try setting the IP manually on the phone, but it may not work on the wifi network depending on how it is configured. You may also have to let it get the IP through DHCP and then change it to static with the same IP it was assigned by DHCP. If it works you may still have to repeat the procedure any time the IP lease expires on the router. At least it is worth a try.


----------



## oz0ne

abqnm said:


> Unfortunately, I have not found a way.
> 
> You could try setting the IP manually on the phone, but it may not work on the wifi network depending on how it is configured. You may also have to let it get the IP through DHCP and then change it to static with the same IP it was assigned by DHCP. If it works you may still have to repeat the procedure any time the IP lease expires on the router. At least it is worth a try.


Good thinking on changing it to static. Can't believe I didn't think of that! Unfortunately, changing it to static makes no discernable difference. I'm not able to manually set the IP either. Oh well...thanks again! If you happen to think of anything else, please post.


----------



## abqnm

oz0ne said:


> Good thinking on changing it to static. Can't believe I didn't think of that! Unfortunately, changing it to static makes no discernable difference. I'm not able to manually set the IP either. Oh well...thanks again! If you happen to think of anything else, please post.


It was worth a try. Definitely means it is coming from the router.

Another more elaborate solution if you rely on that network a lot, is to purchase a wireless bridge or gaming adapter and connect it to your apartment wifi and then connect your own wifi router to that. Then the gaming adapter would get the dhcp IP from your apartment (so who cares if it is renewing it constantly) and your router would treat the connection just as if you were connected directly to an internet connection. Then configure your router for static IP addresses or if your router does not cause issues with DHCP then you don't need static IPs.


----------



## oz0ne

abqnm said:


> It was worth a try. Definitely means it is coming from the router.
> 
> Another more elaborate solution if you rely on that network a lot, is to purchase a wireless bridge or gaming adapter and connect it to your apartment wifi and then connect your own wifi router to that. Then the gaming adapter would get the dhcp IP from your apartment (so who cares if it is renewing it constantly) and your router would treat the connection just as if you were connected directly to an internet connection. Then configure your router for static IP addresses or if your router does not cause issues with DHCP then you don't need static IPs.


Hmm, never would have thought of that. Seems feasible. I do rely on the apartment wifi for data because 3G inside is nonexistent. I have an old wireless DSL router, would that work? Any recommendations on a gaming adapter? Again, can't tell you how much I appreciate your brainstorming.


----------



## Serenity_FF

That should work but you may want to look into putting dd-wrt on it if possible to turn it into a wireless bridge.

Sent from my Galaxy Nexus using RootzWiki


----------



## abqnm

oz0ne said:


> Hmm, never would have thought of that. Seems feasible. I do rely on the apartment wifi for data because 3G inside is nonexistent. I have an old wireless DSL router, would that work? Any recommendations on a gaming adapter? Again, can't tell you how much I appreciate your brainstorming.


I have used this one with good results. http://www.newegg.com/Product/Product.aspx?Item=N82E16833156258 Currently $45.99/free shipping. You have to configure it by connecting it to a PC with ethernet first and then you can transfer it to the router.

As for your old DSL router, that likely won't work because most DSL routers don't have a WAN port. They usually have an integrated modem, so there is no way to connect an external one. If it does have a WAN port, then it likely would work fine.

If your router doesn't have a WAN port, then you would need one that does. For just a basic budget router, I have bought about a dozen of these over the past 2 years with good luck with all of them. http://www.newegg.com/Product/Product.aspx?Item=N82E16833320023 $43.99 before $10 mail in rebate right now. It is just basic wireless G, but chances are that is faster than your apartment internet will go anyhow.


----------



## abqnm

Serenity_FF said:


> That should work but you may want to look into putting dd-wrt on it if possible to turn it into a wireless bridge.
> 
> Sent from my Galaxy Nexus using RootzWiki


I would have suggested that option, however to connect in bridge mode, OP would need access to the primary access point to configure it as well.

Edit: Oh and in bridge mode, connected devices would still obtain DHCP addresses from the primary router, which is what the OP is trying to get away from.


----------



## eitama

I know this thread is old, but i'm now searching on the same subject and found this - Wanted to add a few notes to possible solutions.

1. Increase DHCP Lease time to the maximum possible, will cause less DHCP Activity on the network.
2. Allow DHCP Snooping to prevent DHCP Activity on unwanted ports (usually on large scale switches)
3. If you don't need to access any of the local hosts on the network, but only get internet, you can activate AP Isolation to prevent from useless junk arriving from different hosts. Broadcast packets mainly. Some DHCP packets are broadcast packets.
4. And the 4th, which should be the 1st  use iptables to filter out stuff you don't want arriving to your network card. might even filter-out dhcp packets with source mac address which is not your router. This should prevent all broadcast packets from clients looking for addresses from reaching your phone.

Home this helps.


----------



## oz0ne

I had totally forgot I posted this! Thanks for everyone's input and help. They're all good suggestions and I'll report back my results.


----------



## atomicminded

abqnm said:


> That particular wake lock is triggered any time the phone is awoken from deep sleep to send or receive data on wifi. If you are having issues with just one particular wifi network, that is likely DHCP/dynamic IP related. There are reports of issues with certain wifi routers that are using dynamic IP addresses causing DHCP queries to constantly wake the device. The only known work-around is to set a static IP address or use a different router. Since this is your apartment's wifi, you may not be able to do either of those, unfortunately.


Hey, I know I'm waking up an old thread, but I'm now tracking down this exact issue with my wifi network, at work.

Could DHCPv6 also be causing these wakeups? Also, what other types of traffic might wake the device, other than just DHCP?


----------



## greenro89

I had this trouble too.. I found out that my android devices hated belkin routers haha. I tried 2 different belkins and now have a netgear. Zero problems with that wake lock. I was seeing the up and down arrows constantly on my wifi but no app was requesting data so I knew it was my router. Hope this helps

Sent from my Galaxy Nexus using Tapatalk 2


----------



## atomicminded

Thanks, I have enterprise wifi hardware, ruckus networks.

I might contact them in the near future....


----------



## zhexio

Hi, my phone's been experiencing a disproportionate amount of wlan_rx_wake wakelocks ever since I switched to JB. Through a (not 100% thorough) process of elimination, I've found that switching from WPA2-TKIP to AES virtually eliminates all of the excessive wlan_rx_wake wakelocks, bringing it back down to the minutes instead of hours in BBS readings after a whole day's use.

Did I do something wrong, or is it possible that TKIP was the cause of the wakelocks? I did a quick google and found that TKIP is software-based encryption, and AES hardware based. Any truth to that?


----------



## creaky24

It just so happens that my wife's phone (AT&T SGS2) is experiencing this on our home WiFi and it is frustrating. Everything was working fine and then suddenly the wakelocks - no switching routers, ROMs, kernels, etc. The strange thing is I don't get any wlan_rx_wake wakelocks on my GNex. How could that be?

The solutions provided above are a little beyond me at the moment but I will Google and see what I can learn in order to find a solution. Meantime, this post on xda might be helpful:

http://forum.xda-developers.com/showpost.php?p=25876666&postcount=3

Any additional guidance and suggestions are appreciated. Thanks.

EDIT: I should also mention that I'm on a Mac.


----------



## atomicminded

Something on your network is sending a lot of broadcast traffic. Yes, it sucks, especially if you're on an office network, with plenty of broadcast traffic going around.


----------



## creaky24

atomicminded said:


> Something on your network is sending a lot of broadcast traffic. Yes, it sucks, especially if you're on an office network, with plenty of broadcast traffic going around.


That very well may be, but it's on my home WiFi, and it suddenly happened without any changes in hardware or software. Further, the wakelocks drain my wife's phone, but mine doesn't have any wlan_rx_wake wakelocks at all.

Thanks for responding - I'll keep working on it!

[edited for grammar]


----------



## atomicminded

creaky24 said:


> That very well may be, but it's on my home WiFi, and it suddenly happened without any changes in hardware or software. Further, the wakelocks drain my wife's phone, but mine doesn't have any wlan_rx_wake wakelocks at all.
> 
> Thanks for responding - I'll keep working on it!
> 
> [edited for grammar]


Two apps to help your search:

1. Shark for Android - Capture the packets with this. Use wireshark on your PC/MAC to read the captures.
2. Network Log (also in play store) : Will help identify which applications are using your network, on a per packet basis. Note, this is a higher level capture than Shark for Android. (As in, shark will capture every packet that hits the interface. Network log will not.)

Let me know what you find.


----------



## Joesyr

Found this thread searching just now as I started having this problem today. I swapped two routers around in my house to get a better signal in the rooms I'm usually in when home, and while that's been nice for my laptop, it looks like the new router is draining my phone's battery. The problem router is running ddwrt and I'm going to play with some of the settings people have proposed here and see if I can pinpoint anything in particular. For science!

Attached is a screencap just to illustrate the drain and how drastic it can be. A rough timeline so you know what you're looking at: I was mostly home today. The first three-fifths of the graph are idle drain while I was sleeping or home in the morning. Pretty clean data; dips when I used the phone, nice even slope when it was idling. Trace up from the "46s" on the timestamp; at that dip, I installed the router, promptly went out for a bit (drain from using phone while out), and then came back. After that dip, it's still largely idle drain, but the slope speaks for itself.

Premptive edit: Doodled on picture for added clarity.

Postemptive edit: Hmm, competing theory: Where I'm sitting right now, I've got two routers broadcasting a signal. One is good (about -50 rssi), the other varies wildly (from better than the steady one all the way up to the -80 range). I wonder if it's not actually a problem of the phone switching between the two of them when they're both in range. Maybe the first course of action will be to just unplug the further one and see if the supposedly bad router plays nice when it's alone.


----------



## creaky24

OK, so here's a screen shot of some of the captures made by Shark from last night. I honestly have no idea what any of this means or what I should be looking for. Any help is appreciated!


----------



## atomicminded

creaky24 said:


> OK, so here's a screen shot of some of the captures made by Shark from last night. I honestly have no idea what any of this means or what I should be looking for. Any help is appreciated!


Honestly, I would probably start with the network log app, first. Install it, and let it run for a while with the screen off.

See if there are any apps that are transferring data behind your back, in a major way, first. Also, pay attention to the app named "KERNEL" (lol.)

the kernel handles all the DHCP and low level traffic. If the kernel has a lot of activity, then shark captures might be in order.


----------



## creaky24

atomicminded said:


> Honestly, I would probably start with the network log app, first. Install it, and let it run for a while with the screen off.
> 
> See if there are any apps that are transferring data behind your back, in a major way, first. Also, pay attention to the app named "KERNEL" (lol.)
> 
> the kernel handles all the DHCP and low level traffic. If the kernel has a lot of activity, then shark captures might be in order.


OK, thanks, atomic. I'll get some network logs tonight and post them later or tomorrow. Really appreciate the help.

Sent from my Liquified Nexus


----------



## creaky24

So it looks like download manager/downloads are snagging 428 packets while other apps are receiving like 6. Wondering what the next course or action might be....

Sent from my Liquified Nexus


----------



## timdor

I also hate to bump an old thread but I was hunting down this problem last night and I seemed to have found an answer. I downloaded Network Log from the play store and started looking through the data this app provided. I found most of my wifi traffic was to/from my desktop PC downstairs on port 17500. Turns out, DropBox was trying LanSync and it was apparently polling my phone and keeping it awake.

Killing LanSync and/or the DropBox app fixed the problem for me. Hope this helps anyone else having the same issue!


----------

