Abstract
This article analyzes the clock model of sensor nodes and the basic principle of time synchronization. Then, it systematically introduces the existing time synchronization mechanisms and compares their advantages and disadvantages. In order to solve the problems of consensus-based time synchronization, such as propagation delay and convergence speed, Group Consensus Time Synchronization algorithm is proposed. In this protocol, minimum data exchange is achieved for both frequency and phase offset compensation, and at the same time, the propagation delay is considered and compensated for. The simulation results show that the protocol can adapt to dynamic topology and be suitable to large-scale wireless sensor networks.
Keywords
Introduction
Time synchronization is an important issue, which must be addressed in all distributed systems, especially in wireless sensor networks (WSNs). It is crucial for WSNs when performing a number of fundamental operations, 1 such as low-power medium access control (MAC) protocol operation, reliable data fusion, 2 target tracking, and precise positioning.
The research on time synchronization has a long history. In the past few decades, many algorithms and mechanisms have been proposed and applied. However, the existing synchronization mechanism is not suitable for WSNs due to the special nature of WSNs.
In WSNs, time synchronization refers to exchanging and adjusting clock information of all nodes through single-hop or multi-hop manner to make all nodes running with the same clock. In order to achieve time synchronization in the WSN, the following challenges need to be overcome: 3
Related work
So far, many algorithms can solve some of the problems described above. All of these agreements have some common characteristics: the simple packet transport protocol, exchanging clock information between nodes, reducing the effect of communication delay, and the implementation of the corresponding different schemes and algorithms. They are classified into two types: centralized and distributed time synchronization.
The centralized time synchronization algorithms, such as Reference Broadcasts Synchronization (RBS), 4 Timing-sync Protocol for Sensor Networks (TPSN), 5 and Flooding Time Synchronization Protocol (FTSP), 6 have many advantages including fast convergence speed, low complexity, and high convergence precision. However, these synchronization algorithms are based on structure type and mostly depend on the reference node. So, their robustness as well as scalability is poor. For example, if a node dies or a new node is added, it is necessary to rebuild the tree or cluster, which requires additional implementation overhead and may lead to worse synchronous precision.
Distributed time synchronization algorithms, such as Reachback Firefly Algorithm (RFA) 7 and Distributed Time Synchronization Protocol (DTSP), 8 achieve time synchronization using the time information of neighbor nodes. In order to overcome the limitations of centralized time synchronization algorithm and the distributed algorithm, the concept of consistency is introduced in sensor networks.
Average Time Synchronization Protocol (ATS) 9 takes clock phase shift and frequency shift into consideration. At the same time, each node in the network complies with the same consensus protocol. Consensus Clock Synchronization (CCS) 10 also uses consensus protocol to compensate for clock phase offset. The main idea is that weighted coefficient is introduced into the protocol and each node can get own clock offset, ultimately correct itself through the information. In a sense, the CCS is an enhanced version of ATS, but the drawback is that it still has a slow convergence rate. Time Synchronization using Max and Average Consensus Protocol (TSMA), 3 based on ATS and CCS, achieves time synchronization by the way of the combination of the maximum consensus and average consensus, which can make the clock converge to a virtual global clock. Wu et al. 11 use two-order consistency algorithm to improve the convergence speed of the algorithm, but it also increases the complexity of the algorithm.
Consistency algorithms discussed above have ignored a major problem: propagation delay. However, it is significant in the actual time synchronization. The algorithm in the work by Leng and Wu 12 describes two cases of fixed and random distribution of propagation delay. Du and Wu 13 put forward a kind of asynchronous synchronization algorithm. Different nodes can update their estimated value based on different frequencies. However, the time and space complexity of these two algorithms are relatively high, which need more storage and computing resources. Due to these reasons, both of them are not suitable for large-scale WSNs. So, this article presents a fully novel DTSP in WSN called Group Consensus Time Synchronization Protocol (GCTS). It has simple calculation, fast convergence rate, and low energy consumption.
System model
The algorithm based on GCTS mainly includes two parts: the compensation for the clock frequency offset and phase offset. The compensations are realized through the exchange and calculation of time information between sensor nodes. Finally, all nodes in the network will converge to a virtual clock. In the process of information exchange, the propagation delay may affect the accuracy of the time synchronization. So, this article proposes the two-way information exchange to attain the time synchronization.
The propagation delay model
As shown in Figure 1, node 1 requires the time information of node 2. Before node 1 sends a request instruction, it records its instantaneous timestamp

Two-way message exchange.
Then, the estimated propagation delay can be used to compensate for the clock frequency offset and phase offset.
The correction of the clock frequency offset
The clock frequency offset correction for the sensor nodes is designed to allow all nodes to run at the same frequency because if two sensor nodes are not running at the same frequency, the network even gets synchronization at the present time and the next moment will lose synchronization. Moreover, with the passage of time, the time offset between the two nodes will become bigger. Therefore, there would be a need for more frequent time synchronization information exchanges to realize time synchronization.
A method 14 that can use two-way synchronization information package exchange to estimate the frequency of the node is proposed. In addition, the frequency drift of the most of sensor nodes can be found in the specification. In the initial phase of the network, it is easy to obtain the clock frequency through the programming operation.
In the WSN composed of
In the end,
As is shown in Figures 2 and 3, this article compares the group exchange mechanism with the point-to-point exchange mechanism.

Point-to-point message exchange.

Group message exchange.
In Figure 2, through broadcasting synchronization packets, the consistent clock frequency between two nodes is realized. Node 2, node 3, and node 4 can achieve the clock frequency through operation after receiving the synchronization information packet of the node 1. In this synchronization mode, the propagation delay is ignored. After a round of synchronization, the clock frequencies of the four nodes are still different but their standard deviation is reduced. This is a typical consensus algorithm called consensus time synchronization algorithm based on two nodes.
As is shown in Figure 3, it is just the time synchronization method used in this article. Node 1 waits for a period of time to collect all the clock information from the surrounding nodes and then calculates the propagation delay and the consistent clock information of the entire group. This method can realize accurate and fast time synchronization.
The correction of the clock phase offset
According to the previous analysis, after correcting the clock frequency offset, all local virtual clock estimators will eventually have the same drift
where
Whether the sensor network synchronization is completed or not, the local time of all network nodes is always increasing with the passage of time. From equations (3) and (4) above, when the network node clock achieves synchronization, variable
where
Therefore, it is convenient to study
In the WSN composed of
The purpose of discrete protocol control is to establish the relationship between the present state and the upper state of a system so that the relationship between the final convergence state and the initial state can be obtained by the recurrence relation. Equation (7) represents the group consensus protocol discussed in this article
where
The specific clock offset correction algorithm is as the same as the correction of the clock frequency offset algorithm. The difference is transmitting the clock offset information
Convergence proof of GCTS
The control protocol of the discrete system composed of
where
In order to prove the convergence of GCTS, it is necessary to prove the equation
where the characteristic value of
Similarly, the matrix
According to equations (9)–(11), it can be obtained
It can be obtained as below by solving the above inequality
Within this range,
Then
So, the final value converges to the mean of the time offset of the initial state.
Simulations
In order to verify the performance of the algorithm based on GCTS, this article uses MATLAB simulation software to simulate the algorithm.
Simulation under different network topology types
First, GCTS is performed in four kinds of small networks composed of eight nodes shown in Figure 4. They are linear network (L8), ring network (R8), star network (S8), and full-connection Network (F8). These small networks are really part of a large network.

Four different network topologies.
At the same time, in order to measure the degree of synchronization of the whole network, a synchronization criterion called Kuramoto is introduced. 14 Kuramoto is shown as follows
where

Kuramoto parameters of nodes in different network topologies based on GCTS.
Simulation in large-scale WSNs
This article analyzes time synchronization in large-scale WSNs.
Specific simulation conditions are shown in Table 1. 100 nodes are distributed in 100 m×100 m region (Figure 6). The transmission radius of the node is 10 m and the number of simulation operations is 100. The node’s clock frequency of crystal oscillator is 32.768 kHz. Therefore 1 tick = 1/32,768 Hz = 30.5
Simulation parameters.
ATS: Average Time Synchronization Protocol; CCS: Consensus Clock Synchronization; TSMA: Time Synchronization using Max and Average Consensus Protocol; GCTS: Group Consensus Time Synchronization Protocol.

Distribution of nodes in the simulation.
Simulation of a round iteration
Before and after running the operation based on group consistency algorithm, average time error area distribution of each node in the network is shown in Figure 7. According to Figure 7(a), it can be seen that the maximum relative time error of the nodes in the network can be up to 500 ticks before the group consistency algorithm is implemented. From Figure 7(b), the maximum relative error of nodes in the network is reduced to less than 100 ticks. Moreover, the time error distribution after running the group consistency algorithm is more stable. A statistical histogram of the average error of all nodes before and after the operation is shown in Figure 8. From Figure 8(a), the standard deviation of the time error is 293.33 before implementing group consistency algorithm, while the standard deviation is 43.69 after the operation, as shown in Figure 8(b). So, after running the group consistency algorithm, the time synchronization performance of the network is improved obviously.

Synchronization error (a) before and (b) after one round of group consensus algorithm.

Histogram of the synchronization errors (a) before and (b) after one round of group consensus algorithm.
Performance simulation of several algorithms
Convergence rate is an important factor to measure the performance of the distributed time synchronization algorithm. In order to study the convergence rate of GCTS algorithm, it is simulated under the same environment with other classical time synchronization algorithms like ATS, CCS, and TSMA. The relationship between rounds and Kuramoto parameter of all nodes’ phase through the corresponding iterations is shown in Figure 9.

Kuramoto parameters of nodes after running ATS, CCS, TSMA, and GCTS.
The Kuramoto parameter represents the convergence degree of the current state of the whole network. The closer to 1 Kuramoto parameter of the node phase, the higher the degree of convergence under this condition.
From Figure 9, it can be seen that the performance of GCTS is better than ATS, CCS, and TSMA. After each round operation, Kuramoto parameter of GCTS is closer to 1 than ATS, CCS, and TSMA. This is because GCTS exchanges information between that node with all the neighbor nodes, while ATS, CCS, and TSMA algorithms are carried out between two nodes.
In order to analyze the change in the phase of each node in the network more clearly, the relationship between the phase error of each node and the number of iterations for each node after running ATS, CCS, TSMA, and GCTS algorithms is shown in Figure 10.

Clock errors of 100 simulated nodes running ATS, CCS, TSMA, and GCTS.
It can be seen from the figure that the convergence rate of GCTS is the fastest. In summary, GCTS has better convergence performance.
The plot in Figure 11 clearly shows the relationship between the scale of network and the convergence rate. The synchronization speed of the GCTS, CCS, and TSMA algorithms can still maintain a steady state with the size of the network increasing. For distributed algorithms, although the number of nodes in the network is increasing, the number of neighbor nodes increases as well as the range of iteration when the propagation distance is constant. However, the synchronization speed of GCTS is significantly faster than that of CCS and TSMA since GCTS algorithm employs group mechanism instead of point-to-point communication mechanism. Therefore, in large-scale WSNs, the performance of GCTS is better. The condition above is for network within a fixed region. However, if the average node density and transmission range remain same, the partial synchronization is still the same as before. As the network size increases, the number of iterations increases and the convergence speed of each algorithm will decrease correspondingly.

Average number of rounds of CCS, TSMA, and GCTS in networks of different sizes.
Simulation in the dynamic topology network
This article also analyzes convergence performance under the dynamic topology network. When the node dies and is replaced, the convergence of the network and the stability of the clock error after implementing the GCTS algorithm are observed in Figure 12.

The performance of the algorithms in dynamic topology network.
The experimental process is divided into four stages: stage A as the beginning phase, stage B as the stable phase, stage C as the death phase, and stage D as the recovery phase.
In stage A, as a result of just running GCTS algorithm, the clock phase offset of each node is different initially. So, through about 30 rounds of iterations, the entire network enters the synchronization phase.
In stage B, 3% of nodes closed randomly, and once the node is open, it will begin running GCTS algorithm. Because most of the nodes have been in the synchronization phase, new nodes added have little influence on the whole event adjustment. At the same time, it can also be seen from Figure 12 that nodes can quickly enter the synchronization state.
In stage C, 5% of nodes are dead due to the long-time work. When a small number of nodes turn off their radio, the convergence of the whole network is affected little.
In stage D, after replacing these dead nodes, due to no clock correction, these nodes cannot be synchronized. When these nodes begin to perform the GCTS algorithm, all the nodes are synchronized soon.
Conclusion
In this article, a new algorithm for clock synchronization of the large-scale WSNs is proposed based on the group consensus protocol. In the protocol, the main idea is to use the group information exchange mechanism to replace the original point-to-point mechanism. At the same time, it takes propagation delay into consideration and compensates for the clock frequency shift together with the clock phase shift. The advantages of the protocol are fully distributed, scalable, and it has simple calculation, fast convergence rate, and low energy consumption. Finally, a set of simulations is presented to show the good performance of the proposed protocol.
Footnotes
Handling Editor: Luis Orozco-Barbosa
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) received no financial support for the research, authorship, and/or publication of this article.
