有关 SDP 中 UDP candidate 类型说明 ( host, srflx, prflx, relay )

28 篇文章 21 订阅
27 篇文章 3 订阅

----------------------------------------------------------------------------------------------------------------------

一分钟快速搭建 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.

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值