janus ice 協商過程失敗的一些記錄

@janus ice 協商過程失敗的一些記錄

janus ice 協商過程失敗的一些記錄

Lite Implementations:

一般是ice服務器可以實現,這種模式下,只接受binding request請求,並且回覆。 不會主動發送binding request請求給對方,如果服務器一直處於公網IP下,就可使用這種模式,服務器不收集candidate,只接受stun binding request 測試,並回復
如果兩個端,一個是full 一個lite 則lite端一定是controled。

Full Implementations:

這種模式既可以收binding request,也可以發binding request.
也就是full 模式既可以作爲controlld 又可以作爲controlling,發起offer的是controling

https://tools.ietf.org/html/rfc5245#section-5.2 Determining Role 有詳細描述

那麼controled 和controling 有什麼區別?

controlling agent從所有有效的候選者中找出適用於媒體的一個進行任命。它可以用以下兩種方法。用REGULAR NOMINATION和AGGRESSIVE NOMINATION。
在regular nomination中,the controlling agent讓檢查繼續,直到至少一個有效的候選者被找到。然後在這些有效的候選者中挑選,向它任命的候選者對中發送第二次STUN請求

兩種提名方式

  • 常規的提名在協商中controlling一端在發送binding request時候不會攜帶確認標誌,當所有協商完成後對所有的candidate進行評估,最後會再次發送一個帶有標誌位的請求來表示確認。

  • 而激進提名方式controlling在發送binding request的時候就會攜帶對應的標誌位,當該次連通性測試完成時,就選定該連接,這種時候不會發送第二次的binding request。

With regular nomination, the controlling agent lets the checks
continue until at least one valid candidate pair for each media
stream is found.  Then, it picks amongst those that are valid, and
sends a second STUN request on its NOMINATED candidate pair, but this
time with a flag set to tell the peer that this pair has been
nominated for use.  This is shown in Figure 4.

L                        R
-                        -
STUN request ->             \  L's
          <- STUN response  /  check

           <- STUN request  \  R's
STUN response ->            /  check

STUN request + flag ->      \  L's
          <- STUN response  /  check

                    Figure 4: Regular Nomination

Once the STUN transaction with the flag completes, both sides cancel
any future checks for that media stream.  ICE will now send media
using this pair.  The pair an ICE agent is using for media is called
the SELECTED PAIR.

In aggressive nomination, the controlling agent puts the flag in
every STUN request it sends.  This way, once the first check
succeeds, ICE processing is complete for that media stream and the
controlling agent doesn't have to send a second STUN request.  The
selected pair will be the highest-priority valid pair whose check
succeeded.  Aggressive nomination is faster than regular nomination,
but gives less flexibility.  Aggressive nomination is shown in
Figure 5.

L                        R
-                        -
STUN request + flag ->      \  L's
          <- STUN response  /  check

           <- STUN request  \  R's
STUN response ->            /  check

                   Figure 5: Aggressive Nomination

Once all of the media streams are completed, the controlling endpoint
sends an updated offer if the candidates in the m and c lines for the
media stream (called the DEFAULT CANDIDATES) don't match ICE's
SELECTED CANDIDATES.

stun binding request 標誌位

ICE擴展了以下幾個stun的attribute,其中6.1中的標誌位是USE_CANDIDATE,controlling在選擇candidate的時候會在binding request中攜帶該標誌位,而controlled在binding response和binding request都不會攜帶該標誌位。

This specification defines four new attributes, PRIORITY, USE-
CANDIDATE, ICE-CONTROLLED, and ICE-CONTROLLING.

The PRIORITY attribute indicates the priority that is to be
associated with a peer reflexive candidate, should one be discovered
by this check.  It is a 32-bit unsigned integer, and has an attribute
value of 0x0024.

The USE-CANDIDATE attribute indicates that the candidate pair
resulting from this check should be used for transmission of media.
The attribute has no content (the Length field of the attribute is
zero); it serves as a flag.  It has an attribute value of 0x0025.

The ICE-CONTROLLED attribute is present in a Binding request and
indicates that the client believes it is currently in the controlled
role.  The content of the attribute is a 64-bit unsigned integer in
network byte order, which contains a random number used for tie-
breaking of role conflicts.

The ICE-CONTROLLING attribute is present in a Binding request and
indicates that the client believes it is currently in the controlling
role.  The content of the attribute is a 64-bit unsigned integer in
network byte order, which contains a random number used for tie-
breaking of role conflicts.

Janus服務器中的controlling判斷

    從日誌中可以看出Janus的服務器屬於controlled,因此連接的最終選擇權在客戶端。在日誌中我們可以看到如下log信息,並搜索對應代碼,最終在janus_ice_set_local函數中。
[3814770425474886] Setting ICE locally: got OFFER (1 audios, 1 videos)
[3814770425474886] Creating ICE agent (ICE Full mode, controlled)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章