UDP port changes every time over a 3G connection

I use java-compatible UDP sockets to communicate with the 3G module; but the port (and sometimes the IP address) of the received packet changes every time, which is very surprising. This means that I cannot assign a fixed IP / port for the 3G module and exchange data with it, but I only rely on incoming packets to get recipient information. Can someone tell me why? What is the difference between a TCP / UDP connection over 3G and a shared Internet? Thanks in advance!

+3
source share
1 answer

Mobile carriers often have NAT firewalls. Try to keep your UDP session alive by sending UDP packets that your application may ignore. Sending every 30 seconds may be required for active NAT mapping.

If the mobile carrier's NAT firewall does not receive a packet from the destination IP / destination IP port / UDP source IP address port, it will remove it and assign a new IP port when the next packet arrives from your application.

+9
source

Source: https://habr.com/ru/post/1773229/


All Articles