xStunt Reference(xStunt参考)

原文引自http://www.cis.nctu.edu.tw/~gis87577/xDreaming/XSTUNT/index.html中提供的参考手册

xStunt是一个协议栈,实现了基于TCP协议穿越NAT设备以实现P2P通信。翻译了参考手册的概述部分,后面API说明没有翻译。因水平有限,不足之处恳请指正,不胜感谢!

 

The goal of XSTUNT is to provide a solution to accomplish TCP NAT traversal. The XSTUNT architecture has three roles as above figure: one stunt server and two clients. The STUNT server is in the public internet but the two clients are behind NATs. The STUNT server opens 3 ports for listening: Log, communication, and control. Log is responsible for client registration, connection notifications, and error log. This is a long term connection from registering to deregistering. Communication is responsible for connection requests, deregistering, and query function of management. Control channel is a shunt mechanism when two clients begin to exchange their information.  Here we illustrate the XSTUNT procedure by the following example: Client A wants to make a direct TCP connection to Client B.

XSTUNT的目标是为实现TCP NAT穿越提供解决方案。XSTUNT架构上图中有三个角色:一个XSTUNT服务器和两个客户端。XSTUNT服务器位于公共互联网,两个客户端位于NAT之后。STUNT服务器打开3个监听端口:Control、Log和Communication

Log端口:负责客户端注册,连接通知和错误日志。这是一个从注册到撤销注销的长连接。

Communication端口:负责连接请求、注销和查询功能的管理。

Control channel端口:用于在两个客户端之间交换各自的信息

 接下来,我们通过下面的例子说明的XSTUNT的过程:客户端A想要创建一个直接的TCP连接到客户端B

  

Client A and Client B must register their IDs, probe NAT type, get the server data on the Log port of STUNT SERVER by XInit()

客户端AB必须在STUNT服务器注册各自IDNAT设备类型,使用XInit()STUNT服务器的Log端口获取服务器数据

  The connections between Clients and STUNT SERVER are established.

建立客户端和STUNT服务器之间的连接。

  Client A send a connection request to port Communication of STUNT SERVER by XConnect() and Client B is in the listen state by XListen().

客户端A使用XConnect()发送一个连接请求到STUNT服务器的Communication端口,并且客户端B使用XListen()进入到监听状态。

  STUNT SERVER accepts the request, validates it, and informs the 2 clients by the connection established in [2].

STUNT服务器接受并验证请求,并通知AB客户端步骤⑵的连接建立。

  Client A and Client B begin to exchange their information through the control channel of STUNT SERVER.

客户A和客户B开始通过STUNT服务器的Control通道交换他们的信息。

  Client A finally makes a direct TCP connection through NATs to B.

最终使客户端A创建一个直接的TCP连接,穿越NAT设备到客户端B

 

Following library is an implementation of the above architecture. The method to do the TCP NAT Traversal can be referred to "Characterization and Measurement of TCP Traversal through NAT and Firewalls" addressed by Saikat and Paul. The library implements "STUNT #2" approach in above paper . This program should cooperate with a particular STUNT server for function.

随后XSTUNT Lib是上述架构的实现。TCP NAT穿越的方法称为“TCP穿越NAT和防火墙的表征和测量”由SaikatPaul处理。XSTUNT Lib使用上述方案实现了“STUNT2”。该方案应与一个特殊的STUNT服务器配合使用。

 

XSTUNT LIBRARY

This library provides programmers with a set of simple functions to create STUNT connections through cooperation with a XSTUNT server . Those functions implement the architecture and procedure mentioned above for the client side. Following table lists its abilities in different conditions: Source is the client side who attempts to create a connection to the Destination. Public IP means the client is in the public internet and Private IP means the client is behind NATs.

这个库提供了一组简单的函数,通过与XSTUNT服务器的合作,创建STUNT连接。这些函数实现上文提到的客户端侧的架构和功能。下表列出了在不同条件下的能力:Source是客户端侧试图创建一个到Destination的连接。公网IP是指主机位于公共互联网、私有IP是指主机位于NAT之后。

 

Obviously, if the destination is in the public internet, we do not use this library to create a TCP connection because a plain TCP socket connection should definitely work well. This library should be used when the destination is behind NAT . A hairpin problem will happen if two clients are behind the same NAT . In this situation, this API returns a local IP address to the Source and then it can create a direct TCP connection in LAN. Following topics will guide you to understand how to use this library.

显然,如果连接目标在公共互联网,不需要使用XSTUNT LIB建立TCP连接,因为普通的TCP套接字就可以很好完成工作。连接目标位于NAT之后,可以使用这个库。如果两个客户端位于相同的NAT之后,会发生一个问题。在这种情况下,这个API返回的本地IP地址的来源,就可以在局域网建立直接的TCP连接。下列主题将引导您了解如何使用这个库。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值