ICE(Interactive Connectivity Establishment)

ICE

Overview

概述

ICE (link) provides unreliable packet transport between two clients (p2p) or between a client and a server.

​ICE(链路)在两个客户端(p2p)之间或客户端和服务器之间提供不可靠的分组传输。

This documentation provides an overview of how ICE is implemented, i.e how the following classes interact.

本文档概述了ICE是如何实现的,即以下类是如何交互的。

  • cricket::IceTransportInternal - is the interface that does ICE (manage ports, candidates, connections to send/receive packets). The interface is implemented by cricket::P2PTransportChannel.

  • cricket::IceTransportInternal-是执行ICE(管理端口、候选端口、发送/接收数据包的连接)的接口。该接口由cricket::P2PTransportChannel实现。

  • cricket::PortInterface Represents a local communication mechanism that can be used to create connections to similar mechanisms of the other client. There are 4 implementations of cricket::PortInterface cricket::UDPPortcricket::StunPortcricket::TcpPort and cricket::TurnPort. The ports share lots of functionality in a base class, cricket::Port.

  • cricket::PortInterface表示一种本地通信机制,可用于创建与其他客户端类似机制的连接。有4种cricket::PortInterface的实现:  cricket::UDPPortcricket::StunPortcricket::TcpPort and cricket::TurnPort 。这些端口在一个基类中共享许多功能,即板球:端口。

  • cricket::Candidate represents an address discovered by a cricket::Port. A candidate can be local (i.e discovered by a local port) or remote. Remote candidates are transported using signaling, i.e outside of webrtc. There are 4 types of candidates: localstunprflx or relay (standard)

  • cricket::Candidate代表cricket::Port发现的地址。候选可以是本地的(即通过本地端口发现的)或远程的。远程候选者通过信令传输,即在webrtc之外传输。有4种候选类型:本地、stun、prflx或中继(标准)

  • cricket::Connection provides the management of a cricket::CandidatePair, i.e for sending data between two candidates. It sends STUN Binding requests (aka STUN pings) to verify that packets can traverse back and forth and keep connections alive (both that NAT binding is kept, and that the remote peer still wants the connection to remain open).

  • cricket::Connection提供了对cricket::CandidatePair的管理,即用于在两个候选人之间发送数据。它发送STUN绑定请求(又称STUN ping),以验证数据包可以来回遍历并保持连接有效(NAT绑定保持不变,远程对等方仍然希望连接保持打开)。

  • cricket::P2PTransportChannel uses an cricket::PortAllocator to create ports and discover local candidates. The cricket::PortAllocator is implemented by cricket::BasicPortAllocator.

  • ​cricket::P2PTransportChannel使用cricket::PortAllocator创建端口并发现本地候选端口。cricket::PortAllocator分配器由cricket::BasicPortAllocator实现。

  • cricket::P2PTransportChannel uses an cricket::IceControllerInterface to manage a set of connections. The cricket::IceControllerInterface decides which cricket::Connection to send data on.

  • ​cricket::P2PTransportChannel使用cricket::IceControllerInterface来管理一组连接。cricket::IceControllerInterface决定在哪个cricket::Connection上发送数据。

Connection establishment

连接建立

This section describes a normal sequence of interactions to establish ice state completed link ( standard )

​本节描述了建立ice状态完整链路的正常交互过程(标准)

All of these steps are invoked by interactions with PeerConnection.

所有这些步骤都是通过与PeerConnection的交互来调用的。

1.P2PTransportChannel::MaybeStartGathering This function is invoked as part of PeerConnection::SetLocalDescriptionP2PTransportChannel will use the cricket::PortAllocator to create a cricket::PortAllocatorSession. The cricket::PortAllocatorSession will create local ports as configured, and the ports will start gathering candidates.

​1.P2PTransportChannel::MaybeStartGathering此函数作为PeerConnection::SetLocalDescription的一部分调用。P2PTransportChannel将使用cricket::PortAllocator创建cricket::PortAllocatorSession。cricket::PortAllocatorSession将根据配置创建本地端口,端口将开始收集候选端口。

2.IceTransportInternal::SignalCandidateGathered When a port finds a local candidate, it will be added to a list on cricket::P2PTransportChannel and signaled to application using IceTransportInternal::SignalCandidateGathered. A p2p application can then send them to peer using favorite transport mechanism whereas a client-server application will do nothing.

2.IceTransportInternal::SignalCandidateGathered当端口找到本地候选端口时,它将被添加到cricket::P2PTransportChannel上的列表中,并使用IceTransport Internal::signalCandidateGathered向应用程序发出信号。然后,p2p应用程序可以使用最喜欢的传输机制将它们发送到对等端,而客户端-服务器应用程序则什么都不做。

3.P2PTransportChannel::AddRemoteCandidate When the application get a remote candidate, it can add it using PeerConnection::AddRemoteCandidate (after PeerConnection::SetRemoteDescription has been called!), this will trickle down to P2PTransportChannel::AddRemoteCandidateP2PTransportChannel will combine the remote candidate with all compatible local candidates to form new cricket::Connection(s). Candidates are compatible if it is possible to send/receive data (e.g ipv4 can only send to ipv4, tcp can only connect to tcp etc...) The newly formed cricket::Connection(s) will be added to the cricket::IceController that will decide which cricket::Connection to send STUN ping on.

​3.P2PTransportChannel::AddRemoteCandidate当应用程序获得远程候选时,它可以使用PeerConnection::AddRemoteCandidate添加它(在调用了PeerConnection::SetRemoteDescription之后!),这将渗透到P2PTransportChannel::AddRemoteCandidate。P2PTransport Channel将远程候选与所有兼容的本地候选组合,以形成新的cricket::Connection。如果可以发送/接收数据(例如,ipv4只能发送到ipv4,tcp只能连接到tcp等),则候选者是兼容的。新形成的cricket::Connection(s)将添加到cricket::IceController,该控制器将决定在哪个cricket::Connection上发送STUN ping。

4.P2PTransportChannel::SignalCandidatePairChanged When a remote connection replies to a STUN ping, cricket::IceController will instruct P2PTransportChannel to use the connection. This is signalled up the stack using P2PTransportChannel::SignalCandidatePairChanged. Note that cricket::IceController will continue to send STUN pings on the selected connection, as well as other connections.

​4.P2PTransportChannel::SignalCandidatePairChanged当远程连接回复STUN ping时,cricket::IceController将指示P2PTransportChannel使用该连接。这是使用P2PTransportChannel::SignalCandidatePairChanged在堆栈中向上发送信号的。请注意,cricket::IceController将继续在所选连接以及其他连接上发送STUN ping。

5.​​​​​​P2PTransportChannel::SignalIceTransportStateChanged The initial selection of a connection makes P2PTransportChannel signal up stack that state has changed, which may make cricket::DtlsTransportInternal initiate a DTLS handshake (depending on the DTLS role).

5.P2PTransportChannel::SignalIceTransportStateChanged连接的初始选择会使P2PTransport Channel向上发送状态已更改的信号,这可能会使cricket::DtlsTransportInternal启动DTLS握手(取决于DTLS角色)。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值