The following event flow describes basic synchronization of PTP:
-
The master sends a Sync message to the
slave, notes the time (t1) it was sent, and embeds the t1 time in the
message.
-
The slave receives the Sync message, and notes the time
it is received (t2).
-
The master conveys to the slave the timestamp t1 either by
(1) embedding the timestamp t1 in the Sync message (this requires hardware processing for
highest accuracy and precision, and is called as one step clocking) or by (2) embedding
the timestamp t1 in a Follow_Up message (this is called as two step clocking).
-
The slave sends a DelayReq message to the master, and
notes the time (t3) it was sent.
-
The master receives the DelayReq message, and notes the
time it is received (t4).
-
The master embeds the t4 timestamp in a DelayResp message
to the slave.
At the conclusion of this exchange of messages, the slave possesses
all four timestamps. You can use these timestamps to compute the offset of the slave‘s
clock with respect to the master, and the mean propagation time of messages between the
two clocks.
The formula to compute the offset is as follows:
- master_to_slave_delay = offset + delay = t2 – t1
- slave_to_master_delay = offset − delay = t4 – t3
- one_way_delay = (master_to_slave_delay +
slave_to_master_delay) / 2
The calculation for the offset from the master is as follows: offset_from_master =
t2 - t1 - one_way_delay.
Note
The above explanation for offset calculation is provided simply
for understanding the basic PTP protocol. The actual calculations involve many more
variables.
The computation of offset and propagation time assumes
that the master-to-slave and slave-to-master propagation times are
equal. Any asymmetry in propagation time introduces an error in
the computed value of the clock offset.