Clock(Time) synchronization — Part 2


Various methods of time synchronization

In our previous article, we gave you a brief introduction to clock synchronization and mentioned that this is essential to most systems using clocks, including bio-signal analysis. Today, we’d like to go a little deeper into the topic and cover some different methods of clock synchronization. Let’s find out how it actually works!

Time measurements and cause of errors

Let’s look at what error occurs in the synchronization process before we consider how time synchronization actually works. The determinants of clock synchronization errors in a wireless system can be classified into 4 types of durations — send time, access time, propagation time, and receive time. In a wired network, access time is excluded, since problems such as channel interference are rare (H. Kopetz & W. Schwabl, 1989).

Among these, propagation delay is the most important one. As send time and receive time are the processing time through the entire system, the offset is almost negligible considering the desired degree of accuracy in clock synchronization. (But of course, there are several ways to reduce this part, in which the process for synchronization is handled in the lowest layer.) In the case of propagation time, the clock of the sender and the receiver aren’t synchronized, and therefore, there is no way to measure it. The solution to this obstacle is methods like NTP (Network Time Protocol).

Basic time synchronization algorithm: Network Time Protocol

NTP is regarded as a basic algorithm to solve clock synchronization problems. In fact, many algorithms developed afterward have been modified based on NTP by the characteristics of communication medium.

In NTP, when a device is set as a master clock(server), a message is sent to all slaves(clients) to synchronize the clock. Then, the slaves calculate their local time and the drift of the master clock. But the problem in this process is that a propagation delay exists. Let’s say, for example, that the master sends a PTP(Precision Time Protocol) message signaling 1:00:00 pm on a network with a transmission time of 1 second. The slave, however, will receive the message at 1:00:01 pm. A correction is then required for the network latency, which can be done as follows.

First, we define the offset as the difference between the slave clock and the master clock. Then, let s (t) be the slave clock and m (t) the master clock for time t, and the offset o (t) is

o(t) = s(t) — m(t)

To calculate this, master and slave need two message exchanges.

Figure 2.

<image credit:>

1. M: send a sync message at T1

2. S: receive sync message at T1 ‘

3. S: send a delay request at T2

4. M: receive delay request at T2 ‘

Through this process, the master clock gets to know all of T1, T1 ‘, T2, T2’(T3 and T3 ‘ are additionally required for the slave to know the offset as well.). Let RTT(Round Trip Time), i.e. transmission delay, be d, and assuming that the delays in master -> slave and slave -> master are the same,

T1′-T1 = o + d

T2′-T2 = -o + d

Offset o can be obtained, using this, as follows.

o = 12{(T1′-T1) — (T2′-T2)}

If the transmission delay is not constant, it is recommended to repeat the process several times and use the average value or to exchange the time as often as possible to the extent that it does not affect the actual data transfer.

Video, screen synchronization

Also for instruments that measure biosignals, the clock offset to the server should be measured to obtain the correct timestamp of the signal. However, it is not easy to apply algorithms such as NTP as it is when the clock(time) of the equipment itself is unknown or if the logic is inaccessible.

In this case, you can measure the clock offset by generating a signal that has an accurate timestamp. For example, a photodiode can be used to measure the offset of electroencephalography(EEG). But for this method, of course, you need a light emitting source capable of recording a correct event time, such as a computer monitor which can change its color suddenly from dark to white. When the photodiode, connected to an EEG electrode, receives the light, it generates an electric signal that is recorded together with the timestamp.

Figure 3. Time synchronization with photodiode

<image credit:>

Figure 4. Time synchronization with video

<image credit:>

By comparing the timestamp of light emission with the timestamp taken when receiving the electrical signal, you can to verify the time difference between the two devices and the synchronization accuracy.

To Conclude

Now you might have a sense of how clock offset is calculated and how the synchronization is applied in practice. I hope this article helps you understand the process in real cases, such as biosignal analysis or relevant experiments.


<H. Kopetz and W. Schwabl, “Global time in distributed realtime systems,” Technical Report 15/89, Technishe Universitat Wien, 1989>

Read More

Feature Matters


The performance of machine learning tasks highly depends on data representation or feature selection based on the problem you want to solve. For example, when distinguishing between apples and oranges in a photo, colors could be a more intuitively noti…

Read More