-
Notifications
You must be signed in to change notification settings - Fork 861
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
Drift Tracer: RTT samples are now taken into account when calculating the clock drift #1965
Drift Tracer: RTT samples are now taken into account when calculating the clock drift #1965
Conversation
Without RTT Adjustment (SRT v1.4.3 and prior)Experiment set up
ResultsChanging RTT changes end-to-end latency (roughly +225ms). |
With RTT Adjustments (SRT v1.4.4)Experiment set up
ResultsChanging RTT does not change end-to-end latency. |
This comment has been minimized.
This comment has been minimized.
42c36ed
to
c919802
Compare
c919802
to
b613028
Compare
b613028
to
36cdfa7
Compare
So after this patch, drift tracer will only reflect the change of clock drift, will not be affected by network latency? |
Two steady clocks also drift. The drift, in this case, will be monotonic by nature: an increasing or decreasing trend. Therefore, the drift tracer is needed in any case. |
Got it, but the initial |
@gou4shi1 If network latency changes, we assume this change is reflected in the change of RTT, and compensate it. |
For example, the initial |
Actually my question is: |
The end-to-end latency is formed once the handshake is made (CONCLUSION phase) as: There is an idea for a feature request to add a possibility for a user to specify the desired target end-to-end latency. That would require SRT to determine RTT based on the Handshake exchange delays, and extract it from the buffering delay. There is also another FR #2016 to add a possibility for a user to have an estimate of the actual end-to-end latency. |
Got it, thanks for your explanation :) |
RTT samples are now taken into account when calculating the clock drift.
Drift Estimation
TSBPD time base is the base time difference between the local clock of the receiver, and the clock used by the sender to timestamp packets being sent.
It is first initialized with the reception of the conclusion handshake as follows:
where
Tnow
is the time the HS packet is received (current time),usPktTimeStamp
is the timestamp set on the packet.For any further packet with its
usPktTimeStamp
corresponding to the sending time (only true for control packets), It is assumed that:Any consistent difference is caused by the drift of the two clocks (SND and RCV).
Therefore, drift is measured on every incoming ACKACK control packet as:
However, the formula does not take possible network delay change into account. Longer or shorter journeys on the net result is a shift of the arrival time.
Taking RTT Sample into Account
RTT sample is measured on every ACK-ACKACK pair. Therefore, it is available at the time of drift sample estimation. RTT sample can be used to estimate the change in one-way network delay (SND->RCV) as:
where RTT0 is the first know RTT sample. Ideally, it should be estimated at the handshaking stage, but this is not yet implemented. The very first RTT measurement is taken instead with an assumption that it is close to the initial RTT.
Thus,
usRTTDelta / 2
is assumed to roughly correspond to the change of the one-way network delay. This is of course close to the actual value for symmetric networks, but might be far from the truth for asymmetric networks. However, it is the best guess available.So, this PR changes drift sample estimation to:
Notes
Fixes #753, #984.
Refactoring extracted to PR #1968. TSBPD and clock drift tracing logic are moved to a separate class
CTsbpdTime
. It should also provide a cleaner update of #1964.TODO
CTsbpdTime
), 2) RTT usage in Drift.