每次通过3G连接UDP端口都会改变 [英] UDP port changes every time over 3G connection

查看:249
本文介绍了每次通过3G连接UDP端口都会改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用基于java的UDP套接字与3G模块通信;但是每次接收数据包的端口(有时是IP地址)都会发生变化,这是非常令人惊讶的。这表示我无法为3G模块分配固定的IP /端口并与之通信,但仅依靠传入的数据包来获取目的地信息。谁能告诉我为什么? 3G和普通互联网上的TCP / UDP连接有什么区别?提前感谢!

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!

推荐答案

移动运营商通常拥有NAT防火墙到位。尝试通过发送应用程序可能忽略的UDP数据包来保持UDP会话活跃。可能需要每30秒发送一次以保持NAT映射处于活动状态。

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.

如果移动运营商的NAT防火墙没有从UDP源ip /端口目标IP /接收数据包端口四倍,它将删除它并在您的应用程序的下一个数据包到达时分配一个新的IP /端口。

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.

这篇关于每次通过3G连接UDP端口都会改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆