WebRTC
WebRTC is a Voice over Internet Protocol (VoIP) technology that expands on and integrates existing real-time communications technologies, such as Session Initiation Protocol (SIP)-based architectures [2]. WebRTC allows the development of high-quality applications with media capabilities in web browsers by leveraging three types of JavaScript APIs: (i) MediaStream, to acquire audio and video streams; (ii) RTCPeerConnection, to communicate audio and video in real time; and (iii) RTCDataChannel, to communicate arbitrary application data in real time.
Browsers send their user media using the RTCPeerConnection API through SRTP (Secure Real-Time Transport Protocol) and custom data using the RTCDataChannel API through SCTP (Stream Control Transport Protocol). Then, the next protocol layer is DTLS (Datagram Transport Layer Security), which allows securing data exchange betweenWebRTC peers using encryption techniques.
Regarding connectivity, WebRTC peers are usually connected to the Internet behind firewalls and NAT (Network Address Translators) devices. The WebRTC stack relies on the protocol ICE (Interactive Connectivity Establishment) to achieve connectivity between peers. ICE collects all available candidates to the connection. Depending on the nature of the NAT devices, STUN (Session Traversal Utilities for NAT) or TURN (Traversal Using Relay around NAT) servers might be required.
In WebRTC, low latency and timeliness are more important than reliability. For this reason, UDP (User Datagram Protocol) is the transport protocol of the whole stack. UDP offers no reliability or order of the data and delivers each packet to the upper layers at the moment it is available. All in all, different aspects may affect the quality of WebRTC communications: packet loss (due to using best-effort protocols at transport and network level) and jitter (due to the variation in the latency on a packet flow between peers)
Another relevant mechanism implemented inWebRTC which may affect the perceived quality is the bandwidth estimation (BWE). Modern BWE algorithms implemented in browsers predict congestion by analyzing the delay between packets. These algorithms progressively increase the bitrate used to encode the media according to the estimated bandwidth. When a receiver detects congestion, it sends REMB (Receiver Estimated Max Bitrate) messages to the sender, which adapts the transmission bitrate accordingly. (类似于TCP 流量控制)
The RTP Control Protocol (RTCP RTPport+1(UDP)) is a sister protocol of the Real-time Transport Protocol (RTP 16384 to 32767 (UDP))
RTCP itself does not provide any flow encryption or authentication methods. Such mechanisms may be implemented, for example, with the Secure Real-time Transport Protocol (SRTP 5004 (UDP) ) or (S-RTCP 5005 (UDP) )
RTCP provides out-of-band statistics and control information for an RTP session. It partners with RTP in the delivery and packaging of multimedia data, but does not transport any media data itself.
The primary function of RTCP is to provide feedback on the quality of service (QoS) in media distribution by periodically sending statistics information such as transmitted octet and packet counts, packet loss, packet delay variation, and round-trip delay time to participants in a streaming multimedia session
Typically RTP will be sent on an even-numbered UDP port, with RTCP messages being sent over the next higher odd-numbered port.
SIP是会话初始化协议的缩写,是一种用于建立、修改和终止VOIP电话通话的IP电话信号协议。SIP已席卷VOIP市场,该协议与 HTTP协议相似,是一种基于文本的、非常开放和灵活的协议,已在很大范围内取代了H323标准。
SDP是会话描述协议的缩写,通常发生在SIP行令建立之后, 是描述流媒体初始化参数的格式,由IETF作为RFC 4566颁布。流媒体是指在传输过程中看到或听到的内容
RTP和RTCP连接紧密,RTP实施实际数据的传输,RTCP则就服务质量做出反馈。