Go to the source code of this file.
|
| STATUS | onRtcpPacket (PKvsPeerConnection, PBYTE, UINT32) |
| STATUS | onRtcpRembPacket (PRtcpPacket, PKvsPeerConnection) |
| STATUS | onRtcpPLIPacket (PRtcpPacket, PKvsPeerConnection) |
| STATUS | createRtcpPLIPacket (UINT32, UINT32, PBYTE, PUINT32) |
| STATUS | parseRtcpTwccPacket (PRtcpPacket, PTwccManager) |
| STATUS | onRtcpTwccPacket (PRtcpPacket, PKvsPeerConnection) |
| STATUS | updateTwccHashTable (PTwccManager, PINT64, PUINT64, PUINT64, PUINT64, PUINT64) |
| STATUS | computeTwccTrendline (PTwccManager, PDOUBLE, PDOUBLE) |
| | Estimates network congestion trend using least-squares linear regression on accumulated one-way delay variations, smoothed with an exponential moving average (EMA).
|
◆ IS_TWCC_RUNLEN
| #define IS_TWCC_RUNLEN |
( |
| packetChunk | ) |
|
Value:((((packetChunk) >> 15u) & 1u) == 0)
◆ MICROSECONDS_PER_SECOND
| #define MICROSECONDS_PER_SECOND 1000000LL |
◆ MILLISECONDS_PER_SECOND
| #define MILLISECONDS_PER_SECOND 1000LL |
◆ RTCP_PLI_PACKET_LEN
◆ TWCC_ESTIMATOR_TIME_WINDOW
| #define TWCC_ESTIMATOR_TIME_WINDOW (4 * HUNDREDS_OF_NANOS_IN_A_SECOND) |
◆ TWCC_FB_PACKETCHUNK_SIZE
| #define TWCC_FB_PACKETCHUNK_SIZE 2 |
◆ TWCC_FB_PAYLOAD_MIN_LEN
| #define TWCC_FB_PAYLOAD_MIN_LEN 16 |
◆ TWCC_IS_NOTRECEIVED
| #define TWCC_IS_NOTRECEIVED |
( |
| statusSymbol | ) |
|
Value:
@ TWCC_STATUS_SYMBOL_NOTRECEIVED
Definition Rtcp.h:74
◆ TWCC_ISRECEIVED
| #define TWCC_ISRECEIVED |
( |
| statusSymbol | ) |
|
Value:
@ TWCC_STATUS_SYMBOL_LARGEDELTA
Definition Rtcp.h:76
@ TWCC_STATUS_SYMBOL_SMALLDELTA
Definition Rtcp.h:75
◆ TWCC_MAX_PACKET_STATUS_COUNT
| #define TWCC_MAX_PACKET_STATUS_COUNT 2048 |
◆ TWCC_PACKET_LOST_TIME
| #define TWCC_PACKET_LOST_TIME ((UINT64) (-1LL)) |
◆ TWCC_PACKET_STATUS_COUNT
| #define TWCC_PACKET_STATUS_COUNT |
( |
| payload | ) |
|
Value:(getUnalignedInt16BigEndian((payload) + 10))
◆ TWCC_PACKET_UNITIALIZED_TIME
| #define TWCC_PACKET_UNITIALIZED_TIME 0 |
◆ TWCC_RUNLEN_GET
| #define TWCC_RUNLEN_GET |
( |
| packetChunk | ) |
|
Value:((packetChunk) & 0x1fffu)
◆ TWCC_RUNLEN_ISRECEIVED
| #define TWCC_RUNLEN_ISRECEIVED |
( |
| packetChunk | ) |
|
Value:
#define TWCC_RUNLEN_STATUS_SYMBOL(packetChunk)
Definition Rtcp.h:81
#define TWCC_ISRECEIVED(statusSymbol)
Definition Rtcp.h:84
◆ TWCC_RUNLEN_STATUS_SYMBOL
| #define TWCC_RUNLEN_STATUS_SYMBOL |
( |
| packetChunk | ) |
|
Value:(((packetChunk) >> 13u) & 3u)
◆ TWCC_STATUSVECTOR_COUNT
| #define TWCC_STATUSVECTOR_COUNT |
( |
| packetChunk | ) |
|
Value:
#define TWCC_STATUSVECTOR_IS_2BIT(packetChunk)
Definition Rtcp.h:86
◆ TWCC_STATUSVECTOR_IS_2BIT
| #define TWCC_STATUSVECTOR_IS_2BIT |
( |
| packetChunk | ) |
|
Value:(((packetChunk) >> 14u) & 1u)
◆ TWCC_STATUSVECTOR_SMASK
| #define TWCC_STATUSVECTOR_SMASK |
( |
| packetChunk | ) |
|
◆ TWCC_STATUSVECTOR_SSIZE
| #define TWCC_STATUSVECTOR_SSIZE |
( |
| packetChunk | ) |
|
◆ TWCC_STATUSVECTOR_STATUS
| #define TWCC_STATUSVECTOR_STATUS |
( |
| packetChunk, |
|
|
| i ) |
Value:
#define TWCC_STATUSVECTOR_SMASK(packetChunk)
Definition Rtcp.h:88
#define TWCC_STATUSVECTOR_SSIZE(packetChunk)
Definition Rtcp.h:87
◆ TWCC_TICKS_PER_SECOND
| #define TWCC_TICKS_PER_SECOND (1000000LL / 250) |
◆ TWCC_TRENDLINE_SMOOTHING_FACTOR
| #define TWCC_TRENDLINE_SMOOTHING_FACTOR 0.2 |
◆ TWCC_STATUS_SYMBOL
| Enumerator |
|---|
| TWCC_STATUS_SYMBOL_NOTRECEIVED | |
| TWCC_STATUS_SYMBOL_SMALLDELTA | |
| TWCC_STATUS_SYMBOL_LARGEDELTA | |
◆ computeTwccTrendline()
| STATUS computeTwccTrendline |
( |
PTwccManager | pTwccManager, |
|
|
PDOUBLE | pDelayTrend, |
|
|
PDOUBLE | pQueueDelay ) |
Estimates network congestion trend using least-squares linear regression on accumulated one-way delay variations, smoothed with an exponential moving average (EMA).
Algorithm overview:
- For each consecutive packet pair (i-1, i), compute the inter-arrival delay variation: d_i = (recvTime_i - recvTime_{i-1}) - (sendTime_i - sendTime_{i-1}) A positive d_i means the network took longer to deliver packet i than packet i-1.
- Accumulate these variations into a running sum (the "accumulated delay"): D_i = D_{i-1} + d_i (where D_0 = 0) This represents the total queuing delay buildup over the observation window.
- Fit a line to the points (x_i, y_i) = (i, D_i) using ordinary least-squares regression. The slope formula is: rawSlope = (n * sum(x_i * y_i) - sum(x_i) * sum(y_i)) / (n * sum(x_i^2) - (sum(x_i))^2) A positive slope indicates delay is growing (congestion building up). A near-zero slope indicates stable network conditions. A negative slope indicates delay is decreasing (congestion clearing).
- Smooth the slope with an EMA to reduce noise: smoothedSlope = alpha * rawSlope + (1 - alpha) * prevSmoothedSlope where alpha = TWCC_TRENDLINE_SMOOTHING_FACTOR (0.2 by default).
- Parameters
-
| [in] | pTwccManager | TWCC manager containing packet timing history |
| [out] | pDelayTrend | Smoothed slope in ms per sample (positive = congestion building) |
| [out] | pQueueDelay | Total accumulated delay variation in ms over the window |
◆ createRtcpPLIPacket()
| STATUS createRtcpPLIPacket |
( |
UINT32 | senderSsrc, |
|
|
UINT32 | mediaSsrc, |
|
|
PBYTE | pRawPacket, |
|
|
PUINT32 | pPacketLen ) |
◆ onRtcpPacket()
| STATUS onRtcpPacket |
( |
PKvsPeerConnection | pKvsPeerConnection, |
|
|
PBYTE | pBuff, |
|
|
UINT32 | buffLen ) |
◆ onRtcpPLIPacket()
◆ onRtcpRembPacket()
◆ onRtcpTwccPacket()
◆ parseRtcpTwccPacket()
◆ updateTwccHashTable()
| STATUS updateTwccHashTable |
( |
PTwccManager | pTwccManager, |
|
|
PINT64 | duration, |
|
|
PUINT64 | receivedBytes, |
|
|
PUINT64 | receivedPackets, |
|
|
PUINT64 | sentBytes, |
|
|
PUINT64 | sentPackets ) |