简体   繁体   English

每次通过3G连接都会改变UDP端口

[英]UDP port changes every time over 3G connection

I am using java based UDP sockets to communicate with a 3G module; 我使用基于java的UDP套接字与3G模块通信; but the port (and sometimes the IP address) of the received packet changes every time, which is very surprising. 但是每次接收数据包的端口(有时是IP地址)都会发生变化,这是非常令人惊讶的。 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. 这表示我无法为3G模块分配固定的IP /端口并与之通信,但仅依靠传入的数据包来获取目的地信息。 Could anybody tell me why? 谁能告诉我为什么? What's the difference between TCP/UDP connection over 3G and the general Internet ?Thanks in advance! 通过3G和普通互联网的TCP / UDP连接有什么区别?提前感谢!

Mobile carriers often have NAT firewalls in place. 移动运营商通常都有NAT防火墙。 Try keeping your UDP 'session' alive by sending UDP packets that your application may ignore. 尝试通过发送应用程序可能忽略的UDP数据包来保持UDP“会话”活跃。 Sending every 30 s might be necessary to keep the NAT mapping active. 可能需要每30秒发送一次以保持NAT映射处于活动状态。

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. 如果移动运营商的NAT防火墙没有从UDP源IP /端口目标IP /端口四重接收数据包,它将删除它并在应用程序的下一个数据包到达时分配新的IP /端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM