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)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章