The Precision Time Protocol (PTP) is a protocol used to synchronize clocks throughout a computer network. On a local area network, it achieves clock accuracy in the sub-microsecond range, making it suitable for measurement and control systems.[1] PTP is employed to synchronize financial transactions, mobile phone tower transmissions, sub-sea acoustic arrays, and networks that require precise timing but lack access to satellite navigation signals.
The first version of PTP, IEEE 1588-2002, was published in 2002. IEEE 1588-2008, also known as PTP Version 2, is not backward compatible with the 2002 version. IEEE 1588-2019 was published in November 2019 and includes backward-compatible improvements to the 2008 publication. IEEE 1588-2008 includes a profile concept defining PTP operating parameters and options. Several profiles have been defined for applications including telecommunications, electric power distribution and audiovisual uses. is an adaptation of PTP for use with Audio Video Bridging and Time-Sensitive Networking.
According to John Eidson, who led the IEEE 1588-2002 standardization effort, "IEEE 1588 is designed to fill a niche not well served by either of the two dominant protocols, NTP and GPS. IEEE 1588 is designed for local systems requiring accuracies beyond those attainable using NTP. It is also designed for applications that cannot bear the cost of a GPS receiver at each node, or for which GPS signals are inaccessible."[2]
PTP was originally defined in the IEEE 1588-2002 standard, officially entitled Standard for a Precision Clock Synchronization Protocol for Networked Measurement and Control Systems, and published in 2002. In 2008, IEEE 1588-2008 was released as a revised standard; also known as PTP version 2 (PTPv2), it improves accuracy, precision and robustness but is not backward compatible with the original 2002 version.[3] IEEE 1588-2019 was published in November 2019,[4] is informally known as PTPv2.1 and includes backwards-compatible improvements to the 2008 publication.[5]
The IEEE 1588 standards describe a hierarchical master–slave architecture for clock distribution. Under this architecture, a time distribution system consists of one or more communication media (network segments), and one or more clocks. An ordinary clock is a device with a single network connection and is either the source of (master or leader) or destination for (slave or follower) a synchronization reference. A boundary clock has multiple network connections and can accurately synchronize one network segment to another. A synchronization master is selected for each of the network segments in the system. The root timing reference is called the grandmaster.[6] The grandmaster transmits synchronization information to the clocks residing on its network segment. The boundary clocks with a presence on that segment then relay accurate time to the other segments to which they are also connected.
A simplified PTP system frequently consists of ordinary clocks connected to a single network, and no boundary clocks are used. A grandmaster is elected and all other clocks synchronize directly to it.
IEEE 1588-2008 introduces a clock associated with network equipment used to convey PTP messages. The transparent clock modifies PTP messages as they pass through the device.[7] Timestamps in the messages are corrected for time spent traversing the network equipment. This scheme improves distribution accuracy by compensating for delivery variability across the network.
PTP typically uses the same epoch as Unix time (start of 1 January 1970). While the Unix time is based on Coordinated Universal Time (UTC) and is subject to leap seconds, PTP is based on International Atomic Time (TAI). The PTP grandmaster communicates the current offset between UTC and TAI, so that UTC can be computed from the received PTP time.
Synchronization and management of a PTP system is achieved through the exchange of messages across the communications medium. To this end, PTP uses the following message types.
Messages are categorized as event and general messages. Event messages are time-critical in that accuracy in transmission and receipt timestamp accuracy directly affects clock distribution accuracy. Sync, Delay_Req, Pdelay_Req and Pdelay_resp are event messages. General messages are more conventional protocol data units in that the data in these messages is of importance to PTP, but their transmission and receipt timestamps are not. Announce, Follow_Up, Delay_Resp, Pdelay_Resp_Follow_Up, Management and Signaling messages are members of the general message class.
PTP messages may use the User Datagram Protocol over Internet Protocol (UDP/IP) for transport. IEEE 1588-2002 uses only IPv4 transports, but this has been extended to include IPv6 in IEEE 1588-2008. In IEEE 1588-2002, all PTP messages are sent using multicast messaging, while IEEE 1588-2008 introduced an option for devices to negotiate unicast transmission on a port-by-port basis. Multicast transmissions use IP multicast addressing, for which multicast group addresses are defined for IPv4 and IPv6 (see table). Time-critical event messages (Sync, Delay_req, Pdelay_Req and Pdelay_Resp) are sent to port number 319. General messages (Announce, Follow_Up, Delay_Resp, Pdelay_Resp_Follow_Up, management and signaling) use port number 320.
+ Multicast group addresses | |||||
Messages | IPv4 | IPv6 | IEEE 802.3 Ethernet | Type | |
---|---|---|---|---|---|
All except peer delay messages | 224.0.1.129 | FF0x::181 | 01-1B-19-00-00-00 | Forwardable | |
Peer delay messages: Pdelay_Req, Pdelay_Resp and Pdelay_Resp_Follow_Up | 224.0.0.107 | FF02::6B | 01-80-C2-00-00-0E | Non-forwardable |
In IEEE 1588-2008, encapsulation is also defined for DeviceNet, ControlNet and PROFINET.
A domain is an interacting set of clocks that synchronize to one another using PTP. Clocks are assigned to a domain by virtue of the contents of the Subdomain name (IEEE 1588-2002) or the domainNumber (IEEE 1588-2008) fields in PTP messages they receive or generate. Domains allow multiple clock distribution systems to share the same communications medium.
Subdomain name field contents | IPv4 multicast address | domainNumber | Notes | |
---|---|---|---|---|
_DFLT | 224.0.1.129 | 0 | Default domain | |
_ALT1 | 224.0.1.130 | 1 | Alternate domain 1 | |
_ALT2 | 224.0.1.131 | 2 | Alternate domain 2 | |
_ALT3 | 224.0.1.132 | 3 | Alternate domain 3 | |
Application specific up to 15 octets | 224.0.1.130, 131 or 132 as per hash function on Subdomain name | 4 through 127 | User-defined domains |
The best master clock algorithm (BMCA) performs a distributed selection of the best candidate clock based on the following clock properties:
IEEE 1588-2008 uses a hierarchical selection algorithm based on the following properties, in the indicated order:
IEEE 1588-2002 uses a selection algorithm based on similar properties.
Clock properties are advertised in IEEE 1588-2002 Sync messages and in IEEE 1588-2008 Announce messages. The current clock master transmits this information at regular interval. A clock which considers itself a better master clock will transmit this information in order to invoke a change of master clock. Once the current master recognises the better clock, the current master stops transmitting Sync messages and associated clock properties (Announce messages in the case of IEEE 1588-2008) and the better clock takes over as master. The BMC algorithm only considers the self-declared quality of clocks and does not take network link quality into consideration.
Through use of the BMC algorithm, PTP selects a master source of time for an IEEE 1588 domain and for each network segment in the domain.
Clocks determine the offset between themselves and their master.[8] Let the variable
t
o(t)
t
o(t)=s(t)-m(t)
where
s(t)
t
m(t)
t
The master periodically broadcasts the current time as a message to the other clocks. Under IEEE 1588-2002 broadcasts are up to once per second. Under IEEE 1588-2008, up to 10 per second are permitted.
Each broadcast begins at time
T1
T1'
The master may subsequently send a multicast Follow_Up with accurate
T1
T1
In order to accurately synchronize to their master, clocks must individually determine the network transit time of the Sync messages. The transit time is determined indirectly by measuring round-trip time from each clock to its master. The clocks initiate an exchange with their master designed to measure the transit time
d
T2
T2'
T2'
Through these exchanges a clock learns
T1
T1'
T2
T2'
If
d
\tilde{o}
T1'-T1=\tilde{o}+dand T2'-T2=-\tilde{o}+d
Combining the above two equations, we find that
\tilde{o}=
1 | |
2 |
(T1'-T1-T2'+T2)
The clock now knows the offset
\tilde{o}
One assumption is that this exchange of messages happens over a period of time so small that this offset can safely be considered constant over that period. Another assumption is that the transit time of a message going from the master to a slave is equal to the transit time of a message going from the slave to the master. Finally, it is assumed that both the master and slave can accurately measure the time they send or receive a message. The degree to which these assumptions hold true determines the accuracy of the clock at the slave device.
IEEE 1588-2008 standard lists the following set of features that implementations may choose to support:
IEEE 1588-2019 adds additional optional and backward-compatible features:[5]