Search code examples
androidudpwifi

Massive UDP packet loss in the sleep mode


There is Android native app, which send about 10 UDP packets per second over WiFi connection. Packets are very small (3-4 bytes each) and they are not multicast (directed to antother host in the same subnet).

So, problem good seen on the following graphs.

  1. Normal operation while android device in the active state
  2. After device screen was muted (time between splaches ~5 sec, splash duration ~0.5 s, but periodicity is not ideal)
  3. If in parallel perform ping of android device from third host

WifiLock on the device is acquired, but this nothing change at all.


Solution

  • Problem resolved. As it turned out, it's not about packets loss. Due to CPU sleep, transmitter send packets not as solid stream and result was look like a massive loss. So solution is usage of WAKE_LOCK.