• Ei tuloksia

Precision Time Protocol IEEE 1588

Precision Time Protocol is a clock synchronization solution for distributed systems and it is described in IEEE 1588 standard. The first version of PTP was approved in 2002 and was called IEEE 1588-2002. Second version was named IEEE 1588-2008 and it was approved in 2008. This was the version that was widely deployed and is used currently.

The protocol was designed originally for testing systems, but it is now used also with real-time control systems and telecommunications equipment. [24]

PTP and NTP protocols both uses time stamping for calculating time differences be-tween devices. PTP uses software-based and hardware-based time stamping methods.

This means that synchronization messages or timestamping are implemented in soft-ware or hardsoft-ware level. This is one of the main reasons why PTP can provide accuracy in nanosecond range inside a local network. More precise, stamping is ideally done at physical layer (PHY) but usually it is done at Media-Independent Interface (MII) of the PHY. MII is used to connect a MAC block to a PHY chip and therefore the stamping is happening close to the link of a node as shown in Figure 2.5. [24, 25]

Figure 2.5.Generation of a timestamp

PTP network has usually multiple nodes that uses different clock-modes. PTP uses usu-ally three different kinds of clocks such as ordinary clock (OC), boundary clock (BC) and transparent clock (TC). Ordinary clock has one PTP port and it could be used as a master clock or slave clock. Boundary clock is otherwise similar as OC but it has multiple PTP ports. Ethernet switches, for example, are normally used as a Transparent Clock or a Boundary Clock. [26]

BC determines one port as a slave and others as masters. BC is synchronized by its slave port and it distributes the time from its master ports. Transparent clock has always multiple ports and it is passive. PTP frames goes through switches that uses TC unless it is a Peer-to-Peer message. TC calculates the time it takes for one packet to go through a network device, and adds that time to the PTP packet’s correction field. [26]

Ethernet network that incorporates PTP chooses the master clock with the best master clock algorithm (BMCA). BMCA defines the best clock to be used as a reference clock.

Master clock sends frequently Sync messages to all slaves, usually from every second to every few seconds. Master node and slave node exchanges messages between each other using End to End (E2E) mechanism according to Figure 2.6 and Peer to Peer (P2P) mechanism according to Figure 2.7. [26, 27]

Figure 2.6. PTP End to End Synchronization Process [27]

PTP synchronization process starts with master sending a synchronization (Sync) mes-sage to a slave. Sync mesmes-sage contains time information (t1) when the packet has left

from the master. The Sync message will be time stamped at the physical layer when it departures from the master and arrives to the slave. After the first Sync message is successfully sent, the master will send a Follow_Up message. The Follow_Up message contains time information about when the first Sync message (t1) was actually sent. After the Follow_Up message the slave corrects its local time (t2) according to the master. [26, 27, 28]

At this point, using E2E, the slave clock will be corrected according to the master clock excluding the propagation delay between master and slave. Next, slave sends a delay request (Delay_Req) message which is timestamped when the message departures from the slave (t3) and arrives to the master (t4). Then, master will send a delay response (Delay_Resp) message which contains information the when the Delay_Req message was arrived (t4) to the master. According to these timing information slave calculates the propagation delay and corrects its local clock to be synchronous with the master. [27]

The delay can be calculated from equation:

Delay = (t2−t1) + (t4−t3)

2 . (2.13)

Figure 2.7.PTP Peer to Peer Synchronization Process [27]

With P2P mechanism the slave sends a delay request message (Pdelay_Req) which is timestamped when the message has sent (t1). The master receives the Pdelay_Req message and timestamps it when it arrives (t2). Then the master sends a delay response message (Pdelay_Resp) and gets timestamped on the departure of the message (t3).

Pdelay_Resp message contains information about timestamps depending is the process using one-step or two-step operations. [26, 28, 29]

With two-step mode, the Pdelay_Resp contains only the information when the message has left from the master (t3). With one-step mode, the Pdelay_Resp contains delta be-tween arrived Pdelay_Req message (t2) and departured Pdelay_Resp message (t3). If the node is not able to use one-step mode it will use two-step mode instead and send a

follow up message (Pdelay_Resp_Follow_Up) after Pdelay_Resp. [26]

The Pdelay_Resp_Follow_Up message contains timestamp information when the Pde-lay_Resp has sent (t3). The slave receives the Pdelay_Resp message and timestamps it when the message arrives (t4). Now the node that requested the delay has all necessary information for calculating the delay between nodes using Equation 2.13. This peer delay link measurement is done from the slave to the master and also from the master to the slave. [26, 28, 29]

After calculating the delay, the slave is able to calculate the phase difference which is also called Offset. Slave can adjust the Offset after calculating it using the following equation as presented in Figure 2.6:

Of f set= (t2−t1)−Delay. (2.14) There are two different mechanisms to measure delay such as Peer to Peer (P2P) and End to End (E2E). P2P is used to measure delay between every two neighbour ports as shown in Figure 2.7. E2E mechanism is used to measure delay from slave to master as shown in Figure 2.6 and calculated in Equation 2.13. Both mechanisms assumes that the transmission delay is symmectrical between nodes. [27]