UDP port changes every time over 3G connection
I am using java based UDP sockets to communicate with a 3G 开发者_开发问答module; but the port (and sometimes the IP address) of the received packet changes every time, which is very surprising. This indicates that i can't assign a fixed IP/Port to the 3G module and communicate with it, but only rely on the incoming packets to get the destination information. Could anybody tell me why? What's the difference between TCP/UDP connection over 3G and the general Internet ?Thanks in advance!
Mobile carriers often have NAT firewalls in place. Try keeping your UDP 'session' alive by sending UDP packets that your application may ignore. Sending every 30 s might be necessary to keep the NAT mapping active.
If the mobile carrier's NAT firewall does not receive a packet from a UDP source ip/port destination IP/port quadruple, it will remove it and assign a new IP/port when the next packet from your application arrives.
精彩评论