Two machines can estimate their clock difference by exchanging timestamped messages.
Step through the process below, or let it play automatically.
Calculation
Collected timestamps
t1 = ?
t2 = ?
t3 = ?
t4 = ?
The problem — why can't we just compare clocks?
(t2 − t1) = ?
← this is NOT the pure offset; it's offset + forward delay
(t3 − t4) = ?
← also not pure offset; it's offset − return delay
Each measurement mixes the offset we want with an unknown one-way delay we can't measure!
The trick — add both directions so the unknown delays cancel
What each measurement really contains:
(t2 − t1) = offset + delay→
(t3 − t4) = offset − delay←
Add them together:
(t2 − t1) + (t3 − t4) = (offset + delay→) + (offset − delay←)
= 2·offset + delay→ − delay← ← delays cancel when equal!
= 2·offset (when delay→ = delay←)
The offsets ADD UP (both +offset), while the delays have opposite signs (+delay→, −delay←) and cancel! Divide by 2:
offset = ((t2 − t1) + (t3 − t4)) / 2
= (? + ?) / 2
= ?
This is exact when delay→ = delay←. Any asymmetry causes error = (delay→ − delay←) / 2.
How confident are we? — round-trip delay as a quality measure
RTT = (t4 − t1) − (t3 − t2)
= (?) − (?)
= ?
RTT is not used in the offset formula — it tells us the maximum possible error (RTT/2).
A smaller RTT means a tighter bound on accuracy. NTP picks the sample with the lowest RTT.
Accuracy check
True offset: ? |
Estimated: ? |
Error: ?