order to improve the accuracy of the clock. They can be selected and used for
synchronisation only if they agree with the trusted and required source.
*xleave*:::
-This option enables an interleaved mode which enables the server to
-send transmit timestamps captured after the actual transmission (e.g. when the
-server is running *chronyd* with software (kernel) or hardware
-timestamping). This can significantly improve the accuracy of the measurements.
+This option enables the interleaved mode of NTP. It enables the server to
+respond with more accurate transmit timestamps (e.g. kernel or hardware
+timestamps), which cannot be contained in the transmitted packet itself and
+need to refer to a previous packet instead. This can significantly improve the
+accuracy and stability of the measurements.
+
The interleaved mode is compatible with servers that support only the basic
mode. Note that even
smooth_time = 0;
smooth_offset = 0.0;
+ /* Get an initial transmit timestamp. A more accurate timestamp will be
+ taken later in this function. */
+ SCH_GetLastEventTime(&local_transmit, NULL, NULL);
+
if (my_mode == MODE_CLIENT) {
/* Don't reveal local time or state of the clock in client packets */
precision = 32;
our_root_delay = our_root_dispersion = 0.0;
UTI_ZeroTimespec(&our_ref_time);
} else {
- /* This is accurate enough and cheaper than calling LCL_ReadCookedTime.
- A more accurate timestamp will be taken later in this function. */
- SCH_GetLastEventTime(&local_transmit, NULL, NULL);
-
REF_GetReferenceParams(&local_transmit,
&are_we_synchronised, &leap_status,
&our_stratum,
/* Prepare random bits which will be added to the transmit timestamp */
UTI_GetNtp64Fuzz(&ts_fuzz, precision);
- /* Transmit - this our local time right now! Also, we might need to
- store this for our own use later, next time we receive a message
- from the source we're sending to now. */
- LCL_ReadCookedTime(&local_transmit, &local_transmit_err);
-
- if (smooth_time)
- UTI_AddDoubleToTimespec(&local_transmit, smooth_offset, &local_transmit);
-
- /* Pre-compensate the transmit time by approximately how long it will take
- to generate the authentication data */
- if (auth)
- NAU_AdjustRequestTimestamp(auth, &local_transmit);
- else
- NAU_AdjustResponseTimestamp(request, request_info, &local_transmit);
+ /* Get a more accurate transmit timestamp if it needs to be saved in the
+ packet (i.e. in the server, symmetric, and broadcast basic modes) */
+ if (!interleaved && precision < 32) {
+ LCL_ReadCookedTime(&local_transmit, &local_transmit_err);
+ if (smooth_time)
+ UTI_AddDoubleToTimespec(&local_transmit, smooth_offset, &local_transmit);
+
+ /* Pre-compensate the transmit time by approximately how long it will
+ take to generate the authentication data */
+ if (auth)
+ NAU_AdjustRequestTimestamp(auth, &local_transmit);
+ else
+ NAU_AdjustResponseTimestamp(request, request_info, &local_transmit);
+ }
UTI_TimespecToNtp64(interleaved ? &local_tx->ts : &local_transmit,
&message.transmit_ts, &ts_fuzz);
return 0;
}
+ /* If the transmit timestamp will be saved, get an even more
+ accurate daemon timestamp closer to the transmission */
+ if (local_tx)
+ LCL_ReadCookedTime(&local_transmit, &local_transmit_err);
+
ret = NIO_SendPacket(&message, where_to, from, info.length, local_tx != NULL);
if (local_tx) {
+ if (smooth_time)
+ UTI_AddDoubleToTimespec(&local_transmit, smooth_offset, &local_transmit);
local_tx->ts = local_transmit;
local_tx->err = local_transmit_err;
local_tx->source = NTP_TS_DAEMON;