Wifi chip sleepy

Hi there, I currently have a network extension running with open UDP sockets via both cellular and wifi interfaces.

When the device is locked (and not attached to power) the wifi chip goes to sleep periodically.

Obviously this is to save battery, however is there a way to stop this happening? The use case is to send a ping every second for a set duration of time to calculate the average round trip time.

regards
Byron

When the device is locked (and not attached to power) the wifi chip
goes to sleep periodically.

It’s not just the Wi-Fi chip that goes to sleep. Unless there’s something that’s specifically prevents it — like music playback — the system aims to sleep the entire application processor.

is there a way to stop this happening?

No. If a device has both Wi-Fi and WWAN, services are expected to transition to WWAN when Wi-Fi is unavailable.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Just to highlight this is a VPN network extension on iOS
Thanks for the reply, just to confirm.. is this also relevant for a VPN extension on iOS? Will it aim to sleep that process in the background?

Just to highlight this is a VPN network extension on iOS

Understood. Notably, macOS doesn’t have WWAN.

Will it aim to sleep that process in the background?

This question doesn’t make sense because it’s mixing up two different concepts:
  • iOS will suspend an app when it moves it to the background (assuming it’s not doing something that requires it to keep running, like playing music).

  • iOS will sleep the application processor when it can. This is like closing the lid on your MacBook. The entire CPU goes to sleep.

Clearly the latter subsumes the former, that is, if the application processor is asleep than it doesn’t matter whether your app is suspended or not. No process is running instructions.

In the case of an NE provider, it will not be suspended but it’s still subject to system sleep.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Hello Eskimo,
I see your response -
"No. If a device has both Wi-Fi and WWAN, services are expected to transition to WWAN when Wi-Fi is unavailable."

I understand this is not possible, but this would mean every time the network switches the vpn might reconnect if the on-demand is on. Wouldn't that cause the VPN icon to appear more frequently? Is there a way to prevent the VPN icon not flashing every time the network changes?

Note:
  • I restart the tunnel every time a network changes (wifi-cell and vice versa) - Is this the right thing to do?

  • Is the vpn icon flashing because of tunnel restart or it happens irrespectively?

Wouldn't that cause the VPN icon to appear more frequently?

That depends on how you handle the connect / disconnect cycle. See this post.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"

Greetings @byron_coderus, @eskimo,

Hopping on the back of @byron_coderus question:

Is it possible to prevent an iOS device with Wi-Fi and Cellular interfaces from disassociating itself from Wi-Fi - and keeping it in a state where it is always ready to process incoming network traffic? Ideally without resorting to preventing system sleep by playing audio in the background, or keeping the screen awake or the device plugged in to power.

We are using the PacketTunnelProvider, with logic in the network extension listening on a specific UDP port. The use case is relaying traffic from a device on the Wi-Fi network, to a remote server using its cellular connection.

From our investigation so far, we've noticed that if the device screen is off, the sleep() method may be invoked, with the device entering system sleep shortly after. In this state, the device does not respond to ICMP pings, but may still be able to receive other network traffic, which wakes the device for a short amount of time as it handles the traffic.

After some time, a sleeping device will disassociate itself from the Wi-Fi, causing any packets to be sent to the device to be dropped. Is there any way to prevent this? We have tried sending arbitrary packets to the device every second in order to keep it awake, but it often still sleeps for periods of 2-4 seconds.

Regards,

Chris

Wifi chip sleepy
 
 
Q