Clock Synchronization in Linux

This section assists you in clock synchronization setup on Linux-based systems.

1. Timestamping Accuracy #

In Linux, the timestamp mode parameter, like in Windows, does not exist. This is not a problem, since the timestamping process in Linux has already good enough resolution. Also, Linux systems have typically NTPNetwork Time Protocol
A very common protocol for synchronizing the clocks of devices across a network.
running with parameters suiting also to measurements, while, of course, it is still likely that the parameters are not optimal, and tuning might be useful. Especially, select as close NTP server (in terms of network delay) as possible. In addition, check that the minimum and maximum poll values are small enough. How to tweak the NTP parameters can change from one distribution to another.

Besides NTP, PTPPrecision Time Protocol
A protocol for synchronizing the clocks of devices across a network. The reached synchronization accuracy is typically considerably better than with NTP.
is typically also available, enabling better accuracy for the system clock synchronization. In good conditions (a lightly loaded LAN), PTP can yield a microsecond-level accuracy. If you are aiming for microsecond-level accuracy, and fixed connections for PTP are not possible, GNSS clock synchronization is recommended.

2. PTP in Linux #

If GNSSGlobal Navigation Satellite System
A general term under which all the different global satellite navigation systems (e.g., GPS, GLONASS, Galileo, BDS) fall.
clock source is not available, PTP is the second best option to synchronize the machines where you run Qosium Probe. In the simplest case, PTP works in a way that there is a Master device and then Slave devices around the network synchronize to that. Thus, if you have a server in the network, which already has an accurate system time, and is accessible, set that as the Master, and let the other machines synchronize into that. If, however, you have only two devices communicating directly, you can select either one of them as the Master.

A good PTP solution is PTPd. Setting a Master service with PTPd is done as follows:

ptpd --masteronly --interface <network interface over which PTP synch messages will be sent>

PTP Slave service is set as:

ptpd --slaveonly --interface <network interface over which PTP synch messages will be sent>

In addition, it is useful to use --verbose argument to see that Slave finds a Master and also to see the observed time drift. There’s no need to switch the system timesyncd service off. Everything should start working directly.

PTP messages are sent by default as multicast. If you want to use unicast mode instead, use the following arguments in both the Master and the Slave: --unicast and --unicast-destinations. So, in the case of unicast, you need to tell the Master by parameters who is allowed to connect. If a particular Slave is not on the Master’s list, synchronization will not work.

Sometimes PTP is desired to be tied into a PTP domain. This is done with the switch --domain. Remember that if the Master uses a certain domain, you need to use the same domain in the Slave.

In addition to command line parameters, PTPd can be configured by using a configuration file.

Glossary >

Network Time Protocol

A very common protocol for synchronizing the clocks of devices across a network.

Precision Time Protocol

A protocol for synchronizing the clocks of devices across a network. The reached synchronization accuracy is typically considerably better than with NTP.

Global Navigation Satellite System

A general term under which all the different global satellite navigation systems (e.g., GPS, GLONASS, Galileo, BDS) fall.