Skip to content

Commit

Permalink
[core] Init reorder tolerance with maximum value.
Browse files Browse the repository at this point in the history
See #901.
  • Loading branch information
maxsharabayko authored and rndi committed Nov 5, 2019
1 parent 2b34c21 commit 4070ff3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
39 changes: 24 additions & 15 deletions docs/statistics.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ and are not exchanged between peers, unless explicitly stated.

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.

* `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

## msTimeStamp
Expand Down Expand Up @@ -39,22 +39,22 @@ The total number of data packets detected lost on the receiver's side.

Includes packets that failed to be decrypted (only as of SRT version 1.4.0).

If a packet was received out of order, the gap (sequence discontinuity) is also
If a packet was received out of order, the gap (sequence discontinuity) is also
treated as lost packets, independent of the reorder tolerance value.

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
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.

## pktRetransTotal

The total number of retransmitted packets. Calculated on the sender's side only.
The total number of retransmitted packets. Calculated on the sender's side only.
Not exchanged with the receiver.

## pktSentACKTotal
Expand Down Expand Up @@ -256,12 +256,21 @@ Same as `usSndDurationTotal`, but measured on a specified interval.

## pktReorderDistance

`SRTO_LOSSMAXTTL` sets the maximum reorder tolerance value. The internal algorithm
checks the order of incoming packets and adjusts the tolerance based on the reorder
The distance in sequence numbers between the two original (not retransmitted) packets,
that were received out of order. Receiver only.

The traceable distance values are limited by the maximum reorder tolerance set by  `SRTO_LOSSMAXTTL`.
`SRTO_LOSSMAXTTL` sets the maximum reorder tolerance value, or the time-to-live for the original packet,
that was received after with a gap in the sequence of incoming packets. Those missing packets
are expected to come out of order, therefore no loss is reported.
The TTL value specifies the number of packet to receive further, before considering the preceding packets lost,
and sending the loss report.

The internal algorithm checks the order of incoming packets and adjusts the tolerance based on the reorder
distance, but not to a value higher than the maximum.

SRT starts from 0 tolerance. Once it receives the first
reordered packet, it increases the tolerance to the distance in the sequence
SRT starts from tolerance value set in `SRTO_LOSSMAXTTL` (initial tolerance is set to 0 in SRT v1.4.0 and prior versions).
Once the receiver receives the first reordered packet, it increases the tolerance to the distance in the sequence
discontinuity of the two packets. \
After 10 consecutive original (not retransmitted) packets come in order, the reorder distance
is decreased by 1 for every such packet.
Expand Down
3 changes: 3 additions & 0 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ CUDT::CUDT(const CUDT &ancestor)
m_bTLPktDrop = ancestor.m_bTLPktDrop;
m_bMessageAPI = ancestor.m_bMessageAPI;
m_iIpV6Only = ancestor.m_iIpV6Only;
m_iReorderTolerance = ancestor.m_iMaxReorderTolerance; // Initialize with maximum value
m_iMaxReorderTolerance = ancestor.m_iMaxReorderTolerance;
// Runtime
m_bRcvNakReport = ancestor.m_bRcvNakReport;
Expand Down Expand Up @@ -708,6 +709,8 @@ void CUDT::setOpt(SRT_SOCKOPT optName, const void *optval, int optlen)

case SRTO_LOSSMAXTTL:
m_iMaxReorderTolerance = *(int *)optval;
if (!m_bConnected)
m_iReorderTolerance = m_iMaxReorderTolerance;
break;

case SRTO_VERSION:
Expand Down

0 comments on commit 4070ff3

Please sign in to comment.