UDP port changes every time over 3G connection

老子叫甜甜 提交于 2019-12-10 10:16:59

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/4106010/udp-port-changes-every-time-over-3g-connection

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!