webrtc NACK 与 RTX
前言
NACK stands for Negative Acknowledgement. It is one of the error resiliency mechanisms in WebRTC.NACK is a way for the receiving end to indicate it hasn’t received a specific packet.
A NACK message is sent over RTCP to the sender of the media, which in turn needs to decide if it will retransmit the lost packet based on its availability in its cache and its estimate to the usefulness of the retransmission (will it be possible to use it once received).
RTX stands for retransmission.In the context of WebRTC, this refers to IETF RC 4588 that defines a special RTP payload that is used to retransmit packets that were previously sent.
While retransmission is usually useless in RTC, there are times where it can make sense – especially if a previous frame needs to be used for the decoding of fresh frames.
上面两段英文摘自webrtcglossary ,最近也把 webrtc NACK 与 RTX 相关代码翻了一遍,就个人理解做个总结。
Nack 与 Rtx 介绍
NACK 包属于 rtcp 的一种,而 RTX 则属于 rtp,两者有一定的关系。
1),Nack
rfc4585 对 Nack 进行了详细描述,它在第六章 定义了 nack 的 Generic/Payload-Specific Feedback Messages 两种类型。
Generic: rtp 报文丢失重传,PT=RTPFB。
Payload-Specific Feedback :指定净荷重传,PT=PSFB 指定净荷又包括以下 3 种
Picture Loss Indication (PLI)
Slice Loss Indication (SLI)
Reference Picture Selection Indication (RPSI)
2),Rtx
webrtc 重传数据支持两种方式:
rtx:当两端 sdp 协商都支持 rtx,会生成一个新的 ssrc,这个 ssrc 就是 rtx 的 ssrc。
普通模式:当 rtx 不启用,直接使用 rtp 包,下面的代码是发送端收到 nack 包处理流程。
备注: rtx 不一定都是重传包,当 prober 开启,发送的 padding 数据也会打成 rtx 包。
评论