The estimation of NTP time offset between a local system and a remote system using RTCP XR (Extended Reports) RRTR and DLRR blocks involves two main steps: Round-Trip Time (RTT) calculation and NTP Offset estimation.
The flow is as follows (RFC 3611):
last_rr: The middle 32 bits of the $T_1$ timestamp from the received RRTR.delay_since_last_rr: The time elapsed between receiving the RRTR and sending the DLRR ($D = T_3 - T_2$).The RTT is calculated in RTCPReceiver::HandleXrDlrrReportBlock (in modules/rtp_rtcp/source/rtcp_receiver.cc) as: $$RTT = (T_4 - T_1) - ext{delay_since_last_rr}$$ In code, this uses compact NTP representation (1/2^16 seconds resolution).
Once the RTT is known, it is used along with Sender Reports (SR) to estimate the NTP offset between the remote and local clocks. This logic is implemented in RemoteNtpTimeEstimator::UpdateRtcpTimestamp (in modules/rtp_rtcp/source/remote_ntp_time_estimator.cc).
This offset is inserted into a smoothing filter (ntp_clocks_offset_estimator_).
The estimated offset is used by:
RemoteNtpTimeEstimator::EstimateNtp: To convert RTP timestamps to receiver-local NTP time.CaptureClockOffsetUpdater: To adjust Absolute Capture Time extensions in RTP packets, allowing the receiver to know the exact capture time in its own NTP clock.modules/rtp_rtcp/source/rtcp_receiver.cc: HandleXrDlrrReportBlock - RTT calculation logic.modules/rtp_rtcp/source/remote_ntp_time_estimator.cc: UpdateRtcpTimestamp - NTP offset estimation.modules/rtp_rtcp/source/ntp_time_util.h: NTP conversion helpers like CompactNtp, ToNtpUnits, and CompactNtpRttToTimeDelta.