I have an application that requires users who share a 3G or 4G network access point (same public IP address) to communicate directly through their local IP addresses rather than trying to traverse their global IP addresses, but the local network addresses on my T-mobile 3G and 4G network are not like normal local IP addresses on most routers - they never start with
10. Instead, they start with other numbers - for example, my phone now says that my private IP address is
126.96.36.199. How do you tell if an IP address is a local address when the IP address originates from a cellular network?
I am implementing a peer to peer NAT traversal solution for cellular applications. I avoid using the public IP address when the devices share a common public IP address because most routers do not support hairpin translation.
Hairpin is a behavior where a NAT device forwards packets from a host in an internal network (lets call it host A) back to some other host (host B) in the same internal network when it detects that the (public IP address) destination of the packet is actually a mapped IP address that was created for the internal host (host B). This is a desirable behavior of a NAT, but, unfortunately, not all NAT devices support this. Lacking this behavior, two (internal) hosts behind the same NAT will not be able to communicate with each other if they exchange their public addresses.
That is why they must exchange and use their local IP addresses if they share a public IP address.