牵着老婆满街逛

严以律己,宽以待人. 三思而后行.
GMail/GTalk: yanglinbo#google.com;
MSN/Email: tx7do#yahoo.com.cn;
QQ: 3 0 3 3 9 6 9 2 0 .

libjingle翻译之《Important Concepts(重要概念)之Candidates(候选)》

转载自:http://blog.csdn.net/night_cat/article/details/3501217

Candidates(候选)

libjingle一个主要的好处就是它可以穿透防火墙和NAT设备进行链接协商。libjingle使用ICE机制穿透防火墙。libjingle应用程序第一步要做的就是在试图协商一个链接时为其它计算机的链入创建一个潜在的本地端口地址链表。链表中的每个潜在的地址就称作一个候选。候选就是“IP地址:端口”对应对,这些对应对使应用程序和其它计算机互联(技术上,这些对应对只在本地机上监听)。libjingle提供了强壮的机制在本地链接上发现候选供其它计算机进入,甚至穿透防火墙或NAT设备。

为了向其它计算机提供尽可能多的候选链接地址,libjingle生成三种本地候选:

 Local IP addresses 一种候选是计算机上的本地IP地址。与它共同在一个网络中的其它计算机能够通过这个候选进入。

 Global addresses第二种候选是两个计算机之间的NAT或防火墙设备的对外地址。如果这个候选是NAT设备对外地址,libjingle使用心跳包使NAT端口与本地机绑定起来并对外公布这个全局地址。这个全局地址被作为从NAT对外地址链接进入的候选。

A second candidate is an external address on a NAT or firewall device between the two computers. If this

is outside a NAT device, libjingle uses STUN to cause the NAT to bind to your computer and expose a global address.

This address is used as a candidate to connect from outside the NAT device.

 Relay server addresses 大约有8%的链接尝试在穿越防火墙时,上述方法失败。第三种方法就是在两个防火墙之间进行服务器中转。尽管libjingle有能力使用中转服务器,但是没有提供中转服务器的URIlibjingle包含中转服务的代码(relayserver.h)。应用程序可以自己创建和运行这个服务,使用方法是以中转服务器的IP地址做为BasicPortAllocator的构造函数的第三个参数。

下面的图演示了两台计算机之间生成的  local addrress 候选(C1),external NAT 候选(C2),Relay server候选(C3)。

 Candidate selection diagram

 

libjingle以链表的形式储存着全部的候选,这样可以做到在链接建立后,libjingle能够在当前链接迟缓或中断后很快地切换到新的链接上。

libjingle包支持多种传输方式,实现了Jingle<transport>元素表现出来的精神。一个transport元素能够包含比简单的候选地址更多的信息:例如:ICE标签支持像优先权,密码,用户碎片(user fragments)的特殊ICE。尽管这是协商链接的首选方法,为了向下兼容的正规考虑,libjingle仍然支持客户继续使用老式的<candidate>节。请查看Jingle ICE Transport Specification 里的transport详细说明。(对这一段的翻译无自信,把原文附出,请高手指教。)

libjingle now includes support for multiple transports, in the spirit of the Jingle <transport> element. A transport can contain much more information than a simple candidate address: for example, the ICE transport tag supports ICE-specific information such as priority, password, and user fragments. Although this is the preferred way to negotiate connections, for backward compatibility purposes libjingle still supports clients that still use the older bare <candidate> stanza. See the Jingle ICE Transport Specification for an example of a transport specification.




posted on 2013-09-02 00:11 杨粼波 阅读(357) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理