Based on recent empirical findings, and based on various posts on the web, it seems that an application running on an iPhone with personal hotspot enabled cannot send broadcasts and/or multicasts out onto the personal hotspot's network. Can anyone shed light on the cause of this problem?
The Application
I have an IOS application, built with cross-platform C++ code, that broadcasts and multicasts its presence onto the network it is running on. The application works flawlessly when the iPhone is connected to a Wi-Fi network. In this case, other devices on the network receive the broadcasts/multicasts, and everything functions correctly. This can be verified easily by connecting a computer running WireShark to the network -- the broadcast/multicast packets can be seen in the packet trace.
Needless to say, the application works well on an iPhone connected to a local Wi-Fi.
The Problem
When I run the application on an iPhone that has its personal hotspot enabled, no broadcasts/multicasts are released onto the hotspot network. This can be verified using WireShark, which shows no such packets in its trace.
Is there any constraint regarding using a personal hotspot as a network router capable of handling broadcasts and multicasts?
When I requested a web page on my "WireSharking" device using a browser, the personal hotspot responds correctly to all packets, returning the web contents.
Collateral Information
I have come across other Stack Overflow posts that report the same, or similar, problems:
A good tutorial for writing such a broadcasting/multicasting application on iPhone is Michael Tyson's "The Making of Talkie: Multi-interface broadcasting and multicast". Suffice it to say that my application conforms with all requirements (e.g., setting socket options SO_BROADCAST, SO_DONTROUTE, and IP_MULTICAST_IF where appropriate).
A reply to reference (1) above writes "Could it be because the personal hotspot introduces Network Address Translation?". I filtered the WireShark traces to show only packets connected to the hotspot IP, and there is no evidence of the personal hotspot sending anything to a NAT address.
In summary
Can anyone explain why an iPhone running a personal hotspot does not broadcast/multicast packets, and how to solve the problem?
Many thanks in advance.
Go to Settings > Cellular, tap Set Up Personal Hotspot, then follow the onscreen instructions. Note: If you don't see Set Up Personal Hotspot as an option, and Cellular Data is turned on in Settings > Cellular, contact your carrier about adding Personal Hotspot to your plan.
If you can't find or turn on Personal Hotspot, check that your network provider enabled it and that your network plan supports it. Restart the iPhone or iPad that provides Personal Hotspot and the other device that needs to connect to Personal Hotspot. Make sure you have the latest version of iOS or iPadOS.
If your hotspot won't work, ensure the internet works and you're entering the right password. You can also try disabling battery saver or low power mode or restarting your phone's Wi-Fi. If your phone's hotspot still won't work, then tethering or turning the phone on and off might help.
Quick-and-dirty workaround
I also ran into the same problem when developing an iPhone app that uses a UDP multicast message to discover devices on the network. Apparently the iPhone blocks multicast messages in personal hotspot mode.
However, iPhone seems to use the 172.20.10.0/28
subnet for devices on the personal hotspot network. This means that there are just 16 possible addresses. Of these, 172.20.10.0
is apparently not used, 172.20.10.1
is the iPhone itself, and sending messages to 172.20.10.15
fails with a 'not permitted' error. This means that only the following 13 addresses can be used by clients: 172.20.10.2
, 172.20.10.3
, ..., 172.20.10.14
.
So my work-around is pretty simple: instead of sending broadcast messages only to to 224.0.0.0
, I also send them to all the other possible addresses in the subnet (172.20.10.2
- 172.20.10.14
).
Of course, to be future-proof in a production app you should probably check the list of network interfaces, check the IP and subnet, etc., but for my personal use this method is sufficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With