Abstract
Time synchronization is a crucial component in wireless sensor networks (WSN), especially for location-aware applications. The precision of time-based localization algorithms is closely related to the accuracy of synchronization. The estimation of synchronization errors in most of the existing time synchronization algorithms is based on some statistical distribution models. However, these models may not be able to accurately describe the synchronization errors due to the uncertainties in clock drift and message delivery delay in synchronization. Considering that the synchronization errors are highly temporally correlated (short-term correlation), in this paper, we present an adaptive linear prediction synchronization (ALPS) scheme for WSN. By applying linear prediction on synchronization errors and adaptively adjusting prediction coefficients based on the difference between the estimated values and the real values, ALPS enhances synchronization accuracy at a relatively low cost. ALPS has been implemented on the Tmote-sky platform. As experiment results demonstrate, compared with RBS and TPSN, ALPS cuts synchronization cost by almost 50% while achieving the same accuracy; compared with DMTS and PulseSync, ALPS reduces the MSE (mean square error) of synchronization errors by 41% and 24%, respectively, with the same cost.
1. Introduction
Time synchronization is one of the key middle-ware components in wireless sensor networks (WSN) [1]. Accurate time synchronization is critical to many tasks in various WSN applications including duty cycling scheduling, data fusion and tracking, and transmission scheduling. Localization is another important application of time synchronization. The accuracy of time synchronization directly influences the precision of localization [2].
Among the existing localization algorithms [3–6], the most accurate localization approaches are ranged-based methods. These methods usually use the time-of-arrival (TOA) [7], time-difference-of-arrival (TDOA) [8, 9], angle-of-arrival (AOA) [10], and received signal strength (RSS) [6] to compute the distances between nodes and anchors and then obtain the location information. Among the above four methods, TOA and TDOA are time-based localization algorithms, which are promising ranging methods due to their high accuracy and low cost. The simulation results [2] demonstrate that the accuracy of the time synchronization is a central issue in time-based localization approaches. Therefore, time synchronization plays a critical role in localization algorithms.
Many time synchronization algorithms have been proposed in recent years. The early time synchronization algorithms, such as RBS [11], TPSN [12], DMTS [13], and FTSP [14], are all based on timestamp exchanges, which are intended to offset the uncertainties of message delivery delay to enhance the synchronization accuracy. On-demand synchronization (ODS) [15] adaptively adjusts the synchronization interval for customized accuracy with minimized communication overhead. Lenzen et al. propose PulseSync [16] which distributes information on clock values as fast as possible and achieves a higher synchronization accuracy than FTSP. Leng and Wu present a synchronization scheme under unknown Gaussian distribution aiming at achieving both low computational complexity and high performance [17]. Leng and Wu also model the WSN synchronization under exponential delays as a linear programming problem and solve it with a novel low-complexity estimator [18]. In [19], a Kalman filter is used to estimate both clock offset and skew. An improvement on [19] by adopting an adaptive multimodel mechanism is presented in [20]. Zheng and Wu present a unified framework to jointly solve time synchronization and localization problems at the same time [2]. Jin et al. study how voltage influences the clock skew and proposes a novel voltage-aware time synchronization (VATS) scheme [21].
Most of existing synchronization schemes assume that the distribution of clock skew and the delivery delay of synchronization packets follow some statistical models (such as Gaussian distribution model in [15, 17, 20, 21], exponential distribution model in [18, 22, 23], and gamma distribution model in [1]). However, the clock drift and message delivery delay are essentially very random and easily affected by some environment factors (such as temperature and voltage). Therefore, it is not easy to describe them accurately through any predetermined model [1, 24]. Moreover, some algorithms need to calibrate the clock skew frequently (such as [11, 14, 20, 22]). However, as [15] demonstrates, frequent clock skew calibration will not only increase the computation and communication overhead, but also may increase the synchronization errors due to the miscalculation of the message delivery delay.
Linear prediction is a mathematical operation where future values of a discrete-time signal are estimated as a linear function of previous samples. In digital signal processing, linear prediction is often called linear predictive coding (LPC) and is widely used in speech coding, digital filter, and wireless channel estimation. Considering that synchronization errors are highly temporally correlated (as Figure 3 shows), in this paper, an adaptive linear predication synchronization (ALPS) scheme for WSN is proposed. To the best of our knowledge, this is the first work which applies linear prediction to the time synchronization in WSN.
ALPS predicts clock offset based on its historical values. ALPS does not assume the clock offset to follow any particular statistical distribution or need frequent clock skew calibration. As experimental results demonstrate, ALPS has a better performance than DMTS and PulseSync without increasing synchronization cost; ALPS reduces synchronization cost compared to RBS and TPSN while maintaining the same synchronization accuracy.
2. Motivation
In WSN, each node has an independent local clock. Ideally, the clock should satisfy the equation

Clock model of sensor nodes.
In WSN, offsets exist between clocks of different nodes due to the difference in clock skew and the initial phase. Consider the time synchronization process between node A and node B, where B is the reference node and A is the node to be synchronized, as illustrated in Figure 2. Suppose node B sends a message to node A about its clock reading

Synchronization model.

Synchronization errors over time using a fixed compensation value.
The goal of time synchronization is to make the clocks of node A and node B the same. In (2), there are three parameters, f, θ, and τ to be estimated. For f and τ, most of the synchronization schemes first assume that they follow a particular statistical distribution and then estimate them by some statistical means. For example, the least squares (LS) estimator is applied in [14, 24]. In [18, 23], the parameters are estimated using the maximum likelihood estimator (MLE) and minimum variance unbiased estimator (MVUE), respectively.
However, the delay of the message for synchronization (τ) consists of many components, including send/receive time, access time, transmission/reception time, interrupt time, and encoding/decoding time. Among them, the send/receive time, access time, and interrupt time are nondeterministic. Although the nondeterminacy of the synchronization delay can be reduced by inserting the timestamp into the appropriate place in the packet at the lower layers [13, 14], it can not be eliminated completely. On the other hand, clock skew (f), affected by voltage, temperature, and other environment factors [21], exhibits great randomness and is difficult to be described by any particular statistical model. Moreover, since the randomness of clock skew and synchronization delay are not independent of each other, inappropriate estimation not only can not eliminate the errors, but also introduce new errors [15]. Therefore, there are limitations when using a specific statistical distribution model in time synchronization. Linear prediction, however, as a widely used method in the field of random signal estimation, is independent of any special statistical distribution model. Considering that the clock skew changes slowly and the synchronization error samples exhibit high short-term temporal correlation and periodicity, we adopt adaptive linear prediction as the estimator of the synchronization errors in our synchronization scheme.
3. Algorithm
3.1. Linear Prediction Model
The key idea of linear prediction is that if there is temporal correlation between signal samples, we can use past sample values to predict current and future sample values. The sample to be predicted can be closely approximated as a linear combination of past samples. The prediction coefficients are determined by minimizing a certain function of differences between sample values and predicted values.
In the time synchronization model, if we consider the clock offset caused by both clock skew and the synchronization delay as a single variable
In order to examine how the synchronization errors change with time, we implemented several experiments (lasting 24 hours, with synchronization interval 2 s, 3 groups) on the Tmote-sky platform. In these experiments, we compensated the clock offset with a fixed value
The basic idea of linear prediction is that
3.2. Calculation of the Prediction Coefficient
We use the synchronization mean square error (MSE) to evaluate the synchronization performance. Smaller MSE indicates higher synchronization accuracy [22]. The
To minimize
Equation (7) can be further reduced to the following equation:
Apparently, by solving this equation set, we can obtain all the prediction coefficients
Define
Combining (8) and (9) and the properties of the autocorrelation function, we will have
The above is called Yule-Walker equations, where the coefficient matrix is a
We can use Levinson-Durbin recursion algorithm to solve Yule-Walker equations. The Levinson-Durbin recursion algorithm is given as follows [25].
Perform recursive calculation with the following formulas:
The final solution is given as follows:
3.3. Algorithm Description
ALPS is given as follows. First, a routing tree is established in the network initialization stage, where SINK node acts as its root. SINK node periodically broadcasts synchronization packets, which include timestamp, to the lower levels of the tree. When a child node receives the packet, it extracts the timestamp and calculates the difference (clock offset, which is used as the input of ALPS) between the local clock and the timestamp and rebroadcasts the synchronization packet only with its own local timestamp. Then, the child node calculates the prediction coefficients
The method to calculate
Calculate
ALPS is described as follows.
The child node maintains a FIFO queue which consists of p registers. The previous p clock offset samples are put into the registers by the order of With (9), With Using Levinson-Durbin iterative algorithm, calculate the prediction coefficients Calculate the next clock offset Use When the next synchronization packet arrives, calculate Insert
The complexity of ALPS algorithm is analyzed as follows. The most complex part of ALPS is the Levinson-Durbin algorithm. Within the Levinson-Durbin algorithm, the most complicated calculation is resolving the
4. Performance Evaluation
To evaluate the performance of ALPS, we implemented it in a real testbed, as shown in Figure 4. In our experiments, we adopt CTP (collection tree protocol, commonly used in WSN), as the routing algorithm on the nodes. Each node looks for a parent node to be synchronized and transfers data packets to the SINK node hop by hop through this data collection tree, thus forming a tree-based topology. The target hardware platform is Tmote-sky node, and the software platform is Contiki, an open source lightweight embedded operating system widely used in WSN. The Tmote-sky node features an MSP430 MCU and a CC2420 radio transceiver, and the clock frequency is 32768 Hz. In the following experiments, we synchronize the local time generated by the 32768 Hz clock. Thus, one clock tick is equal to 1/32768 s. The Tmote-sky supports complicated calculations and has the ability to store plenty of external data. These advantages of Tmote-sky facilitate the ALPS implementation.

Indoor testbed.
In order to obtain the clock readings of parent nodes and their children nodes at the same time, a pulse signal was sent periodically to these nodes. The nodes recorded and output their clock readings upon receiving the pulse signal. In this way, we can periodically sample the clocks of the synchronization nodes to be tested.
The experimental scenario is a multihop wireless sensor network. The default experiment configuration parameters are given in Table 1.
Experimental configuration.
The experiment is based on tree topology network. Since we are more concerned with the synchronization errors between parent nodes and children nodes, we have only analyzed synchronization performance among parent nodes and their children nodes. The analysis of the synchronization errors for the whole network will be in our future work.
4.1. Prediction Order
P
From analysis in Section 3.1, we know that synchronization accuracy is highly related to the prediction order p. So we explore the relationship between the MSE

Relationship between MSE of synchronization errors
As Figure 5 demonstrates,
4.2. Comparison with DMTS and PulseSync
Delay measurement time synchronization (DMTS) [13] is based on the estimation of all delays involved in time synchronization message transfer path, and the delay is calculated by the length and the transmission rate of synchronization packet. PulseSync [16] is presented to reduce the global synchronization errors by making the synchronization messages disseminated as fast as possible. And the clock skew is estimated by least-squares linear regression (LSLR) on eight data points (8LR). In our experiments, we evaluate DMTS, PulseSync, and ALPS algorithms on the same platform, the Tmote-sky platform.
To compare ALPS with DMTS and PulseSync, we implemented these algorithms into the testbed in three experiments. In each experiment, the SINK node periodically broadcasts synchronization messages to the whole network, and the other nodes receive the synchronization messages and run DMTS, PulseSync, and ALPS, respectively, and calibrate their clocks to be synchronized with the SINK.
Figure 6 plots the histogram of the synchronization errors of the DMTS, PulseSync, and ALPS algorithms, and the results are also summarized in Table 2. As shown in Table 2, the MSE of ALPS declines by 41% and 24%, respectively, compared with DMTS and PulseSync. This is because DMTS compensates the random synchronization delay with a fixed value, while PulseSync and ALPS use the historical data points to estimate the current synchronization error. The difference between PulseSync and ALPS is analyzed as follows. PulseSync uses eight data points (8LR) where the weights of all sample points are equal for estimation. Therefore, the degree of freedom (DOF) of PulseSync is only two (clock offset and skew) although it has eight data points. On the other hand, the prediction coefficients in ALPS are not equal and adaptively change with time (as shown in Section 3.2), so the DOF of ALPS is equal to the prediction order p. In this experiment, p is 3.
Statistics of synchronization errors.

Histogram of synchronization errors.
In short, PulseSync uses eight samples with the DOF as two. However, although ALPS only uses three data points, its DOF is three. Apparently, the efficiency of ALPS is higher than PulseSync.
Figure 7 depicts the synchronization errors of PulseSync and ALPS along the timeline for 1000 samples (2 s per sample). Compared with Figure 3 (without prediction), we can find that in ALPS the variance of errors is smaller, and the outliers are less and are more stable.

Synchronization errors of PulseSync and ALPS over time.
Through analysis on data of synchronization errors, we can get error distribution falling in different ranges. As demonstrated by Figure 8, the error distribution of ALPS is more concentrated than DMTS and PulseSync; hence the MSE of ALPS is also smaller than DMTS and PulseSync. 85% and 75% of the errors in ALPS and PulseSync fall in

Probability of synchronization errors falling into different ranges.
4.3. Synchronization Cost
Since the synchronization cost is highly correlated with the amount of the synchronization packets (assume the transceiver is turned off when no message is sent or received), we take the number of synchronization packets to represent the synchronization cost.
Considering the scenario where one reference node and n nodes to be synchronized are within a single broadcast domain, the synchronization cost of different schemes is given in Table 3. In RBS, K denotes the number of reference broadcasts. As K increases, the synchronization error goes down while the energy consumption goes up. According to [12], the average synchronization errors of RBS and TPSN are 29.13 μs and 16.9 μs, respectively. The average synchronization error of ALPS is 19.33 μs. As Table 3 demonstrates, ALPS has a big advantage in synchronization cost, which is at least half of both RBS and TPSN. Although ALPS, PulseSync, and DMTS share the same synchronization cost, as shown in Table 2, ALPS has a better performance than PulseSync and DMTS in terms of both average and MSE of synchronization errors.
Comparison of synchronization cost.
We also compare PulseSync and ALPS in resource consumption. PulseSync uses LSLR to estimate the clock skew, and a typical LSLR needs a single loop with complexity
In summary, ALPS performs the same as RBS and TPSN in synchronization accuracy with a less cost and performs better than PulseSync and DMTS at a similar expense. Therefore, when both performance and cost are taken into consideration, APLS performs better than the other four synchronization schemes.
5. Conclusion
Considering the high temporal correlation of time synchronization errors, this paper proposes ALPS, a synchronization scheme based on adaptive linear prediction. Through linear prediction on the clock offset and adaptively adjusting prediction coefficients, ALPS improves synchronization accuracy without increasing synchronization costs. Experiments on the Tmote-sky platform indicate that ALPS cuts synchronization cost by at least half compared with RBS and TPSN without sacrificing accuracy and performs better than DMTS and PulseSync with the same cost. The MSE of synchronization errors in ALPS declines by 41% and 24% compared to DMTS and PulseSync, respectively.
Footnotes
Conflict of Interests
The authors declare that there is no conflict of interests regarding the publication of this paper.
Acknowledgment
This work was supported by the National Science & Technology Pillar Program during the 12th Five-Year Plan Period (no. 2012BAJ24B01).
