在NAT之后到NAT连接之后 [英] Behind NAT to behind NAT connection

查看:124
本文介绍了在NAT之后到NAT连接之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个有趣的问题.基本上我有两部都位于NAT之后的手机.我想使用UDP直接在2个设备之间进行通信.

I've come across an interesting problem. Basically I have 2 mobile phones that are both behind NATs. I want to communicate directly between the 2 devices using UDP.

我知道如果我启动了电话到服务器的连接,那么我可以将数据向下推回该连接到电话(即,从接收消息的同一端口将其发送回与该IP相同的ip和端口从......收到).因此,通过将两部手机都连接到服务器,我可以轻松地在这两个设备之间进行通信.然后将数据发送到服务器,然后将其重新路由回电话.这样可以绕开我可能遇到的所有NAT遍历问题.

I know if I initiate a connection from the phones to a server then I can push data back down that connection to the phone (ie send it back from the same port that received the message to the same ip and port that it was received from). So I can easily communicate between the 2 devices by connecting both phones to the server. Then sending data to the server and having it re-routed back to the phones. This bypasses any NAT traversal issues I may come up against.

但是,我宁愿只使用服务器将两个设备指向彼此,然后让它们直接通信.我将如何去做呢?是否可以不使用uPnP之类的东西?

However I would rather just use the server to point the 2 devices at each other and then let them communicate directly. How would I go about doing this? Is it possible without using something like uPnP?

任何帮助将不胜感激!

编辑:我发现此文档 http://www. brynosaurus.com/pub/net/p2pnat/看起来发夹式翻译是我所追求的,但是它似乎并没有得到广泛的支持.我想知道移动ISP对UPnP的支持有多好?

Edit: I found this document http://www.brynosaurus.com/pub/net/p2pnat/ It looks like hairpin translation is what I'm after but it doesn't look to be widely supported. I wonder how good mobile ISP's support for UPnP is?

推荐答案

您要查找的是UDP打孔,请参见例如 http://en.wikipedia.org/wiki/UDP_hole_punching

What you're looking for is UDP hole punching, see e.g. http://en.wikipedia.org/wiki/UDP_hole_punching

基本思想很简单,您告诉每个端点要使用的端口,然后它们开始发送udp数据包. NAT设备在看到第一个传出数据包时将设置遍历规则,然后另一端的下一次尝试将与此遍历规则匹配.

The basic idea is simple, you tell each endpoint the ports to use, and they start sending udp packets. The NAT'ing devices will set up a traversal rule when they see the first outgoing packet, and then the next attempt from the other end will match this traversal rule.

这篇关于在NAT之后到NAT连接之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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