diff --git a/docs/API-functions.md b/docs/API-functions.md index b4a0bf96a..7aec1c0d7 100644 --- a/docs/API-functions.md +++ b/docs/API-functions.md @@ -102,7 +102,7 @@ be called from the C++ global destructor, if not called by the application, alth relying on this behavior is stronly discouraged. - Returns: - + * 0 (A possibility to return other values is reserved for future use) **IMPORTANT**: Note that the startup/cleanup calls have an instance counter. @@ -837,7 +837,7 @@ are then derived by the member sockets. * `SRT_EINVSOCK`: Socket `u` indicates no valid socket ID * `SRT_EINVOP`: Option `opt` indicates no valid option * Various other errors that may result from problems when setting a specific - option (see option description for details). + option (see option description for details). ### srt_getversion @@ -1311,7 +1311,7 @@ would be 0x7FFFFFE0, the "distance" is 0x20. // perfmon with Byte counters for better bitrate estimation. int srt_bstats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear); -// permon with Byte counters and instantaneous stats instead of moving averages for Snd/Rcvbuffer sizes. +// perfmon with Byte counters and instantaneous stats instead of moving averages for Snd/Rcvbuffer sizes. int srt_bistats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear, int instantaneous); ``` @@ -1436,7 +1436,7 @@ level-triggered, you can do two separate subscriptions for the same socket. - Returns: - + * 0 if successful, otherwise -1 - Errors: @@ -1461,7 +1461,7 @@ The `_usock` suffix refers to a user socket (SRT socket). The `_ssock` suffix refers to a system socket. - Returns: - + * 0 if successful, otherwise -1 - Errors: diff --git a/docs/statistics.md b/docs/statistics.md index 8e22b7e19..cf25ffc15 100644 --- a/docs/statistics.md +++ b/docs/statistics.md @@ -1,269 +1,373 @@ -SRT provides a powerful set of statistical data on a socket. -This data can be used to keep an eye on a socket's health, -and track faulty behavior. +# SRT Statistics -Statistics are calculated independently on each side (receiver and sender), -and are not exchanged between peers, unless explicitly stated. +SRT provides a powerful set of statistical data on a socket. This data can be used to keep an eye on a socket's health and track faulty behavior. -The following API functions can be used to retrieve statistics on an SRT socket. -Refer to the documentation of the [API functions](API-functions.md) for usage instructions. +Statistics are calculated independently on each side (receiver and sender) and are not exchanged between peers unless explicitly stated. + +The following API functions can be used to retrieve statistics on an SRT socket: * `int srt_bstats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear)` * `int srt_bistats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear, int instantaneous)` -# Total accumulated measurements +Refer to the documentation of the [API functions](API-functions.md) for usage instructions. + +# Summary Table + +The table below provides the summary on the SRT statistics: name, type, unit of measurement, the side it's calculated (sender or receiver), and data type. See section ["Detailed Description"](#Detailed Description) for detailed description of each statistic. + +There are three types of statistics: + +- Accumulated that means the statistic is accumulated since the time an SRT socket has been created (after the successful call to `srt_connect(...)` or `srt_bind(...)` function), e.g., `pktSentTotal`, etc., +- Interval-based that means the statistic is accumulated during the specified time interval, e.g., 100 milliseconds if SRT statistics is collected each 100 milliseconds, since the time an SRT socket has been created, e.g., `pktSent` , etc.. The value of the statistic can be reset by calling the `srt_bstats(..., int clear)` function with `clear = 1`, +- Instantaneous that means the statistic is obtained at the moment `srt_bstats()` function is called. + +| Statistic | Type of Statistic | Unit of Measurement | Available for Sender | Available for Receiver | Data Type | +| ----------------------- | ----------------- | ------------------- | -------------------- | ---------------------- | --------- | +| msTimeStamp | accumulated | ms (milliseconds) | ✓ | ✓ | int64_t | +| pktSentTotal | accumulated | packets | ✓ | - | int64_t | +| pktRecvTotal | accumulated | packets | - | ✓ | int64_t | +| pktSndLossTotal | accumulated | packets | ✓ | - | int32_t | +| pktRcvLossTotal | accumulated | packets | - | ✓ | int32_t | +| pktRetransTotal | accumulated | packets | ✓ | - | int32_t | +| pktRcvRetransTotal | accumulated | packets | - | ✓ | int32_t | +| pktSentACKTotal | accumulated | packets | - | ✓ | int32_t | +| pktRecvACKTotal | accumulated | packets | ✓ | - | int32_t | +| pktSentNAKTotal | accumulated | packets | - | ✓ | int32_t | +| pktRecvNAKTotal | accumulated | packets | ✓ | - | int32_t | +| usSndDurationTotal | accumulated | us (microseconds) | ✓ | - | int64_t | +| pktSndDropTotal | accumulated | packets | ✓ | - | int32_t | +| pktRcvDropTotal | accumulated | packets | - | ✓ | int32_t | +| pktRcvUndecryptTotal | accumulated | packets | - | ✓ | int32_t | +| pktSndFilterExtraTotal | accumulated | packets | ✓ | - | int32_t | +| pktRcvFilterExtraTotal | accumulated | packets | - | ✓ | int32_t | +| pktRcvFilterSupplyTotal | accumulated | packets | - | ✓ | int32_t | +| pktRcvFilterLossTotal | accumulated | packets | - | ✓ | int32_t | +| byteSentTotal | accumulated | bytes | ✓ | - | uint64_t | +| byteRecvTotal | accumulated | bytes | - | ✓ | uint64_t | +| byteRcvLossTotal | accumulated | bytes | - | ✓ | uint64_t | +| byteRetransTotal | accumulated | bytes | ✓ | - | uint64_t | +| byteSndDropTotal | accumulated | bytes | ✓ | - | uint64_t | +| byteRcvDropTotal | accumulated | bytes | - | ✓ | uint64_t | +| byteRcvUndecryptTotal | accumulated | bytes | - | ✓ | uint64_t | +| pktSent | interval-based | packets | ✓ | - | int64_t | +| pktRecv | interval-based | packets | - | ✓ | int64_t | +| pktSndLoss | interval-based | packets | ✓ | - | int32_t | +| pktRcvLoss | interval-based | packets | - | ✓ | int32_t | +| pktRetrans | interval-based | packets | ✓ | - | int32_t | +| pktRcvRetrans | | | | | int32_t | +| pktSentACK | interval-based | packets | | | int32_t | +| pktRecvACK | interval-based | packets | | | int32_t | +| pktSentNAK | interval-based | packets | | | int32_t | +| pktRecvNAK | interval-based | packets | | | int32_t | +| pktSndFilterExtra | interval-based | packets | ✓ | - | int32_t | +| pktRcvFilterExtra | interval-based | packets | - | ✓ | int32_t | +| pktRcvFilterSupply | interval-based | packets | - | ✓ | int32_t | +| pktRcvFilterLoss | interval-based | packets | - | ✓ | int32_t | +| mbpsSendRate | interval-based | Mbps | ✓ | - | double | +| mbpsRecvRate | interval-based | Mbps | - | ✓ | double | +| usSndDuration | interval-based | us (microseconds) | ✓ | - | int64_t | +| pktReorderDistance | interval-based | packets | - | ✓ | int32_t | +| pktReorderTolerance | interval-based | | | | int32_t | +| pktRcvAvgBelatedTime | | | | | double | +| pktRcvBelated | | | | | int64_t | +| pktSndDrop | interval-based | packets | ✓ | - | int32_t | +| pktRcvDrop | interval-based | packets | - | ✓ | int32_t | +| pktRcvUndecrypt | interval-based | packets | - | ✓ | int32_t | +| byteSent | interval-based | bytes | ✓ | - | uint64_t | +| byteRecv | interval-based | bytes | - | ✓ | uint64_t | +| byteRcvLoss | interval-based | bytes | - | ✓ | uint64_t | +| byteRetrans | interval-based | bytes | ✓ | - | uint64_t | +| byteSndDrop | interval-based | bytes | ✓ | - | uint64_t | +| byteRcvDrop | interval-based | bytes | - | ✓ | uint64_t | +| byteRcvUndecrypt | interval-based | bytes | - | ✓ | uint64_t | +| usPktSndPeriod | instantaneous | us (microseconds) | ✓ | - | double | +| pktFlowWindow | instantaneous | packets | ✓ | - | int32_t | +| pktCongestionWindow | instantaneous | packets | ✓ | - | int32_t | +| pktFlightSize | instantaneous | packets | ✓ | - | int32_t | +| msRTT | instantaneous | ms (milliseconds) | ✓ | ✓ | double | +| mbpsBandwidth | instantaneous | Mbps | ✓ | ✓ | double | +| byteAvailSndBuf | instantaneous | bytes | ✓ | - | int32_t | +| byteAvailRcvBuf | instantaneous | bytes | - | ✓ | int32_t | +| mbpsMaxBW | instantaneous | Mbps | ✓ | - | double | +| byteMSS | instantaneous | bytes | ✓ | ✓ | int32_t | +| pktSndBuf | instantaneous | packets | ✓ | - | int32_t | +| byteSndBuf | instantaneous | bytes | ✓ | - | int32_t | +| msSndBuf | instantaneous | ms (milliseconds) | ✓ | - | int32_t | +| msSndTsbPdDelay | instantaneous | ms (milliseconds) | ✓ | - | int32_t | +| pktRcvBuf | instantaneous | packets | - | ✓ | int32_t | +| byteRcvBuf | instantaneous | bytes | - | ✓ | int32_t | +| msRcvBuf | instantaneous | ms (milliseconds) | - | ✓ | int32_t | +| msRcvTsbPdDelay | instantaneous | ms (milliseconds) | - | ✓ | int32_t | + + +# Detailed Description + +## Accumulated Statistics + +### msTimeStamp + +The time elapsed since the SRT socket has been created (after successful call to `srt_connect(...)` or `srt_bind(...)` function), in milliseconds. Available both for sender and receiver. + +### pktSentTotal + +The total number of sent data packets, including retransmitted packets. Available for sender. + +### pktRecvTotal + +The total number of received packets, including retransmitted packets. Available for receiver. + +### pktSndLossTotal + +The total number of data packets considered or reported as lost at the sender side. Does not correspond to the packets detected as lost at the receiver side. Available for sender. -## msTimeStamp +A packet is considered lost in two cases: +1. Sender receives a loss report from a receiver, +2. Sender initiates retransmission after not receiving an ACK packet for a certain timeout. Refer to `FASTREXMIT` and `LATEREXMIT` algorithms. -Time elapsed since the SRT socket was started (after successful call to `srt_connect(...)` or `srt_bind(...)`), in milliseconds. +### pktRcvLossTotal -## pktSentTotal +The total number of SRT DATA packets detected as presently missing (either reordered or lost) at the receiver side. Available for receiver. -The total number of sent data packets, including retransmitted packets. Applicable for data sender. +The detection of presently missing packets is triggered by a newly received DATA packet with the sequence number `s`. If `s` is greater than the sequence number `next_exp` of the next expected packet (`s > next_exp`), the newly arrived packet `s` is considered in-order and there is a sequence discontinuity of size `s - next_exp` associated with this packet. The presence of sequence discontinuity means that some packets of the original sequence have not yet arrived (presently missing), either reordered or lost. Once the sequence discontinuity is detected, its size `s - next_exp` is added to `pktRcvLossTotal` statistic. Refer to [RFC 4737 - Packet Reordering Metrics](https://tools.ietf.org/html/rfc4737) for details. -## pktRecvTotal +If the packet `s` is received out of order (`s < next_exp`), the statistic is not affected. -The total number of received packets, including received retransmitted packets. Applicable for data receiver. +Note that only original (not retransmitted) SRT DATA packets are taken into account. Refer to [pktRcvRetransTotal](#pktRcvRetransTotal) for the formula of obtaining the total number of lost retransmitted packets. -## pktSndLossTotal +In SRT v1.4.0, v1.4.1, `pktRcvLossTotal` statistics includes packets that failed to be decrypted. To receive the number of presently missing packets, substract [pktRcvUndecryptTotal](#pktRcvUndecryptTotal) from the current one. This is going to be fixed within SRT v.1.5.0. -The total number of data packets considered or reported lost (sender side). Does not correspond to packets detected as lost at receiving side. Applicable for data sender. +### pktRetransTotal -A packet is considered lost in two cases: -1. Sender receives a loss report from receiver. -2. Sender initiates retransmission after not receiving ACK for a certain timeout. Refer to `FASTREXMIT` and `LATEREXMIT` algorithms. +The total number of retransmitted packets sent by the SRT sender. Available for sender. -## pktRcvLossTotal +This statistics is not interchangeable with the receiver [pktRcvRetransTotal](#pktRcvRetransTotal) statistic. -The total number of data packets detected lost on the receiver's side. +### pktRcvRetransTotal -Includes packets that failed to be decrypted (only as of SRT version 1.4.0). +The total number of retransmitted packets registered at the receiver side. Available for receiver. -If a packet was received out of order, the gap (sequence discontinuity) is also -treated as lost packets, independent of the reorder tolerance value. +This statistics is not interchangeable with the sender [pktRetransTotal](#pktRetransTotal) statistic. -Loss detection is based on gaps in Sequence Numbers of SRT DATA packets. Detection -of a packet loss is triggered by a newly received packet. An offset is calculated -between sequence numbers of the newly arrived DATA packet and previously received -DATA packet (the received packet with highest sequence number). Receiving older -packets does not affect this value. The packets from that gap are considered lost, -and that number is added to this `pktRcvLossTotal` measurement. In the case where -the offset is negative, the packet is considered late, meaning that it was either -already acknowledged or dropped by TSBPD as too late to be delivered. Such late -packets are ignored. +Note that the total number of lost retransmitted packets can be calculated as the total number of retransmitted packets sent by receiver minus the total number of retransmitted packets registered at the receiver side: `pktRetransTotal - pktRcvRetransTotal`. -## pktRetransTotal +This is going to be implemented in SRT v1.5.0, see issue [#1208](https://github.com/Haivision/srt/issues/1208). -The total number of retransmitted packets. Calculated on the sender's side only. -Not exchanged with the receiver. +### pktSentACKTotal -## pktSentACKTotal +The total number of sent ACK (Acknowledgement) control packets. Available for receiver. -The total number of sent ACK packets. Applicable for data sender. +### pktRecvACKTotal -## pktRecvACKTotal +The total number of received ACK (Acknowledgement) control packets. Available for sender. -The total number of received ACK packets. Applicable for data receiver. +### pktSentNAKTotal -## pktSentNAKTotal +The total number of sent NAK (Negative Acknowledgement) control packets. Available for receiver. -The total number of NAK (Not Acknowledged) packets sent. Essentially means LOSS -reports. Applicable for data sender. +### pktRecvNAKTotal -## pktRecvNAKTotal +The total number of received NAK (Negative Acknowledgement) control packets. Available for sender. -The total number of NAK (Not Acknowledged) packets received. Essentially means -LOSS reports. Applicable for data receiver. +### usSndDurationTotal -## usSndDurationTotal +The total accumulated time in microseconds, during which the SRT sender has some data to transmit, including packets that have been sent, but not yet acknowledged. In other words, the total accumulated duration in microseconds when there was something to deliver (non-empty senders' buffer). Available for sender. -The total accumulated time in microseconds, during which the SRT sender has some -data to transmit, including packets that were sent, but is waiting for acknowledgement. -In other words, the total accumulated duration in microseconds when there was something -to deliver (non-empty senders' buffer). -Applicable for data sender. +### pktSndDropTotal -## pktSndDropTotal +The total number of "too late to send" packets dropped by the sender (refer to `SRTO_TLPKTDROP` in [API.md](API.md)). Available for sender. -The number of "too late to send" packets dropped by sender (refer to `TLPKTDROP`). +The total delay before TLPKTDROP mechanism is triggered consists of the `SRTO_PEERLATENCY`, plus `SRTO_SNDDROPDELAY`, plus 2 * the ACK interval (default ACK interval is 10 ms). The delay used is the timespan between the very first packet and the latest packet in the sender's buffer. -The total delay before `TLPKTDROP` is triggered consists of the `SRTO_PEERLATENCY`, -plus `SRTO_SNDDROPDELAY`, plus 2 * the ACK interval (default ACK interval is 10 ms). -The delay used is the timespan between the very first packet and the latest packet -in the sender's buffer. +### pktRcvDropTotal +The total number of "too late to deliver" missing packets. Available for receiver. -## pktRcvDropTotal +Missing packets means lost or not yet received out-of-order packets. The receiver drops only those packets that are missing by the time there is at least one packet ready to be delivered to the upstream application. -The number of "too late to play" missing packets. Receiver only. +Also includes packets that failed to be decrypted (see [pktRcvUndecryptTotal](#pktRcvUndecryptTotal)). These packets are present in the receiver's buffer and not dropped at the moment the decryption has failed. -TSBPD and TLPacket drop socket option should be enabled. + `SRTO_TSBPDMODE` and `SRTO_TLPKTDROP` socket options should be enabled (refer to in [API.md](API.md)). -The receiver drops only those packets that are missing by the time there is at -least one packet ready to play. +### pktRcvUndecryptTotal -Also includes packets that failed to be decrypted (pktRcvUndecryptTotal). These -packets are present in the receiver's buffer, and not dropped directly. +The total number of packets that failed to be decrypted at the receiver side. Available for receiver. -## pktRcvUndecryptTotal +### pktSndFilterExtraTotal -The number of packets that failed to be decrypted. Receiver side. +The total number of packet filter control packets supplied by the packet filter (refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md)). Available for sender. -## pktSndFilterExtraTotal +Packet filter control packets are SRT DATA packets. -The number of control packets supplied by the packet filter (refer to -[SRT Packet Filtering & FEC](packet-filtering-and-fec.md)). Sender only. +`SRTO_PACKETFILTER` socket option should be enabled (refer to in [API.md](API.md)). Introduced in SRT v1.4.0. -Introduced in v1.4.0. +### pktRcvFilterExtraTotal -## pktRcvFilterExtraTotal +The total number of packet filter control packets received and not supplied back by the packet filter +(refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md)). Available for receiver. -The number of control packets received and not supplied back by the packet filter -(refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md)). Receiver only. +Packet filter control packets are SRT DATA packets. -Introduced in v1.4.0. +For FEC, this is the total number of received FEC control packets. -## pktRcvFilterSupplyTotal +`SRTO_PACKETFILTER` socket option should be enabled (refer to in [API.md](API.md)). Introduced in SRT v1.4.0. -The number of packets supplied by the packet filter excluding actually received packets -(e.g. FEC rebuilt). Receiver only. Refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md). +### pktRcvFilterSupplyTotal -Introduced in v1.4.0. +The total number of packets supplied by the packet filter excluding actually received packets +(e.g., FEC rebuilt packets, refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md)). Available for receiver. -## pktRcvFilterLossTotal +Packet filter control packets are SRT DATA packets. -The number of lost packets, that were not covered by the packet filter. Receiver only. -Refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md). +`SRTO_PACKETFILTER` socket option should be enabled (refer to in [API.md](API.md)). Introduced in SRT v1.4.0. -Introduced in v1.4.0. +### pktRcvFilterLossTotal -## byteSentTotal +The total number of lost packets that were not covered by the packet filter (refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md)). Available for receiver. -Same as `pktSentTotal`, but expressed in bytes, including payload and all headers (SRT+UDP+IP). \ -20 bytes IPv4 + 8 bytes of UDP + 16 bytes SRT header. Sender side. +Packet filter control packets are SRT DATA packets. -## byteRecvTotal +`SRTO_PACKETFILTER` socket option should be enabled (refer to in [API.md](API.md)). Introduced in SRT v1.4.0. -Same as `pktRecvTotal`, but expressed in bytes, including payload and all headers (SRT+UDP+IP). \ -20 bytes IPv4 + 8 bytes of UDP + 16 bytes SRT header. Receiver side. +### byteSentTotal -## byteRcvLossTotal +Same as [pktSentTotal](#pktSentTotal), but expressed in bytes, including payload and all the headers (20 bytes IPv4 + 8 bytes UDP + 16 bytes SRT). Available for sender. -Same as `pktRcvLossTotal`, but expressed in bytes, including payload and all headers (SRT+UDP+IP). \ -20 bytes IPv4 + 8 bytes of UDP + 16 bytes SRT header. Receiver side. +### byteRecvTotal -## byteRetransTotal +Same as [pktRecvTotal](#pktRecvTotal), but expressed in bytes, including payload and all the headers (20 bytes IPv4 + 8 bytes UDP + 16 bytes SRT). Available for receiver. -Same as `pktRetransTotal`, but expressed in bytes, including payload and all headers (SRT+UDP+IP). \ -20 bytes IPv4 + 8 bytes of UDP + 16 bytes SRT header. Sender side only. +### byteRcvLossTotal -## byteSndDropTotal +Same as [pktRcvLossTotal](#pktRcvLossTotal), but expressed in bytes, including payload and all the headers (20 bytes IPv4 + 8 bytes UDP + 16 bytes SRT). Bytes for the presently missing (either reordered or lost) packets' payloads are estimated based on the average packet size. Available for receiver. -Same as `pktSndDropTotal`, but expressed in bytes, including payload and all headers (SRT+UDP+IP). \ -20 bytes IPv4 + 8 bytes of UDP + 16 bytes SRT header. Sender side only. +### byteRetransTotal -## byteRcvDropTotal +Same as [pktRetransTotal](#pktRetransTotal), but expressed in bytes, including payload and all the headers (20 bytes IPv4 + 8 bytes UDP + 16 bytes SRT). Available for sender. -Same as `pktRcvDropTotal`, but expressed in bytes, including payload and all headers (SRT+UDP+IP). \ -Bytes for dropped packet payloads are estimated based on average packet size. \ -20 bytes IPv4 + 8 bytes of UDP + 16 bytes SRT header. Receiver side only. +### byteSndDropTotal -## byteRcvUndecryptTotal +Same as [pktSndDropTotal](#pktSndDropTotal), but expressed in bytes, including payload and all the headers (20 bytes IPv4 + 8 bytes UDP + 16 bytes SRT). Available for sender. -Same as `pktRcvUndecryptTotal`, but expressed in bytes, including payload and all headers (SRT+UDP+IP). \ -20 bytes IPv4 + 8 bytes of UDP + 16 bytes SRT header. Receiver side. +### byteRcvDropTotal -# Interval-based measurements +Same as [pktRcvDropTotal](#pktRcvDropTotal), but expressed in bytes, including payload and all the headers (20 bytes IPv4 + 8 bytes UDP + 16 bytes SRT). Bytes for the dropped packets' payloads are estimated based on the average packet size. Available for receiver. -These values can be reset by calling `srt_bstats(..., int clear)` with `clear = 1`. \ -This is helpful to get statistical measurements within a certain period, e.g. 1 second. +### byteRcvUndecryptTotal -## pktSent +Same as [pktRcvUndecryptTotal](#pktRcvUndecryptTotal), but expressed in bytes, including payload and all the headers (20 bytes IPv4 + 8 bytes UDP + 16 bytes SRT). Available for receiver. -Same as `pktSentTotal`, but for a specified interval. -## pktRecv +## Interval-Based Statistics -Same as `pktRecvTotal`, but for a specified interval. +### pktSent -## pktSndLoss +Same as `pktSentTotal`, but for a specified interval. Available for sender. -Same as `pktSndLossTotal`, but for a specified interval. +### pktRecv -## pktRcvLoss +Same as `pktRecvTotal`, but for a specified interval. Available for receiver. -Same as `pktRcvLossTotal`, but for a specified interval. +### pktSndLoss -## pktRetrans +Same as `pktSndLossTotal`, but for a specified interval. Available for sender. -Same as `pktRetransTotal`, but for a specified interval. +### pktRcvLoss -## pktRcvRetrans +Same as `pktRcvLossTotal`, but for a specified interval. Available for receiver. + +### pktRetrans + +Same as `pktRetransTotal`, but for a specified interval. Available for sender. + +### pktRcvRetrans Same as `pktRcvRetransTotal`, but for a specified interval. -## pktSentACK +TODO: + +- There is no `pktRcvRetransTotal` stats. +- Which side +- include in table + +### pktSentACK Same as `pktSentACKTotal`, but for a specified interval. -## pktRecvACK +TODO: Update accordingly. + +### pktRecvACK Same as `pktRecvACKTotal`, but for a specified interval. -## pktSentNAK +TODO: Update accordingly. + +### pktSentNAK Same as `pktSentNAKTotal`, but for a specified interval. -## pktRecvNAK +TODO: Update accordingly. + +### pktRecvNAK Same as `pktRecvNAKTotal`, but for a specified interval. -## pktSndFilterExtra +TODO: Update accordingly. + +### pktSndFilterExtra -Same as `pktSndFilterExtraTotal`, but for a specified interval. +Same as `pktSndFilterExtraTotal`, but for a specified interval. Sender only. Introduced in v1.4.0. Refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md). -## pktRcvFilterExtra +### pktRcvFilterExtra -Same as `pktRcvFilterExtraTotal`, but for a specified interval. +Same as `pktRcvFilterExtraTotal`, but for a specified interval. Receiver only. -Introduced in v1.4.0. Refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md). +Introduced in SRT v1.4.0. Refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md). -## pktRcvFilterSupply +### pktRcvFilterSupply -Same as `pktRcvFilterSupplyTotal`, but for a specified interval. +Same as `pktRcvFilterSupplyTotal`, but for a specified interval. Receiver only. -Introduced in v1.4.0. Refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md). +Introduced in SRT v1.4.0. Refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md). -## pktRcvFilterLoss +### pktRcvFilterLoss -Same as `pktRcvFilterLossTotal`, but for a specified interval. +Same as `pktRcvFilterLossTotal`, but for a specified interval. Receiver only. -Introduced in v1.4.0. Refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md). +Introduced in SRT v1.4.0. Refer to [SRT Packet Filtering & FEC](packet-filtering-and-fec.md). -## mbpsSendRate +### mbpsSendRate Sending rate in Mbps. Sender side. -## mbpsRecvRate +TODO: How it is calculated? + +### mbpsRecvRate Receiving rate in Mbps. Receiver side. -## usSndDuration +TODO: How it is calculated? + +### usSndDuration + +Same as `usSndDurationTotal`, but measured on a specified interval. Available for sender. -Same as `usSndDurationTotal`, but measured on a specified interval. +### pktReorderDistance -## pktReorderDistance +TODO: How it is calculated? Why it is interval based? -The distance in sequence numbers between the two original (not retransmitted) packets, -that were received out of order. Receiver only. +The distance in sequence numbers between two original (not retransmitted) packets received out of order. Receiver only. The traceable distance values are limited by the maximum reorder tolerance set by  `SRTO_LOSSMAXTTL`. -## pktReorderTolerance +### pktReorderTolerance -Instant value of the packet reorder tolerance. Receiver side. Refer to [pktReorderDistance](#pktReorderDistance). +TODO: +- Why it is in interval-based statistics? +- broken link + +Instant value of the packet reorder tolerance (refer to [pktReorderDistance](#pktReorderDistance)). Receiver side. `SRTO_LOSSMAXTTL` sets the maximum reorder tolerance value. The value defines the maximum time-to-live for the original packet, that was received after with a gap in the sequence of incoming packets. @@ -294,14 +398,16 @@ Missing packets with sequence numbers 8 and 9 will be reported lost with the nex The next received packet has sequence number 8. Reorder tolerance value is increased to 2. The packet with sequence number 9 is reported lost. +### pktRcvAvgBelatedTime - -## pktRcvAvgBelatedTime +TODO: What's this? Accumulated difference between the current time and the time-to-play of a packet that is received late. -## pktRcvBelated +### pktRcvBelated + +TODO: Revise this, which side, measured over the interval The number of packets received but IGNORED due to having arrived too late. @@ -314,266 +420,230 @@ either already acknowledged or dropped by TSBPD as too late to be delivered. Retransmitted packets can also be considered late. -## pktSndDrop +### pktSndDrop -Same as `pktSndDropTotal`, but for a specified interval. +Same as `pktSndDropTotal`, but for a specified interval. Available for sender. -## pktRcvDrop +### pktRcvDrop -Same as `pktRcvDropTotal`, but for a specified interval. +Same as `pktRcvDropTotal`, but for a specified interval. Available for receiver. -## pktRcvUndecrypt +### pktRcvUndecrypt -Same as `pktRcvUndecryptTotal`, but for a specified interval. +Same as `pktRcvUndecryptTotal`, but for a specified interval. Available for receiver. -## byteSent +### byteSent -Same as `byteSentTotal`, but for a specified interval. +Same as `byteSentTotal`, but for a specified interval. Available for sender. -## byteRecv +### byteRecv -Same as `byteRecvTotal`, but for a specified interval. +Same as `byteRecvTotal`, but for a specified interval. Available for receiver. -## byteRcvLoss +### byteRcvLoss -Same as `byteRcvLossTotal`, but for a specified interval. +Same as `byteRcvLossTotal`, but for a specified interval. Available for receiver. -## byteRetrans +### byteRetrans -Same as `byteRetransTotal`, but for a specified interval. +Same as `byteRetransTotal`, but for a specified interval. Available for sender. -## byteSndDrop +### byteSndDrop -Same as `byteSndDropTotal`, but for a specified interval. +Same as `byteSndDropTotal`, but for a specified interval. Available for sender. -## byteRcvDrop +### byteRcvDrop -Same as `byteRcvDropTotal`, but for a specified interval. +Same as `byteRcvDropTotal`, but for a specified interval. Available for receiver. -## byteRcvUndecrypt +### byteRcvUndecrypt -Same as `byteRcvUndecryptTotal`, but for a specified interval. +Same as `byteRcvUndecryptTotal`, but for a specified interval. Available for receiver. -# Instant measurements -The measurements effective at the time retrieved. +## Instantaneous Statistics -## usPktSndPeriod +### usPktSndPeriod -Current minimum time interval between which consecutive packets are sent, in -microseconds. Sender only. +TODO: -Note that several sockets sharing one outgoing port use the same sending queue. -They may have different pacing of the outgoing packets, but all the packets will -be placed in the same sending queue, which may affect the send timing. +- How is this calculated? The minimum time during which period? +- probing packets +- rephrase - They may have different pacing of the outgoing packets, but all the packets will + be placed in the same sending queue, which may affect the send timing. - who may have sockets? which may affect? -`usPktSndPeriod` is the minimum time (sending period) that must be kept +The current minimum packet inter-sending time, in microseconds. Does not take into account the probing packet pairs. Available for sender. + +`usPktSndPeriod` is the minimum time (minimum sending period) that must be kept between two packets sent consecutively over the link used by an SRT socket. It is not the EXACT time interval between two consecutive packets. In the case where the time spent by an application between sending two consecutive packets exceeds `usPktSndPeriod`, the next packet will be sent faster, or even immediately, to preserve the average sending rate. -**Note**: Does not apply to probing packets. +Note that several SRT sockets sharing one outgoing port use the same sending queue. +They may have different pacing of the outgoing packets, but all the packets will +be placed in the same sending queue, which may affect the send timing. -## pktFlowWindow +### pktFlowWindow -The maximum number of packets that can be "in flight". Sender only. -See also [pktFlightSize](#pktFlightSize). +TODO: -The value retrieved on the sender side represents an estimation of the amount -of free space in the buffer of the peer receiver. -The actual amount of available space is periodically reported back by the receiver in ACK packets. -When this value drops to zero, the next packet sent will be dropped by the receiver -without processing. In **file mode** this may cause a slowdown of sending in -order to wait until the receiver has more space available, after it -eventually extracts the packets waiting in its receiver buffer; in **live -mode** the receiver buffer contents should normally occupy not more than half -of the buffer size (default 8192). If `pktFlowWindow` value is less than that -and becomes even less in the next reports, it means that the receiver -application on the peer side cannot process the incoming stream fast enough and -this may lead to a dropped connection. +- Rephrase this - The maximum number of packets that can be "in flight" state. - it does not reflect the idea +- revise the whole paragraph +The maximum number of packets that can be "in flight" state. See also [pktFlightSize](#pktFlightSize). Available for sender. -## pktCongestionWindow +The value retrieved on the sender side represents an estimation of the amount of free space left in the SRT receiver buffer. The actual amount of available space is periodically reported back by the receiver in ACK packets. When this value drops to zero, the next packet sent (??? Received) will be dropped by the receiver without processing. -Congestion window size, in number of packets. Sender only. +In **file mode**, this may cause a slowdown of packets' sending in order to wait until the receiver has more space available, after it eventually extracts the packets waiting in its receiver buffer. In **live mode**, the receiver buffer contents should normally occupy not more than half of the buffer size (default 8192 - ??? Packets). If `pktFlowWindow` value is less than that and becomes even less in the next reports, it means that the receiver application on the peer side cannot process the incoming stream fast enough and this may lead to a dropped connection. -Dynamically limits the maximum number of packets that can be in flight. -Congestion control module dynamically changes the value. +### pktCongestionWindow -In **file mode** this value starts at 16 and is increased to the number of reported -acknowledged packets. This value is also updated based on the delivery rate, reported by the receiver. -It represents the maximum number of packets that can be safely -sent without causing network congestion. The higher this value is, the faster the -packets can be sent. In **live mode** this field is not used. +The current congestion window size, in packets. Sender only. -## pktFlightSize +The congestion window dynamically limits the maximum number of packets that can be "in flight" state. During transmission, congestion control module dynamically changes the size of congestion window. + +In **file mode**, the size of congestion control window is equal to 16 packets at the very beginning and is increased during transmision to the number of reported acknowledged packets. This value is also updated based on the delivery rate reported by the receiver. It represents the maximum number of packets that can be safely sent without causing network congestion. The higher this value is, the faster the packets can be sent. In **live mode**, this field is not used. + +### pktFlightSize The number of packets in flight. Sender only. -`pktFlightSize <= pktFlowWindow` and `pktFlightSize <= pktCongestionWindow` +The number of packets in flight is calculated as the difference between sequence numbers of the latest acknowledged packet (latest reported by an ACK message packet) and the latest sent packet at the moment statistic is being read. Note that `pktFlightSize <= pktFlowWindow` and `pktFlightSize <= pktCongestionWindow`. + +**NOTE:** ACKs are received by the SRT sender periodically at least every 10 milliseconds. This statistic is most accurate just after receiving an ACK packet and becomes a little exaggerated over time until the next ACK packet arrives. This is because with a new packet sent, while the ACK number stays the same for a moment, the value of `pktFlightSize` increases. But the exact number of packets arrived since the last ACK report is unknown. A new statistic might be added to only report the distance between the ACK sequence number and the sent packet sequence number at the moment when an ACK arrives. This statistic will not be updated until the next ACK packet arrives. The difference between the suggested statistic and `pktFlightSize` would then reveal the number of packets with an unknown state at that moment. + +### msRTT + +The estimation for the round-trip time (RTT), in milliseconds. Available both for sender and receiver. -This is the distance -between the packet sequence number that was last reported by an ACK message and -the sequence number of the latest packet sent (at the moment when the statistics -are being read). +This value is calculated by the SRT receiver based on the incoming ACKACK control packets (sent back by the SRT sender to acknowledge incoming ACKs). -**NOTE:** ACKs are received periodically (at least every 10 ms). This value is most accurate just -after receiving an ACK and becomes a little exaggerated over time until the -next ACK arrives. This is because with a new packet sent, -while the ACK number stays the same for a moment, -the value of `pktFlightSize` increases. -But the exact number of packets arrived since the last ACK report is unknown. -A new statistic might be added which only reports the distance -between the ACK sequence and the sent sequence at the moment when an ACK arrives, -and isn't updated until the next ACK arrives. The difference between this value -and `pktFlightSize` would then reveal the number of packets with an unknown state -at that moment. +TODO: peer to agent terminology, with the same journal -## msRTT +The round-trip time (RTT) is the sum of two single-trip time (STT) values: one from agent to peer, the other from peer to agent. Note that the measurement method is different the method used in TCP. SRT measures only the "reverse RTT", that is, the time measured at the receiver between sending an ACK packet until receiving back the sender's ACKACK response message (with the same journal). This happens to be a little different from the "forward RTT" measured in TCP, which is the time between sending a data packet of a particular sequence number and receiving an ACK with a sequence number that is later by 1. Forward RTT isn't being measured or reported in SRT, although some research works have shown that these values, even though they should be the same, happen to differ; "reverse RTT" seems to be more optimistic. -Calculated Round trip time (RTT), in milliseconds. Sender and Receiver. \ -The value is calculated by the receiver based on the incoming ACKACK control packets -(used by sender to acknowledge ACKs from receiver). +### mbpsBandwidth -The RTT (Round-Trip time) is the sum of two STT (Single-Trip time) -values, one from agent to peer, and one from peer to agent. Note that **the -measurement method is different than in TCP**. SRT measures only the "reverse -RTT", that is, the time measured at the receiver between sending a `UMSG_ACK` -message until receiving the sender's `UMSG_ACKACK` response message (with the -same journal). This happens to be a little different from the "forward RTT" -measured in TCP, which is the time between sending a data packet of a particular -sequence number and receiving `UMSG_ACK` with a sequence number that is later -by 1. Forward RTT isn't being measured or reported in SRT, although some -research works have shown that these values, even though they should be the same, -happen to differ; "reverse RTT" seems to be more optimistic. +The estimation of the available bandwidth of the network link, in Mbps. Available both for sender and receiver. -## mbpsBandwidth +At the protocol level, bandwidth and delivery rate estimations are calculated at the receiver side and used primarily as well as packet loss ratio and other protocol statistics for smoothed sending rate adjustments during the file transmition process (in congestion control module). This statistic is also available in live mode. -Estimated bandwidth of the network link, in Mbps. Sender only. +TODO: -The bandwidth is estimated at the receiver. -The estimation is based on the time between two probing DATA packets. -Every 16th data packet is sent immediately after the previous data packet. -By measuring the delay between probe packets on arrival, -it is possible to estimate the maximum available transmission rate, -which is interpreted as the bandwidth of the link. -The receiver then sends back a running average calculation to the sender with an ACK message. +- What about stats on sender and rcv? smoothed average? +- there is no receiving speed stats, see also mbpsRecvRate; make a note here -## byteAvailSndBuf +The receiver records the inter-arrival time of each packet (time delta with the previous data packet) which is further used in the models to estimate bandwidth and receiving speed. The communication between receiver and sender happens by means of acknowledgment packets which are sent regularly (each 10 milliseconds) and contain some control information as well as bandwidth and delivery rate estimations. At the sender side, upon receiving a new value, a smoothed average is used to update the latest estimation mantained at the sender side. -The available space in the sender's buffer, in bytes. Sender only. +It is important to note that for bandwidth estimation only data probing packets are taken into account while all the data packets (both data and data probing) are used for receiving speed estimation. The idea behind packet pair techniques is to send the groups of back-to-back packets, i.e., probing packet pairs, to a server thus making it possible to measure the minimum interval in receiving the consecutive packets. -This value decreases with data scheduled for sending by the application, and increases -with every ACK received from the receiver, after the packets are sent over -the UDP link. +### byteAvailSndBuf -## byteAvailRcvBuf +The available space in the SRT sender buffer, in bytes. Sender only. -The available space in the receiver's buffer, in bytes. Receiver only. +TODO: -This value increases after the application extracts the data from the socket -(uses one of `srt_recv*` functions) and decreases with every packet received -from the sender over the UDP link. +- increases first, decreases second or good? +- after the packets are sent over the UDP link - ? -## mbpsMaxBW +This value decreases with the data scheduled for sending by the application and increases with every ACK received from the SRT receiver after the packets are sent over the UDP link. -Transmission bandwidth limit, in Mbps. Sender only. -Usually this is the setting from -the `SRTO_MAXBW` option, which may include the value 0 (unlimited). Under certain -conditions a nonzero value might be be provided by a congestion -control module, although none of the built-in congestion control modules -currently use it. +### byteAvailRcvBuf + +The available space in the SRT receiver buffer, in bytes. Receiver only. + +TODO: SRT socket? + +This value increases after the application extracts the data from the socket (uses one of the `srt_recv*` functions) and decreases with every packet received from the SRT sender over the UDP link. + +### mbpsMaxBW + +TODO: Revise + +The transmission bandwidth limit, in Mbps. Available for sender. + +Usually this is the setting from the `SRTO_MAXBW` option, which may include the value 0 (unlimited). Under certain conditions a nonzero value might be be provided by a congestion control module, although none of the built-in congestion control modules currently use it. Refer to `SRTO_MAXBW` and `SRTO_INPUTBW` in [API.md](API.md). -## byteMSS +### byteMSS + +The maximum segment size (MSS), in bytes. Available for both sender and receiver. -Maximum Segment Size (MSS), in bytes. -Same as the value from the `SRTO_MSS` socket option. -Should not exceed the size of the maximum transmission unit (MTU), in bytes. Sender and Receiver. -The default size of the UDP packet used for transport, -including all possible headers (Ethernet, IP and UDP), is 1500 bytes. +Same as the value from the `SRTO_MSS` socket option. Should not exceed the size of the maximum transmission unit (MTU), in bytes. The default size of the UDP packet used for transport, including all possible headers (Ethernet, IP and UDP), is 1500 bytes. Refer to `SRTO_MSS` in [API.md](API.md). -## pktSndBuf +### pktSndBuf + +The number of packets in the SRT sender's buffer that are already scheduled for sending or even possibly sent, but not yet acknowledged. Available for sender. -The number of packets in the sender's buffer that are already -scheduled for sending or even possibly sent, but not yet acknowledged. -Sender only. +Once the SRT receiver acknowledges the receipt of a packet, or the Too-Late Packet Drop (TLPKTDROP) is triggered, the packet is removed from the sender's buffer. Until this happens, the packet is considered as unacknowledged. -Once the receiver acknowledges the receipt of a packet, or the TL packet drop -is triggered, the packet is removed from the sender's buffer. -Until this happens, the packet is considered as unacknowledged. +TODO: ??? -A moving average value is reported when the value is retrieved by calling -`srt_bstats(...)` or `srt_bistats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear, int instantaneous)` -with `instantaneous=false`. +A moving average value is reported when the value is retrieved by calling `srt_bstats(...)` or `srt_bistats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear, int instantaneous)` with `instantaneous=false`. The current state is returned if `srt_bistats(...)` is called with `instantaneous=true`. -The current state is returned if `srt_bistats(...)` is called with `instantaneous=true`. +### byteSndBuf -## byteSndBuf +Same as `pktSndBuf`, but expressed in bytes, including payload and all the headers (20 bytes IPv4 + 8 bytes UDP + 16 bytes SRT). Available for sender. -Instantaneous (current) value of `pktSndBuf`, but expressed in bytes, including payload and all headers (SRT+UDP+IP). \ -20 bytes IPv4 + 8 bytes of UDP + 16 bytes SRT header. Sender side. +### msSndBuf -## msSndBuf +The timespan of packets in the sender's buffer (unacknowledged packets), in milliseconds. Available for sender. -The timespan (msec) of packets in the sender's buffer (unacknowledged packets). Sender only. +A moving average value is reported when the value is retrieved by calling `srt_bstats(...)` or `srt_bistats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear, int instantaneous)` +with `instantaneous=false`. The current state is returned if `srt_bistats(...)` is called with `instantaneous=true`. -A moving average value is reported when the value is retrieved by calling -`srt_bstats(...)` or `srt_bistats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear, int instantaneous)` -with `instantaneous=false`. +### msSndTsbPdDelay -The current state is returned if `srt_bistats(...)` is called with `instantaneous=true`. +The Timestamp Based Packet Delivery (TSBPD) delay value of the peer, in milliseconds. Available for sender. -## msSndTsbPdDelay +TODO: + +- ??? +- seems to be only for sender -Timestamp-based Packet Delivery Delay value of the peer. If `SRTO_TSBPDMODE` is on (default for **live mode**), it returns the value of `SRTO_PEERLATENCY`, otherwise 0. The sender reports the TSBPD delay value of the receiver. The receiver reports the TSBPD delay of the sender. -## pktRcvBuf - -The number of acknowledged packets in receiver's buffer. Receiver only. +/// TsbpdDelay is the receiver's buffer delay (or receiver's buffer + latency, or SRT Latency). This is the time, in milliseconds, that + SRT holds a packet from the moment it has been received till the + time it should be delivered to the upstream application -This measurement does not include received but not acknowledged packets, stored in the receiver's buffer. +### pktRcvBuf -A moving average value is reported when the value is retrieved by calling -`srt_bstats(...)` or `srt_bistats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear, int instantaneous)` -with `instantaneous=false`. +The number of acknowledged packets in the receiver's buffer. Receiver only. -The current state is returned if `srt_bistats(...)` is called with `instantaneous=true`. +This statistic does not include received but not acknowledged packets stored in the receiver's buffer. -## byteRcvBuf +A moving average value is reported when the value is retrieved by calling `srt_bstats(...)` or `srt_bistats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear, int instantaneous)` +with `instantaneous=false`. The current state is returned if `srt_bistats(...)` is called with `instantaneous=true`. -Instantaneous (current) value of `pktRcvBuf`, expressed in bytes, including payload and all headers (SRT+UDP+IP). \ -20 bytes IPv4 + 8 bytes of UDP + 16 bytes SRT header. Receiver side. +### byteRcvBuf -## msRcvBuf +The instantaneous value of `pktRcvBuf`, expressed in bytes, including payload and all the headers (20 bytes IPv4 + 8 bytes UDP + 16 bytes SRT). Available for receiver. -The timespan (msec) of acknowledged packets in the receiver's buffer. Receiver side. +### msRcvBuf -If TSBPD mode is enabled (defualt for **live mode**), -a packet can be acknowledged, but not yet ready to play. -This range includes all packets regardless of whether -they are ready to play or not. +The timespan of acknowledged packets in the receiver's buffer, in milliseconds. Available for receiver. -A moving average value is reported when the value is retrieved by calling -`srt_bstats(...)` or `srt_bistats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear, int instantaneous)` -with `instantaneous=false`. +If TSBPD mode is enabled (defualt for **live mode**), a packet can be acknowledged, but not yet ready to play. +This range includes all packets regardless of whether they are ready to play or not. -The current state is returned if `srt_bistats(...)` is called with `instantaneous=true`. +A moving average value is reported when the value is retrieved by calling `srt_bstats(...)` or `srt_bistats(SRTSOCKET u, SRT_TRACEBSTATS * perf, int clear, int instantaneous)` +with `instantaneous=false`. The current state is returned if `srt_bistats(...)` is called with `instantaneous=true`. Instantaneous value is only reported if TSBPD mode is enabled, otherwise 0 is reported (see #900). -## msRcvTsbPdDelay +### msRcvTsbPdDelay -Timestamp-based Packet Delivery Delay value set on the socket via `SRTO_RCVLATENCY` or `SRTO_LATENCY`. -The value is used to apply TSBPD delay for reading the received data on the socket. Receiver side. +The Timestamp Based Packet Delivery (TSBPD) delay value set on the socket via `SRTO_RCVLATENCY` or `SRTO_LATENCY`, in milliseconds. Available for receiver. -If `SRTO_TSBPDMODE` is off (default for **file mode**), 0 is returned. +The value is used to apply TSBPD delay for reading the received data on the socket. +If `SRTO_TSBPDMODE` is off (default for **file mode**), 0 is returned. \ No newline at end of file