----------------------------------------------------------------------------------------------------------------------
一分钟快速搭建 rtmpd 服务器: https://blog.csdn.net/freeabc/article/details/102880984
软件下载地址: http://www.qiyicc.com/download/rtmpd.zip
github 地址:https://github.com/superconvert/smart_rtmpd
----------------------------------------------------------------------------------------------------------------------
在学习 webrtc 的过程中,我们在学习 SDP 的过程中,发现有个字段 candidate,网上很多资料都一笔带过,或者解释含糊,或者解释错误。主要是 udp 下的 host, srflx, prflx, relay 四种 candidate 类型的解释不清,会导致很多疑惑。下面我就分享一下我的研究结果。最为权威的解释参见官方 RFC ,这个里面解释的最有权威。
https://tools.ietf.org/html/rfc5245
Host Candidate: A candidate obtained by binding to a specific port
from an IP address on the host. This includes IP addresses on
physical interfaces and logical ones, such as ones obtained
through Virtual Private Networks (VPNs) and Realm Specific IP
(RSIP) [RFC3102] (which lives at the operating system level).
这个地址来源于本地的物理网卡或逻辑网卡上的地址,对于具有公网地址或者同一内网的端可以用
Server Reflexive Candidate: A candidate whose IP address and port
are a binding allocated by a NAT for an agent when it sent a
packet through the NAT to a server. Server reflexive candidates
can be learned by STUN servers using the Binding request, or TURN
servers, which provides both a relayed and server reflexive
candidate.
这个地址是端发送 Binding 请求到 STUN/TURN server 经过 NAT 时,NAT 上分配的地址和端口
Peer Reflexive Candidate: A candidate whose IP address and port are
a binding allocated by a NAT for an agent when it sent a STUN
Binding request through the NAT to its peer.
这个地址是端发送 Binding 请求到对等端经过 NAT 时,NAT 上分配的地址和端口
PeerA PeerB
( Full Cone <---> [Restricted Cone, Port Restricted Cone, Symmetric] )
如果对方是 Full Cone 类型,对方就可以提供 prflx 类型的 candidate 了,个人理解,仅供参考。
Relayed Candidate: A candidate obtained by sending a TURN Allocate
request from a host candidate to a TURN server. The relayed
candidate is resident on the TURN server, and the TURN server
relays packets back towards the agent.
这个地址是端发送 Allocate 请求到 TURN server ,由 TURN server 用于中继的地址和端口(这个可能是本机或 NAT 地址)
有关 TCP candidate type 的解释如下
https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Connectivity
TCP candidate types
TCP candidates (that is, candidates whose protocol
is tcp
) can be of these types:
active
The transport will try to open an outbound connection but won't receive incoming connection requests. This is the most common type, and the only one that most user agents will gather.
passive
The transport will receive incoming connection attempts but won't attempt a connection itself.
so
The transport will try to simultaneously open a connection with its peer.