UDP打孔不可能与移动服务提供商 [英] UDP Hole Punching not possible with mobile provider

查看:214
本文介绍了UDP打孔不可能与移动服务提供商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上IAM编码一个Android应用程序接收一个摄像头的图片,它连接到PC。为了获得更多的FPS我使用TCP UDP协议来代替。我们的想法是,PC机发送图片到手机的IP和端口。但在手机的供应商有不同的公共端口。所以我不能直接解决了手机。这就是为什么我试图解决通过UDP打洞的问题,但没有工作。当我的手机发送一个数据包发送到电脑,电脑可让手机的公网IP​​和端口。这种情况发生的每一秒,以保持conenction开放。然后服务器发送webcame帧到这个IP和端口一样快,他可以。不过手机仅收到10-15图片wihtin 1-2秒。在此之后,供应商似乎过滤掉所有后续包之类的东西,因为手机犯规得到任何进一步的数据包。

actually iam coding an android app that receives the pictures of a webcam that it connected to a pc. To gain more fps i use the udp protocol instead of tcp. The idea is, that the pc sends the pictures to the phone's ip and port. But the provider of the phone has different public ports. so i cant address the phone directly. That's why i tried to solve the problem via udp hole punching, but that didnt work. When my phone sends one packet to the pc, the pc gets the phone's public ip and port. that happens every second to keep the conenction open. Then the server sends the webcame frames to this ip and port as fast as he can. but the phone receives just 10-15 pictures wihtin 1-2 seconds. after that the provider seems to filter every following packet or something like that because the phone doesnt receive any further packet.

现在我的问题是:发生了什么(或什么是供应商在做),我该如何解决这个问题? TCP协议的作品,但对于因为过多的开销,纠错的流过慢。

Now my question is: what is happening (or what is the provider doing) and how can i fix this problem? TCP protocol works but is too slow for streaming because of too much overhead and error corrections.

推荐答案

有几个问题要记住使用UDP,这是放大了的移动网络:

There are several issues to keep in mind with UDP, which are magnified on mobile networks:

  • 正如你可能知道,当你发送一个UDP数据报,也绝对不能保证它会得到通过,并没有确定的办法知道,如果它没发生什么事。

  • As you probably know, once you send a UDP datagram, there is absolutely no guarantee that it will get through and no sure way to know what happened if it didn't.

有效载荷比大约1400字节的有可能被分解成IP碎片。接收操作系统的可能的重新组装这些成一个整体包,但仅当每个片段到达。有些路由器丢弃碎片随意,有些防火墙丢弃片段是否含有特定字节模式,有的限制在该片段可能会被发送的速率。它最好始终保持你的小数据包和处理重组和自己缺件的重复。

Payloads larger than roughly 1400 bytes are likely to be broken up into IP fragments. The receiving operating system may reassemble those into a whole packet, but only if every fragment arrives. Some routers drop fragments arbitrarily, some firewalls drop fragments if they contain particular byte patterns, and some limit the rate at which fragments may be sent. Its best to always keep your datagrams small and handle reassembly and repeats of missing pieces yourself.

有没有流量控制:如果任何一台路由器的缓冲区已满,之后的一切都将被丢弃。有些路由器将开始随机丢弃报文的百分比,如果他们的缓冲区增长,但还没有满。某些防火墙会列入黑名单的UDP源,如果去比一些任意的阈值更快。

There is no flow-control: if any router's buffer is full, everything after that is dropped. Some routers will begin randomly dropping a percentage of packets if their buffers are growing but not yet full. Some firewalls will blacklist a UDP source if it goes faster than some arbitrary threshold.

在一般情况下,设备和防火墙制造商倾向于把UDP像废话这样一个UDP开发人员,你必须是一个额外的好公民不被人抛弃在:调节你的流量,请记住,丢弃的数据包的意思是,你可能会走得太快,并保持数据包小。有很多,你可以逃脱在受控环境中,但如果应用程序将在野外进行部署,将采取了很多精心设计的编程,以避免出现问题。

In general, device and firewall makers tend to treat UDP like crap so as a UDP developer you have to be an extra good citizen to not get dumped on: regulate your flow, remember that dropped packets mean you might be going too fast, and keep the packets small. There is a lot you can get away with in a controlled environment, but if the application will be deployed "in the wild" it will take a lot of careful programming to avoid problems.

这篇关于UDP打孔不可能与移动服务提供商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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