A Reliable Time Synchronization Protocol for ... - Academy Publisher

72 downloads 5527 Views 136KB Size Report
1 Key Laboratory of Industrial Informatics Shenyang Institute of Automation, Shenyang, China. Email: [email protected] ... Email: { zp & yhb & zhaoxiaoquan2000}@ sia.cn ... on the SIA2420 platform using TinyOS and the result show.
ISBN 978-952-5726-10-7 Proceedings of the Third International Symposium on Computer Science and Computational Technology(ISCSCT ’10) Jiaozuo, P. R. China, 14-15,August 2010, pp. 009-013

A Reliable Time Synchronization Protocol for Wireless Sensor Networks Fuqiang Wang1,2, Peng Zeng1, Haibin Yu1 and Xiaoquan Zhao1 1

Key Laboratory of Industrial Informatics Shenyang Institute of Automation, Shenyang, China Email: [email protected] 2 Chinese Academy of Sciences & Graduate School of the Chinese Academy of Sciences Beijing, China Email: { zp & yhb & zhaoxiaoquan2000}@ sia.cn

Abstract—Reliability is crucial for time synchronization in Wireless Sensor Networks (WSNs). Existing time synchronization algorithms provide on average good synchronization in laboratory environment, however, outdoor environment associated with radio interference will influence the performance of time synchronization. In this paper, we proposed a Reliable Time Synchronization Protocol (RTSP) which is designed to adapt topology changes due to link failures or node mobility. RTSP works in a level fashion: each level means the nodes in this level have the same hop. MAC layer time-stamping and linear regression is adopted to compensate clock drift. Compensation mechanism and random time source choice mechanism is introduced to make synchronization robust against link and node failures. The protocol is implemented on the SIA2420 platform using TinyOS and the result show the reliability of our protocol.

can get high precision for the network time synchronization, following with intensive computing [2]. In WSNs, with battery-powered nodes, the limits for energy supplying, bound of the size and the cost, even the Harsh Environment for the node distributed, GPS and NTP are not suitable for WSNs. Several time synchronization protocols have been developed to deal with the special requirements of WSNs application. Some of the notable ones are Reference Broadcast Synchronization (RBS) algorithm [3], Timingsync Protocol for Sensor Networks (TPSN) [4] and Flooding Time Synchronization Protocol (FTSP) [5], Simple Time Synchronization [6], Tsync [7] and Lightweight Time Synchronization (LTS) [8]. There are protocols implementations for these protocols that can achieve synchronization of a few microseconds. However, all these experiments are implemented in laboratory environment with less radio interference. Most of the protocols employ node to node time synchronization and once the parent node failed, all the child of this node will out of synchronization and a process of refresh the topology or re-synchronization may occur. As in figure 1, node 0 is the root of the whole network and it act as the reference time source of other nodes. If node 1 is invalidation all the nodes synchronized through node 1 such as node 3, 4, 5, 6 will out of synchronization soon.

Index Terms—WSNs; time synchronization; clock drift; random time source; RTSP

I. INTRODUCTION WSNs consist of large populations of wirelessly connected nodes, capable of computation, communication, and sensing. As one of the key technologies in WSNs, time synchronization plays an important role in node localization, low power listening, data fusion, TDMA, synchronized hopping system etc. Although each sensor node is equipped with a hardware clock, these hardware clocks can usually not be used directly, as they suffer from severe drift. No matter how well these hardware clocks will be calibrated at deployment, the clocks will ultimately exhibit a large skew. In order to get an accurate common time, nodes need to exchange messages from time to time, constantly adjusting their clock values. Recently, two main network time synchronization methods GPS and NTP are widely used. The GPS method is by receiving time from a Global Position System (GPS) [1], which can provide a high precision; however this information is not available in some situations especially in the battlefield. In addition, GPS receivers are expensive. The other method is Network Time Protocol (NTP), which is operated for internet, and by which we

0

2 4

6

5

Figure 1. one example of time synchronization

In this paper we propose an error prediction compensation mechanism to provide better average synchronization precision and random time source choice mechanism to decrease the probability of synchronization failure. The remainder of this paper is organized as follows. In Section 2 Time Mode of Timesynchronization shows the model of packet delay and oscillator frequency. Time synchronization algorithm and error prediction compensation mechanism will be described in Section 3. In Section 4, the random choice of

This work was supported by Chinese National 863 High Technology Plan under grant number 2007AA041201, National Natural Science Foundation of China 60804067 and National Excellent Young Leader Foundation under grant number 60725312 © 2010 ACADEMY PUBLISHER AP-PROC-CS-10CN007

1

3

9

time source is discussed. In Section 5, the experiment results are given and the conclusion is presented in Section 6. I.

estimates. In this case, a quadratic model can be used to detect clock drift [5]. Without concern the drift between two clocks, constant model should exchange messages from time to time, constantly adjusting their clock values. A quadratic model will lead to higher computational complexity and this is not suitable for resource constrained wireless sensor networks. Current state-of–the–art linear model is widely used for time synchronization in WSNs, and the design such as FTSP can optimize the clock skew to get good performance in WSNs.

THE INFLUENCE ON TIME-SYNCHRONIZATION

Clocks in nodes, in general, based on crystal oscillators which provide a local time for each network node. The time in a node clock is just a counter that gets incremented with crystal oscillators and is referred to as software clock. The software clock must be increased by the interrupt handler every time an interrupt occurs. Most hardware oscillators are not so precise because the frequency which makes time increase is never exactly right. Even a frequency deviation of only 0.001% would bring a clock error of about one second per day [9]. Considering the physical clock synchronization in a distributed system to UTC (Universal Time Controller), the node clock shows time C(t), which may or may not be the same as t, at any point of real time t. For a perfect clock, the derivative dC(t)/dt should be equal to 1. This term is referred to as clock rate. The clock rate can actually vary over time due to environmental conditions, such as humidity and temperature, but we assume that it stays bounded and close to 1, so that:

1− ρ ≤

dC (t ) ≤1+ ρ . dt

II.

In this section, we describe our clock synchronization algorithm. The basic idea of the algorithm is to use linear regression to achieve time drift between nodes and an error prediction approach to obtain one-step look-ahead prediction is taken charge for compensation mechanism. Given a time window of n observations, (TAi, TBi), we can predict the time at node B give a new time at node A, TA using ordinary least squares (OLS) to get a linear regression estimation with equation (3) as:

TˆB = βˆ + λˆTA .



t

t0

fi (τ )dτ + Ψ i (t0 ) .

TˆB ± ⎡t(1−α ) / 2,n − 2 * SE (TˆB ) ⎤ . ⎣ ⎦

(2)

(5)

The first term in the product in equation (5) stands for an upper quantile of the t distribution with n-2 degrees of freedom, and the last is the standard error of the predicted value [13]. The estimate of the prediction error (Ep) we represent as δ. Using 95% confidence interval is the typical choice made in literature due the Gaussian assumption on the error distribution. For clock used in networks, we will pay the whole attention to the present and future clock time. Arithmetic of linear regression takes charge of the time segment of collecting data for calculation and the parameters acquired gives a good approach for the past time but additional error may occur at present time or the future so the prediction of time error mentioned before is necessarily and a compensation algorithm implemented to compensate the prediction error.

Where ψi(t0) is the hardware clock offset of node i at time t0. From equation (1) the f(t) in equation (2) can be denote as 1 - ρ ≤ f(t) ≤ 1 + ρ. Where 0 ≤ ρ < 1, which means the hardware clock never stops and always makes progress with at least a rate of 1 - ρ. This is a reasonable assumption since common sensor nodes are equipped with external crystal oscillators which are used as clock source for the clock of the nodes. Dealing with equation (2) a Taylor series expansion of T(t) yields [11]

Ti (t ) = βi + λi t + γ i t 2 " .

(4)

Follow standard regression theory [12], a (1-α) confidence interval can be constructed for this prediction as:

(1)

The clock rate dC(t)/dt denote as f(t), so the clock value in a node i at time t can be defined as [10]

Ti (t ) =

SYNCHRONIZATION ALGORITHM

(3)

Here the subscript β is the offset, and α is the skew, and γ can be used to model and detect time variation, i.e., departure from the linear model. Some protocol such as TPSN use constant model (αi=0 and γi=0) that concern noting more than time offset between two clocks. Several protocols such as FTSP employ linear model (γi=0) and estimation of αi and βi is readily accomplished via linear regression (least squares). This is optional if the error is Gaussian and can provide the best linear estimator for any error pdf commonly. When the skew and offset are varying with time, a quadratic model can be employed. If αi and βi change in the observation interval, a linear fit will get biased

^ T

B

Ep

0

Figure 2. The compensation algorithm

10

TA

IV.

The compensation algorithm will work once Ep is derived while new time information arrived. As show in figure 2, the black line acts as the time of node A, and the red dashed line denotes as the logical time of node B relative to TA. When Ep is compensated after the calculation, the static error of the logical time in node B can be eliminated and the same process with the next period and so on. III.

This section describes the implementation of our Reliable Time Synchronization Protocol on the SIA2420 sensor nodes using the TinyOS operating system. Target Platform The hardware platform used for the implementation of the protocol is the SIA2420 sensor node from Shenyang Institute of Automation in China. It features a TI MSP430 microcontroller with 10kB RAM. The CC2420 radio module has been designed for low-power applications and offers data rates up to 250 kBaud using Direct Sequence Spread Spectrum (DSSS). The MSP430 microcontroller has 10 build-in 16 bit timers in which 3 timers denoted as timer A and the other 7 as timer B. The SIA2420 board is equipped with two different quartz oscillators (32 kHz and 8 MHz) which can be used as clock sources for the timers. Timer A is configured to operate at 1/8 of oscillator frequency (8 MHz) leading to a clock frequency of 1 MHz. Since Timer A is sourced by an external oscillator it is also operational when the microcontroller is in low-power mode. We employ Timer 2 in Timer A to provide our system with a free-running 32-bit hardware clock which offers a precision of a microsecond.

RANDOM TIME SOURCE

The protocols mentioned earlier always make use of node to node time synchronization. The time precision and the survival period of synchronization depends on the time source the synchronized node selected and if any problem occurs for the time source, all the children of this node will be out of synchronization. If wireless devices deploy in places accompany with other wireless equipments or in industrial plant full of electronic interference, communication fails will be familiar. In this protocol, node in the network employs several potential nodes as time source and randomly selects one for time synchronization every time period. Some rules deploy as follow: z The better of the link quality implies much more probability to be chosen as time source. z If the node success received time information from its recent time source, the parameters according to link quality will be updated, otherwise decrease the parameters. Once the parameters of the potential time source lower the limit of link quality, the corresponding node will be deleted from the potential time source queue. z If the node fails to synchronize to all the potential time sources, a resynchronization process will be held. One example of the choice of time source show in figure 3 and the choice of time source depends on the hops from the root. The node 1 and 2 can hear from the network root 0 and they can only synchronize to node 0. The node within the radio radius of node 1 and node 2 can make these two nodes as potential time sources like node 4 and node 7 in figure 3. In the same way, node 5 can acquire 3 potential time source as 4, 6 and 7 in figure 3.

TinyOS Implementation The implementation of RTSP on SIA2420 platform is done in TinyOS 2.1. The protocol implementation provides time synchronization as service for an application running on the mote. The architecture of the time synchronization component and its relation to other system components is shown in figure 4 Applicaton Time Synchronization Component

1

Logical Clock

Rdio

Local Clock

The RTSP module periodically broadcasts a synchronization beacon containing the sending timestamp. Each node overhearing messages sort by the choice of time source managed by RTSP module and run compensation mechanism is disposed by Logical Clock module.

2 4

RTSP

Figure 4. Architecture of time synchronization service and its integration within the hardware and software platform

0

3

EXPERIMENT RESULTS

Experiment Results We tested the protocol focusing on the precision after compensation and the reliability with our random time source select mechanism. The precision test is carried out to make compare with the widely used FTSP. The instant error of two protocols is show in figure 5. Part (a) shows the precision using FTSP and part (b) shows the RTSP with compensation. Analyzing the two curves our protocol can acquire more stable precision under our compensation mechanism.

7

6 5 Figure 3. Example of random time source algorithm

Random selecting can reduce the probability of resynchronization due to link failure and get robust of synchronization. As depict in figure 3 if one of the parents of node 5 fails, it can remain synchronized with the other two nodes. 11

SIA2420 platforms running TinyOS. The average precision is no more than 5µs and robustness to link failure. This performance is markedly better than those of other existing time synchronization approaches on the same platform.

A scene show as figure 6 is adopted to test the reliability of our random time source mechanism. Node 0 acts as the root and the reference time of the network, and the one hop with nodes (1, 2 and 3) act as the first level of network maintain the unique time source of node 0. Node 5 deploys within the radio range of the three one hop nodes but beyond the scope of node 0 and the same as node 4 and node 6. Node 5 can randomly synchronized to it three potential time sources of one hop and the other two nodes (4 and 6) run unique time source selecting mechanism. The result shows in figure 7 and the node that runs a random selection with 3 time sources achieves better performance. Although nodes with single source can not always choose time source with the most stable as figure 7 in which the node with single source selects its time source of the curve with diamond shape and following with our protocol the node with random choice can obtain a compromise performance. The point at the peak means the node out of synchronization, which we adopt for the convenient of exhibiting the relation of our experiment since the error has great value. The node with single time source may fail of synchronization for the failure of the link with its source node as the peak point in figure 7 and the node performs random choice can always under good synchronization for not relying one single time source. 10 9 8 7 6 5 4 3 2 1 0

0

1

4

3

5

6

Figure 6. Test scene of the experiment

The RTSP was tested and its performance was verified in a real world application. This is important because the service had to operate not in isolation, but as part of a complex application where resource constraints as well as intended and unintended interactions between components can and usually do cause undesirable effects. Moreover, the system operated in the field with factory device and other interference. This is a testimony to the robustness of the protocol and its implementation. Several further researches can be done in the future. The first is the influence of temperature to the accuracy of our protocol should be concerned and eliminated. Also synchronization information can be carried by some normal message in the network to reduce the energy cost by synchronous messages.

precision(us)

without compensation

one hop one hop

one hop single time source

random 3 time sources

30

60

8.00

90 120 150 180 210 240 270 300 time(s)

average error(us)

0

(a) time precision of FTSP

10 precision(us)

2

with compensation

8 6

7.00 6.00 5.00 4.00 3.00 2.00 1.00 0.00

4

0

2

10

20

30

40

50

60

time(min)

0 0

30

60

Figure 7. The compare of single time source and random time sources

90 120 150 180 210 240 270 300 time(s)

(b) time precision of RTSP

ACKNOWLEDGMENT

Figure 5. The compare of FTSP and RTSP with compensation

V.

This work is supported by Chinese National 863 High Technology Plan under grant number 2007AA041201, National Natural Science Foundation of China 60804067 and National Excellent Young Leader Foundation under grant number 60725312.

CONCLUSION AND FUTURE IMPROVEMENT

We have described the Reliable Time Synchronization Protocol for WSN. The protocol was implemented on 12

REFERENCES [1] W. Zhu and Ieee, TDMA Frame Synchronization of Mobile Stations Using a Radio Clock Signal for Short Range Communications, 1994. [2] K. Guanlin, W. Fubao, and D. Weijun, "Survey on Time Synchronization for Wireless Sensor Networks," Computer Measurement & Control, vol. 13, pp. 1021-1023,1030, 2005. [3] J. Elson, L. Girod, D. Estrin, and U. Usenix, "Fine-grained network time synchronization using reference broadcasts," Boston, Ma, 2002, pp. 147-163. [4] P. Ganeriwal, P. Kumar, and M. B. Srivastava, "Timingsync protocol for sensor networks " Conference On Embedded Networked Sensor Systems, pp. 138 - 149 2003. [5] M. Maroti, B. Kusy, G. Simon, and A. Ledeczi, "The flooding time synchronization protocol," Baltimore, MD, United states, 2004, pp. 39-49. [6] M. L. Sichitiu, C. Veerarittiphan, and I. Ieee, "Simple accurate time synchronization for wireless sensor networks," New Orleans, La, 2003, pp. 1266-1273. [7] H. Dai and R. Han, "TSync: a lightweight bidirectional time synchronization service for wireless sensor networks "

[8]

[9] [10] [11] [12] [13]

13

ACM SIGMOBILE Mobile Computing and Communications Review vol. 8, pp. 125 - 139 2004. J. v. Greunen and J. Rabaey, "Lightweight Time Synchronization for Sensor Networks," Proceedings of the 2nd ACM international conference on Wireless sensor networks and applications pp. 11-19, 2003. I. K. Rhee, J. Lee, J. Kim, E. Serpedin, and Y. C. Wu, "Clock Synchronization in Wireless Sensor Networks: An Overview," Sensors, vol. 9, pp. 56-85, Jan 2009. P. Sommer, R. Wattenhofer, and Ieee, Gradient Clock Synchronization in Wireless Sensor Networks, 2009. B. M. Sadler, A. Swami, and Ieee, "Synchronization in sensor networks: an overview," Washington, DC, 2006, pp. 1983-1988. C. R. Rao, Linear Statistical Inference and Its Applications. New York: Wiley, 1973. S. Ganeriwal, I. Tsigkogiannis, H. Shim, V. Tsiatsis, M. B. Srivastava, and D. Ganesan, "Estimating Clock Uncertainty for Efficient Duty-Cycling in Sensor Networks," Ieee-Acm Transactions on Networking, vol. 17, pp. 843-856, Jun 2009.