Documentation
¶
Overview ¶
Package timesync computes the clock offset and round-trip delay between two hosts from the four-timestamp NTP exchange (DESIGN.md §10, ADR-0010). It is the math seam for one-way-delay measurement: the controller stamps t1/t4 and the agent stamps t2/t3, and these functions turn the four into an offset and delay. The package is pure — no I/O, no clock — so it is trivially testable.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delay ¶
Delay returns the round-trip network delay in nanoseconds (the total time on the wire, excluding the remote's processing time t3-t2) from the four NTP timestamps described in Offset.
func Offset ¶
Offset returns the estimated offset of the remote clock relative to the local clock, in nanoseconds, from the four NTP timestamps:
t1 — local send time t2 — remote receive time t3 — remote send time t4 — local receive time
A positive offset means the remote clock is ahead of the local clock. The estimate assumes the network delay is symmetric.