# Introducing precision time protocol to public\_regulated\_data\_types

**URL:** <https://forum.opencyphal.org/t/introducing-precision-time-protocol-to-public-regulated-data-types/1538>\
**Category:** Applications & Usage\
**Created:** [December 8, 2021, 8:46am UTC](https://forum.opencyphal.org/t/introducing-precision-time-protocol-to-public-regulated-data-types/1538 "2021-12-08T08:46:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cherish-forever](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/cherish-forever/32/802_2.png) [@Cherish-forever](https://forum.opencyphal.org/u/Cherish-forever)\
**Post date:** [December 8, 2021, 8:46am UTC](https://forum.opencyphal.org/t/introducing-precision-time-protocol-to-public-regulated-data-types/1538/1 "2021-12-08T08:46:13Z")

</div>

> **[Precision Time Protocol](https://en.wikipedia.org/wiki/Precision_Time_Protocol)**
>
> 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. PTP is currently 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 original version of PTP, IEEE 1588-...

> **[PTP-1588.pdf](https://endruntechnologies.com/pdf/PTP-1588.pdf)**
>
> 195.26 KB

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [December 13, 2021, 10:24am UTC](https://forum.opencyphal.org/t/introducing-precision-time-protocol-to-public-regulated-data-types/1538/2 "2021-12-13T10:24:44Z")

</div>

The public regulated data types already include a basic time synchronization protocol that is similar in its construction to IEEE 1588, except that the communication is strictly one-directional, from the time sync master to slaves. This comes with certain trade-offs: the algorithm scales better but the worst-case jitter bound is substantially higher. If higher precision is desired, IEEE 1588 should be implemented as-is.

> [@Alternative transport protocols in UAVCAN](https://forum.opencyphal.org/t/alternative-transport-protocols-in-uavcan/324/1):
>
> ### Time synchronization
> 
> As mentioned earlier, the currently defined time synchronization algorithm hinges on the assumption that the frame propagation latency throughout the whole bus is much less than a single bit period. This is true for CAN and similar physical bus topologies but does not hold for star or tree networks.
> 
> In the case of Ethernet-based networks, the problem of precise time synchronization is addressed well by IEEE 1588. Nearly every modern Ethernet-enabled microcontroller supports IEEE 1588 in hardware (all modern MCUs from NXP, STM, and Microchip seem to support it, according to my quick look-up), and the theoretical performance of this protocol exceeds that of UAVCAN.
> 
> Other transports, however, may not have such well-defined and well-supported standard solutions. In these cases, the algorithm defined in UAVCAN can still be used if augmented with the Olson latency recovery algorithm. The resulting solution will be less accurate than the native CAN-based one or IEEE 1588 but it is likely to still be sufficient for most distributed control needs.
> 
> The core assumption of the Olson algorithm is that the message propagation medium adds an unknown and variable latency to the message, but it is assumed that _occasionally_ the medium will exhibit the minimal latency. The Olson algorithm can identify such low-latency packets and use them to establish synchronization with minimal clock skew. The algorithm is implemented entirely on the receiving side and requires no slave-to-master communication. Therefore, unlike IEEE 1588, it scales very well for large networks. The short-term attainable accuracy equals the best-case (minimal) packet propagation delay from the master to the slave (the long-term accuracy is also dependent on the drift rate of the slave’s local clock); the worst case error is bounded by the worst case propagation delay.
> 
> The described algorithm can be implemented without any modifications to the synchronization protocol; the changes will be limited to slave-side logic only.

---

<div class="post-metadata">

**Author:** ![Cherish-forever](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/cherish-forever/32/802_2.png) [@Cherish-forever](https://forum.opencyphal.org/u/Cherish-forever)\
**Post date:** [December 14, 2021, 3:39am UTC](https://forum.opencyphal.org/t/introducing-precision-time-protocol-to-public-regulated-data-types/1538/3 "2021-12-14T03:39:19Z")

</div>

Where can I find the paper of Olson latency recovery algorithm?

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [December 15, 2021, 8:25am UTC](https://forum.opencyphal.org/t/introducing-precision-time-protocol-to-public-regulated-data-types/1538/4 "2021-12-15T08:25:56Z")

</div>

Here: [olson\_sensor\_synchronization.pdf](https://forum.opencyphal.org/uploads/short-url/mE5KdJt9zlzFncPHpHctrRke279.pdf) (202.7 KB)

A basic implementation is available in the legacy PyUAVCAN v0 library:

> <https://github.com/OpenCyphal/pycyphal/blob/acf1e158a5224fb969117b9c96119ab767886090/pyuavcan_v0/driver/timestamp_estimator.py#L82-L182>
