yashsingh1/xdaforums huggingface dataset:
[Nexus 4 General] bganley:
This is exactly what I was experiencing before applying this patch. I saw a previous post of yours that said you could now ping the phone while the screen is off which means the fix is applied properly to your phone.

There are a bunch of other things which could potentially cause this same type of issue. Something that bit me in the past was the session timeouts on the router. Your router will keep track of the state of all network connections passing through it. Every time a packet matching that connection goes through your router, it will reset the timer. If enough time elapses without any traffic being passed for a specific connection, then the router will remove the state of that connection from its state tables. This can cause exactly what you are describing. Try taking a look at the settings on your router, in particular the TCP Established timer. If it's set really low, you can try using 14400 secs for testing with.
[Nexus 4 General] bganley:
Thanks for submitting a bug report! I went ahead and starred it. Please, everyone else star this bug if you can. The more stars the more likely Google will notice (in theory anyways).
[Nexus 4 General] mobilehavoc:
This just explains so much. I never had issue on work wifi which runs Cisco hw but problems on my Linksys and dlink at home. Ddwrt seems to be fine too. Didn't find a way to adjust ARP timeout on my Linksys or slink but this patch works.

For some of you who are working without the patch. Try this. Leave your phone in standby overnight. Bet you will wake up to gray bars since ARP will have timed out overnight. Can't be plugged in obviously.
[Nexus 4 General] bganley:
If your have access to your router and if your router supports it, you could also just put a static ARP entry on the router itself. The negatives are you would have to do this on every router your phone connects to, and a lot of routers don't allow you to easily do this anyways. Other than that, you can flash the file in the first post without root using CWM (on an unlocked phone) as someone else mentioned.

I personally don't use bluetooth very much so maybe that's why, but I haven't experienced the problems you've described. I have seen a few others with the same problems so you aren't alone. This particular patch addresses a different problem and I'd be surprised if it made any difference with your issues but then again I've seen much stranger things.
[Nexus 4 General] bganley:
Unfortunately, it's not quite that simple :) Before the ARP entry times out completely, it is marked as stale for a period of time where the next packet will cause an ARP request to happen, but instead of using broadcast it will actually unicast the request directly to the phone. Since the phone is listening to unicast traffic during sleep, it will respond. Even while the screen is off, there is periodic network traffic from the phone which will basically cause the ARP entry to never expire if the ARP timers are set high enough.
[Nexus 4 General] defnz:
I ended up applying the change anyway as I was getting inconsistent results, sometimes it was instant other times not. With the change it's a couple of seconds slower than the SGS2 now.

On another note, I've changed my TCP Established Timeout from 1200 to 14400 to see what impact that has.
[Nexus 4 General] aimetti:
I actually created the original 40065 issue.

Its very counterproductive creating another bug report especially with how many views / stars the original already has. Heck I would be even willing to merge mine into yours if I had the ability to do so.

At this point , due to its popularity, its bound to have some spam / worthless info in it, but if you bothered to read through it you would have noticed there are a few google devs in there requesting bug reports / log files to review this.

Im optimistic that with 4.2.2 will come bug fixes for this but it sure has taken a long time.

Also, to credit the OP , the fix seems to work alittle better as I dont drop as often however the problem still remains.
[Nexus 4 General] defnz:
I doubt it, your issue is something beyond the ARP issue discussed in this thread, there's something else in play that potentially affects certain router/ap combos

I'm showing google a fault plus fix to the ARP issue specifically.
[Nexus 4 General] zdenoh1975:
1. Is the solution of this issue also change the router? Because most of people dont have this issue (or else this thread should have milion posts..) - i think it depends of router hardware - specific type and behavior of wifi router.. When yes, which concrete? - although, weŕe here only mans with router issue....

2. question: - when i flash kernel (f.i. franco), stay this fix, or i must flash this fix again? Thank you very much!
[Nexus 4 General] defnz:
No, 1 is only applicable if you have wifi instability, this thread is for the phone not responding to ARP requests when the screen is off.

If it fixes instability issues then bonus, if not then you're among the 300 odd in the other bug request

Nope, the kernel doesn't modify system files so you only need to flash this once
[Nexus 4 General] zdenoh1975:
I havent classic wifi instability, I have exactly the issues which are described here - only when screen was off (when sreen is on, wifi goes perfect) Also - realy no new router dont solve this described wifi issue?..ok.

This thread fixes for me this issues, now is all ok, BUT I got more battery use (in statistic "Android system" is more than "screen time" - before by the same phoneusing it was reverse..) - help for this battery use change kernel to f.i. Franco? (currently use stock)
[Nexus 4 General] mobilehavoc:
Yes you can try to use Franco kernel to help battery. Keep in mind it all depends how much broadcast and multicast traffic is on your network. If there's a lot then it could take battery but if its not a lot then this shouldn't really change much.
[Nexus 4 General] zdenoh1975:
it all depends how much broadcast and multicast traffic is on your network. If there's a lot then it could take battery but if its not a lot then this shouldn't really change much.

What this means in layman's terms, please, can you tell me it otherwise, some examples? - i´m idiot of this networks world..:) Thank you.
[Nexus 4 General] LeaYo:
You guys are "lucky". My Nexus 4 can't connect at all to wifi. I called Google, they're replacing my device. I hope the new one works.
[Nexus 4 General] floepie:
I'd sort of like to retract the above and say that this fix does indeed work. It turns out that testing this fix by sending yourself emails via Gmail (both sending and receiving) isn't an appropriate way to test for some reason. When I send emails to myself, they appear instantly online at the PC, but take several minutes to be received at the device, even with this fix. However, for external emails, the device receives them either at the same time as the PC or within the minute.

So, for those of you who are testing this by sending emails to yourself (from within the same account), take your results with a grain of salt.
[Nexus 4 General] defnz:
Yeah I noticed this too..

Also, when you test externally, the more emails you send the longer the delay. I'm wondering if there's a throttle of some sorts to stop the phone from receiving a barrage of emails
[Nexus 4 General] floepie:
Does anyone know how the custom ROMs deal with this issue, if at all? I think I'm going to give CM a shot soon. Just curious to know what to expect.
[Nexus 4 General] danielvc:
Nope. And I've tried a few. These fix seem to work. Not all WhatsApp messages are directly delivered, but it's a big improvement (and doesn't seem to waste too much battery)

However, someone in Franco.Kernel topic says CM Kernel fixed it for them. So give it a try :)
[Nexus 4 General] archibald_schlick:
Ok, i will try this. Do you know how this impact on battery drain?
[Nexus 4 General] kara mustafa:
In my case it is the same. The optimisation option need to be unchecked

With the option off the WiFi seems to be faster

Nexus 4 - Stock 4.3
[Nexus 4 General] jeffwei8:
Ok guys something weird is happening.

I reported a few days ago that I was running the 4.3 leaked rom and that this problem was fixed.

Well today, I flashed the official factory images for 4.3 and the problem has come back.

Anytime with screen off now, pinging my phone with my computer will instantly drop packets again (same as 4.2.2 problem).

Once again, my settings are static ip, wifi optimization ON.

Now here is the weird part: I compared the WCNSS_QCOM_CFG.ini file from the leaked 4.3 rom and the official factory image and they are identical except for two lines:

gEnableActiveModeOffload

hostArpOffload

Both flags are set to =0 on the factory 4.3 image; while in the leaked rom they are set to =1.

Since this discovery, I have changed both settings to mimic the leaked 4.3 rom (ie. to =1 for both settings) and NOW my problem is FIXED again.

Anyone else notice this? Is this a mistake on Google's part for not enabling these two flags on the factory images? Does anyone that got the OTA want to check their wcnss_qcom_cfg.ini file?

tldr: change gEnableActiveModeOffload AND hostARPOffload in the wcnss_qcom_cfg.ini file to =1 and the problem should be fixed...at least for me so far..
[Nexus 4 General] kara mustafa:
With WiFi optimisation off the problem is fixed .

Nexus 4 - Stock 4.3
[Nexus 4 General] jeffwei8:
More battery drain with wifi optimization turned off. Phone does not deep sleep as quickly nor does it stay in deep sleep as long I find.

Besides, I thought it would be more interesting to find out why those two flags are different in the final release vs the leaked build. Seems to be the culprit in my case.
[Nexus 4 General] hwti:
On 4.3, when wifi optimization is on, the N4 doesn't respond to ARP requests with screen off.

Broadcast filter enabled, and no ARP offload means ARP requests are ignored.

I suppose the broadcast filter is disabled if wifi optimization is off.
[Nexus 4 General] Nexus-Revolution:
It doesn't appear to be fixed for me either, I tried sending myself an email, and I didn't receive it all. Once I turned on the screen and tried going to a website on Chrome, then I received the email. I have WiFi optimisation on, I will try turning it off and seeing if it makes a difference.

---------- Post added at 12:16 PM ---------- Previous post was at 12:15 PM ----------

How much does WiFi optimisation improve battery life?
[Nexus 4 General] acid74:
No wifi fix for me:( already tried the above mentioned tricks.
[Nexus 4 General] kara mustafa:
I dont know. For know I dont see any differnces but my wifi is not busy.
[Nexus 4 General] nguyen47:
Me neither , I just have some missed calls on Viber :(
[Nexus 4 General] Kaanu74:
I hate the Google for this ****. They take all money. Still they don't care.
[Nexus 4 General] rayiskon:
Well today my phone vibrated before my openned gmail tab on my PC showed that i got a new mail.. Well Google, it was about time :)
[Nexus 4 General] jeffwei8:
Did you restart your phone after editing the 2 lines in the wifi configuration file?

I can't believe I'm the only one that fixed the problem by editing those two lines. They both have to do with Arp offload (although granted I don't know what the lines do exactly) but it seems like too much of a coincidence for it to not have something to do with it.
[Nexus 4 General] Blockberd:
Leaked 4.3 or factory official image?

Could u also provide me a link to the ROM u used? Everyone is mentioning it but I have no clue where they got it from. :-/
[Nexus 4 General] rayiskon:
I flashed factory image yesterday. fastboot flash bootloader, radio, system and boot over stock 4.2.2 , no wipes needed.

Unchecking wifi optimisations solved it for me (like many others here). With wifi optimisations ON i was still getting the delay problem.

I think people who are still having this wifi notification delay problem are doing something wrong along the way..
[Nexus 4 General] thracemerin:
Turning WiFi optimization off in 4.2.1 and 4.2.2 also solved it for most, this isn't a fix it's a workaround. This means that Google didn't fix the problem.
[Nexus 4 General] Blockberd:
So I can save myself the trouble and flashing 4.3 as Google just didn't give any f***s about their customers.

Someone wanna buy a N4 in a mint condition? :(
[Nexus 4 General] rayiskon:
switching it off on earlier versions didn't solve it for me, maybe the wifi drivers in 4.3 are more compatible with my router , but still , on 4.3 without turning optimisations off i'm still getting delayed notifications..

whatever google did doesn't matter for me, i'm just glad i'm receiving notifications normally now :)
[Nexus 4 General] moizsami:
They still havent fixed the wifi issue!!

-cant browse 9gag app

-cant download through chrome(download gets failed)

-if downloading speed is too low.

I was using kalo's fix b4 and it solved all these problems...but i needed something official, as my dad doesnt want to root his phone, he's pissed off too!

Im using the official version..

The notification delay seems to be fixed..
[Nexus 4 General] bganley:
As jeffwei8 found, the options in the ini file for ARP offload were enabled in the leaked 4.3 image, and disabled in the official 4.3 image. I have no idea why Google has these settings disabled now - there very well may be a good reason for it. Either way it is interesting that some people are reporting that their wifi issue is now fixed with 4.3, and some are still having the same problem with delayed notifications.

I don't have an N4 anymore, so I can't test this but since re-enabling ARP offload in the ini file seemed to fix jeffwei8's delayed notifications on wifi, I put together a CWM zip update to enable ARP offload in the wifi ini file.

Flash this patch using CWM at your own risk - this is untested. Also attached to this post is a CWM zip to restore the ini file to what was included in the official 4.3 image.
[Nexus 4 General] moizsami:
Is this suppose to fix the slow wifi speed issue too..?
[Nexus 4 General] Blockberd:
It could solve it (depends on what is causing your slow WiFi) but this thread and the fix is all about WiFi connection loss when screen goes black.

What signal strength do you have when WiFi is slow? Have u done a speedtest with all WiFi devices and checked how fast each is going? Maybe its a problem with your WiFi in general.
[Nexus 4 General] gizzmoffm:
Ahhhhh... not fixed! But configurable it seems.

I just found out that arp filtering is connected to the Wifi optimization setting.

Optimization on - no arp reply when screen off

Optimization off - arp works

Can anyone confirm?
[Nexus 4 General] Blockberd:
Many people mentioned already that turning off WiFi optimization solves their problem on 4.3.
[Nexus 4 General] thracemerin:
It would appear that this is how it works, though I don't think that's how it's supposed to work.
[Nexus 4 General] gizzmoffm:
Sorry, I didn't see that. Maybe a typo in the search I did.

That's a shame. A Google engineer confirmed that the driver would have been updated in 4.3. Maybe the diver is new, but the setting was reverted in the last minute it seems. Might have caused some issues on test devices? Who knows...

One word: cmongoogle!
[Nexus 4 General] Blockberd:
I installed 4.3 leak now. Will keep you guys posted.
[Nexus 4 General] jeffwei8:
Just to update: I've been using the factory image of 4.3 with the changes I detailed above (post #584) for half-a-day now. Still have not had any dropped notifications on wifi with screen off. My whatsapp messages are all being received on time, emails are being pushed to me properly, and hangouts messages are all coming in on time.

I still think what I suggested above works and I'd really recommend someone to try and flash the file that bganley made above (or just edit the wcnss_qcom_cfg.ini file manually with root explorer) to see if it makes a difference for you so that we can try to see if the solution to the problem is reproducible since I'm the only one that seems to report this working.

Note that Wifi optimization is ON with my setup and definitely results in better battery life (for me). I have tested this quite extensively using CPUspy. After 2 minutes of screen off, I get around 80-90% deep sleep. However, if I disable wifi optimization then I get a pretty even split (40%/50%) between 384mhz and deep sleep (for my network) which I expect will lead to dramatically lower battery life in the long-run; so I don't think leaving the optimization OFF is a good compromise if the above changes to the wcnss_qcom_cfg file works.

The easiest way to see if a fix works is to ping your nexus 4 ip address in a Dosbox (or equivalent). Usually when I ping my device now it may drop the first attempt or have a very high ping (1000-2000) then the rest will be in the 100-300 range. I've tried this every couple hours and it is consistent.
[Nexus 4 General] Nexus-Revolution:
Probably a stupid question, but is there any way I can do this without rooting? Using adb or something like that?
[Nexus 4 General] thracemerin:
Need to be able to write to /system which means you need to root.
[Nexus 4 General] hwti:
It seems to work fine, no problems with optimization on.

The first 2s ping seems to happen when the ARP cache on the PC is empty, else it's about 300ms.

Not sure if it's a small bug in the ARP offload, or if it's just designed to save more battery.
[Nexus 4 General] Nexus-Revolution:
Another stupid question, but what exactly does WiFi optimisation do? How exactly does it save battery? I searched online, and many people were saying different things. I tried it with optimisation off, and it works now. Hopefully battery life isn't impacted too much.
[Nexus 4 General] m_gl:
I can confirm this is working, with Wifi optimization ON.

Turning off Wifi optimization is no option, because the drain is heavy and deep sleep is down to about 50%.
[Nexus 4 General] __dsTny__:
Hello,

thank you for this information. Does your fix impacts the battery life in any way? I mean, you tested it with optimization on + your fix and with optimization off without your fix. What is with optimization on without your fix? Does this results in a same bettery life as optimization on + your fix?

Btw to give some feedback: My push works sometimes and sometimes not. Currently it works (university), but yesterday sometimes it didn't work - pushed notifications arrived only as I turn on my screen. Very strange.. If this happen today, too, I will try your fix. Some users in an other forum give a positive feedback (as for now..).
[Nexus 4 General] MasterJam882:
We finally need an offical explanation from google. So far it's blind guessing why they disabled it in final and didn't in leak.

But I doubt we will ever see such a statement.

I posted the problem to google.code:

https://code.google.com/p/android/issues/detail?id=58076&thanks=58076&ts=1374847518
[Nexus 4 General] genevois26:
You have an answer. Please move your post to the correct forum. We need a solution! Thanks!
[Nexus 4 General] thracemerin:
It appears to have been a mistake, the ARP offload code is enabled in the AOSP repositories now, so it will be on by default for JSS builds, it's just not enabled for JWR official builds.
[Nexus 4 General] MasterJam882:
I did now but his answer was totally wrong. It's not an Nexus issue it's even an AOSP issue as the deactivated ARP-offload is even there. What the heck???

Now I posted it here:

https://productforums.google.com/fo...roid-devices/android-applications/NaKJioLKvGc

and one more time on google.code

https://code.google.com/p/android/issues/detail?id=58082&thanks=58082&ts=1374852875

---------- Post added at 05:46 PM ---------- Previous post was at 05:40 PM ----------

It seems that's not the whole truth.

See the answer to my second post:

"The flags in question were found to trigger a bug in the Wi-Fi firmware that caused significant battery regressions from 4.2.2. The Wi-Fi firmware can't be fixed in AOSP (or, for that matter, by Google)."

I think right now we are ****ed up!
[Nexus 4 General] thracemerin:
I don't see any negative battery issues from setting the flags to 1, and if that were true it wouldn't have been pushed to AOSP (JSS builds) with them set as 1.
[Nexus 4 General] MasterJam882:
Hmmmm but why would they state it then? It's all more than strange. And right now I'm pretty pissed off to be honest.
[Nexus 4 General] thracemerin:
Nobody that responds on code.google.com or productforums.google.com really has any idea what they're talking about, they've proven on a number of occasions that they don't.
[Nexus 4 General] MasterJam882:
Really hope you are right mate^^
[Nexus 4 General] jeffwei8:
Agreed. It's a pretty bad fix for the problem from a battery standpoint in my experience.

Optimization on without the fix means it's the same as the stock JW-retail build from factory images. I expect battery life to be good since it's filtering all the ARP requests. However, that is a moot point since push notifications will be delayed and the Nexus 4 will be in a semi-broken state again.

I don't see any negative battery issues either from setting the flags to 1. In fact battery life has been pretty stellar and easily way better than 4.2.2 so far with my use.

lol but wasn't that jbq@android.com that responded? How could he not know what he's talking about? :p
[Nexus 4 General] thracemerin:
Ok, fair enough, but the majority of them are just PR/Customer Service type people who are charged with answering questions, not real engineers who have an idea of what's going on. Just because the answer came from Google, doesn't mean it came from someone at Google that knows what they're talking about.

Plus, since AOSP (JSSXXX builds) has the flags set to 1, it invalidates the claim that they believe battery was negatively affected, because if that were true they could easily push an update to AOSP which they haven't, in fact they reverted the flags to 0 and then reverted that revert.
[Nexus 4 General] jeffwei8:
lol.

Well it'd be interesting to find out the true story for this one. Seems like they messed up.

I just feel bad for the people that use their Nexus 4 bone stock and do not unlock their bootloader/root or do not flash custom roms. Google should really push a fix to these people since the only alternative for them is to disable wifi optimization.
[Nexus 4 General] thracemerin:
Interesting that they said they wouldn't be updating the factory images to JSS, means many implications including custom kernels need 2 builds since there is strange artifacting and graphical tearing on JW builds with the JSS version of the kernel and vice versa.
[Nexus 4 General] jeffwei8:
Yeah I read that too in the franco thread.

This just sounds like a huge headache for you kernel devs and you'll likely have people repeatedly downloading the wrong versions or posting about tearing artifacts. :(
[Nexus 4 General] kzakhar:
So, what is the final, guys? Can the notification issue be fixed?

My N4 is on its way from the UK, and it would be a big f*ck up to have delayed notifications and/or bad battery life :(
[Nexus 4 General] thracemerin:
If you plan to stay stock, it's fixable if you unlock the bootloader and flash a custom recovery so you can flash updated files or if you root and adjust the file yourself. If you plan to flash custom ROMs, it will probably be fixed in those anyway since they are built from the JSS tree. If you plan to stay stock without root and without unlocked bootloader/custom recovery you may be out of luck unless Google decides to help people out with another OTA.
[Nexus 4 General] jeffwei8:
Yes it can be fixed.

The "proper" fix requires you to unlock the bootloader and root.

You can:

1) flash the above file from bganley

2) edit the wifi file yourself

3) flash a custom JSS rom when they become available as this will have the fix already.

If you don't want to unlock/root, then you are left with disabling wifi optimization which (in my experience) leads to more battery drain.
[Nexus 4 General] kzakhar:
Thank you for the detailed explanation! I will probably stay stock and root, so should be ok then :)

Thanks to jeffwei8 as well.