WebRTC如何决定使用哪些TURN服务器 [英] How does WebRTC decide which TURN Servers to Use

查看:240
本文介绍了WebRTC如何决定使用哪些TURN服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对这个问题进行分支 WebRTC - 我需要指定多少个STUN / TURN服务器?

WebRTC如何确定使用多个TURN服务器提供一个?

How does WebRTC determine which TURN servers to use when more than one is provided?

推荐答案

每个冰候选人在收集时都会获得优先权。它是两种东西的混合物,我相信每个平台(Chrome,FireFox等)都有自己的偏好。

Every Ice candidate is given a priority when it is gathered. It is a mixture of a couple of things and I believe that each platform(Chrome, FireFox, etc.) has their own preferences.

这是一个链接到RFC 解释如何生成优先级。由于候选ID应该是唯一的(如果遵循RFC),每个优先级都保证是唯一的。所以,你永远不应该优先考虑。首先尝试具有较高优先级的那些,如果不能与它们建立连接,则使用下一个在线。

Here is a link to the RFC explaining how priorities are to be generated. Each priority is guaranteed to be unique as the candidate ID should be unique(if the RFC is followed). So, you should never have a tie in priorities. Those with higher priorities are tried first, if a connection cannot be made with them, then the next in line is used.

来自RFC的报价关于优先级:

Quote from the RFC Regarding priority:


使用公式时,代理通过为每种类型的候选者确定
a首选项来计算优先级(服务器自反,对等

反身,中继和主机),并且当代理是多宿主时,

选择其IP地址的首选项。然后组合这两个首选项

来计算候选者的优先级。使用以下公式计算
优先级:

When using the formula, an agent computes the priority by determining a preference for each type of candidate (server reflexive, peer
reflexive, relayed, and host), and, when the agent is multihomed,
choosing a preference for its IP addresses. These two preferences
are then combined to compute the priority for a candidate. That
priority is computed using the following formula:



    priority = (2^24)*(type preference) +
               (2^8)*(local preference) +
               (2^0)*(256 - component ID)




类型首选项必须是0到126之间的整数,而
表示首选项候选人的类型(其中$
类型是本地的,服务器反身的,同伴反身的和中继的)。 A $
126是最高优先级,0是最低优先级。将

值设置为0意味着此类型的候选项将仅用作最后的
。对于所有相同类型的
候选者,类型首选项必须相同,并且对于
不同类型的候选者必须是不同的。同伴反身候选人的类型偏好

必须高于服务器反身候选人的类型偏好。请注意,根据第4.1.1节的程序收集的
候选人将是$
永远不是同行反身候选人;这些类型的候选者是从ICE执行的连通性检查中学到的$

The type preference MUST be an integer from 0 to 126 inclusive, and represents the preference for the type of the candidate (where the
types are local, server reflexive, peer reflexive, and relayed). A
126 is the highest preference, and a 0 is the lowest. Setting the
value to a 0 means that candidates of this type will only be used as
a last resort. The type preference MUST be identical for all
candidates of the same type and MUST be different for candidates of
different types. The type preference for peer reflexive candidates
MUST be higher than that of server reflexive candidates. Note that
candidates gathered based on the procedures of Section 4.1.1 will
never be peer reflexive candidates; candidates of these type are
learned from the connectivity checks performed by ICE.

本地首选项必须是0到65535之间的整数。
它表示在代理是多宿主的情况下,获取候选人的
的特定IP地址的首选项。

65535代表最高优先级,以及零,最低。

当只有一个IP地址时,该值应该设置为
65535.更一般地说,如果特定媒体流的特定组件有多个候选者具有相同的
类型,本地首选项必须是唯一的。在这个
规范中,这仅适用于多宿主主机。如果主机是$
多宿主,因为它是双栈,本地首选项应该是

设置等于RFC中描述的IP地址的优先级值

3484 [RFC3484]。

The local preference MUST be an integer from 0 to 65535 inclusive. It represents a preference for the particular IP address from which
the candidate was obtained, in cases where an agent is multihomed.
65535 represents the highest preference, and a zero, the lowest.
When there is only a single IP address, this value SHOULD be set to 65535. More generally, if there are multiple candidates for a particular component for a particular media stream that have the same type, the local preference MUST be unique for each one. In this
specification, this only happens for multihomed hosts. If a host is
multihomed because it is dual stack, the local preference SHOULD be
set equal to the precedence value for IP addresses described in RFC
3484 [RFC3484].

组件ID是候选人的组件ID,必须是1到256之间的

The component ID is the component ID for the candidate, and MUST be between 1 and 256 inclusive.

您可以看到转弯服务器的IP和端口显示在中继候选中。以下内容源自 RFC第82页 webrtc hacks

You can see the turn server ip and port is shown in a relay candidate. The following is derived from the RFC page 82 and webrtc hacks.

a=candidate:2157334355<ID> 2<Component> udp<NetType> 33562367<Prioirty> 180.6.6.6<NAT pub IP> 54278<NAT pub Port> typ relay<Means it needs to be relayed through Turn> raddr 46.2.2.2<Relay address of turn> rport 38135<relay port of turn> generation 0

这篇关于WebRTC如何决定使用哪些TURN服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆