TCP打孔(NAT穿越)库的东西? [英] TCP Hole Punch (NAT Traversal) Library or something?

查看:144
本文介绍了TCP打孔(NAT穿越)库的东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在C#中做TCP冲孔(NAT穿越)。它可以与一个会合服务器,如果需要来进行。我发现 HTTP://sharpstunt.$c$cplex.com/ ,但不能得到这个工作。理想情况下,我需要在NAT的一些方法,我给一个端口号(INT)作为参数,经过这种方法的调用可用(端口转发)。这将是也行,如果该方法仅返回其随后可在一些NAT端口号。是否有人在C#这样做呢?你能不能给我sharpstunt还是别的什么工作的例子吗?

I want to do TCP Hole Punching (NAT Traversal) in C#. It can be done with a rendezvous server if needed. I found http://sharpstunt.codeplex.com/ but can not get this to work. Ideally i need some method which i give a Port Number (int) as parameter that after a call to this method is available ("Port Forwarded") at the NAT. It would be also OK if the method just returns some port number which is then available at the NAT. Has anybody done this in C# ? Can you give me working examples for sharpstunt or something else?

推荐答案

在每一个网络的情况下,TCP打孔以类似的方式为UDP打孔操作。例如,如果两个对等体A和B是背后二FF erent的NAT中,每个对等体的第一个SYN包到其它对等开辟了在其各自的NAT其公共地址相关联的孔送出。如果A的第一个SYN包到B到达B的NAT之前B的第一个SYN包到A到达B的NAT,B的NAT认为A的SYN数据包不请自来,并丢弃。然而,随后B的第一个SYN数据包可通过的NAT成功地旅行,因为A的NAT承认B的公网地址作为A已经开始传出会话的目的地。

In each network scenario, TCP hole punching operates in a similar way to UDP hole punching. For example, if two peers A and B are behind different NATs, each peer’s first SYN packet sent to the other peer opens up a hole associated with its public address in its respective NAT. If A’s first SYN packet to B reaches B’s NAT before B’s first SYN packet to A reaches B’s NAT, B’s NAT considers A’s SYN packet unsolicited and drops it. However, subsequently B’s first SYN packet can travel through A’s NAT successfully because A’s NAT recognises B’s public address as the destination of the outgoing session that A has initiated.

所以,是的。这是可能的TCP holepunch。我不明白为什么有人会认为并非如此。

So yes. It's possible to TCP holepunch. I don't see why anyone would think otherwise.

另外,你能不能创建这种类型的手动bahaviour的?它不需要只要步骤是收集所有必需的信息的相同,以依赖于任何特定的协议。

Also, could you not create this type of bahaviour manually? It doesn't need to depend on any specific protocol as long as the steps are the same to gather all of the required information.

在一般情况下,TCP打孔(3.2.1),过程如下:

In general, TCP hole punching (3.2.1) proceeds as follows:

客户:A,B
服务器:•

Clients: A, B Server: S

•一个使用它的带S的连接要求S代表的连接
与B
•小号回复到A与B的私人和公共地址,
同时发送的​​地址到B

• A uses its connection with S to ask S for a connection with B. • S replies to A with B’s private and public addresses, and simultaneously sends A’s addresses to B.

•A和B异步使传出连接AT-
嘴馋(发送SYN包)到对方的公共和
私有地址,从它们所使用的相同的端口
与S.注册与此同时,他们听
TCP传入的连接尝试在本地TCP
端口。

• A and B asynchronously make outgoing connection at- tempts (send SYN packets) to each other’s public and private addresses, from the same port that they used to register with S. At the same time, they listen for TCP incoming connection attempts on their local TCP ports.

•A和B等待一个SYN-ACK响应他们的输出
去SYN数据包,或传入的连接请求
(SYN数据包)。如果连接失败,同行可以重试
它最多为超时时间。

• A and B wait for a SYN-ACK response to their out- going SYN packets, or an incoming connection request (SYN packet). If a connection fails, the peer can retry it up to a maximum timeout period.

•一旦三次握手过程完成后,
对等相互验证。如果authentica-
失败,则关闭同行这方面,并等待
另一连接是成功验证。该
第一个成功通过身份验证的连接将被使用
传输TCP数据。

• Once the three-way handshake process has completed, the peers authenticate each other. If the authentica- tion fails, the peers close that connection and wait until another connection is successfully authenticated. The first successfully authenticated connection will be used to transfer TCP data.

(我知道这是不是太多的答案,但没有足够的空间,评论)

(I know this isn't much of an answer but there wasn't enough room for a comment).

这篇关于TCP打孔(NAT穿越)库的东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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