TWCC is also known as transport-cc.
TWCC stands for Transport Wide Congestion Control. It is used as a sender-side bandwidth estimation technique in WebRTC.
TWCC is operated under the following concept:
- Receiver of the media calculates the intra-packet delays and reports it back to the sender of the media
- The sender then calculates the estimated bitrate based on that information
TWCC is considered a better algorithm for bandwidth estimation by many, and is also the algorithm that Google is focusing and investing in more time and effort. The main reason for this is that the actual estimation implementation is reliant on only the sender, and in media servers such as an SFU that means better control over the algorithm.
The draft for TWCC implementation can be found in draft-holmer-rmcat-transport-wide-cc-extensions-01. The support for TWCC is negotiated in the Offer/Answer SDP Exchange.
What is Congestion Control?
Before diving into TWCC, it’s crucial to understand the concept of congestion control. In a network, congestion occurs when the demand for resources exceeds the available capacity. This can lead to packet loss, increased latency, and jitter, all of which are detrimental to real-time communication. Congestion control algorithms aim to optimize network performance by regulating the flow of data packets.
What is TWCC?
Transport Wide Congestion Control (TWCC) is a Google-developed extension to the RTP (Real-Time Protocol) for WebRTC. It provides a feedback mechanism that allows the sender to adjust the rate of media packet transmission based on the network conditions experienced by the receiver. Unlike traditional congestion control algorithms that operate on a per media stream basis, TWCC works across all media streams in a single transport channel. This “transport-wide” approach offers a more holistic view of network conditions, enabling more accurate and efficient adjustments.
How Does TWCC Work?
Each RTP packet sent by the sender is marked with a unique sequence number. This sequence number is transport-wide, meaning it is unique across all media streams sharing the same transport channel.
The receiver monitors the arrival time of each RTP packet and generates feedback reports. These reports contain the sequence numbers and the observed arrival times of the packets. The feedback is then sent back to the sender.
The sender uses the feedback reports to calculate the network congestion level. If packets are arriving late or are lost, it’s an indication of network congestion. The sender then adjusts the rate of packet transmission accordingly.
Advantages of TWCC
- Holistic View: By working across all media channels, TWCC provides a more comprehensive and more accurate understanding of network conditions
- Quick Adaptation: TWCC enables the sender to quickly adapt to changing network conditions, improving the quality of experience for end-users
- Efficiency: Traditional congestion control mechanisms require separate feedback for each media channel, consuming more bandwidth. TWCC’s transport-wide feedback is more bandwidth-efficient
- Flexibility: TWCC is codec-agnostic, meaning it can be used with any media codec, offering greater flexibility in application development
Implementing TWCC in your WebRTC application involves both client-side and server-side changes. On the client-side, you’ll need to enable the TWCC extension in your RTP parameters. On the server-side, you’ll need to handle incoming TWCC feedback reports and adjust your sending rate accordingly. Many WebRTC libraries and SDKs already support TWCC, making it easier to implement.