Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Improved SND dropping mechanism #2791

Closed
wants to merge 0 commits into from

Conversation

yomnes0
Copy link
Collaborator

@yomnes0 yomnes0 commented Aug 31, 2023

As stated in #1910, dropping mechanism was using buffer timespan to decide when to drop packets. This new mechanism is based on SRT latency and RTT, and should only drop packets that have no chance to make it through the network

@yomnes0 yomnes0 marked this pull request as ready for review August 31, 2023 15:23
Copy link
Collaborator

@maxsharabayko maxsharabayko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #2230 introduced (SRT v1.5.0) the CSndBuffer::getBufferingDelay(const time_point& tnow) function. The function returns the delay (oldness) of the oldest (the very first) packet in the SRT buffer towards the current time.
The CSndBuffer::getFirstPacketTS() function introduced in this PR does the same, just returns the time instead of the delay.

The logical changes in this PR are:

  • threshold accuracy changed from ms to microseconds.
  • the threshold is increased from m_iPeerTsbPdDelay_ms + 20ms to iPeerTsbPdDelay_us + (duration(m_iSRTT/2))
  • m_config.iSndDropDelay (SRTO_SNDDROPDELAY) is now ignored (❗)

The effective change is only

index 0e3cce0..6d24c08 100644
--- a/srtcore/core.cpp
+++ b/srtcore/core.cpp
@@ -6375,7 +6378,7 @@ int srt::CUDT::sndDropTooLate()
     // XXX Make SRT_TLPKTDROP_MINTHRESHOLD_MS option-configurable
     const int threshold_ms = (m_config.iSndDropDelay >= 0)
         ? std::max(m_iPeerTsbPdDelay_ms + m_config.iSndDropDelay, +SRT_TLPKTDROP_MINTHRESHOLD_MS)
-            + (2 * COMM_SYN_INTERVAL_US / 1000)
+            + (m_iSRTT / 2 / 1000)
         : 0;

     if (threshold_ms == 0 || buffdelay_ms <= threshold_ms)

Probably SRT_TLPKTDROP_MINTHRESHOLD_MS can be removed then (it seems to be a workaround for smaller latencies) if testing confirms no side effects at small SRT latencies and RTT values < 1 ms.

srtcore/core.cpp Outdated
have no chance to make it through the network
RTT/2 is used instead of OWD, further developments are needed to handle networks that are not symmetrical*/

duration iPeerTsbPdDelay_us(m_iPeerTsbPdDelay_ms*1000);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you know that duration defaults to microseconds?

srtcore/core.cpp Outdated

time_point time_to_drop(first_pkt_ts);
time_point threshold_us = first_pkt_ts + iPeerTsbPdDelay_us - (duration(m_iSRTT/2));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes the possibility to override this value by the setting of the SRTO_SNDDROPDELAY option available here as m_config.iSndDropDelay field. Maybe the rules for setting this option and whether and how it overrides this threshold value can be changed, but it should still be used.

ScopedLock lck(m_BufLock);
SRT_ASSERT(m_pFirstBlock);
if (m_iCount == 0)
return time_point(0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time_point(0) -> time_point().
Then you'll need to check if (first_pkt_ts != time_point()).
But might be better to keep using the CSndBuffer::getBufferingDelay(..) function.

@maxsharabayko maxsharabayko added this to the v1.6.0 milestone Sep 4, 2023
@maxsharabayko maxsharabayko added Type: Bug Indicates an unexpected problem or unintended behavior [core] Area: Changes in SRT library core Type: Maintenance Work required to maintain or clean up the code and removed Type: Bug Indicates an unexpected problem or unintended behavior labels Sep 4, 2023
@yomnes0 yomnes0 closed this Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Maintenance Work required to maintain or clean up the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants