ntp: apply HW TX/RX compensation to system time

Apply the compensation to the cooked local time instead of HW time. This
might make a difference when the HW clock has a large frequency error.
This commit is contained in:
Miroslav Lichvar 2017-06-15 11:16:57 +02:00
parent 39da10d939
commit db93180ce1

View file

@ -451,14 +451,14 @@ process_hw_timestamp(struct Interface *iface, struct timespec *hw_ts,
UTI_AddDoubleToTimespec(hw_ts, rx_correction, hw_ts);
}
if (!rx_ntp_length && iface->tx_comp)
UTI_AddDoubleToTimespec(hw_ts, iface->tx_comp, hw_ts);
else if (rx_ntp_length && iface->rx_comp)
UTI_AddDoubleToTimespec(hw_ts, -iface->rx_comp, hw_ts);
if (!HCL_CookTime(iface->clock, hw_ts, &ts, &local_err))
return;
if (!rx_ntp_length && iface->tx_comp)
UTI_AddDoubleToTimespec(&ts, iface->tx_comp, &ts);
else if (rx_ntp_length && iface->rx_comp)
UTI_AddDoubleToTimespec(&ts, -iface->rx_comp, &ts);
ts_delay = UTI_DiffTimespecsToDouble(&local_ts->ts, &ts);
if (fabs(ts_delay) > MAX_TS_DELAY) {