[ntpwg] On-wire protocol
David L. Mills
mills at udel.edu
Fri Jun 29 01:15:52 UTC 2007
Guys,
Several people have pointed out errors in the on-wire description and
Figure 17. Some said it hard to follow. As a word description would be
hard for the editors to follow, I have provided replacements for the
diagram and paragraphs immediately before and after it. I have also
included the transmit replay provision mentioned in previous messages.
Somebody else should copycheck and verify that I'm not having a bad
dream. This is the kind of thing you can (and I have) read it many times
and still fail to spot nits.
For amusement: prepare a paper triangle with equal sides six inches.
Print with bold font three lines: top "Paris", middle "in the", bottom
"the spring". Sic, read that again carefully. Now ask your friends to
read it. Ask them several times until they get it. Works on just about
everybody.
Dave
=============================================================================
The on-wire protocol uses four timestamps numbered t1 through t4 and
three state variables, org, rec and xmt, as shown in Figure 17. This
figure shows the most general case where each of two peers A and B
independently measure the offset and delay relative to the other. For
purposes of illustration the packet timestamps are shown in lower case,
while the state variables are shown in upper case. The state variables
are copied from the packet timestamps upon arrival or departure of a packet.
t2 t3 t6 t7
+---------+ +---------+ +---------+ +---------+
| 0 | | t1 | | t3 | | t5 |
+---------+ +---------+ +---------+ +---------+
| 0 | | t2 | | t4 | | t6 | Packet
+---------+ +---------+ +---------+ +---------+ Timestamps
| t1 | |t3=clock | | t5 | |t7=clock |
+---------+ +---------+ +---------+ +---------+
|t2=clock | |t6=clock |
+---------+ +---------+
Peer B
+---------+ +---------+ +---------+ +---------+
org | T1 | | T1 | | t5<>T1? | | T5 |
+---------+ +---------+ +---------+ +---------+ State
rec | T2 | | T2 | | T6 | | T6 | Variables
+---------+ +---------+ +---------+ +---------+
xmt | 0 | | T3 | | t3=T3? | | T7 |
+---------+ +---------+ +---------+ +---------+
t2 t3 t6 t7
---------------------------------------------------------
/\ \ /\ \
/ \ / \
/ \ / \
/ \/ / \/
---------------------------------------------------------
t1 t4 t5 t8
t1 t4 t5 t8
+---------+ +---------+ +---------+ +---------+
| 0 | | t1 | | t3 | | t5 |
+---------+ +---------+ +---------+ +---------+
| 0 | | t2 | | t4 | | t6 | Packet
+---------+ +---------+ +---------+ +---------+ Timestamps
|t1=clock | | t3 | |t5=clock | | t7 |
+---------+ +---------+ +---------+ +---------+
|t4=clock | |t8=clock |
+---------+ +---------+
Peer A
+---------+ +---------+ +---------+ +---------+
org | 0 | | t3<>0? | | T3 | | t7<>T3? |
+---------+ +---------+ +---------+ +---------+ State
rec | 0 | | T4 | | T4 | | T8 | Variables
+---------+ +---------+ +---------+ +---------+
xmt | T1 | | t1=T1? | | T5 | | t5=T5? |
+---------+ +---------+ +---------+ +---------+
Figure 17: On-Wire Protocol
In the figure the first packet transmitted by A contains only the origin
timestamp t1, which is then copied to T1. B receives the packet at t2
and copies t1 to T1 and the receive timestamp t2 to T2. At this time or
some time later at t3, B sends a packet to A containing t1 and t2 and in
addition the transmit timestamp t3. All three timestamps are copied to
the corresponding state variables. A receives the packet at t4
containing the three timestamps t1, t2 and t3 and in addition the
destination timestamp t4. These four timestamps are used to compute the
offset and delay of B relative to A, as described below.
Before the xmt and org state variables are updated, two sanity checks
are performed in order to protect against duplicate, bogus or replayed
packets. In the exchange above, a packet is duplicate or replay if the
transmit timestamp t3 in the packet matches the org state variable T3. A
packet is bogus if the origin timestamp t1 in the packet does not match
the xmt state variable T1. In either of these cases the state variables
are updated, then the packet is discarded. To protect against replay of
the last transmitted packet, the xmt state variable is set to zero
immediately after a successful bogus check.
More information about the ntpwg
mailing list