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有能力使用中轉服務器,但是沒有提供中轉服務器的URI。libjingle包含中轉服務的代碼(relayserver.h)。應用程序可以自己創建和運行這個服務,使用方法是以中轉服務器的IP地址做為BasicPortAllocator的構造函數的第三個參數。
下面的圖演示了兩臺計算機之間生成的 local addrress 候選(C1),external NAT 候選(C2),Relay server候選(C3)。

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.)