research article time synchronization in wireless sensor...

11
Hindawi Publishing Corporation International Journal of Distributed Sensor Networks Volume 2013, Article ID 192128, 10 pages http://dx.doi.org/10.1155/2013/192128 Research Article Time Synchronization in Wireless Sensor Networks Using Max and Average Consensus Protocol Zhao Dengchang, An Zhulin, and Xu Yongjun Institute of Computing Technology, Chinese Academy of Sciences, Beijing 100190, China Correspondence should be addressed to Xu Yongjun; [email protected] Received 26 December 2012; Accepted 28 February 2013 Academic Editor: Guangjie Han Copyright © 2013 Zhao Dengchang et al. is is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. is paper proposes a novel distributed time synchronization scheme for wireless sensor networks, which uses max consensus to compensate for clock driſt and average consensus to compensate for clock offset. e main idea is to achieve a global synchronization just using local information. e proposed protocol has the advantage of being totally distributed, asynchronous, and robust to packet drop and sensor node failure. Finally, the protocol has been implemented in MATLAB. rough several simulations, we can see that this protocol can reduce clock error to ±10 ticks, adapt to dynamic topology, and be suitable to large-scale applications. 1. Introduction As in all distributed systems, time synchronization is very important in wireless sensor networks (WSNs) since the design of many protocols and implementation of applications require precise time, for example, forming an energy-efficient radio schedule, conducting in-network processing (data fusion, data suppression, data reduction, etc.), distributing an acoustic beamforming array, performing acoustic ranging (i.e., measuring the time of flight of sound), logging causal events during system debugging, and querying a distributed database. Time synchronization is a research area with a very long history. Various mechanisms and algorithms have been pro- posed and extensively used over the past few decades. How- ever, several unique characteristics of WSNs oſten preclude the use of the existing synchronization techniques in this domain. First, since the amount of energy available to battery- powered sensors is quite limited, time synchronization must be implemented in an energy-efficient way. Second, some messages need to be exchanged for achieving synchronization while limited bandwidth of wireless communication discour- ages frequent message exchanges among sensor nodes. ird, the small size of a sensor node imposes restrictions on com- putational power and storage space. erefore, traditional synchronization schemes such as network time protocol (NTP) and global positioning system (GPS) are not suitable for WSNs because of complexity and energy issues, cost efficiency, limited size, and so on. In the context of WSNs, time synchronization refers to the problem of synchronizing clocks across a set of sensor nodes that are connected to one another over a single-hop or multihop wireless networks. To achieve time synchronization in wireless sensor networks, we have to face the following four challenges. 1.1. Nondeterministic Delays. ere are many sources of mes- sage delivery delays. Kopetz and Ochsenreiter [1] describe the components of message latency, which they call the Reading Error, as being comprised of 4 distinct components plus the local granularity of the nodes clocks. eir work was later expanded by [2] to include transmission and reception time. e most nondeterministic delay is called Access Time, which is incurred in the MAC layer waiting for access to the transmit channel, its orders of magnitude is larger than the synchronization precision required by the network. 1.2. Clock Driſt. Manufacturers of crystal oscillators spec- ify a tolerance value in parts per million (PPM) relative

Upload: others

Post on 01-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Research Article Time Synchronization in Wireless Sensor …downloads.hindawi.com/journals/ijdsn/2013/192128.pdf · 2015-11-21 · powered sensors is quite limited, time synchronization

Hindawi Publishing CorporationInternational Journal of Distributed Sensor NetworksVolume 2013 Article ID 192128 10 pageshttpdxdoiorg1011552013192128

Research ArticleTime Synchronization in Wireless Sensor Networks UsingMax and Average Consensus Protocol

Zhao Dengchang An Zhulin and Xu Yongjun

Institute of Computing Technology Chinese Academy of Sciences Beijing 100190 China

Correspondence should be addressed to Xu Yongjun xyjictaccn

Received 26 December 2012 Accepted 28 February 2013

Academic Editor Guangjie Han

Copyright copy 2013 Zhao Dengchang et al This is an open access article distributed under the Creative Commons AttributionLicense which permits unrestricted use distribution and reproduction in any medium provided the original work is properlycited

This paper proposes a novel distributed time synchronization scheme for wireless sensor networks which uses max consensus tocompensate for clock drift and average consensus to compensate for clock offsetThemain idea is to achieve a global synchronizationjust using local information The proposed protocol has the advantage of being totally distributed asynchronous and robust topacket drop and sensor node failure Finally the protocol has been implemented inMATLABThrough several simulations we cansee that this protocol can reduce clock error to plusmn10 ticks adapt to dynamic topology and be suitable to large-scale applications

1 Introduction

As in all distributed systems time synchronization is veryimportant in wireless sensor networks (WSNs) since thedesign ofmany protocols and implementation of applicationsrequire precise time for example forming an energy-efficientradio schedule conducting in-network processing (datafusion data suppression data reduction etc) distributingan acoustic beamforming array performing acoustic ranging(ie measuring the time of flight of sound) logging causalevents during system debugging and querying a distributeddatabase

Time synchronization is a research area with a very longhistory Various mechanisms and algorithms have been pro-posed and extensively used over the past few decades How-ever several unique characteristics of WSNs often precludethe use of the existing synchronization techniques in thisdomain First since the amount of energy available to battery-powered sensors is quite limited time synchronization mustbe implemented in an energy-efficient way Second somemessages need to be exchanged for achieving synchronizationwhile limited bandwidth of wireless communication discour-ages frequentmessage exchanges among sensor nodesThirdthe small size of a sensor node imposes restrictions on com-putational power and storage space Therefore traditional

synchronization schemes such as network time protocol(NTP) and global positioning system (GPS) are not suitablefor WSNs because of complexity and energy issues costefficiency limited size and so on

In the context of WSNs time synchronization refers tothe problem of synchronizing clocks across a set of sensornodes that are connected to one another over a single-hop ormultihopwireless networks To achieve time synchronizationinwireless sensor networks we have to face the following fourchallenges

11 Nondeterministic Delays There are many sources of mes-sage delivery delays Kopetz andOchsenreiter [1] describe thecomponents of message latency which they call the ReadingError as being comprised of 4 distinct components plusthe local granularity of the nodes clocks Their work waslater expanded by [2] to include transmission and receptiontimeThemost nondeterministic delay is called Access Timewhich is incurred in the MAC layer waiting for access to thetransmit channel its orders of magnitude is larger than thesynchronization precision required by the network

12 Clock Drift Manufacturers of crystal oscillators spec-ify a tolerance value in parts per million (PPM) relative

2 International Journal of Distributed Sensor Networks

the nominal frequency at 25∘C which determines the max-imum amount that the skew rate will deviate from 1 For thenodes used in WSNs the tolerance value is typically in theorder of 5 to 20 PPM If no drift compensation applied twosynchronized nodes will be out of step soon

13 Robustness Since sensor networks are often left unat-tended for long periods of time in possibly hostile environ-ments synchronization schemes should be robust againstlink and node failures Mobile nodes can also disrupt routingschemes and network partitioning may occur

14 Convergence Speed Nodes in wireless sensor networksalways distribute in large scales one node may get in touchwith another by many hops This increases the difficultyin reducing the convergence speed in time synchronizationalgorithm design

Up to nowmany protocols have been designed to addressthis problem These protocols all have some basic featuresin common a simple connectionless messaging protocolexchange of clock information among nodes mitigatingthe effect of nondeterministic factors in message deliveryand processing utilizing different schemes and algorithmsrespectivelyThey can be classified into two types centralizedsynchronization and distributed synchronization

Centralized synchronization protocol such as RBS [4]TPSN [2] and FTSP [3] usually has fast convergence speedand little synchronization error This kind of protocol needsa physical node acting as the whole networkrsquos referenceclock so it has to divide the nodes into different roles forexample client node and beacon node in RBS If the nodewith the special role such as beacon node in RBS is out ofwork the protocol will suffer from big damage To deal withthe WSNsrsquo dynamic topology centralized synchronizationprotocol is often designed with complexity logic Anotherdisadvantage of centralized synchronization protocol is thatsynchronization error grows with the increase of networkhops

Distributed synchronization protocol such as TDP[5]GCS [6]RFA [7]ATS [8]CCS [9] can use local informa-tion to achieve the whole network synchronizationThis kindof protocol can easily adapt toWSNsrsquo dynamic topology prop-erty with lite computation Currently the disadvantage ofdistributed synchronization protocol is that the convergencespeed may be a bit slow relating to the network topology

This paper describes a new distributed protocol for timesynchronization in wireless sensor networks called timesynchronization using max and average consensus protocol(TSMA) We adapt a number of techniques to take up thechallenges time synchronization has in WSNs To eliminatethe nondeterministic delays we make use of MAC layertimestamp technique To compensate for the clock drift weadapt max consensus protocol and we use average consensusprotocol to compensate for the clock offset This protocolhas the advantages of being computationally light scalableasynchronous robust to node and link failure and it does notrequire a master or controlling node

The rest of the paper is organized as follows Section 2summarizes the related work Section 3 introduces somemathematical tools and definitions that will be instrumentalfor the proof of convergence of the proposed TSMA algo-rithm Section 4 introduces a model for the clock dynamicsand formally defines the synchronization objectives whileSection 5 presents the TSMA algorithm in details Thisis followed by MATLAB simulations in Section 6 FinallySection 7 briefly summarizes the results obtained and pro-poses potential research directions

2 Related Work

Typical time synchronization algorithms in WSNs includetiming-sync protocol for sensor networks (TPSNs) [2] ref-erence broadcast synchronization (RBS) [4] flooding timesynchronization protocol (FTSP) [3] time diffusion protocol(TDP) [5] global clock synchronization (GCS) [6] Reach-back Firefly algorithm (RFA) [7] average time synchroniza-tion (ATS) [8] and consensus clock synchronization (CCS)[9] RBS TPSN and FTSP are centralized synchronizationprotocols while TDP GCS RFA ATS and CCS are dis-tributed synchronization protocols

TPSN [2] is designed as a flexible extension of NTP[10] for use in wireless sensor networks which consists oftwo phases a level discovery phase and a synchronizationphaseThe level discovery phase organizes the whole networkinto a hierarchical tree topology with the master node atits root then perform the pair wise synchronization alongthe branches of the hierarchical structure using the classicalsender-receiver synchronization handshake exchange in thesynchronization phase TPSN is a centralized synchroniza-tion protocol utilizes MAC layer timestamping to reducemessage delivery nondeterminism and improve synchro-nization accuracy its convergence speed increases linearlywith the max network hops This approach suffers fromtwo limitations The first limitation arises because if theroot node or parent node dies then a new root election orparent-discovery procedure needs to be initiated thus addingsubstantial overhead to the code and long periods of networkdesynchronization The second limitation is due to the factthat geographically closed nodes might be far in terms of thetree distance which is directly related to increase the clockserror locally

RBS [4] aims to provide synchronization amongst aset of client nodes located within the single-hop broad-cast range of a beacon node Compared to the traditionalprotocols working on an LAN its main contribution is todirectly remove two of the largest sources of nondeterminisminvolved in message transmission transmission time andaccess time by exploiting the concept of a time criticalpath which is the path of a message that contributes tonondeterministic synchronization errors This centralizedprotocol uses least squares linear regression to compensatefor the clock drift its convergence speed also increaseslinearly with the max network hops Using the beacon nodemakes this protocol vulnerable to node failure and nodemobility

International Journal of Distributed Sensor Networks 3

FTSP [3] is an ad-hoc multihop time synchronizationprotocol for WSNs It achieves high accuracy by utilizingtimestamping of radio messages in low layers of radio stackcompletely eliminating access time to the radio channelrequired in CSMA MAC protocols Further accuracy isachieved by compensating for clock skews of participat-ing nodes via linear regression Several mechanisms areused to provide robustness against node and link failuresmost notably periodic flooding of synchronization messagesthroughout the whole network but this approach still do notcompletely solve the limitations aforementioned in TPSN

Nodes employing TDP [5] periodically self-determine tobecome masterdiffusion leader nodes using an electionre-election procedure Master nodes then engage neighboringnodes in a peer evaluation procedure to isolate problemnodes Timing information messages are broadcasted frommaster nodes and then rebroadcasted by the diffused leadernodes for a fixed number of hops forming a radial treestructure This approach is fully distributed but it does notcompensate for the clock drift To the application needingsmall tolerance time this algorithm has to increase the syn-chronization frequency which greatly decreases the nodersquosbattery life

In GCS [6] nodes take turns to broadcast a synchro-nization request to their neighbors who each respond witha message containing their local time The receiving node(at the center of this exchange) averages the received time-stamps and broadcasts this value back to its neighbors whichadopt this value as their new time This is repeated by eachnode in the network until network wide synchronization isachieved This approach is fully distributed but it does notcompensate for the clock drift To get higher time accuracy ithas to decrease the time synchronization period

RFA [7] is inspired by firefly synchronizationmechanismIn this algorithm every node periodically broadcasts asynchronization message and anytime they hear a messagethey advance of a small quantity the phase of their internalclock that schedules the periodic message broadcastingEventually all nodes will advance their phase till they are allsynchronized that is they fire a message at the same timeThis approach however does not compensate for clock drifttherefore the firing period needs to be rather small

ATS [8] uses a cascade of two consensus algorithmsto tune compensation parameters and converge nodes to asteady state virtual clock In the first stage nodes broadcastlocal timestamps in order to estimate the clock skew ratesrelative to each other Nodes then broadcast their currentestimate of the virtual clock skew rate and receiving nodescombine this with their relative skew estimates to adjust theirown virtual clock estimateThe same principle is then appliedto remove the offset errorsThis is a fully distributed protocolits convergence speed is a bit slow related to the networktopology

CCS [9] utilizes average consensus algorithm to compen-sate the clock offset By the accumulated offset error thatthey remove during each round of offset compensation nodescan observe how much their own clocks drift away from theconsensus time then they use this information to compensatethe clock drift which can be seen as an enhancement of

Table 1 Time synchronization features for different protocols

Distrib Skew comp MACtimestamp

Linear skewconvergence speed

TPSN [2] No No No NoFTSP [3] No Yes Yes YesRBS [4] No Yes Yes YesTDP [5] Yes No No NoGCS [6] Yes No No NoRFA [7] Yes No No NoATS [8] Yes Yes Yes NoCCS [9] Yes Yes Yes NoTSMA Yes Yes Yes Yes

ATS This approach is also fully distributed and has thedisadvantage of slow convergence speed

The TSMA protocol proposed in this paper is similarto ATS and CCS It is fully distributed that is it doesnot require any special root including skew compensationand exploits MAC-layer timestamping for higher accuracyUnlike ATS and CCS the proposed protocol uses maxconsensus method to compensate the clock drift which hasfaster skew convergence speed as the centralized protocolthat is it increases linearly with the max network hops Thefeatures of all the protocols mentioned in this section aresummarized in Table 1

3 Mathematical Preliminaries

We assume that links inWSNs are symmetric so the networkcan be modeled as an undirected graph 119866 = (119881 119864) where119881 = V

119894| 119894 = 1 2 119899 represents the nodes in the WSNs

and the edge set 119864 represents the available communicationlinks that is (V

119894 V119895) isin 119864 if node 119895 sends information to node

119894 We refer to V119894and V119895as the tail and head of the edge (V

119894 V119895)

respectively The orientation of the graph is a choice of headsand tails for each undirected edge The set of edges of a fixorientation of the graph is denoted by 119864

0 Thus 119864

0contains

one and only one of the two edges (V119894 V119895) (V119895 V119894) isin 119864 We

use 119898 to present edge number and 119899 the vertex number forexample 119899 = |119881| 119898 = |119864

0| The set of neighbors of node is

denoted by 119873119894= V119895| 119890119894119895isin 119864 The degree of node V

119894is the

number of its neighbors |119873119894| and is denoted by deg(V

119894) The

degreematrix is an 119899times119899matrix defined asΔ = Δ(119866) = Δ119890119894119895

where

Δ119890119894119895=

deg (V119894) 119894 = 119895

0 119894 = 119895

(1)

Let 119860 denote the adjacency matrix of 119866 Then theLaplacian of graph 119866 is defined by

119871 = Δ minus 119860 (2)

The matrix 119871 has the following features(i) All the row sums of 119871 are zero and thus 119890

0= (1

1 1)119879

isin 119877119899 is an eigenvector of 119871 associated with

the eigenvalue 0

4 International Journal of Distributed Sensor Networks

(ii) Fix and orientation of the graph and let 1198640= 119890119894|

119894 = 1 2 119898 then 119871 = 119862119862119879 where 119862 = 119888119901119902 is an

119899 times 119898matrix 119899 is the number of vertex set119881 and119898is the number of the edge set 119864

0

119888119901119902=

+1 if V119901is the head of edge 119890

119902

minus1 if V119901is the tail of edge 119890

119902

0 otherwise(3)

It is a well-known fact that this property holds regardlessof the choice of the orientation of119866 [11] Let 119909

119894denote a scalar

real value assigned to V119894 Then 119909 = (119909

1 1199092 119909

119899)119879 denotes

the state of the graph 119866 We define the Laplacian potential ofthe graph as follows

Ψ119866(119909) =

1

2

119909119879

119871119909 (4)

Lemma 1 (Laplacian potential [12]) Ψ119866(119909) has the following

properties

(i) Undirected graph 119866rsquos Laplacian potential is positivesemidefiniteness and

119909119879

119871119909 = sum

(V119894 V119895)isin1198640

(119909119894minus 119909119895)

2

(5)

(ii) If 119866 is a connected graph Ψ119866(119909) = 0 if and only if 119909

119894=

119909119895 for all 119894 119895

Lemma 2 (connectivity and graph Laplacian [11]) Assumegraph G has c connected components then

rank (119871) = 119899 minus 119888 (6)

Particularly for a connected graph with 119888 = 1 rank(119871) =119899 minus 1

Lemma 3 119866 is an undirected and connected graph 119871 is 119866rsquosLaplacian matrix then there must be a zero in 119871rsquos eigenvaluesand all the other eigenvalues of 119866 are positive and real

Proof 119866 is an undirected graph then 119871 is a real symmetricmatrix After diagonalization the rank of matrix 119871 stays thesame 119866 is a connected graph then based on Lemma 2 therank of matrix 119871 is 119899 minus 1 then there must be a zero in 119871rsquoseigenvalues and all the other eigenvalues of 119866 are nonzero 119871is a real symmetric matrix so 119871rsquos eigenvalues are real Basedon Lemma 1 119871 is a positive semidefinite matrix then 119871rsquoseigenvalues are nonnegative In conclusion there must be azero in 119871rsquos eigenvalues and all the other eigenvalues of 119866 arepositive and real

Definition 4 (consensus) Let the value of all nodes 119909 be thesolution of the following differential equation

= 119891 (119909) 119909 (0) isin 119877119899

(7)

In addition let 119883 119877119899

rarr 119877 be a multi-input single-output operation on 119909 = (119909

1 1199092 119909

119899)119879 that generates

a decision value 119910 = 119883(119909) We say all the nodes of the graphhave reached consensus wrt 119883 in finite time 119879 gt 0 if andonly if all the nodes agree and 119909

119894(119879) = 119883(119909(0)) for all 119894 isin 119868

Some of the common examples of the operation 119883 are givenas follows

(i) average consensus

119883 (119909) = Ave (119909) = 1

119899

119899

sum

119894=1

119909119894 (8)

(ii) max consensus

119883 (119909) = Max (119909) = max (1199091 1199092 119909

119899) (9)

(iii) min consensus

119883 (119909) = Min (119909) = min (1199091 1199092 119909

119899) (10)

Theorem 5 119866 is an undirected and connected graph if everynode in 119866 runs the following distributed protocol

119906119894(119905) = sum

119895isin119873119894

(119909119895(119905) minus 119909

119894(119905)) + 119879

0 (11)

where 1198790is a constant then the vector of the value of the nodes

119909 is the solution of the following ordinary differential equations

= minus119871119909 + (1198790 1198790 119879

0)119879

119909 (0) isin 119877119899

(12)

In addition all the nodes of the graph globally asymptoti-cally reach an average consensus and then every node will havethe same status

119909119894(119905) = 119909

119895(119905) = 119905119879

0+ Ave(119909 (0)) forall119894 119895 119894 = 119895 (13)

Proof Equation (12) corresponds to a typical linear timeinvariant system its complete response can be solved bycalculating zero-status response and zero-input responserespectively

(a) Solve the zero-status response 119909119904(119905) where

119904= minus119871119909

119904+ (1198790 1198790 119879

0)119879

119909119904(0) = (0 0 0)

119879

(14)

Based on Laplacian matrix 119871rsquos features the particularsolution of 119909

119904(119905) is 119909

119901(119905) = 119879

0(119905 119905 119905)

119879 minus119871 is a realsymmetric matrix so minus119871 can do diagonalization let 119875 bethe corresponding invertible matrix Based on the theory oflinear algebra the homogeneous solution of 119909

119904(119905) is

119909ℎ(119905) = 119888

112057211198901205821119905

+ 119888212057221198901205822119905

+ sdot sdot sdot + 119888119899120572119899119890120582119899119905

(15)

where 119888119894(1 le 119894 le 119899) is undetermined coefficient 120582

119894(1 le 119894 le

119899) is matrix 119871rsquos 119894th eigenvalue 120572119894(1 le 119894 le 119899) is119875rsquos 119894th column

which is the corresponding eigenvector of eigenvalue 120582119894 so

the zero-statusrsquos complete response is

119909119904(119905) = 119909

119901(119905) + 119909

ℎ(119905) = 119879

0(119905 119905 119905)

119879

+ 119888112057211198901205821119905

+ 119888212057221198901205822119905

+ sdot sdot sdot + 119888119899120572119899119890120582119899119905

(16)

International Journal of Distributed Sensor Networks 5

We know that 119909(0) = (0 0 0)119879 so 119888

11205721+ 11988821205722+

sdot sdot sdot + 119888119899120572119899= (0 0 0)

119879 in addition 1205721 1205722 120572

119899is linear

independence then 1198881= 1198882= sdot sdot sdot = 119888

119899= 0 the solution of

zero-status response is 119909119904(119905) = 119879

0(119905 119905 119905)

119879(b) Solve the zero-input response 119909

119904(119905) where

0= minus119871119909

0 1199090(0) = 119909 (0) (17)

Observe that all the eigenvalues of minus119871 are negative exceptfor the single zero eigenvalueThus any solution of the systemasymptotically converges to a point 119909lowast

0

in the eigenspaceassociatedwith120582

1= 0This implies that an average consensus

is globally asymptotically reached by all the nodes Let 119909lowast0

beone equilibrium of the system

0= minus119871119909

0 Then minus119871119909lowast

0

= 0and thus 119909lowast is the eigenvector of the Laplacian 119871 associatedwith the zero eigenvalue 120582

1= 0 On the other hand we

have 120595119866(119909lowast

0

) = (12)(119909lowast

0

)119879

119871119909lowast

0

= 0 and from connectivityof 119866 it follows that 119909lowast

0119894

= 119909lowast

0119895

= 119886 for all 119894 119895 that is 119909lowast0

=

(119886 119886 119886)119879 119886 isin 119877 Notice that sum119899

119894=1

1199090119894= 0 Thus Ave(119909

0)

is an invariant quantity This implies Ave(119909lowast0

) = Ave(119909(0))But Ave(119909lowast

0

) = 119886 therefore 119886 = Ave(119909(0)) then the solutionof zero-input response is 119909lowast

0

= (119886 119886 119886)119879 where 119886 =

Ave(119909(0))Above all when zero-input response reaches the equilib-

rium status the systemrsquos full response is

119909 (119905) = 119909119904(119905) + 119909

0(119905)

= (1199051198790+ Ave (119909 (0)) 119905119879

0+ Ave (119909 (0)) 119905119879

0

+ Ave (119909 (0)))119879

(18)

In other words every node in the network finally has thesame status

4 Clock Model

Clock synchronization is of significant importance in WSNsBefore delving into the details of synchronizing clocks wefirst define some terminologies used in this paper 119888(119905)denotes a reference clock where 119905 is the real time thatis coordinated universal time (UTC) Every sensor nodemaintains its own local clock which is a monotonicallynondecreasing function of 119905 This local clock is an ensembleof hardware and software components essentially a timer thatcounts the oscillations of a quartz crystal running a particularfrequency In general the timer is programmed to generatean interrupt which is called a clock tick At each clock tickthe interrupt procedure increments the clock value stored inmemory

For any two nodesrsquo local clocks 119888119894(119905) and 119888

119896(119905) the clock

119888119894(119905) is considered correct at time 119905 if 119888

119894(119905) = 119888(119905) or the clock

119888119894(119905) is considered accurate at time 119905 if 119889119888

119894(119905)119889119905 = 119889119888(119905)119889119905

and two clocks 119888119894(119905) and 119888

119896(119905) are synchronized at time 119905 if

119888119894(119905) = 119888

119896(119905) The aforementioned definitions show that the

two synchronized clocks are not always correct or accuratetime synchronization is not related to time correctness andaccuracy As for most applications in WSNs it is sufficient toachieve clock synchronization Since the oscillator frequency

is time varying due to ambient conditions such as temper-ature changes variations of electric supply voltage and airpressure clock 119888

119894(119905) of node 119894 can be modeled as

119888119894(119905) = 119896

119894119905 + 119887119894 (19)

where 119887119894is the clock offset the difference between the time

reported by clock 119888119894(119905) and the real time at the initial instant

1199050(ie 119887

119894= 119888119894(1199050) minus 119888(119905

0)) and 119896

119894is defined as the skew of

the clock 119888119894(119905) To achieve perfect synchronization in a sensor

network all nodes 119894 = 1 2 119873must precisely compensatefor their clock parameters 119896

119894and 119887119894so that all clocks have zero

offset error and all tick at the same rate

5 TSMA Method

In this section we present our time synchronization algo-rithm that is TSMA Instead of trying to synchronize toan external reference like absolute time or UTC the TSMAmethod aims to achieve an internal consensus within thenetwork on what time is and how fast it travels In everysynchronization round the TSMA algorithm updates thecompensation parameters for each node and over time thenetwork clocks converge to a consensus

limtrarrinfin

1198881015840

119894

(119905) = 119888119888(119905) (20)

where 119888119888(119905) is the consensus clock

The consensus clock is not a physical clock it is a newvirtual clock that is generated from the network of nodesrunning the TSMA algorithm The consensus clock has itsown skew rate and offset relative to the absolute time

By expanding the clock functions from both sides of (20)we can see the compensation parameters that all nodes mustobtain in order to synchronize to the consensus clock

lim119905rarrinfin

(1198961015840

119894

119888119894(119905) + 119887

1015840

119894

) = 119896119888119905 + 119887119888

lim119905rarrinfin

(1198961015840

119894

119896119894119905 + 1198961015840

119894

119887119894+ 1198871015840

119894

) = 119896119888119905 + 119887119888

(21)

Then we have

lim119905rarrinfin

1198961015840

119894

=119896119888

119896119894

lim119905rarrinfin

1198871015840

119894

= 119887119888minus 1198961015840

119894

119887119894

(22)

To achieve these compensation parameters nodes repeatthe TSMA algorithm in synchronization rounds whichconsist of two main tasks skew compensation and offsetcompensation In skew compensation the nodes iterativelyselect the max skew rate estimation from its neighbors inorder to improve their skew compensation parameter In theoffset compensation phase nodes average their neighborsrsquoclock readings to synchronize nodes to a common time

51 Skew Compensation Thegoal of skew compensation is toensure all compensated clocks in the network tick at the samerate that is

lim119905rarrinfin

1198961015840

119894

119896119894= 119896119888 forall119894 (23)

6 International Journal of Distributed Sensor Networks

We use max consensus protocol to compensate for clockskew For perfect skew compensation the skew rate of theconsensus clock is given by

119896119888= max (119896

1 1198962 119896

119899) (24)

Nodes execute the following algorithm to converge theirclock skew to the consensus value

Step 1 Before running the synchronization algorithm nodesset their skew estimation 1198961015840

119894

to 1 and set their respect life timelife119894to 0

Step 2 At the beginning of each synchronization round everynode increases their own life time life

119894by 1 If node 119894rsquos life time

life119894gt 3 then node 119894 broadcasts a synchronization packet

containing its own local clock value 120591119894and estimated skew 1198961015840

119894

using a CSMACA MAC scheme once per synchronizationround Like other synchronization techniques MAC layertimestamping is required to ensure that clock values aretransmitted instantly

Step 3 If node 119894 receives a synchronization packet from node119895 at time 119905 then this node should immediately record its ownlocal time 120591

119894(119905) and node 119895rsquos information (120591

119895(119905) 1198961015840

119895

(119905)) If node119894 has not stored a history local time pair before then createthe local time pair (120591

119894(old) 120591

119895(old)) and assign it with

(120591119894(old) 120591

119895(old)) = (120591

119894(119905) 120591119895(119905)) (25)

If the history local time pair has already existed andsatisfies 1198961015840

119894

(119905) lowast (120591119895(119905) minus 120591

119895(old)) gt 119896

1015840

119895

(119905) lowast (120591119894(119905) minus 120591

119894(old))

we will update this nodersquos estimated skew 1198961015840

119894

and the historylocal time pair (120591

119894(old) 120591

119895(old)) using

1198961015840

119894

(119905) = 1198961015840

119895

(119905) lowast120591119894(119905) minus 120591

119894(old)

120591119895(119905) minus 120591

119895(old)

(120591119894(old) 120591

119895(old)) = (120591

119894(119905) 120591119895(119905))

(26)

52 Offset Compensation After the skew compensation algo-rithm is applied all local estimators will eventually have thesame drift that is they will run at the same speed At thispoint it is only necessary to compensate for possible offseterrors To achieve this each node aims to accurately estimatethe instantaneous average time of all its neighborsrsquo clock inthe network and set their clocks to this time FromTheorem 5we can see that every node in the network will finally reachthe same status

119887 (119905) =1

1003816100381610038161003816119873119894

1003816100381610038161003816

sum

119895isin119873119894

119887119895(119905) (27)

In reality however it is not practically possible for nodesto calculate the instantaneous global average time of all itsneighborsrsquo clock in the network Since sensor networks mayconsist of a large number of nodes and one node may havelots of neighbors It is impossible for nodes to exchange clockvalues instantaneously and nodesmay suffer frompacket lossand other network dynamics

0 5 10 15

0

200

400

600Error from average time

Time (mins)

Erro

r (tic

ks)

minus400

minus200

Figure 1 Clock error of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 2

Instead the TSMA algorithm converges network clocksto an approximation of 119887(119905) using the locally availableinformationwithin the single-hop transmission range of eachnode Nodes execute the following algorithm to convergetheir clock offset to the consensus value

Step 1 Before running the synchronization algorithm nodesset their offset estimation 1198871015840

119894

to their current local time and settheir respect life time life

119894to 0

Step 2 At the beginning of each synchronization roundnodes reset their confidence parameter Conf

119894to 1 and

increase their life time life119894by 1 If node 119894rsquos life time life

119894gt 3

then node 119894 broadcasts a synchronization packet containingits estimated offset 1198871015840

119894

and confidence parameter Conf119894using

a CSMACA MAC scheme once per synchronization roundMAC layer timestamping is required to ensure that clockvalues are transmitted instantly

Step 3 For each broadcast all other nodes within receivingrange update their own clocks by combining this value withtheir own clocks using the confidenceweighted running aver-age equation and then increase their confidence parameterConf119894by 1

1198871015840

119894

(119905)=

1198871015840

119895

(119905) if life119894=1

Conf119894(119905)lowast1198871015840

119894

(119905)+Conf119895(119905)lowast1198871015840

119895

(119905)

Conf119894(119905)+Conf

119895(119905)

if life119894gt1

Conf119894(119905)=Conf

119894(119905) + 1

(28)

The confidence parameters give weighting to the clockvalues fromnodes that have already received synchronizationpackets in the current round These nodes are generallycloser to a local consensus than those who have not received

International Journal of Distributed Sensor Networks 7

1 2 3 4 5 6 7 8 9 10

12345678910

0100200300400500

Clock error from the average time before synchronization

50100150200250300350400450500550

∣Err

or∣

(tick

s)

119910119909

(a)

0

200

400

600

800

Clock error from the average time after the synchronization round

20

40

60

80

100

120

140

1 2 3 4 5 6 7 8 9 10

12345678910

∣Err

or∣

(tick

s)

119910

119909

(b)

Figure 2 Geographic distribution of synchronization error of a 10 lowast 10 sensor network for transmission range of 2 (a) before and (b) afterone round of offset compensation

any sync packets and this was found to increase the rateof convergence

6 Simulation

In this paper we use max consensus to compensate for clockskew and use average consensus to compensate for clockoffset To show the correctness and robustness of the TSMAalgorithm we make a simulation in MATLAB the followingis the simulation environment there are 100WSN nodes inthe 10 lowast 10 grid one grid one node and we place the nodein the center of the grid the base value of nodesrsquo oscillatoris 32768KHz the skew rates are assigned randomly from anormal distribution with mean = 1 and standard deviation =20 PPM nodes are given an initial error distribution between0 and 1000 ticks

61 Offset Compensation In this simulation we set the timesynchronization period to 1 minute Nodes broadcast onesync packet per round in random order with a transmissionrange of 2 which means if the distance between two nodesis less than 2 then they can communicate with each otherFigure 1 shows the clock errors from average time measuredin clock cycles In the first three synchronization periodsnodesrsquo life time is less than 3 so they do not transmit anysynchronization packet to their neighbors and then in 3min-utes nodes start to compensate for the clock skew and offsetAfter seven rounds compensation 100 nodes in the networkachieve the synchronization state the synchronization errorbetween any two nodes is included between plusmn10 ticks

The geographic distribution of clock errors in the networkis shown in Figure 2 It can be seen that before Figure 2(a)the first round of offset compensation the clock error relativeto the average time can reach up to 550 ticks but afterFigure 2(b) the first round offset compensation the clockerror reduces to 140 ticks Also we can see that the clock

error after compensation transfer smoothly in geographicdistribution the local error between any neighboring nodesis no larger than 50 ticks

A histogram of the clock errors is shown in Figure 3It can be seen that before Figure 3(a) the first round ofoffset compensation the standard deviation of clock errorreaches up to 28632 but after Figure 3(b) the first roundof offset compensation this value reduces to 7090 FromFigures 2 and 3 we can see that after the first round of offsetcompensation the clock errors among nodes are significantlyreduced

Figure 4 shows the convergence of the skew rates of 100nodes in this simulation From Figure 4 we can see that aftertwo synchronization periods all the 100 nodesrsquo skew ratesconverge on the maximum clock skew

62 Transmission Range Figure 5 shows the transmissionrangersquos effect to algorithm performance We set the trans-mission range to 1 2 and 3 respectively then comparetheir convergence speed with each other From Figure 5we can see that synchronization accuracy and convergencespeed are found to improve as the transmission range of thenodes increased since nodes could receive synchronizationpackets from a greater proportion of the network populationOn the other side to increase the transmission range wealso increase the energy consumption of nodes so in thepractical application we should make a tradeoff betweenenergy consumption and convergence speed

63 Dynamic Topology The simulation shown in Figure 6is intended to study the robustness properties of the TMSAprotocol subject to node failure and node replacement as wellas the performance in terms of convergence speed and steadystate synchronization errorThe synchronization period is setto 1 minute which is sufficiently large to exhibit the effectsof different clock speeds The simulation was run for about

8 International Journal of Distributed Sensor Networks

0 500 1000 15000

2

4

6

8

10

12

14

Clock error (ticks)

Num

ber o

f nod

esHistogram of sync error

120590 = 28632

minus1500 minus1000 minus500

(a)

0

5

10

15

20

25

30

35

40

45

Clock error (ticks)

Num

ber o

f nod

es

Histogram of sync error

120590 = 709

0 500 1000 1500minus1500 minus1000 minus500

(b)

Figure 3 Histogram of the synchronization errors from the instantaneous global average time of the sensor network (a) before and (b) afterone round of offset compensation

0 5 10 151

1

1

1

1

1

1

1

1

1Normalized skew

Time (mins)

Skew

Figure 4 Convergence of the skew rate of 100 simulated nodes run-ning the TSMA protocol in a 10 lowast 10 network with synchronizationperiod of 1min and transmission range of 2

50 minutes and presents 4 different regions of operationindicated by the letters A B C and D which model potentialnode failure or the addition of the new nodes In RegionA all nodes are turned on simultaneously with randominitial conditions of their local clocks After 2 synchronizationperiods the synchronization error between any two nodesis included between plusmn10 ticks that is the maximum error issmaller than 20 ticks At the beginning of Region B about20 of the nodes chosen random in the grid are switchedoff and then switched on at different random times Oncea node is switched on it starts updating its estimated time

using TSMA protocol but does not transmit any messagefor the first three synchronization periods to avoid injectinglarge disturbances into the already synchronized networkand then it starts to transmitting and receiving messagesequally The plot in Figure 6 clearly shows that the nodesget synchronized as soon as they are turned on withoutperturbing the overall network behavior At the beginning ofRegion C about 20 of the nodes turned off their radio thatis they stop updating their parameters 1198961015840 1198871015840 then we turn onthe 20 nodesrsquo radio at about 35 minutes In this procedurewe can see that all nodes keep the synchronized state thereason is that their skew rates have already converged tothe maximum skew rate in the network these 20 nodesstill synchronize with others At the beginning of Region Dwe replace the node in the top left corner with one nodehaving 40 PPM drift which is the max skew rate in thenetwork now and then all the other nodes will compensatethemselves to this skew value From Figure 6 we can see thatthree synchronization period after the new node joining thenetwork it starts to transmitting messages to its neighborsafter a short transient the nodes quickly synchronize again

7 Conclusions

This paper presented a new synchronization algorithm forWSN the time synchronization using consensus protocolwhich is based on consensus algorithms whose main idea isto average local information to achieve a global agreementon a specific quantity of interest The proposed algorithmis fully distributed asynchronous includes skew compensa-tion and is computationally light Moreover it is robust todynamic network topologies due for example to node failureor replacement Finally a set of simulations are presentedto show the good performance of the proposed protocol

International Journal of Distributed Sensor Networks 9

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(a) Transmission Range = 1

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(b) Transmission Range = 2

Error from average time

200

400

600

Erro

r (tic

ks)

5 10 15 20 25Time (mins)

minus400

minus200

0

0

(c) Transmission Range = 3

Figure 5 Clock errors of 100 simulated nodes running the TSMA protocol in a 10 lowast 10 network with synchronization period of 1min intransmission ranges of 1 (a) 2 (b) and 3 (c)

0 5 10 15 20 25 30 35 40 45 50

0

200

400

600

Error from average time

Time (mins)

Erro

r (tic

ks)

A B C D

minus400

minus200

Figure 6 Clock errors of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 3 Region A all nodes are on Region B20 of the nodes are turned off and then turned on at random timesRegion C 20 of the nodes turned off their radio and then turnedon their radio after 5 synchronization periods Region D replace thenode in the top left corner with one node having 40 PPM drift

However extensive work is still necessary to compare theperformance of our proposed approach relative to FTSP [3]and other protocols over large scale multihop sensor networkand over longer periods

Acknowledgments

This paper is supported in part by ImportantNational Scienceamp Technology Specific Projects under Grants nos (2010ZX03006-002 2010ZX03006-007) National Basic Research Pro-gram of China (973 Program) (no 2011CB302803) andNational Natural Science Foundation of China (NSFC) underGrant no (6117313261003307) The authors alone are respon-sible for the content of the paper

References

[1] H Kopetz and W Ochsenreiter ldquoClock synchronization in dis-tributed real-time systemsrdquo IEEE Transactions on Computersvol 36 no 8 pp 933ndash940 1987

[2] S Ganeriwal R Kumar and M B Srivastava ldquoTiming-sync protocol for sensor networksrdquo in Proceedings of the 1st

10 International Journal of Distributed Sensor Networks

International Conference on Embedded Networked Sensor Sys-tems (SenSys rsquo03) pp 138ndash149 Los Angeles Calif USA Novem-ber 2003

[3] M Maroti B Kusy G Simon and A Ledeczi ldquoThe floodingtime synchronization protocolrdquo in presented at Proceedingsof the 2nd International Conference on Embedded NetworkedSensor Systems Baltimore Md USA 2004

[4] J Elson L Girod and D Estrin ldquoFine-grained network timesynchronization using reference broadcastsrdquo SIGOPSOperatingSystems Review vol 36 pp 147ndash163 2002

[5] W Su and I F Akyildiz ldquoTime-diffusion synchronizationprotocol for wireless sensor networksrdquo IEEEACMTransactionson Networking vol 13 no 2 pp 384ndash397 2005

[6] L Qun and D Rus ldquoGlobal clock synchronization in sen-sor networksrdquo in Proceedings of the Conference on ComputerCommunications -23th Annual Joint Conference of the IEEEComputer andCommunications Societies (IEEE INFOCOM rsquo04)pp 564ndash574 March 2004

[7] G Werner-Allen G Tewari A Patel M Welsh and R NagpalldquoFirefly-inspired sensor network synchronicity with realisticradio effectsrdquo in presented at the Proceedings of the 3rd Interna-tional Conference on Embedded Networked Sensor Systems SanDiego Calif USA 2005

[8] L Schenato and F Fiorentin ldquoAverage TimeSynch a consensus-based protocol for clock synchronization in wireless sensornetworksrdquo Automatica vol 47 pp 1878ndash1886 2011

[9] M K Maggs S G OrsquoKeefe and D V Thiel ldquoConsensus clocksynchronization for wireless sensor networksrdquo IEEE SensorsJournal vol 12 pp 2269ndash2277 2012

[10] D L Mills ldquoInternet time synchronization the network timeprotocolrdquo IEEE Transactions on Communications vol 39 no 10pp 1482ndash1493 1991

[11] C D Godsil and G Royle Algebraic Graph Theory Springer2001

[12] R Olfati Saber and R M Murray ldquoConsensus protocols fornetworks of dynamic agentsrdquo in Proceedings of the AmericanControl Conference pp 951ndash956 June 2003

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 2: Research Article Time Synchronization in Wireless Sensor …downloads.hindawi.com/journals/ijdsn/2013/192128.pdf · 2015-11-21 · powered sensors is quite limited, time synchronization

2 International Journal of Distributed Sensor Networks

the nominal frequency at 25∘C which determines the max-imum amount that the skew rate will deviate from 1 For thenodes used in WSNs the tolerance value is typically in theorder of 5 to 20 PPM If no drift compensation applied twosynchronized nodes will be out of step soon

13 Robustness Since sensor networks are often left unat-tended for long periods of time in possibly hostile environ-ments synchronization schemes should be robust againstlink and node failures Mobile nodes can also disrupt routingschemes and network partitioning may occur

14 Convergence Speed Nodes in wireless sensor networksalways distribute in large scales one node may get in touchwith another by many hops This increases the difficultyin reducing the convergence speed in time synchronizationalgorithm design

Up to nowmany protocols have been designed to addressthis problem These protocols all have some basic featuresin common a simple connectionless messaging protocolexchange of clock information among nodes mitigatingthe effect of nondeterministic factors in message deliveryand processing utilizing different schemes and algorithmsrespectivelyThey can be classified into two types centralizedsynchronization and distributed synchronization

Centralized synchronization protocol such as RBS [4]TPSN [2] and FTSP [3] usually has fast convergence speedand little synchronization error This kind of protocol needsa physical node acting as the whole networkrsquos referenceclock so it has to divide the nodes into different roles forexample client node and beacon node in RBS If the nodewith the special role such as beacon node in RBS is out ofwork the protocol will suffer from big damage To deal withthe WSNsrsquo dynamic topology centralized synchronizationprotocol is often designed with complexity logic Anotherdisadvantage of centralized synchronization protocol is thatsynchronization error grows with the increase of networkhops

Distributed synchronization protocol such as TDP[5]GCS [6]RFA [7]ATS [8]CCS [9] can use local informa-tion to achieve the whole network synchronizationThis kindof protocol can easily adapt toWSNsrsquo dynamic topology prop-erty with lite computation Currently the disadvantage ofdistributed synchronization protocol is that the convergencespeed may be a bit slow relating to the network topology

This paper describes a new distributed protocol for timesynchronization in wireless sensor networks called timesynchronization using max and average consensus protocol(TSMA) We adapt a number of techniques to take up thechallenges time synchronization has in WSNs To eliminatethe nondeterministic delays we make use of MAC layertimestamp technique To compensate for the clock drift weadapt max consensus protocol and we use average consensusprotocol to compensate for the clock offset This protocolhas the advantages of being computationally light scalableasynchronous robust to node and link failure and it does notrequire a master or controlling node

The rest of the paper is organized as follows Section 2summarizes the related work Section 3 introduces somemathematical tools and definitions that will be instrumentalfor the proof of convergence of the proposed TSMA algo-rithm Section 4 introduces a model for the clock dynamicsand formally defines the synchronization objectives whileSection 5 presents the TSMA algorithm in details Thisis followed by MATLAB simulations in Section 6 FinallySection 7 briefly summarizes the results obtained and pro-poses potential research directions

2 Related Work

Typical time synchronization algorithms in WSNs includetiming-sync protocol for sensor networks (TPSNs) [2] ref-erence broadcast synchronization (RBS) [4] flooding timesynchronization protocol (FTSP) [3] time diffusion protocol(TDP) [5] global clock synchronization (GCS) [6] Reach-back Firefly algorithm (RFA) [7] average time synchroniza-tion (ATS) [8] and consensus clock synchronization (CCS)[9] RBS TPSN and FTSP are centralized synchronizationprotocols while TDP GCS RFA ATS and CCS are dis-tributed synchronization protocols

TPSN [2] is designed as a flexible extension of NTP[10] for use in wireless sensor networks which consists oftwo phases a level discovery phase and a synchronizationphaseThe level discovery phase organizes the whole networkinto a hierarchical tree topology with the master node atits root then perform the pair wise synchronization alongthe branches of the hierarchical structure using the classicalsender-receiver synchronization handshake exchange in thesynchronization phase TPSN is a centralized synchroniza-tion protocol utilizes MAC layer timestamping to reducemessage delivery nondeterminism and improve synchro-nization accuracy its convergence speed increases linearlywith the max network hops This approach suffers fromtwo limitations The first limitation arises because if theroot node or parent node dies then a new root election orparent-discovery procedure needs to be initiated thus addingsubstantial overhead to the code and long periods of networkdesynchronization The second limitation is due to the factthat geographically closed nodes might be far in terms of thetree distance which is directly related to increase the clockserror locally

RBS [4] aims to provide synchronization amongst aset of client nodes located within the single-hop broad-cast range of a beacon node Compared to the traditionalprotocols working on an LAN its main contribution is todirectly remove two of the largest sources of nondeterminisminvolved in message transmission transmission time andaccess time by exploiting the concept of a time criticalpath which is the path of a message that contributes tonondeterministic synchronization errors This centralizedprotocol uses least squares linear regression to compensatefor the clock drift its convergence speed also increaseslinearly with the max network hops Using the beacon nodemakes this protocol vulnerable to node failure and nodemobility

International Journal of Distributed Sensor Networks 3

FTSP [3] is an ad-hoc multihop time synchronizationprotocol for WSNs It achieves high accuracy by utilizingtimestamping of radio messages in low layers of radio stackcompletely eliminating access time to the radio channelrequired in CSMA MAC protocols Further accuracy isachieved by compensating for clock skews of participat-ing nodes via linear regression Several mechanisms areused to provide robustness against node and link failuresmost notably periodic flooding of synchronization messagesthroughout the whole network but this approach still do notcompletely solve the limitations aforementioned in TPSN

Nodes employing TDP [5] periodically self-determine tobecome masterdiffusion leader nodes using an electionre-election procedure Master nodes then engage neighboringnodes in a peer evaluation procedure to isolate problemnodes Timing information messages are broadcasted frommaster nodes and then rebroadcasted by the diffused leadernodes for a fixed number of hops forming a radial treestructure This approach is fully distributed but it does notcompensate for the clock drift To the application needingsmall tolerance time this algorithm has to increase the syn-chronization frequency which greatly decreases the nodersquosbattery life

In GCS [6] nodes take turns to broadcast a synchro-nization request to their neighbors who each respond witha message containing their local time The receiving node(at the center of this exchange) averages the received time-stamps and broadcasts this value back to its neighbors whichadopt this value as their new time This is repeated by eachnode in the network until network wide synchronization isachieved This approach is fully distributed but it does notcompensate for the clock drift To get higher time accuracy ithas to decrease the time synchronization period

RFA [7] is inspired by firefly synchronizationmechanismIn this algorithm every node periodically broadcasts asynchronization message and anytime they hear a messagethey advance of a small quantity the phase of their internalclock that schedules the periodic message broadcastingEventually all nodes will advance their phase till they are allsynchronized that is they fire a message at the same timeThis approach however does not compensate for clock drifttherefore the firing period needs to be rather small

ATS [8] uses a cascade of two consensus algorithmsto tune compensation parameters and converge nodes to asteady state virtual clock In the first stage nodes broadcastlocal timestamps in order to estimate the clock skew ratesrelative to each other Nodes then broadcast their currentestimate of the virtual clock skew rate and receiving nodescombine this with their relative skew estimates to adjust theirown virtual clock estimateThe same principle is then appliedto remove the offset errorsThis is a fully distributed protocolits convergence speed is a bit slow related to the networktopology

CCS [9] utilizes average consensus algorithm to compen-sate the clock offset By the accumulated offset error thatthey remove during each round of offset compensation nodescan observe how much their own clocks drift away from theconsensus time then they use this information to compensatethe clock drift which can be seen as an enhancement of

Table 1 Time synchronization features for different protocols

Distrib Skew comp MACtimestamp

Linear skewconvergence speed

TPSN [2] No No No NoFTSP [3] No Yes Yes YesRBS [4] No Yes Yes YesTDP [5] Yes No No NoGCS [6] Yes No No NoRFA [7] Yes No No NoATS [8] Yes Yes Yes NoCCS [9] Yes Yes Yes NoTSMA Yes Yes Yes Yes

ATS This approach is also fully distributed and has thedisadvantage of slow convergence speed

The TSMA protocol proposed in this paper is similarto ATS and CCS It is fully distributed that is it doesnot require any special root including skew compensationand exploits MAC-layer timestamping for higher accuracyUnlike ATS and CCS the proposed protocol uses maxconsensus method to compensate the clock drift which hasfaster skew convergence speed as the centralized protocolthat is it increases linearly with the max network hops Thefeatures of all the protocols mentioned in this section aresummarized in Table 1

3 Mathematical Preliminaries

We assume that links inWSNs are symmetric so the networkcan be modeled as an undirected graph 119866 = (119881 119864) where119881 = V

119894| 119894 = 1 2 119899 represents the nodes in the WSNs

and the edge set 119864 represents the available communicationlinks that is (V

119894 V119895) isin 119864 if node 119895 sends information to node

119894 We refer to V119894and V119895as the tail and head of the edge (V

119894 V119895)

respectively The orientation of the graph is a choice of headsand tails for each undirected edge The set of edges of a fixorientation of the graph is denoted by 119864

0 Thus 119864

0contains

one and only one of the two edges (V119894 V119895) (V119895 V119894) isin 119864 We

use 119898 to present edge number and 119899 the vertex number forexample 119899 = |119881| 119898 = |119864

0| The set of neighbors of node is

denoted by 119873119894= V119895| 119890119894119895isin 119864 The degree of node V

119894is the

number of its neighbors |119873119894| and is denoted by deg(V

119894) The

degreematrix is an 119899times119899matrix defined asΔ = Δ(119866) = Δ119890119894119895

where

Δ119890119894119895=

deg (V119894) 119894 = 119895

0 119894 = 119895

(1)

Let 119860 denote the adjacency matrix of 119866 Then theLaplacian of graph 119866 is defined by

119871 = Δ minus 119860 (2)

The matrix 119871 has the following features(i) All the row sums of 119871 are zero and thus 119890

0= (1

1 1)119879

isin 119877119899 is an eigenvector of 119871 associated with

the eigenvalue 0

4 International Journal of Distributed Sensor Networks

(ii) Fix and orientation of the graph and let 1198640= 119890119894|

119894 = 1 2 119898 then 119871 = 119862119862119879 where 119862 = 119888119901119902 is an

119899 times 119898matrix 119899 is the number of vertex set119881 and119898is the number of the edge set 119864

0

119888119901119902=

+1 if V119901is the head of edge 119890

119902

minus1 if V119901is the tail of edge 119890

119902

0 otherwise(3)

It is a well-known fact that this property holds regardlessof the choice of the orientation of119866 [11] Let 119909

119894denote a scalar

real value assigned to V119894 Then 119909 = (119909

1 1199092 119909

119899)119879 denotes

the state of the graph 119866 We define the Laplacian potential ofthe graph as follows

Ψ119866(119909) =

1

2

119909119879

119871119909 (4)

Lemma 1 (Laplacian potential [12]) Ψ119866(119909) has the following

properties

(i) Undirected graph 119866rsquos Laplacian potential is positivesemidefiniteness and

119909119879

119871119909 = sum

(V119894 V119895)isin1198640

(119909119894minus 119909119895)

2

(5)

(ii) If 119866 is a connected graph Ψ119866(119909) = 0 if and only if 119909

119894=

119909119895 for all 119894 119895

Lemma 2 (connectivity and graph Laplacian [11]) Assumegraph G has c connected components then

rank (119871) = 119899 minus 119888 (6)

Particularly for a connected graph with 119888 = 1 rank(119871) =119899 minus 1

Lemma 3 119866 is an undirected and connected graph 119871 is 119866rsquosLaplacian matrix then there must be a zero in 119871rsquos eigenvaluesand all the other eigenvalues of 119866 are positive and real

Proof 119866 is an undirected graph then 119871 is a real symmetricmatrix After diagonalization the rank of matrix 119871 stays thesame 119866 is a connected graph then based on Lemma 2 therank of matrix 119871 is 119899 minus 1 then there must be a zero in 119871rsquoseigenvalues and all the other eigenvalues of 119866 are nonzero 119871is a real symmetric matrix so 119871rsquos eigenvalues are real Basedon Lemma 1 119871 is a positive semidefinite matrix then 119871rsquoseigenvalues are nonnegative In conclusion there must be azero in 119871rsquos eigenvalues and all the other eigenvalues of 119866 arepositive and real

Definition 4 (consensus) Let the value of all nodes 119909 be thesolution of the following differential equation

= 119891 (119909) 119909 (0) isin 119877119899

(7)

In addition let 119883 119877119899

rarr 119877 be a multi-input single-output operation on 119909 = (119909

1 1199092 119909

119899)119879 that generates

a decision value 119910 = 119883(119909) We say all the nodes of the graphhave reached consensus wrt 119883 in finite time 119879 gt 0 if andonly if all the nodes agree and 119909

119894(119879) = 119883(119909(0)) for all 119894 isin 119868

Some of the common examples of the operation 119883 are givenas follows

(i) average consensus

119883 (119909) = Ave (119909) = 1

119899

119899

sum

119894=1

119909119894 (8)

(ii) max consensus

119883 (119909) = Max (119909) = max (1199091 1199092 119909

119899) (9)

(iii) min consensus

119883 (119909) = Min (119909) = min (1199091 1199092 119909

119899) (10)

Theorem 5 119866 is an undirected and connected graph if everynode in 119866 runs the following distributed protocol

119906119894(119905) = sum

119895isin119873119894

(119909119895(119905) minus 119909

119894(119905)) + 119879

0 (11)

where 1198790is a constant then the vector of the value of the nodes

119909 is the solution of the following ordinary differential equations

= minus119871119909 + (1198790 1198790 119879

0)119879

119909 (0) isin 119877119899

(12)

In addition all the nodes of the graph globally asymptoti-cally reach an average consensus and then every node will havethe same status

119909119894(119905) = 119909

119895(119905) = 119905119879

0+ Ave(119909 (0)) forall119894 119895 119894 = 119895 (13)

Proof Equation (12) corresponds to a typical linear timeinvariant system its complete response can be solved bycalculating zero-status response and zero-input responserespectively

(a) Solve the zero-status response 119909119904(119905) where

119904= minus119871119909

119904+ (1198790 1198790 119879

0)119879

119909119904(0) = (0 0 0)

119879

(14)

Based on Laplacian matrix 119871rsquos features the particularsolution of 119909

119904(119905) is 119909

119901(119905) = 119879

0(119905 119905 119905)

119879 minus119871 is a realsymmetric matrix so minus119871 can do diagonalization let 119875 bethe corresponding invertible matrix Based on the theory oflinear algebra the homogeneous solution of 119909

119904(119905) is

119909ℎ(119905) = 119888

112057211198901205821119905

+ 119888212057221198901205822119905

+ sdot sdot sdot + 119888119899120572119899119890120582119899119905

(15)

where 119888119894(1 le 119894 le 119899) is undetermined coefficient 120582

119894(1 le 119894 le

119899) is matrix 119871rsquos 119894th eigenvalue 120572119894(1 le 119894 le 119899) is119875rsquos 119894th column

which is the corresponding eigenvector of eigenvalue 120582119894 so

the zero-statusrsquos complete response is

119909119904(119905) = 119909

119901(119905) + 119909

ℎ(119905) = 119879

0(119905 119905 119905)

119879

+ 119888112057211198901205821119905

+ 119888212057221198901205822119905

+ sdot sdot sdot + 119888119899120572119899119890120582119899119905

(16)

International Journal of Distributed Sensor Networks 5

We know that 119909(0) = (0 0 0)119879 so 119888

11205721+ 11988821205722+

sdot sdot sdot + 119888119899120572119899= (0 0 0)

119879 in addition 1205721 1205722 120572

119899is linear

independence then 1198881= 1198882= sdot sdot sdot = 119888

119899= 0 the solution of

zero-status response is 119909119904(119905) = 119879

0(119905 119905 119905)

119879(b) Solve the zero-input response 119909

119904(119905) where

0= minus119871119909

0 1199090(0) = 119909 (0) (17)

Observe that all the eigenvalues of minus119871 are negative exceptfor the single zero eigenvalueThus any solution of the systemasymptotically converges to a point 119909lowast

0

in the eigenspaceassociatedwith120582

1= 0This implies that an average consensus

is globally asymptotically reached by all the nodes Let 119909lowast0

beone equilibrium of the system

0= minus119871119909

0 Then minus119871119909lowast

0

= 0and thus 119909lowast is the eigenvector of the Laplacian 119871 associatedwith the zero eigenvalue 120582

1= 0 On the other hand we

have 120595119866(119909lowast

0

) = (12)(119909lowast

0

)119879

119871119909lowast

0

= 0 and from connectivityof 119866 it follows that 119909lowast

0119894

= 119909lowast

0119895

= 119886 for all 119894 119895 that is 119909lowast0

=

(119886 119886 119886)119879 119886 isin 119877 Notice that sum119899

119894=1

1199090119894= 0 Thus Ave(119909

0)

is an invariant quantity This implies Ave(119909lowast0

) = Ave(119909(0))But Ave(119909lowast

0

) = 119886 therefore 119886 = Ave(119909(0)) then the solutionof zero-input response is 119909lowast

0

= (119886 119886 119886)119879 where 119886 =

Ave(119909(0))Above all when zero-input response reaches the equilib-

rium status the systemrsquos full response is

119909 (119905) = 119909119904(119905) + 119909

0(119905)

= (1199051198790+ Ave (119909 (0)) 119905119879

0+ Ave (119909 (0)) 119905119879

0

+ Ave (119909 (0)))119879

(18)

In other words every node in the network finally has thesame status

4 Clock Model

Clock synchronization is of significant importance in WSNsBefore delving into the details of synchronizing clocks wefirst define some terminologies used in this paper 119888(119905)denotes a reference clock where 119905 is the real time thatis coordinated universal time (UTC) Every sensor nodemaintains its own local clock which is a monotonicallynondecreasing function of 119905 This local clock is an ensembleof hardware and software components essentially a timer thatcounts the oscillations of a quartz crystal running a particularfrequency In general the timer is programmed to generatean interrupt which is called a clock tick At each clock tickthe interrupt procedure increments the clock value stored inmemory

For any two nodesrsquo local clocks 119888119894(119905) and 119888

119896(119905) the clock

119888119894(119905) is considered correct at time 119905 if 119888

119894(119905) = 119888(119905) or the clock

119888119894(119905) is considered accurate at time 119905 if 119889119888

119894(119905)119889119905 = 119889119888(119905)119889119905

and two clocks 119888119894(119905) and 119888

119896(119905) are synchronized at time 119905 if

119888119894(119905) = 119888

119896(119905) The aforementioned definitions show that the

two synchronized clocks are not always correct or accuratetime synchronization is not related to time correctness andaccuracy As for most applications in WSNs it is sufficient toachieve clock synchronization Since the oscillator frequency

is time varying due to ambient conditions such as temper-ature changes variations of electric supply voltage and airpressure clock 119888

119894(119905) of node 119894 can be modeled as

119888119894(119905) = 119896

119894119905 + 119887119894 (19)

where 119887119894is the clock offset the difference between the time

reported by clock 119888119894(119905) and the real time at the initial instant

1199050(ie 119887

119894= 119888119894(1199050) minus 119888(119905

0)) and 119896

119894is defined as the skew of

the clock 119888119894(119905) To achieve perfect synchronization in a sensor

network all nodes 119894 = 1 2 119873must precisely compensatefor their clock parameters 119896

119894and 119887119894so that all clocks have zero

offset error and all tick at the same rate

5 TSMA Method

In this section we present our time synchronization algo-rithm that is TSMA Instead of trying to synchronize toan external reference like absolute time or UTC the TSMAmethod aims to achieve an internal consensus within thenetwork on what time is and how fast it travels In everysynchronization round the TSMA algorithm updates thecompensation parameters for each node and over time thenetwork clocks converge to a consensus

limtrarrinfin

1198881015840

119894

(119905) = 119888119888(119905) (20)

where 119888119888(119905) is the consensus clock

The consensus clock is not a physical clock it is a newvirtual clock that is generated from the network of nodesrunning the TSMA algorithm The consensus clock has itsown skew rate and offset relative to the absolute time

By expanding the clock functions from both sides of (20)we can see the compensation parameters that all nodes mustobtain in order to synchronize to the consensus clock

lim119905rarrinfin

(1198961015840

119894

119888119894(119905) + 119887

1015840

119894

) = 119896119888119905 + 119887119888

lim119905rarrinfin

(1198961015840

119894

119896119894119905 + 1198961015840

119894

119887119894+ 1198871015840

119894

) = 119896119888119905 + 119887119888

(21)

Then we have

lim119905rarrinfin

1198961015840

119894

=119896119888

119896119894

lim119905rarrinfin

1198871015840

119894

= 119887119888minus 1198961015840

119894

119887119894

(22)

To achieve these compensation parameters nodes repeatthe TSMA algorithm in synchronization rounds whichconsist of two main tasks skew compensation and offsetcompensation In skew compensation the nodes iterativelyselect the max skew rate estimation from its neighbors inorder to improve their skew compensation parameter In theoffset compensation phase nodes average their neighborsrsquoclock readings to synchronize nodes to a common time

51 Skew Compensation Thegoal of skew compensation is toensure all compensated clocks in the network tick at the samerate that is

lim119905rarrinfin

1198961015840

119894

119896119894= 119896119888 forall119894 (23)

6 International Journal of Distributed Sensor Networks

We use max consensus protocol to compensate for clockskew For perfect skew compensation the skew rate of theconsensus clock is given by

119896119888= max (119896

1 1198962 119896

119899) (24)

Nodes execute the following algorithm to converge theirclock skew to the consensus value

Step 1 Before running the synchronization algorithm nodesset their skew estimation 1198961015840

119894

to 1 and set their respect life timelife119894to 0

Step 2 At the beginning of each synchronization round everynode increases their own life time life

119894by 1 If node 119894rsquos life time

life119894gt 3 then node 119894 broadcasts a synchronization packet

containing its own local clock value 120591119894and estimated skew 1198961015840

119894

using a CSMACA MAC scheme once per synchronizationround Like other synchronization techniques MAC layertimestamping is required to ensure that clock values aretransmitted instantly

Step 3 If node 119894 receives a synchronization packet from node119895 at time 119905 then this node should immediately record its ownlocal time 120591

119894(119905) and node 119895rsquos information (120591

119895(119905) 1198961015840

119895

(119905)) If node119894 has not stored a history local time pair before then createthe local time pair (120591

119894(old) 120591

119895(old)) and assign it with

(120591119894(old) 120591

119895(old)) = (120591

119894(119905) 120591119895(119905)) (25)

If the history local time pair has already existed andsatisfies 1198961015840

119894

(119905) lowast (120591119895(119905) minus 120591

119895(old)) gt 119896

1015840

119895

(119905) lowast (120591119894(119905) minus 120591

119894(old))

we will update this nodersquos estimated skew 1198961015840

119894

and the historylocal time pair (120591

119894(old) 120591

119895(old)) using

1198961015840

119894

(119905) = 1198961015840

119895

(119905) lowast120591119894(119905) minus 120591

119894(old)

120591119895(119905) minus 120591

119895(old)

(120591119894(old) 120591

119895(old)) = (120591

119894(119905) 120591119895(119905))

(26)

52 Offset Compensation After the skew compensation algo-rithm is applied all local estimators will eventually have thesame drift that is they will run at the same speed At thispoint it is only necessary to compensate for possible offseterrors To achieve this each node aims to accurately estimatethe instantaneous average time of all its neighborsrsquo clock inthe network and set their clocks to this time FromTheorem 5we can see that every node in the network will finally reachthe same status

119887 (119905) =1

1003816100381610038161003816119873119894

1003816100381610038161003816

sum

119895isin119873119894

119887119895(119905) (27)

In reality however it is not practically possible for nodesto calculate the instantaneous global average time of all itsneighborsrsquo clock in the network Since sensor networks mayconsist of a large number of nodes and one node may havelots of neighbors It is impossible for nodes to exchange clockvalues instantaneously and nodesmay suffer frompacket lossand other network dynamics

0 5 10 15

0

200

400

600Error from average time

Time (mins)

Erro

r (tic

ks)

minus400

minus200

Figure 1 Clock error of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 2

Instead the TSMA algorithm converges network clocksto an approximation of 119887(119905) using the locally availableinformationwithin the single-hop transmission range of eachnode Nodes execute the following algorithm to convergetheir clock offset to the consensus value

Step 1 Before running the synchronization algorithm nodesset their offset estimation 1198871015840

119894

to their current local time and settheir respect life time life

119894to 0

Step 2 At the beginning of each synchronization roundnodes reset their confidence parameter Conf

119894to 1 and

increase their life time life119894by 1 If node 119894rsquos life time life

119894gt 3

then node 119894 broadcasts a synchronization packet containingits estimated offset 1198871015840

119894

and confidence parameter Conf119894using

a CSMACA MAC scheme once per synchronization roundMAC layer timestamping is required to ensure that clockvalues are transmitted instantly

Step 3 For each broadcast all other nodes within receivingrange update their own clocks by combining this value withtheir own clocks using the confidenceweighted running aver-age equation and then increase their confidence parameterConf119894by 1

1198871015840

119894

(119905)=

1198871015840

119895

(119905) if life119894=1

Conf119894(119905)lowast1198871015840

119894

(119905)+Conf119895(119905)lowast1198871015840

119895

(119905)

Conf119894(119905)+Conf

119895(119905)

if life119894gt1

Conf119894(119905)=Conf

119894(119905) + 1

(28)

The confidence parameters give weighting to the clockvalues fromnodes that have already received synchronizationpackets in the current round These nodes are generallycloser to a local consensus than those who have not received

International Journal of Distributed Sensor Networks 7

1 2 3 4 5 6 7 8 9 10

12345678910

0100200300400500

Clock error from the average time before synchronization

50100150200250300350400450500550

∣Err

or∣

(tick

s)

119910119909

(a)

0

200

400

600

800

Clock error from the average time after the synchronization round

20

40

60

80

100

120

140

1 2 3 4 5 6 7 8 9 10

12345678910

∣Err

or∣

(tick

s)

119910

119909

(b)

Figure 2 Geographic distribution of synchronization error of a 10 lowast 10 sensor network for transmission range of 2 (a) before and (b) afterone round of offset compensation

any sync packets and this was found to increase the rateof convergence

6 Simulation

In this paper we use max consensus to compensate for clockskew and use average consensus to compensate for clockoffset To show the correctness and robustness of the TSMAalgorithm we make a simulation in MATLAB the followingis the simulation environment there are 100WSN nodes inthe 10 lowast 10 grid one grid one node and we place the nodein the center of the grid the base value of nodesrsquo oscillatoris 32768KHz the skew rates are assigned randomly from anormal distribution with mean = 1 and standard deviation =20 PPM nodes are given an initial error distribution between0 and 1000 ticks

61 Offset Compensation In this simulation we set the timesynchronization period to 1 minute Nodes broadcast onesync packet per round in random order with a transmissionrange of 2 which means if the distance between two nodesis less than 2 then they can communicate with each otherFigure 1 shows the clock errors from average time measuredin clock cycles In the first three synchronization periodsnodesrsquo life time is less than 3 so they do not transmit anysynchronization packet to their neighbors and then in 3min-utes nodes start to compensate for the clock skew and offsetAfter seven rounds compensation 100 nodes in the networkachieve the synchronization state the synchronization errorbetween any two nodes is included between plusmn10 ticks

The geographic distribution of clock errors in the networkis shown in Figure 2 It can be seen that before Figure 2(a)the first round of offset compensation the clock error relativeto the average time can reach up to 550 ticks but afterFigure 2(b) the first round offset compensation the clockerror reduces to 140 ticks Also we can see that the clock

error after compensation transfer smoothly in geographicdistribution the local error between any neighboring nodesis no larger than 50 ticks

A histogram of the clock errors is shown in Figure 3It can be seen that before Figure 3(a) the first round ofoffset compensation the standard deviation of clock errorreaches up to 28632 but after Figure 3(b) the first roundof offset compensation this value reduces to 7090 FromFigures 2 and 3 we can see that after the first round of offsetcompensation the clock errors among nodes are significantlyreduced

Figure 4 shows the convergence of the skew rates of 100nodes in this simulation From Figure 4 we can see that aftertwo synchronization periods all the 100 nodesrsquo skew ratesconverge on the maximum clock skew

62 Transmission Range Figure 5 shows the transmissionrangersquos effect to algorithm performance We set the trans-mission range to 1 2 and 3 respectively then comparetheir convergence speed with each other From Figure 5we can see that synchronization accuracy and convergencespeed are found to improve as the transmission range of thenodes increased since nodes could receive synchronizationpackets from a greater proportion of the network populationOn the other side to increase the transmission range wealso increase the energy consumption of nodes so in thepractical application we should make a tradeoff betweenenergy consumption and convergence speed

63 Dynamic Topology The simulation shown in Figure 6is intended to study the robustness properties of the TMSAprotocol subject to node failure and node replacement as wellas the performance in terms of convergence speed and steadystate synchronization errorThe synchronization period is setto 1 minute which is sufficiently large to exhibit the effectsof different clock speeds The simulation was run for about

8 International Journal of Distributed Sensor Networks

0 500 1000 15000

2

4

6

8

10

12

14

Clock error (ticks)

Num

ber o

f nod

esHistogram of sync error

120590 = 28632

minus1500 minus1000 minus500

(a)

0

5

10

15

20

25

30

35

40

45

Clock error (ticks)

Num

ber o

f nod

es

Histogram of sync error

120590 = 709

0 500 1000 1500minus1500 minus1000 minus500

(b)

Figure 3 Histogram of the synchronization errors from the instantaneous global average time of the sensor network (a) before and (b) afterone round of offset compensation

0 5 10 151

1

1

1

1

1

1

1

1

1Normalized skew

Time (mins)

Skew

Figure 4 Convergence of the skew rate of 100 simulated nodes run-ning the TSMA protocol in a 10 lowast 10 network with synchronizationperiod of 1min and transmission range of 2

50 minutes and presents 4 different regions of operationindicated by the letters A B C and D which model potentialnode failure or the addition of the new nodes In RegionA all nodes are turned on simultaneously with randominitial conditions of their local clocks After 2 synchronizationperiods the synchronization error between any two nodesis included between plusmn10 ticks that is the maximum error issmaller than 20 ticks At the beginning of Region B about20 of the nodes chosen random in the grid are switchedoff and then switched on at different random times Oncea node is switched on it starts updating its estimated time

using TSMA protocol but does not transmit any messagefor the first three synchronization periods to avoid injectinglarge disturbances into the already synchronized networkand then it starts to transmitting and receiving messagesequally The plot in Figure 6 clearly shows that the nodesget synchronized as soon as they are turned on withoutperturbing the overall network behavior At the beginning ofRegion C about 20 of the nodes turned off their radio thatis they stop updating their parameters 1198961015840 1198871015840 then we turn onthe 20 nodesrsquo radio at about 35 minutes In this procedurewe can see that all nodes keep the synchronized state thereason is that their skew rates have already converged tothe maximum skew rate in the network these 20 nodesstill synchronize with others At the beginning of Region Dwe replace the node in the top left corner with one nodehaving 40 PPM drift which is the max skew rate in thenetwork now and then all the other nodes will compensatethemselves to this skew value From Figure 6 we can see thatthree synchronization period after the new node joining thenetwork it starts to transmitting messages to its neighborsafter a short transient the nodes quickly synchronize again

7 Conclusions

This paper presented a new synchronization algorithm forWSN the time synchronization using consensus protocolwhich is based on consensus algorithms whose main idea isto average local information to achieve a global agreementon a specific quantity of interest The proposed algorithmis fully distributed asynchronous includes skew compensa-tion and is computationally light Moreover it is robust todynamic network topologies due for example to node failureor replacement Finally a set of simulations are presentedto show the good performance of the proposed protocol

International Journal of Distributed Sensor Networks 9

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(a) Transmission Range = 1

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(b) Transmission Range = 2

Error from average time

200

400

600

Erro

r (tic

ks)

5 10 15 20 25Time (mins)

minus400

minus200

0

0

(c) Transmission Range = 3

Figure 5 Clock errors of 100 simulated nodes running the TSMA protocol in a 10 lowast 10 network with synchronization period of 1min intransmission ranges of 1 (a) 2 (b) and 3 (c)

0 5 10 15 20 25 30 35 40 45 50

0

200

400

600

Error from average time

Time (mins)

Erro

r (tic

ks)

A B C D

minus400

minus200

Figure 6 Clock errors of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 3 Region A all nodes are on Region B20 of the nodes are turned off and then turned on at random timesRegion C 20 of the nodes turned off their radio and then turnedon their radio after 5 synchronization periods Region D replace thenode in the top left corner with one node having 40 PPM drift

However extensive work is still necessary to compare theperformance of our proposed approach relative to FTSP [3]and other protocols over large scale multihop sensor networkand over longer periods

Acknowledgments

This paper is supported in part by ImportantNational Scienceamp Technology Specific Projects under Grants nos (2010ZX03006-002 2010ZX03006-007) National Basic Research Pro-gram of China (973 Program) (no 2011CB302803) andNational Natural Science Foundation of China (NSFC) underGrant no (6117313261003307) The authors alone are respon-sible for the content of the paper

References

[1] H Kopetz and W Ochsenreiter ldquoClock synchronization in dis-tributed real-time systemsrdquo IEEE Transactions on Computersvol 36 no 8 pp 933ndash940 1987

[2] S Ganeriwal R Kumar and M B Srivastava ldquoTiming-sync protocol for sensor networksrdquo in Proceedings of the 1st

10 International Journal of Distributed Sensor Networks

International Conference on Embedded Networked Sensor Sys-tems (SenSys rsquo03) pp 138ndash149 Los Angeles Calif USA Novem-ber 2003

[3] M Maroti B Kusy G Simon and A Ledeczi ldquoThe floodingtime synchronization protocolrdquo in presented at Proceedingsof the 2nd International Conference on Embedded NetworkedSensor Systems Baltimore Md USA 2004

[4] J Elson L Girod and D Estrin ldquoFine-grained network timesynchronization using reference broadcastsrdquo SIGOPSOperatingSystems Review vol 36 pp 147ndash163 2002

[5] W Su and I F Akyildiz ldquoTime-diffusion synchronizationprotocol for wireless sensor networksrdquo IEEEACMTransactionson Networking vol 13 no 2 pp 384ndash397 2005

[6] L Qun and D Rus ldquoGlobal clock synchronization in sen-sor networksrdquo in Proceedings of the Conference on ComputerCommunications -23th Annual Joint Conference of the IEEEComputer andCommunications Societies (IEEE INFOCOM rsquo04)pp 564ndash574 March 2004

[7] G Werner-Allen G Tewari A Patel M Welsh and R NagpalldquoFirefly-inspired sensor network synchronicity with realisticradio effectsrdquo in presented at the Proceedings of the 3rd Interna-tional Conference on Embedded Networked Sensor Systems SanDiego Calif USA 2005

[8] L Schenato and F Fiorentin ldquoAverage TimeSynch a consensus-based protocol for clock synchronization in wireless sensornetworksrdquo Automatica vol 47 pp 1878ndash1886 2011

[9] M K Maggs S G OrsquoKeefe and D V Thiel ldquoConsensus clocksynchronization for wireless sensor networksrdquo IEEE SensorsJournal vol 12 pp 2269ndash2277 2012

[10] D L Mills ldquoInternet time synchronization the network timeprotocolrdquo IEEE Transactions on Communications vol 39 no 10pp 1482ndash1493 1991

[11] C D Godsil and G Royle Algebraic Graph Theory Springer2001

[12] R Olfati Saber and R M Murray ldquoConsensus protocols fornetworks of dynamic agentsrdquo in Proceedings of the AmericanControl Conference pp 951ndash956 June 2003

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 3: Research Article Time Synchronization in Wireless Sensor …downloads.hindawi.com/journals/ijdsn/2013/192128.pdf · 2015-11-21 · powered sensors is quite limited, time synchronization

International Journal of Distributed Sensor Networks 3

FTSP [3] is an ad-hoc multihop time synchronizationprotocol for WSNs It achieves high accuracy by utilizingtimestamping of radio messages in low layers of radio stackcompletely eliminating access time to the radio channelrequired in CSMA MAC protocols Further accuracy isachieved by compensating for clock skews of participat-ing nodes via linear regression Several mechanisms areused to provide robustness against node and link failuresmost notably periodic flooding of synchronization messagesthroughout the whole network but this approach still do notcompletely solve the limitations aforementioned in TPSN

Nodes employing TDP [5] periodically self-determine tobecome masterdiffusion leader nodes using an electionre-election procedure Master nodes then engage neighboringnodes in a peer evaluation procedure to isolate problemnodes Timing information messages are broadcasted frommaster nodes and then rebroadcasted by the diffused leadernodes for a fixed number of hops forming a radial treestructure This approach is fully distributed but it does notcompensate for the clock drift To the application needingsmall tolerance time this algorithm has to increase the syn-chronization frequency which greatly decreases the nodersquosbattery life

In GCS [6] nodes take turns to broadcast a synchro-nization request to their neighbors who each respond witha message containing their local time The receiving node(at the center of this exchange) averages the received time-stamps and broadcasts this value back to its neighbors whichadopt this value as their new time This is repeated by eachnode in the network until network wide synchronization isachieved This approach is fully distributed but it does notcompensate for the clock drift To get higher time accuracy ithas to decrease the time synchronization period

RFA [7] is inspired by firefly synchronizationmechanismIn this algorithm every node periodically broadcasts asynchronization message and anytime they hear a messagethey advance of a small quantity the phase of their internalclock that schedules the periodic message broadcastingEventually all nodes will advance their phase till they are allsynchronized that is they fire a message at the same timeThis approach however does not compensate for clock drifttherefore the firing period needs to be rather small

ATS [8] uses a cascade of two consensus algorithmsto tune compensation parameters and converge nodes to asteady state virtual clock In the first stage nodes broadcastlocal timestamps in order to estimate the clock skew ratesrelative to each other Nodes then broadcast their currentestimate of the virtual clock skew rate and receiving nodescombine this with their relative skew estimates to adjust theirown virtual clock estimateThe same principle is then appliedto remove the offset errorsThis is a fully distributed protocolits convergence speed is a bit slow related to the networktopology

CCS [9] utilizes average consensus algorithm to compen-sate the clock offset By the accumulated offset error thatthey remove during each round of offset compensation nodescan observe how much their own clocks drift away from theconsensus time then they use this information to compensatethe clock drift which can be seen as an enhancement of

Table 1 Time synchronization features for different protocols

Distrib Skew comp MACtimestamp

Linear skewconvergence speed

TPSN [2] No No No NoFTSP [3] No Yes Yes YesRBS [4] No Yes Yes YesTDP [5] Yes No No NoGCS [6] Yes No No NoRFA [7] Yes No No NoATS [8] Yes Yes Yes NoCCS [9] Yes Yes Yes NoTSMA Yes Yes Yes Yes

ATS This approach is also fully distributed and has thedisadvantage of slow convergence speed

The TSMA protocol proposed in this paper is similarto ATS and CCS It is fully distributed that is it doesnot require any special root including skew compensationand exploits MAC-layer timestamping for higher accuracyUnlike ATS and CCS the proposed protocol uses maxconsensus method to compensate the clock drift which hasfaster skew convergence speed as the centralized protocolthat is it increases linearly with the max network hops Thefeatures of all the protocols mentioned in this section aresummarized in Table 1

3 Mathematical Preliminaries

We assume that links inWSNs are symmetric so the networkcan be modeled as an undirected graph 119866 = (119881 119864) where119881 = V

119894| 119894 = 1 2 119899 represents the nodes in the WSNs

and the edge set 119864 represents the available communicationlinks that is (V

119894 V119895) isin 119864 if node 119895 sends information to node

119894 We refer to V119894and V119895as the tail and head of the edge (V

119894 V119895)

respectively The orientation of the graph is a choice of headsand tails for each undirected edge The set of edges of a fixorientation of the graph is denoted by 119864

0 Thus 119864

0contains

one and only one of the two edges (V119894 V119895) (V119895 V119894) isin 119864 We

use 119898 to present edge number and 119899 the vertex number forexample 119899 = |119881| 119898 = |119864

0| The set of neighbors of node is

denoted by 119873119894= V119895| 119890119894119895isin 119864 The degree of node V

119894is the

number of its neighbors |119873119894| and is denoted by deg(V

119894) The

degreematrix is an 119899times119899matrix defined asΔ = Δ(119866) = Δ119890119894119895

where

Δ119890119894119895=

deg (V119894) 119894 = 119895

0 119894 = 119895

(1)

Let 119860 denote the adjacency matrix of 119866 Then theLaplacian of graph 119866 is defined by

119871 = Δ minus 119860 (2)

The matrix 119871 has the following features(i) All the row sums of 119871 are zero and thus 119890

0= (1

1 1)119879

isin 119877119899 is an eigenvector of 119871 associated with

the eigenvalue 0

4 International Journal of Distributed Sensor Networks

(ii) Fix and orientation of the graph and let 1198640= 119890119894|

119894 = 1 2 119898 then 119871 = 119862119862119879 where 119862 = 119888119901119902 is an

119899 times 119898matrix 119899 is the number of vertex set119881 and119898is the number of the edge set 119864

0

119888119901119902=

+1 if V119901is the head of edge 119890

119902

minus1 if V119901is the tail of edge 119890

119902

0 otherwise(3)

It is a well-known fact that this property holds regardlessof the choice of the orientation of119866 [11] Let 119909

119894denote a scalar

real value assigned to V119894 Then 119909 = (119909

1 1199092 119909

119899)119879 denotes

the state of the graph 119866 We define the Laplacian potential ofthe graph as follows

Ψ119866(119909) =

1

2

119909119879

119871119909 (4)

Lemma 1 (Laplacian potential [12]) Ψ119866(119909) has the following

properties

(i) Undirected graph 119866rsquos Laplacian potential is positivesemidefiniteness and

119909119879

119871119909 = sum

(V119894 V119895)isin1198640

(119909119894minus 119909119895)

2

(5)

(ii) If 119866 is a connected graph Ψ119866(119909) = 0 if and only if 119909

119894=

119909119895 for all 119894 119895

Lemma 2 (connectivity and graph Laplacian [11]) Assumegraph G has c connected components then

rank (119871) = 119899 minus 119888 (6)

Particularly for a connected graph with 119888 = 1 rank(119871) =119899 minus 1

Lemma 3 119866 is an undirected and connected graph 119871 is 119866rsquosLaplacian matrix then there must be a zero in 119871rsquos eigenvaluesand all the other eigenvalues of 119866 are positive and real

Proof 119866 is an undirected graph then 119871 is a real symmetricmatrix After diagonalization the rank of matrix 119871 stays thesame 119866 is a connected graph then based on Lemma 2 therank of matrix 119871 is 119899 minus 1 then there must be a zero in 119871rsquoseigenvalues and all the other eigenvalues of 119866 are nonzero 119871is a real symmetric matrix so 119871rsquos eigenvalues are real Basedon Lemma 1 119871 is a positive semidefinite matrix then 119871rsquoseigenvalues are nonnegative In conclusion there must be azero in 119871rsquos eigenvalues and all the other eigenvalues of 119866 arepositive and real

Definition 4 (consensus) Let the value of all nodes 119909 be thesolution of the following differential equation

= 119891 (119909) 119909 (0) isin 119877119899

(7)

In addition let 119883 119877119899

rarr 119877 be a multi-input single-output operation on 119909 = (119909

1 1199092 119909

119899)119879 that generates

a decision value 119910 = 119883(119909) We say all the nodes of the graphhave reached consensus wrt 119883 in finite time 119879 gt 0 if andonly if all the nodes agree and 119909

119894(119879) = 119883(119909(0)) for all 119894 isin 119868

Some of the common examples of the operation 119883 are givenas follows

(i) average consensus

119883 (119909) = Ave (119909) = 1

119899

119899

sum

119894=1

119909119894 (8)

(ii) max consensus

119883 (119909) = Max (119909) = max (1199091 1199092 119909

119899) (9)

(iii) min consensus

119883 (119909) = Min (119909) = min (1199091 1199092 119909

119899) (10)

Theorem 5 119866 is an undirected and connected graph if everynode in 119866 runs the following distributed protocol

119906119894(119905) = sum

119895isin119873119894

(119909119895(119905) minus 119909

119894(119905)) + 119879

0 (11)

where 1198790is a constant then the vector of the value of the nodes

119909 is the solution of the following ordinary differential equations

= minus119871119909 + (1198790 1198790 119879

0)119879

119909 (0) isin 119877119899

(12)

In addition all the nodes of the graph globally asymptoti-cally reach an average consensus and then every node will havethe same status

119909119894(119905) = 119909

119895(119905) = 119905119879

0+ Ave(119909 (0)) forall119894 119895 119894 = 119895 (13)

Proof Equation (12) corresponds to a typical linear timeinvariant system its complete response can be solved bycalculating zero-status response and zero-input responserespectively

(a) Solve the zero-status response 119909119904(119905) where

119904= minus119871119909

119904+ (1198790 1198790 119879

0)119879

119909119904(0) = (0 0 0)

119879

(14)

Based on Laplacian matrix 119871rsquos features the particularsolution of 119909

119904(119905) is 119909

119901(119905) = 119879

0(119905 119905 119905)

119879 minus119871 is a realsymmetric matrix so minus119871 can do diagonalization let 119875 bethe corresponding invertible matrix Based on the theory oflinear algebra the homogeneous solution of 119909

119904(119905) is

119909ℎ(119905) = 119888

112057211198901205821119905

+ 119888212057221198901205822119905

+ sdot sdot sdot + 119888119899120572119899119890120582119899119905

(15)

where 119888119894(1 le 119894 le 119899) is undetermined coefficient 120582

119894(1 le 119894 le

119899) is matrix 119871rsquos 119894th eigenvalue 120572119894(1 le 119894 le 119899) is119875rsquos 119894th column

which is the corresponding eigenvector of eigenvalue 120582119894 so

the zero-statusrsquos complete response is

119909119904(119905) = 119909

119901(119905) + 119909

ℎ(119905) = 119879

0(119905 119905 119905)

119879

+ 119888112057211198901205821119905

+ 119888212057221198901205822119905

+ sdot sdot sdot + 119888119899120572119899119890120582119899119905

(16)

International Journal of Distributed Sensor Networks 5

We know that 119909(0) = (0 0 0)119879 so 119888

11205721+ 11988821205722+

sdot sdot sdot + 119888119899120572119899= (0 0 0)

119879 in addition 1205721 1205722 120572

119899is linear

independence then 1198881= 1198882= sdot sdot sdot = 119888

119899= 0 the solution of

zero-status response is 119909119904(119905) = 119879

0(119905 119905 119905)

119879(b) Solve the zero-input response 119909

119904(119905) where

0= minus119871119909

0 1199090(0) = 119909 (0) (17)

Observe that all the eigenvalues of minus119871 are negative exceptfor the single zero eigenvalueThus any solution of the systemasymptotically converges to a point 119909lowast

0

in the eigenspaceassociatedwith120582

1= 0This implies that an average consensus

is globally asymptotically reached by all the nodes Let 119909lowast0

beone equilibrium of the system

0= minus119871119909

0 Then minus119871119909lowast

0

= 0and thus 119909lowast is the eigenvector of the Laplacian 119871 associatedwith the zero eigenvalue 120582

1= 0 On the other hand we

have 120595119866(119909lowast

0

) = (12)(119909lowast

0

)119879

119871119909lowast

0

= 0 and from connectivityof 119866 it follows that 119909lowast

0119894

= 119909lowast

0119895

= 119886 for all 119894 119895 that is 119909lowast0

=

(119886 119886 119886)119879 119886 isin 119877 Notice that sum119899

119894=1

1199090119894= 0 Thus Ave(119909

0)

is an invariant quantity This implies Ave(119909lowast0

) = Ave(119909(0))But Ave(119909lowast

0

) = 119886 therefore 119886 = Ave(119909(0)) then the solutionof zero-input response is 119909lowast

0

= (119886 119886 119886)119879 where 119886 =

Ave(119909(0))Above all when zero-input response reaches the equilib-

rium status the systemrsquos full response is

119909 (119905) = 119909119904(119905) + 119909

0(119905)

= (1199051198790+ Ave (119909 (0)) 119905119879

0+ Ave (119909 (0)) 119905119879

0

+ Ave (119909 (0)))119879

(18)

In other words every node in the network finally has thesame status

4 Clock Model

Clock synchronization is of significant importance in WSNsBefore delving into the details of synchronizing clocks wefirst define some terminologies used in this paper 119888(119905)denotes a reference clock where 119905 is the real time thatis coordinated universal time (UTC) Every sensor nodemaintains its own local clock which is a monotonicallynondecreasing function of 119905 This local clock is an ensembleof hardware and software components essentially a timer thatcounts the oscillations of a quartz crystal running a particularfrequency In general the timer is programmed to generatean interrupt which is called a clock tick At each clock tickthe interrupt procedure increments the clock value stored inmemory

For any two nodesrsquo local clocks 119888119894(119905) and 119888

119896(119905) the clock

119888119894(119905) is considered correct at time 119905 if 119888

119894(119905) = 119888(119905) or the clock

119888119894(119905) is considered accurate at time 119905 if 119889119888

119894(119905)119889119905 = 119889119888(119905)119889119905

and two clocks 119888119894(119905) and 119888

119896(119905) are synchronized at time 119905 if

119888119894(119905) = 119888

119896(119905) The aforementioned definitions show that the

two synchronized clocks are not always correct or accuratetime synchronization is not related to time correctness andaccuracy As for most applications in WSNs it is sufficient toachieve clock synchronization Since the oscillator frequency

is time varying due to ambient conditions such as temper-ature changes variations of electric supply voltage and airpressure clock 119888

119894(119905) of node 119894 can be modeled as

119888119894(119905) = 119896

119894119905 + 119887119894 (19)

where 119887119894is the clock offset the difference between the time

reported by clock 119888119894(119905) and the real time at the initial instant

1199050(ie 119887

119894= 119888119894(1199050) minus 119888(119905

0)) and 119896

119894is defined as the skew of

the clock 119888119894(119905) To achieve perfect synchronization in a sensor

network all nodes 119894 = 1 2 119873must precisely compensatefor their clock parameters 119896

119894and 119887119894so that all clocks have zero

offset error and all tick at the same rate

5 TSMA Method

In this section we present our time synchronization algo-rithm that is TSMA Instead of trying to synchronize toan external reference like absolute time or UTC the TSMAmethod aims to achieve an internal consensus within thenetwork on what time is and how fast it travels In everysynchronization round the TSMA algorithm updates thecompensation parameters for each node and over time thenetwork clocks converge to a consensus

limtrarrinfin

1198881015840

119894

(119905) = 119888119888(119905) (20)

where 119888119888(119905) is the consensus clock

The consensus clock is not a physical clock it is a newvirtual clock that is generated from the network of nodesrunning the TSMA algorithm The consensus clock has itsown skew rate and offset relative to the absolute time

By expanding the clock functions from both sides of (20)we can see the compensation parameters that all nodes mustobtain in order to synchronize to the consensus clock

lim119905rarrinfin

(1198961015840

119894

119888119894(119905) + 119887

1015840

119894

) = 119896119888119905 + 119887119888

lim119905rarrinfin

(1198961015840

119894

119896119894119905 + 1198961015840

119894

119887119894+ 1198871015840

119894

) = 119896119888119905 + 119887119888

(21)

Then we have

lim119905rarrinfin

1198961015840

119894

=119896119888

119896119894

lim119905rarrinfin

1198871015840

119894

= 119887119888minus 1198961015840

119894

119887119894

(22)

To achieve these compensation parameters nodes repeatthe TSMA algorithm in synchronization rounds whichconsist of two main tasks skew compensation and offsetcompensation In skew compensation the nodes iterativelyselect the max skew rate estimation from its neighbors inorder to improve their skew compensation parameter In theoffset compensation phase nodes average their neighborsrsquoclock readings to synchronize nodes to a common time

51 Skew Compensation Thegoal of skew compensation is toensure all compensated clocks in the network tick at the samerate that is

lim119905rarrinfin

1198961015840

119894

119896119894= 119896119888 forall119894 (23)

6 International Journal of Distributed Sensor Networks

We use max consensus protocol to compensate for clockskew For perfect skew compensation the skew rate of theconsensus clock is given by

119896119888= max (119896

1 1198962 119896

119899) (24)

Nodes execute the following algorithm to converge theirclock skew to the consensus value

Step 1 Before running the synchronization algorithm nodesset their skew estimation 1198961015840

119894

to 1 and set their respect life timelife119894to 0

Step 2 At the beginning of each synchronization round everynode increases their own life time life

119894by 1 If node 119894rsquos life time

life119894gt 3 then node 119894 broadcasts a synchronization packet

containing its own local clock value 120591119894and estimated skew 1198961015840

119894

using a CSMACA MAC scheme once per synchronizationround Like other synchronization techniques MAC layertimestamping is required to ensure that clock values aretransmitted instantly

Step 3 If node 119894 receives a synchronization packet from node119895 at time 119905 then this node should immediately record its ownlocal time 120591

119894(119905) and node 119895rsquos information (120591

119895(119905) 1198961015840

119895

(119905)) If node119894 has not stored a history local time pair before then createthe local time pair (120591

119894(old) 120591

119895(old)) and assign it with

(120591119894(old) 120591

119895(old)) = (120591

119894(119905) 120591119895(119905)) (25)

If the history local time pair has already existed andsatisfies 1198961015840

119894

(119905) lowast (120591119895(119905) minus 120591

119895(old)) gt 119896

1015840

119895

(119905) lowast (120591119894(119905) minus 120591

119894(old))

we will update this nodersquos estimated skew 1198961015840

119894

and the historylocal time pair (120591

119894(old) 120591

119895(old)) using

1198961015840

119894

(119905) = 1198961015840

119895

(119905) lowast120591119894(119905) minus 120591

119894(old)

120591119895(119905) minus 120591

119895(old)

(120591119894(old) 120591

119895(old)) = (120591

119894(119905) 120591119895(119905))

(26)

52 Offset Compensation After the skew compensation algo-rithm is applied all local estimators will eventually have thesame drift that is they will run at the same speed At thispoint it is only necessary to compensate for possible offseterrors To achieve this each node aims to accurately estimatethe instantaneous average time of all its neighborsrsquo clock inthe network and set their clocks to this time FromTheorem 5we can see that every node in the network will finally reachthe same status

119887 (119905) =1

1003816100381610038161003816119873119894

1003816100381610038161003816

sum

119895isin119873119894

119887119895(119905) (27)

In reality however it is not practically possible for nodesto calculate the instantaneous global average time of all itsneighborsrsquo clock in the network Since sensor networks mayconsist of a large number of nodes and one node may havelots of neighbors It is impossible for nodes to exchange clockvalues instantaneously and nodesmay suffer frompacket lossand other network dynamics

0 5 10 15

0

200

400

600Error from average time

Time (mins)

Erro

r (tic

ks)

minus400

minus200

Figure 1 Clock error of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 2

Instead the TSMA algorithm converges network clocksto an approximation of 119887(119905) using the locally availableinformationwithin the single-hop transmission range of eachnode Nodes execute the following algorithm to convergetheir clock offset to the consensus value

Step 1 Before running the synchronization algorithm nodesset their offset estimation 1198871015840

119894

to their current local time and settheir respect life time life

119894to 0

Step 2 At the beginning of each synchronization roundnodes reset their confidence parameter Conf

119894to 1 and

increase their life time life119894by 1 If node 119894rsquos life time life

119894gt 3

then node 119894 broadcasts a synchronization packet containingits estimated offset 1198871015840

119894

and confidence parameter Conf119894using

a CSMACA MAC scheme once per synchronization roundMAC layer timestamping is required to ensure that clockvalues are transmitted instantly

Step 3 For each broadcast all other nodes within receivingrange update their own clocks by combining this value withtheir own clocks using the confidenceweighted running aver-age equation and then increase their confidence parameterConf119894by 1

1198871015840

119894

(119905)=

1198871015840

119895

(119905) if life119894=1

Conf119894(119905)lowast1198871015840

119894

(119905)+Conf119895(119905)lowast1198871015840

119895

(119905)

Conf119894(119905)+Conf

119895(119905)

if life119894gt1

Conf119894(119905)=Conf

119894(119905) + 1

(28)

The confidence parameters give weighting to the clockvalues fromnodes that have already received synchronizationpackets in the current round These nodes are generallycloser to a local consensus than those who have not received

International Journal of Distributed Sensor Networks 7

1 2 3 4 5 6 7 8 9 10

12345678910

0100200300400500

Clock error from the average time before synchronization

50100150200250300350400450500550

∣Err

or∣

(tick

s)

119910119909

(a)

0

200

400

600

800

Clock error from the average time after the synchronization round

20

40

60

80

100

120

140

1 2 3 4 5 6 7 8 9 10

12345678910

∣Err

or∣

(tick

s)

119910

119909

(b)

Figure 2 Geographic distribution of synchronization error of a 10 lowast 10 sensor network for transmission range of 2 (a) before and (b) afterone round of offset compensation

any sync packets and this was found to increase the rateof convergence

6 Simulation

In this paper we use max consensus to compensate for clockskew and use average consensus to compensate for clockoffset To show the correctness and robustness of the TSMAalgorithm we make a simulation in MATLAB the followingis the simulation environment there are 100WSN nodes inthe 10 lowast 10 grid one grid one node and we place the nodein the center of the grid the base value of nodesrsquo oscillatoris 32768KHz the skew rates are assigned randomly from anormal distribution with mean = 1 and standard deviation =20 PPM nodes are given an initial error distribution between0 and 1000 ticks

61 Offset Compensation In this simulation we set the timesynchronization period to 1 minute Nodes broadcast onesync packet per round in random order with a transmissionrange of 2 which means if the distance between two nodesis less than 2 then they can communicate with each otherFigure 1 shows the clock errors from average time measuredin clock cycles In the first three synchronization periodsnodesrsquo life time is less than 3 so they do not transmit anysynchronization packet to their neighbors and then in 3min-utes nodes start to compensate for the clock skew and offsetAfter seven rounds compensation 100 nodes in the networkachieve the synchronization state the synchronization errorbetween any two nodes is included between plusmn10 ticks

The geographic distribution of clock errors in the networkis shown in Figure 2 It can be seen that before Figure 2(a)the first round of offset compensation the clock error relativeto the average time can reach up to 550 ticks but afterFigure 2(b) the first round offset compensation the clockerror reduces to 140 ticks Also we can see that the clock

error after compensation transfer smoothly in geographicdistribution the local error between any neighboring nodesis no larger than 50 ticks

A histogram of the clock errors is shown in Figure 3It can be seen that before Figure 3(a) the first round ofoffset compensation the standard deviation of clock errorreaches up to 28632 but after Figure 3(b) the first roundof offset compensation this value reduces to 7090 FromFigures 2 and 3 we can see that after the first round of offsetcompensation the clock errors among nodes are significantlyreduced

Figure 4 shows the convergence of the skew rates of 100nodes in this simulation From Figure 4 we can see that aftertwo synchronization periods all the 100 nodesrsquo skew ratesconverge on the maximum clock skew

62 Transmission Range Figure 5 shows the transmissionrangersquos effect to algorithm performance We set the trans-mission range to 1 2 and 3 respectively then comparetheir convergence speed with each other From Figure 5we can see that synchronization accuracy and convergencespeed are found to improve as the transmission range of thenodes increased since nodes could receive synchronizationpackets from a greater proportion of the network populationOn the other side to increase the transmission range wealso increase the energy consumption of nodes so in thepractical application we should make a tradeoff betweenenergy consumption and convergence speed

63 Dynamic Topology The simulation shown in Figure 6is intended to study the robustness properties of the TMSAprotocol subject to node failure and node replacement as wellas the performance in terms of convergence speed and steadystate synchronization errorThe synchronization period is setto 1 minute which is sufficiently large to exhibit the effectsof different clock speeds The simulation was run for about

8 International Journal of Distributed Sensor Networks

0 500 1000 15000

2

4

6

8

10

12

14

Clock error (ticks)

Num

ber o

f nod

esHistogram of sync error

120590 = 28632

minus1500 minus1000 minus500

(a)

0

5

10

15

20

25

30

35

40

45

Clock error (ticks)

Num

ber o

f nod

es

Histogram of sync error

120590 = 709

0 500 1000 1500minus1500 minus1000 minus500

(b)

Figure 3 Histogram of the synchronization errors from the instantaneous global average time of the sensor network (a) before and (b) afterone round of offset compensation

0 5 10 151

1

1

1

1

1

1

1

1

1Normalized skew

Time (mins)

Skew

Figure 4 Convergence of the skew rate of 100 simulated nodes run-ning the TSMA protocol in a 10 lowast 10 network with synchronizationperiod of 1min and transmission range of 2

50 minutes and presents 4 different regions of operationindicated by the letters A B C and D which model potentialnode failure or the addition of the new nodes In RegionA all nodes are turned on simultaneously with randominitial conditions of their local clocks After 2 synchronizationperiods the synchronization error between any two nodesis included between plusmn10 ticks that is the maximum error issmaller than 20 ticks At the beginning of Region B about20 of the nodes chosen random in the grid are switchedoff and then switched on at different random times Oncea node is switched on it starts updating its estimated time

using TSMA protocol but does not transmit any messagefor the first three synchronization periods to avoid injectinglarge disturbances into the already synchronized networkand then it starts to transmitting and receiving messagesequally The plot in Figure 6 clearly shows that the nodesget synchronized as soon as they are turned on withoutperturbing the overall network behavior At the beginning ofRegion C about 20 of the nodes turned off their radio thatis they stop updating their parameters 1198961015840 1198871015840 then we turn onthe 20 nodesrsquo radio at about 35 minutes In this procedurewe can see that all nodes keep the synchronized state thereason is that their skew rates have already converged tothe maximum skew rate in the network these 20 nodesstill synchronize with others At the beginning of Region Dwe replace the node in the top left corner with one nodehaving 40 PPM drift which is the max skew rate in thenetwork now and then all the other nodes will compensatethemselves to this skew value From Figure 6 we can see thatthree synchronization period after the new node joining thenetwork it starts to transmitting messages to its neighborsafter a short transient the nodes quickly synchronize again

7 Conclusions

This paper presented a new synchronization algorithm forWSN the time synchronization using consensus protocolwhich is based on consensus algorithms whose main idea isto average local information to achieve a global agreementon a specific quantity of interest The proposed algorithmis fully distributed asynchronous includes skew compensa-tion and is computationally light Moreover it is robust todynamic network topologies due for example to node failureor replacement Finally a set of simulations are presentedto show the good performance of the proposed protocol

International Journal of Distributed Sensor Networks 9

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(a) Transmission Range = 1

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(b) Transmission Range = 2

Error from average time

200

400

600

Erro

r (tic

ks)

5 10 15 20 25Time (mins)

minus400

minus200

0

0

(c) Transmission Range = 3

Figure 5 Clock errors of 100 simulated nodes running the TSMA protocol in a 10 lowast 10 network with synchronization period of 1min intransmission ranges of 1 (a) 2 (b) and 3 (c)

0 5 10 15 20 25 30 35 40 45 50

0

200

400

600

Error from average time

Time (mins)

Erro

r (tic

ks)

A B C D

minus400

minus200

Figure 6 Clock errors of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 3 Region A all nodes are on Region B20 of the nodes are turned off and then turned on at random timesRegion C 20 of the nodes turned off their radio and then turnedon their radio after 5 synchronization periods Region D replace thenode in the top left corner with one node having 40 PPM drift

However extensive work is still necessary to compare theperformance of our proposed approach relative to FTSP [3]and other protocols over large scale multihop sensor networkand over longer periods

Acknowledgments

This paper is supported in part by ImportantNational Scienceamp Technology Specific Projects under Grants nos (2010ZX03006-002 2010ZX03006-007) National Basic Research Pro-gram of China (973 Program) (no 2011CB302803) andNational Natural Science Foundation of China (NSFC) underGrant no (6117313261003307) The authors alone are respon-sible for the content of the paper

References

[1] H Kopetz and W Ochsenreiter ldquoClock synchronization in dis-tributed real-time systemsrdquo IEEE Transactions on Computersvol 36 no 8 pp 933ndash940 1987

[2] S Ganeriwal R Kumar and M B Srivastava ldquoTiming-sync protocol for sensor networksrdquo in Proceedings of the 1st

10 International Journal of Distributed Sensor Networks

International Conference on Embedded Networked Sensor Sys-tems (SenSys rsquo03) pp 138ndash149 Los Angeles Calif USA Novem-ber 2003

[3] M Maroti B Kusy G Simon and A Ledeczi ldquoThe floodingtime synchronization protocolrdquo in presented at Proceedingsof the 2nd International Conference on Embedded NetworkedSensor Systems Baltimore Md USA 2004

[4] J Elson L Girod and D Estrin ldquoFine-grained network timesynchronization using reference broadcastsrdquo SIGOPSOperatingSystems Review vol 36 pp 147ndash163 2002

[5] W Su and I F Akyildiz ldquoTime-diffusion synchronizationprotocol for wireless sensor networksrdquo IEEEACMTransactionson Networking vol 13 no 2 pp 384ndash397 2005

[6] L Qun and D Rus ldquoGlobal clock synchronization in sen-sor networksrdquo in Proceedings of the Conference on ComputerCommunications -23th Annual Joint Conference of the IEEEComputer andCommunications Societies (IEEE INFOCOM rsquo04)pp 564ndash574 March 2004

[7] G Werner-Allen G Tewari A Patel M Welsh and R NagpalldquoFirefly-inspired sensor network synchronicity with realisticradio effectsrdquo in presented at the Proceedings of the 3rd Interna-tional Conference on Embedded Networked Sensor Systems SanDiego Calif USA 2005

[8] L Schenato and F Fiorentin ldquoAverage TimeSynch a consensus-based protocol for clock synchronization in wireless sensornetworksrdquo Automatica vol 47 pp 1878ndash1886 2011

[9] M K Maggs S G OrsquoKeefe and D V Thiel ldquoConsensus clocksynchronization for wireless sensor networksrdquo IEEE SensorsJournal vol 12 pp 2269ndash2277 2012

[10] D L Mills ldquoInternet time synchronization the network timeprotocolrdquo IEEE Transactions on Communications vol 39 no 10pp 1482ndash1493 1991

[11] C D Godsil and G Royle Algebraic Graph Theory Springer2001

[12] R Olfati Saber and R M Murray ldquoConsensus protocols fornetworks of dynamic agentsrdquo in Proceedings of the AmericanControl Conference pp 951ndash956 June 2003

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 4: Research Article Time Synchronization in Wireless Sensor …downloads.hindawi.com/journals/ijdsn/2013/192128.pdf · 2015-11-21 · powered sensors is quite limited, time synchronization

4 International Journal of Distributed Sensor Networks

(ii) Fix and orientation of the graph and let 1198640= 119890119894|

119894 = 1 2 119898 then 119871 = 119862119862119879 where 119862 = 119888119901119902 is an

119899 times 119898matrix 119899 is the number of vertex set119881 and119898is the number of the edge set 119864

0

119888119901119902=

+1 if V119901is the head of edge 119890

119902

minus1 if V119901is the tail of edge 119890

119902

0 otherwise(3)

It is a well-known fact that this property holds regardlessof the choice of the orientation of119866 [11] Let 119909

119894denote a scalar

real value assigned to V119894 Then 119909 = (119909

1 1199092 119909

119899)119879 denotes

the state of the graph 119866 We define the Laplacian potential ofthe graph as follows

Ψ119866(119909) =

1

2

119909119879

119871119909 (4)

Lemma 1 (Laplacian potential [12]) Ψ119866(119909) has the following

properties

(i) Undirected graph 119866rsquos Laplacian potential is positivesemidefiniteness and

119909119879

119871119909 = sum

(V119894 V119895)isin1198640

(119909119894minus 119909119895)

2

(5)

(ii) If 119866 is a connected graph Ψ119866(119909) = 0 if and only if 119909

119894=

119909119895 for all 119894 119895

Lemma 2 (connectivity and graph Laplacian [11]) Assumegraph G has c connected components then

rank (119871) = 119899 minus 119888 (6)

Particularly for a connected graph with 119888 = 1 rank(119871) =119899 minus 1

Lemma 3 119866 is an undirected and connected graph 119871 is 119866rsquosLaplacian matrix then there must be a zero in 119871rsquos eigenvaluesand all the other eigenvalues of 119866 are positive and real

Proof 119866 is an undirected graph then 119871 is a real symmetricmatrix After diagonalization the rank of matrix 119871 stays thesame 119866 is a connected graph then based on Lemma 2 therank of matrix 119871 is 119899 minus 1 then there must be a zero in 119871rsquoseigenvalues and all the other eigenvalues of 119866 are nonzero 119871is a real symmetric matrix so 119871rsquos eigenvalues are real Basedon Lemma 1 119871 is a positive semidefinite matrix then 119871rsquoseigenvalues are nonnegative In conclusion there must be azero in 119871rsquos eigenvalues and all the other eigenvalues of 119866 arepositive and real

Definition 4 (consensus) Let the value of all nodes 119909 be thesolution of the following differential equation

= 119891 (119909) 119909 (0) isin 119877119899

(7)

In addition let 119883 119877119899

rarr 119877 be a multi-input single-output operation on 119909 = (119909

1 1199092 119909

119899)119879 that generates

a decision value 119910 = 119883(119909) We say all the nodes of the graphhave reached consensus wrt 119883 in finite time 119879 gt 0 if andonly if all the nodes agree and 119909

119894(119879) = 119883(119909(0)) for all 119894 isin 119868

Some of the common examples of the operation 119883 are givenas follows

(i) average consensus

119883 (119909) = Ave (119909) = 1

119899

119899

sum

119894=1

119909119894 (8)

(ii) max consensus

119883 (119909) = Max (119909) = max (1199091 1199092 119909

119899) (9)

(iii) min consensus

119883 (119909) = Min (119909) = min (1199091 1199092 119909

119899) (10)

Theorem 5 119866 is an undirected and connected graph if everynode in 119866 runs the following distributed protocol

119906119894(119905) = sum

119895isin119873119894

(119909119895(119905) minus 119909

119894(119905)) + 119879

0 (11)

where 1198790is a constant then the vector of the value of the nodes

119909 is the solution of the following ordinary differential equations

= minus119871119909 + (1198790 1198790 119879

0)119879

119909 (0) isin 119877119899

(12)

In addition all the nodes of the graph globally asymptoti-cally reach an average consensus and then every node will havethe same status

119909119894(119905) = 119909

119895(119905) = 119905119879

0+ Ave(119909 (0)) forall119894 119895 119894 = 119895 (13)

Proof Equation (12) corresponds to a typical linear timeinvariant system its complete response can be solved bycalculating zero-status response and zero-input responserespectively

(a) Solve the zero-status response 119909119904(119905) where

119904= minus119871119909

119904+ (1198790 1198790 119879

0)119879

119909119904(0) = (0 0 0)

119879

(14)

Based on Laplacian matrix 119871rsquos features the particularsolution of 119909

119904(119905) is 119909

119901(119905) = 119879

0(119905 119905 119905)

119879 minus119871 is a realsymmetric matrix so minus119871 can do diagonalization let 119875 bethe corresponding invertible matrix Based on the theory oflinear algebra the homogeneous solution of 119909

119904(119905) is

119909ℎ(119905) = 119888

112057211198901205821119905

+ 119888212057221198901205822119905

+ sdot sdot sdot + 119888119899120572119899119890120582119899119905

(15)

where 119888119894(1 le 119894 le 119899) is undetermined coefficient 120582

119894(1 le 119894 le

119899) is matrix 119871rsquos 119894th eigenvalue 120572119894(1 le 119894 le 119899) is119875rsquos 119894th column

which is the corresponding eigenvector of eigenvalue 120582119894 so

the zero-statusrsquos complete response is

119909119904(119905) = 119909

119901(119905) + 119909

ℎ(119905) = 119879

0(119905 119905 119905)

119879

+ 119888112057211198901205821119905

+ 119888212057221198901205822119905

+ sdot sdot sdot + 119888119899120572119899119890120582119899119905

(16)

International Journal of Distributed Sensor Networks 5

We know that 119909(0) = (0 0 0)119879 so 119888

11205721+ 11988821205722+

sdot sdot sdot + 119888119899120572119899= (0 0 0)

119879 in addition 1205721 1205722 120572

119899is linear

independence then 1198881= 1198882= sdot sdot sdot = 119888

119899= 0 the solution of

zero-status response is 119909119904(119905) = 119879

0(119905 119905 119905)

119879(b) Solve the zero-input response 119909

119904(119905) where

0= minus119871119909

0 1199090(0) = 119909 (0) (17)

Observe that all the eigenvalues of minus119871 are negative exceptfor the single zero eigenvalueThus any solution of the systemasymptotically converges to a point 119909lowast

0

in the eigenspaceassociatedwith120582

1= 0This implies that an average consensus

is globally asymptotically reached by all the nodes Let 119909lowast0

beone equilibrium of the system

0= minus119871119909

0 Then minus119871119909lowast

0

= 0and thus 119909lowast is the eigenvector of the Laplacian 119871 associatedwith the zero eigenvalue 120582

1= 0 On the other hand we

have 120595119866(119909lowast

0

) = (12)(119909lowast

0

)119879

119871119909lowast

0

= 0 and from connectivityof 119866 it follows that 119909lowast

0119894

= 119909lowast

0119895

= 119886 for all 119894 119895 that is 119909lowast0

=

(119886 119886 119886)119879 119886 isin 119877 Notice that sum119899

119894=1

1199090119894= 0 Thus Ave(119909

0)

is an invariant quantity This implies Ave(119909lowast0

) = Ave(119909(0))But Ave(119909lowast

0

) = 119886 therefore 119886 = Ave(119909(0)) then the solutionof zero-input response is 119909lowast

0

= (119886 119886 119886)119879 where 119886 =

Ave(119909(0))Above all when zero-input response reaches the equilib-

rium status the systemrsquos full response is

119909 (119905) = 119909119904(119905) + 119909

0(119905)

= (1199051198790+ Ave (119909 (0)) 119905119879

0+ Ave (119909 (0)) 119905119879

0

+ Ave (119909 (0)))119879

(18)

In other words every node in the network finally has thesame status

4 Clock Model

Clock synchronization is of significant importance in WSNsBefore delving into the details of synchronizing clocks wefirst define some terminologies used in this paper 119888(119905)denotes a reference clock where 119905 is the real time thatis coordinated universal time (UTC) Every sensor nodemaintains its own local clock which is a monotonicallynondecreasing function of 119905 This local clock is an ensembleof hardware and software components essentially a timer thatcounts the oscillations of a quartz crystal running a particularfrequency In general the timer is programmed to generatean interrupt which is called a clock tick At each clock tickthe interrupt procedure increments the clock value stored inmemory

For any two nodesrsquo local clocks 119888119894(119905) and 119888

119896(119905) the clock

119888119894(119905) is considered correct at time 119905 if 119888

119894(119905) = 119888(119905) or the clock

119888119894(119905) is considered accurate at time 119905 if 119889119888

119894(119905)119889119905 = 119889119888(119905)119889119905

and two clocks 119888119894(119905) and 119888

119896(119905) are synchronized at time 119905 if

119888119894(119905) = 119888

119896(119905) The aforementioned definitions show that the

two synchronized clocks are not always correct or accuratetime synchronization is not related to time correctness andaccuracy As for most applications in WSNs it is sufficient toachieve clock synchronization Since the oscillator frequency

is time varying due to ambient conditions such as temper-ature changes variations of electric supply voltage and airpressure clock 119888

119894(119905) of node 119894 can be modeled as

119888119894(119905) = 119896

119894119905 + 119887119894 (19)

where 119887119894is the clock offset the difference between the time

reported by clock 119888119894(119905) and the real time at the initial instant

1199050(ie 119887

119894= 119888119894(1199050) minus 119888(119905

0)) and 119896

119894is defined as the skew of

the clock 119888119894(119905) To achieve perfect synchronization in a sensor

network all nodes 119894 = 1 2 119873must precisely compensatefor their clock parameters 119896

119894and 119887119894so that all clocks have zero

offset error and all tick at the same rate

5 TSMA Method

In this section we present our time synchronization algo-rithm that is TSMA Instead of trying to synchronize toan external reference like absolute time or UTC the TSMAmethod aims to achieve an internal consensus within thenetwork on what time is and how fast it travels In everysynchronization round the TSMA algorithm updates thecompensation parameters for each node and over time thenetwork clocks converge to a consensus

limtrarrinfin

1198881015840

119894

(119905) = 119888119888(119905) (20)

where 119888119888(119905) is the consensus clock

The consensus clock is not a physical clock it is a newvirtual clock that is generated from the network of nodesrunning the TSMA algorithm The consensus clock has itsown skew rate and offset relative to the absolute time

By expanding the clock functions from both sides of (20)we can see the compensation parameters that all nodes mustobtain in order to synchronize to the consensus clock

lim119905rarrinfin

(1198961015840

119894

119888119894(119905) + 119887

1015840

119894

) = 119896119888119905 + 119887119888

lim119905rarrinfin

(1198961015840

119894

119896119894119905 + 1198961015840

119894

119887119894+ 1198871015840

119894

) = 119896119888119905 + 119887119888

(21)

Then we have

lim119905rarrinfin

1198961015840

119894

=119896119888

119896119894

lim119905rarrinfin

1198871015840

119894

= 119887119888minus 1198961015840

119894

119887119894

(22)

To achieve these compensation parameters nodes repeatthe TSMA algorithm in synchronization rounds whichconsist of two main tasks skew compensation and offsetcompensation In skew compensation the nodes iterativelyselect the max skew rate estimation from its neighbors inorder to improve their skew compensation parameter In theoffset compensation phase nodes average their neighborsrsquoclock readings to synchronize nodes to a common time

51 Skew Compensation Thegoal of skew compensation is toensure all compensated clocks in the network tick at the samerate that is

lim119905rarrinfin

1198961015840

119894

119896119894= 119896119888 forall119894 (23)

6 International Journal of Distributed Sensor Networks

We use max consensus protocol to compensate for clockskew For perfect skew compensation the skew rate of theconsensus clock is given by

119896119888= max (119896

1 1198962 119896

119899) (24)

Nodes execute the following algorithm to converge theirclock skew to the consensus value

Step 1 Before running the synchronization algorithm nodesset their skew estimation 1198961015840

119894

to 1 and set their respect life timelife119894to 0

Step 2 At the beginning of each synchronization round everynode increases their own life time life

119894by 1 If node 119894rsquos life time

life119894gt 3 then node 119894 broadcasts a synchronization packet

containing its own local clock value 120591119894and estimated skew 1198961015840

119894

using a CSMACA MAC scheme once per synchronizationround Like other synchronization techniques MAC layertimestamping is required to ensure that clock values aretransmitted instantly

Step 3 If node 119894 receives a synchronization packet from node119895 at time 119905 then this node should immediately record its ownlocal time 120591

119894(119905) and node 119895rsquos information (120591

119895(119905) 1198961015840

119895

(119905)) If node119894 has not stored a history local time pair before then createthe local time pair (120591

119894(old) 120591

119895(old)) and assign it with

(120591119894(old) 120591

119895(old)) = (120591

119894(119905) 120591119895(119905)) (25)

If the history local time pair has already existed andsatisfies 1198961015840

119894

(119905) lowast (120591119895(119905) minus 120591

119895(old)) gt 119896

1015840

119895

(119905) lowast (120591119894(119905) minus 120591

119894(old))

we will update this nodersquos estimated skew 1198961015840

119894

and the historylocal time pair (120591

119894(old) 120591

119895(old)) using

1198961015840

119894

(119905) = 1198961015840

119895

(119905) lowast120591119894(119905) minus 120591

119894(old)

120591119895(119905) minus 120591

119895(old)

(120591119894(old) 120591

119895(old)) = (120591

119894(119905) 120591119895(119905))

(26)

52 Offset Compensation After the skew compensation algo-rithm is applied all local estimators will eventually have thesame drift that is they will run at the same speed At thispoint it is only necessary to compensate for possible offseterrors To achieve this each node aims to accurately estimatethe instantaneous average time of all its neighborsrsquo clock inthe network and set their clocks to this time FromTheorem 5we can see that every node in the network will finally reachthe same status

119887 (119905) =1

1003816100381610038161003816119873119894

1003816100381610038161003816

sum

119895isin119873119894

119887119895(119905) (27)

In reality however it is not practically possible for nodesto calculate the instantaneous global average time of all itsneighborsrsquo clock in the network Since sensor networks mayconsist of a large number of nodes and one node may havelots of neighbors It is impossible for nodes to exchange clockvalues instantaneously and nodesmay suffer frompacket lossand other network dynamics

0 5 10 15

0

200

400

600Error from average time

Time (mins)

Erro

r (tic

ks)

minus400

minus200

Figure 1 Clock error of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 2

Instead the TSMA algorithm converges network clocksto an approximation of 119887(119905) using the locally availableinformationwithin the single-hop transmission range of eachnode Nodes execute the following algorithm to convergetheir clock offset to the consensus value

Step 1 Before running the synchronization algorithm nodesset their offset estimation 1198871015840

119894

to their current local time and settheir respect life time life

119894to 0

Step 2 At the beginning of each synchronization roundnodes reset their confidence parameter Conf

119894to 1 and

increase their life time life119894by 1 If node 119894rsquos life time life

119894gt 3

then node 119894 broadcasts a synchronization packet containingits estimated offset 1198871015840

119894

and confidence parameter Conf119894using

a CSMACA MAC scheme once per synchronization roundMAC layer timestamping is required to ensure that clockvalues are transmitted instantly

Step 3 For each broadcast all other nodes within receivingrange update their own clocks by combining this value withtheir own clocks using the confidenceweighted running aver-age equation and then increase their confidence parameterConf119894by 1

1198871015840

119894

(119905)=

1198871015840

119895

(119905) if life119894=1

Conf119894(119905)lowast1198871015840

119894

(119905)+Conf119895(119905)lowast1198871015840

119895

(119905)

Conf119894(119905)+Conf

119895(119905)

if life119894gt1

Conf119894(119905)=Conf

119894(119905) + 1

(28)

The confidence parameters give weighting to the clockvalues fromnodes that have already received synchronizationpackets in the current round These nodes are generallycloser to a local consensus than those who have not received

International Journal of Distributed Sensor Networks 7

1 2 3 4 5 6 7 8 9 10

12345678910

0100200300400500

Clock error from the average time before synchronization

50100150200250300350400450500550

∣Err

or∣

(tick

s)

119910119909

(a)

0

200

400

600

800

Clock error from the average time after the synchronization round

20

40

60

80

100

120

140

1 2 3 4 5 6 7 8 9 10

12345678910

∣Err

or∣

(tick

s)

119910

119909

(b)

Figure 2 Geographic distribution of synchronization error of a 10 lowast 10 sensor network for transmission range of 2 (a) before and (b) afterone round of offset compensation

any sync packets and this was found to increase the rateof convergence

6 Simulation

In this paper we use max consensus to compensate for clockskew and use average consensus to compensate for clockoffset To show the correctness and robustness of the TSMAalgorithm we make a simulation in MATLAB the followingis the simulation environment there are 100WSN nodes inthe 10 lowast 10 grid one grid one node and we place the nodein the center of the grid the base value of nodesrsquo oscillatoris 32768KHz the skew rates are assigned randomly from anormal distribution with mean = 1 and standard deviation =20 PPM nodes are given an initial error distribution between0 and 1000 ticks

61 Offset Compensation In this simulation we set the timesynchronization period to 1 minute Nodes broadcast onesync packet per round in random order with a transmissionrange of 2 which means if the distance between two nodesis less than 2 then they can communicate with each otherFigure 1 shows the clock errors from average time measuredin clock cycles In the first three synchronization periodsnodesrsquo life time is less than 3 so they do not transmit anysynchronization packet to their neighbors and then in 3min-utes nodes start to compensate for the clock skew and offsetAfter seven rounds compensation 100 nodes in the networkachieve the synchronization state the synchronization errorbetween any two nodes is included between plusmn10 ticks

The geographic distribution of clock errors in the networkis shown in Figure 2 It can be seen that before Figure 2(a)the first round of offset compensation the clock error relativeto the average time can reach up to 550 ticks but afterFigure 2(b) the first round offset compensation the clockerror reduces to 140 ticks Also we can see that the clock

error after compensation transfer smoothly in geographicdistribution the local error between any neighboring nodesis no larger than 50 ticks

A histogram of the clock errors is shown in Figure 3It can be seen that before Figure 3(a) the first round ofoffset compensation the standard deviation of clock errorreaches up to 28632 but after Figure 3(b) the first roundof offset compensation this value reduces to 7090 FromFigures 2 and 3 we can see that after the first round of offsetcompensation the clock errors among nodes are significantlyreduced

Figure 4 shows the convergence of the skew rates of 100nodes in this simulation From Figure 4 we can see that aftertwo synchronization periods all the 100 nodesrsquo skew ratesconverge on the maximum clock skew

62 Transmission Range Figure 5 shows the transmissionrangersquos effect to algorithm performance We set the trans-mission range to 1 2 and 3 respectively then comparetheir convergence speed with each other From Figure 5we can see that synchronization accuracy and convergencespeed are found to improve as the transmission range of thenodes increased since nodes could receive synchronizationpackets from a greater proportion of the network populationOn the other side to increase the transmission range wealso increase the energy consumption of nodes so in thepractical application we should make a tradeoff betweenenergy consumption and convergence speed

63 Dynamic Topology The simulation shown in Figure 6is intended to study the robustness properties of the TMSAprotocol subject to node failure and node replacement as wellas the performance in terms of convergence speed and steadystate synchronization errorThe synchronization period is setto 1 minute which is sufficiently large to exhibit the effectsof different clock speeds The simulation was run for about

8 International Journal of Distributed Sensor Networks

0 500 1000 15000

2

4

6

8

10

12

14

Clock error (ticks)

Num

ber o

f nod

esHistogram of sync error

120590 = 28632

minus1500 minus1000 minus500

(a)

0

5

10

15

20

25

30

35

40

45

Clock error (ticks)

Num

ber o

f nod

es

Histogram of sync error

120590 = 709

0 500 1000 1500minus1500 minus1000 minus500

(b)

Figure 3 Histogram of the synchronization errors from the instantaneous global average time of the sensor network (a) before and (b) afterone round of offset compensation

0 5 10 151

1

1

1

1

1

1

1

1

1Normalized skew

Time (mins)

Skew

Figure 4 Convergence of the skew rate of 100 simulated nodes run-ning the TSMA protocol in a 10 lowast 10 network with synchronizationperiod of 1min and transmission range of 2

50 minutes and presents 4 different regions of operationindicated by the letters A B C and D which model potentialnode failure or the addition of the new nodes In RegionA all nodes are turned on simultaneously with randominitial conditions of their local clocks After 2 synchronizationperiods the synchronization error between any two nodesis included between plusmn10 ticks that is the maximum error issmaller than 20 ticks At the beginning of Region B about20 of the nodes chosen random in the grid are switchedoff and then switched on at different random times Oncea node is switched on it starts updating its estimated time

using TSMA protocol but does not transmit any messagefor the first three synchronization periods to avoid injectinglarge disturbances into the already synchronized networkand then it starts to transmitting and receiving messagesequally The plot in Figure 6 clearly shows that the nodesget synchronized as soon as they are turned on withoutperturbing the overall network behavior At the beginning ofRegion C about 20 of the nodes turned off their radio thatis they stop updating their parameters 1198961015840 1198871015840 then we turn onthe 20 nodesrsquo radio at about 35 minutes In this procedurewe can see that all nodes keep the synchronized state thereason is that their skew rates have already converged tothe maximum skew rate in the network these 20 nodesstill synchronize with others At the beginning of Region Dwe replace the node in the top left corner with one nodehaving 40 PPM drift which is the max skew rate in thenetwork now and then all the other nodes will compensatethemselves to this skew value From Figure 6 we can see thatthree synchronization period after the new node joining thenetwork it starts to transmitting messages to its neighborsafter a short transient the nodes quickly synchronize again

7 Conclusions

This paper presented a new synchronization algorithm forWSN the time synchronization using consensus protocolwhich is based on consensus algorithms whose main idea isto average local information to achieve a global agreementon a specific quantity of interest The proposed algorithmis fully distributed asynchronous includes skew compensa-tion and is computationally light Moreover it is robust todynamic network topologies due for example to node failureor replacement Finally a set of simulations are presentedto show the good performance of the proposed protocol

International Journal of Distributed Sensor Networks 9

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(a) Transmission Range = 1

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(b) Transmission Range = 2

Error from average time

200

400

600

Erro

r (tic

ks)

5 10 15 20 25Time (mins)

minus400

minus200

0

0

(c) Transmission Range = 3

Figure 5 Clock errors of 100 simulated nodes running the TSMA protocol in a 10 lowast 10 network with synchronization period of 1min intransmission ranges of 1 (a) 2 (b) and 3 (c)

0 5 10 15 20 25 30 35 40 45 50

0

200

400

600

Error from average time

Time (mins)

Erro

r (tic

ks)

A B C D

minus400

minus200

Figure 6 Clock errors of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 3 Region A all nodes are on Region B20 of the nodes are turned off and then turned on at random timesRegion C 20 of the nodes turned off their radio and then turnedon their radio after 5 synchronization periods Region D replace thenode in the top left corner with one node having 40 PPM drift

However extensive work is still necessary to compare theperformance of our proposed approach relative to FTSP [3]and other protocols over large scale multihop sensor networkand over longer periods

Acknowledgments

This paper is supported in part by ImportantNational Scienceamp Technology Specific Projects under Grants nos (2010ZX03006-002 2010ZX03006-007) National Basic Research Pro-gram of China (973 Program) (no 2011CB302803) andNational Natural Science Foundation of China (NSFC) underGrant no (6117313261003307) The authors alone are respon-sible for the content of the paper

References

[1] H Kopetz and W Ochsenreiter ldquoClock synchronization in dis-tributed real-time systemsrdquo IEEE Transactions on Computersvol 36 no 8 pp 933ndash940 1987

[2] S Ganeriwal R Kumar and M B Srivastava ldquoTiming-sync protocol for sensor networksrdquo in Proceedings of the 1st

10 International Journal of Distributed Sensor Networks

International Conference on Embedded Networked Sensor Sys-tems (SenSys rsquo03) pp 138ndash149 Los Angeles Calif USA Novem-ber 2003

[3] M Maroti B Kusy G Simon and A Ledeczi ldquoThe floodingtime synchronization protocolrdquo in presented at Proceedingsof the 2nd International Conference on Embedded NetworkedSensor Systems Baltimore Md USA 2004

[4] J Elson L Girod and D Estrin ldquoFine-grained network timesynchronization using reference broadcastsrdquo SIGOPSOperatingSystems Review vol 36 pp 147ndash163 2002

[5] W Su and I F Akyildiz ldquoTime-diffusion synchronizationprotocol for wireless sensor networksrdquo IEEEACMTransactionson Networking vol 13 no 2 pp 384ndash397 2005

[6] L Qun and D Rus ldquoGlobal clock synchronization in sen-sor networksrdquo in Proceedings of the Conference on ComputerCommunications -23th Annual Joint Conference of the IEEEComputer andCommunications Societies (IEEE INFOCOM rsquo04)pp 564ndash574 March 2004

[7] G Werner-Allen G Tewari A Patel M Welsh and R NagpalldquoFirefly-inspired sensor network synchronicity with realisticradio effectsrdquo in presented at the Proceedings of the 3rd Interna-tional Conference on Embedded Networked Sensor Systems SanDiego Calif USA 2005

[8] L Schenato and F Fiorentin ldquoAverage TimeSynch a consensus-based protocol for clock synchronization in wireless sensornetworksrdquo Automatica vol 47 pp 1878ndash1886 2011

[9] M K Maggs S G OrsquoKeefe and D V Thiel ldquoConsensus clocksynchronization for wireless sensor networksrdquo IEEE SensorsJournal vol 12 pp 2269ndash2277 2012

[10] D L Mills ldquoInternet time synchronization the network timeprotocolrdquo IEEE Transactions on Communications vol 39 no 10pp 1482ndash1493 1991

[11] C D Godsil and G Royle Algebraic Graph Theory Springer2001

[12] R Olfati Saber and R M Murray ldquoConsensus protocols fornetworks of dynamic agentsrdquo in Proceedings of the AmericanControl Conference pp 951ndash956 June 2003

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 5: Research Article Time Synchronization in Wireless Sensor …downloads.hindawi.com/journals/ijdsn/2013/192128.pdf · 2015-11-21 · powered sensors is quite limited, time synchronization

International Journal of Distributed Sensor Networks 5

We know that 119909(0) = (0 0 0)119879 so 119888

11205721+ 11988821205722+

sdot sdot sdot + 119888119899120572119899= (0 0 0)

119879 in addition 1205721 1205722 120572

119899is linear

independence then 1198881= 1198882= sdot sdot sdot = 119888

119899= 0 the solution of

zero-status response is 119909119904(119905) = 119879

0(119905 119905 119905)

119879(b) Solve the zero-input response 119909

119904(119905) where

0= minus119871119909

0 1199090(0) = 119909 (0) (17)

Observe that all the eigenvalues of minus119871 are negative exceptfor the single zero eigenvalueThus any solution of the systemasymptotically converges to a point 119909lowast

0

in the eigenspaceassociatedwith120582

1= 0This implies that an average consensus

is globally asymptotically reached by all the nodes Let 119909lowast0

beone equilibrium of the system

0= minus119871119909

0 Then minus119871119909lowast

0

= 0and thus 119909lowast is the eigenvector of the Laplacian 119871 associatedwith the zero eigenvalue 120582

1= 0 On the other hand we

have 120595119866(119909lowast

0

) = (12)(119909lowast

0

)119879

119871119909lowast

0

= 0 and from connectivityof 119866 it follows that 119909lowast

0119894

= 119909lowast

0119895

= 119886 for all 119894 119895 that is 119909lowast0

=

(119886 119886 119886)119879 119886 isin 119877 Notice that sum119899

119894=1

1199090119894= 0 Thus Ave(119909

0)

is an invariant quantity This implies Ave(119909lowast0

) = Ave(119909(0))But Ave(119909lowast

0

) = 119886 therefore 119886 = Ave(119909(0)) then the solutionof zero-input response is 119909lowast

0

= (119886 119886 119886)119879 where 119886 =

Ave(119909(0))Above all when zero-input response reaches the equilib-

rium status the systemrsquos full response is

119909 (119905) = 119909119904(119905) + 119909

0(119905)

= (1199051198790+ Ave (119909 (0)) 119905119879

0+ Ave (119909 (0)) 119905119879

0

+ Ave (119909 (0)))119879

(18)

In other words every node in the network finally has thesame status

4 Clock Model

Clock synchronization is of significant importance in WSNsBefore delving into the details of synchronizing clocks wefirst define some terminologies used in this paper 119888(119905)denotes a reference clock where 119905 is the real time thatis coordinated universal time (UTC) Every sensor nodemaintains its own local clock which is a monotonicallynondecreasing function of 119905 This local clock is an ensembleof hardware and software components essentially a timer thatcounts the oscillations of a quartz crystal running a particularfrequency In general the timer is programmed to generatean interrupt which is called a clock tick At each clock tickthe interrupt procedure increments the clock value stored inmemory

For any two nodesrsquo local clocks 119888119894(119905) and 119888

119896(119905) the clock

119888119894(119905) is considered correct at time 119905 if 119888

119894(119905) = 119888(119905) or the clock

119888119894(119905) is considered accurate at time 119905 if 119889119888

119894(119905)119889119905 = 119889119888(119905)119889119905

and two clocks 119888119894(119905) and 119888

119896(119905) are synchronized at time 119905 if

119888119894(119905) = 119888

119896(119905) The aforementioned definitions show that the

two synchronized clocks are not always correct or accuratetime synchronization is not related to time correctness andaccuracy As for most applications in WSNs it is sufficient toachieve clock synchronization Since the oscillator frequency

is time varying due to ambient conditions such as temper-ature changes variations of electric supply voltage and airpressure clock 119888

119894(119905) of node 119894 can be modeled as

119888119894(119905) = 119896

119894119905 + 119887119894 (19)

where 119887119894is the clock offset the difference between the time

reported by clock 119888119894(119905) and the real time at the initial instant

1199050(ie 119887

119894= 119888119894(1199050) minus 119888(119905

0)) and 119896

119894is defined as the skew of

the clock 119888119894(119905) To achieve perfect synchronization in a sensor

network all nodes 119894 = 1 2 119873must precisely compensatefor their clock parameters 119896

119894and 119887119894so that all clocks have zero

offset error and all tick at the same rate

5 TSMA Method

In this section we present our time synchronization algo-rithm that is TSMA Instead of trying to synchronize toan external reference like absolute time or UTC the TSMAmethod aims to achieve an internal consensus within thenetwork on what time is and how fast it travels In everysynchronization round the TSMA algorithm updates thecompensation parameters for each node and over time thenetwork clocks converge to a consensus

limtrarrinfin

1198881015840

119894

(119905) = 119888119888(119905) (20)

where 119888119888(119905) is the consensus clock

The consensus clock is not a physical clock it is a newvirtual clock that is generated from the network of nodesrunning the TSMA algorithm The consensus clock has itsown skew rate and offset relative to the absolute time

By expanding the clock functions from both sides of (20)we can see the compensation parameters that all nodes mustobtain in order to synchronize to the consensus clock

lim119905rarrinfin

(1198961015840

119894

119888119894(119905) + 119887

1015840

119894

) = 119896119888119905 + 119887119888

lim119905rarrinfin

(1198961015840

119894

119896119894119905 + 1198961015840

119894

119887119894+ 1198871015840

119894

) = 119896119888119905 + 119887119888

(21)

Then we have

lim119905rarrinfin

1198961015840

119894

=119896119888

119896119894

lim119905rarrinfin

1198871015840

119894

= 119887119888minus 1198961015840

119894

119887119894

(22)

To achieve these compensation parameters nodes repeatthe TSMA algorithm in synchronization rounds whichconsist of two main tasks skew compensation and offsetcompensation In skew compensation the nodes iterativelyselect the max skew rate estimation from its neighbors inorder to improve their skew compensation parameter In theoffset compensation phase nodes average their neighborsrsquoclock readings to synchronize nodes to a common time

51 Skew Compensation Thegoal of skew compensation is toensure all compensated clocks in the network tick at the samerate that is

lim119905rarrinfin

1198961015840

119894

119896119894= 119896119888 forall119894 (23)

6 International Journal of Distributed Sensor Networks

We use max consensus protocol to compensate for clockskew For perfect skew compensation the skew rate of theconsensus clock is given by

119896119888= max (119896

1 1198962 119896

119899) (24)

Nodes execute the following algorithm to converge theirclock skew to the consensus value

Step 1 Before running the synchronization algorithm nodesset their skew estimation 1198961015840

119894

to 1 and set their respect life timelife119894to 0

Step 2 At the beginning of each synchronization round everynode increases their own life time life

119894by 1 If node 119894rsquos life time

life119894gt 3 then node 119894 broadcasts a synchronization packet

containing its own local clock value 120591119894and estimated skew 1198961015840

119894

using a CSMACA MAC scheme once per synchronizationround Like other synchronization techniques MAC layertimestamping is required to ensure that clock values aretransmitted instantly

Step 3 If node 119894 receives a synchronization packet from node119895 at time 119905 then this node should immediately record its ownlocal time 120591

119894(119905) and node 119895rsquos information (120591

119895(119905) 1198961015840

119895

(119905)) If node119894 has not stored a history local time pair before then createthe local time pair (120591

119894(old) 120591

119895(old)) and assign it with

(120591119894(old) 120591

119895(old)) = (120591

119894(119905) 120591119895(119905)) (25)

If the history local time pair has already existed andsatisfies 1198961015840

119894

(119905) lowast (120591119895(119905) minus 120591

119895(old)) gt 119896

1015840

119895

(119905) lowast (120591119894(119905) minus 120591

119894(old))

we will update this nodersquos estimated skew 1198961015840

119894

and the historylocal time pair (120591

119894(old) 120591

119895(old)) using

1198961015840

119894

(119905) = 1198961015840

119895

(119905) lowast120591119894(119905) minus 120591

119894(old)

120591119895(119905) minus 120591

119895(old)

(120591119894(old) 120591

119895(old)) = (120591

119894(119905) 120591119895(119905))

(26)

52 Offset Compensation After the skew compensation algo-rithm is applied all local estimators will eventually have thesame drift that is they will run at the same speed At thispoint it is only necessary to compensate for possible offseterrors To achieve this each node aims to accurately estimatethe instantaneous average time of all its neighborsrsquo clock inthe network and set their clocks to this time FromTheorem 5we can see that every node in the network will finally reachthe same status

119887 (119905) =1

1003816100381610038161003816119873119894

1003816100381610038161003816

sum

119895isin119873119894

119887119895(119905) (27)

In reality however it is not practically possible for nodesto calculate the instantaneous global average time of all itsneighborsrsquo clock in the network Since sensor networks mayconsist of a large number of nodes and one node may havelots of neighbors It is impossible for nodes to exchange clockvalues instantaneously and nodesmay suffer frompacket lossand other network dynamics

0 5 10 15

0

200

400

600Error from average time

Time (mins)

Erro

r (tic

ks)

minus400

minus200

Figure 1 Clock error of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 2

Instead the TSMA algorithm converges network clocksto an approximation of 119887(119905) using the locally availableinformationwithin the single-hop transmission range of eachnode Nodes execute the following algorithm to convergetheir clock offset to the consensus value

Step 1 Before running the synchronization algorithm nodesset their offset estimation 1198871015840

119894

to their current local time and settheir respect life time life

119894to 0

Step 2 At the beginning of each synchronization roundnodes reset their confidence parameter Conf

119894to 1 and

increase their life time life119894by 1 If node 119894rsquos life time life

119894gt 3

then node 119894 broadcasts a synchronization packet containingits estimated offset 1198871015840

119894

and confidence parameter Conf119894using

a CSMACA MAC scheme once per synchronization roundMAC layer timestamping is required to ensure that clockvalues are transmitted instantly

Step 3 For each broadcast all other nodes within receivingrange update their own clocks by combining this value withtheir own clocks using the confidenceweighted running aver-age equation and then increase their confidence parameterConf119894by 1

1198871015840

119894

(119905)=

1198871015840

119895

(119905) if life119894=1

Conf119894(119905)lowast1198871015840

119894

(119905)+Conf119895(119905)lowast1198871015840

119895

(119905)

Conf119894(119905)+Conf

119895(119905)

if life119894gt1

Conf119894(119905)=Conf

119894(119905) + 1

(28)

The confidence parameters give weighting to the clockvalues fromnodes that have already received synchronizationpackets in the current round These nodes are generallycloser to a local consensus than those who have not received

International Journal of Distributed Sensor Networks 7

1 2 3 4 5 6 7 8 9 10

12345678910

0100200300400500

Clock error from the average time before synchronization

50100150200250300350400450500550

∣Err

or∣

(tick

s)

119910119909

(a)

0

200

400

600

800

Clock error from the average time after the synchronization round

20

40

60

80

100

120

140

1 2 3 4 5 6 7 8 9 10

12345678910

∣Err

or∣

(tick

s)

119910

119909

(b)

Figure 2 Geographic distribution of synchronization error of a 10 lowast 10 sensor network for transmission range of 2 (a) before and (b) afterone round of offset compensation

any sync packets and this was found to increase the rateof convergence

6 Simulation

In this paper we use max consensus to compensate for clockskew and use average consensus to compensate for clockoffset To show the correctness and robustness of the TSMAalgorithm we make a simulation in MATLAB the followingis the simulation environment there are 100WSN nodes inthe 10 lowast 10 grid one grid one node and we place the nodein the center of the grid the base value of nodesrsquo oscillatoris 32768KHz the skew rates are assigned randomly from anormal distribution with mean = 1 and standard deviation =20 PPM nodes are given an initial error distribution between0 and 1000 ticks

61 Offset Compensation In this simulation we set the timesynchronization period to 1 minute Nodes broadcast onesync packet per round in random order with a transmissionrange of 2 which means if the distance between two nodesis less than 2 then they can communicate with each otherFigure 1 shows the clock errors from average time measuredin clock cycles In the first three synchronization periodsnodesrsquo life time is less than 3 so they do not transmit anysynchronization packet to their neighbors and then in 3min-utes nodes start to compensate for the clock skew and offsetAfter seven rounds compensation 100 nodes in the networkachieve the synchronization state the synchronization errorbetween any two nodes is included between plusmn10 ticks

The geographic distribution of clock errors in the networkis shown in Figure 2 It can be seen that before Figure 2(a)the first round of offset compensation the clock error relativeto the average time can reach up to 550 ticks but afterFigure 2(b) the first round offset compensation the clockerror reduces to 140 ticks Also we can see that the clock

error after compensation transfer smoothly in geographicdistribution the local error between any neighboring nodesis no larger than 50 ticks

A histogram of the clock errors is shown in Figure 3It can be seen that before Figure 3(a) the first round ofoffset compensation the standard deviation of clock errorreaches up to 28632 but after Figure 3(b) the first roundof offset compensation this value reduces to 7090 FromFigures 2 and 3 we can see that after the first round of offsetcompensation the clock errors among nodes are significantlyreduced

Figure 4 shows the convergence of the skew rates of 100nodes in this simulation From Figure 4 we can see that aftertwo synchronization periods all the 100 nodesrsquo skew ratesconverge on the maximum clock skew

62 Transmission Range Figure 5 shows the transmissionrangersquos effect to algorithm performance We set the trans-mission range to 1 2 and 3 respectively then comparetheir convergence speed with each other From Figure 5we can see that synchronization accuracy and convergencespeed are found to improve as the transmission range of thenodes increased since nodes could receive synchronizationpackets from a greater proportion of the network populationOn the other side to increase the transmission range wealso increase the energy consumption of nodes so in thepractical application we should make a tradeoff betweenenergy consumption and convergence speed

63 Dynamic Topology The simulation shown in Figure 6is intended to study the robustness properties of the TMSAprotocol subject to node failure and node replacement as wellas the performance in terms of convergence speed and steadystate synchronization errorThe synchronization period is setto 1 minute which is sufficiently large to exhibit the effectsof different clock speeds The simulation was run for about

8 International Journal of Distributed Sensor Networks

0 500 1000 15000

2

4

6

8

10

12

14

Clock error (ticks)

Num

ber o

f nod

esHistogram of sync error

120590 = 28632

minus1500 minus1000 minus500

(a)

0

5

10

15

20

25

30

35

40

45

Clock error (ticks)

Num

ber o

f nod

es

Histogram of sync error

120590 = 709

0 500 1000 1500minus1500 minus1000 minus500

(b)

Figure 3 Histogram of the synchronization errors from the instantaneous global average time of the sensor network (a) before and (b) afterone round of offset compensation

0 5 10 151

1

1

1

1

1

1

1

1

1Normalized skew

Time (mins)

Skew

Figure 4 Convergence of the skew rate of 100 simulated nodes run-ning the TSMA protocol in a 10 lowast 10 network with synchronizationperiod of 1min and transmission range of 2

50 minutes and presents 4 different regions of operationindicated by the letters A B C and D which model potentialnode failure or the addition of the new nodes In RegionA all nodes are turned on simultaneously with randominitial conditions of their local clocks After 2 synchronizationperiods the synchronization error between any two nodesis included between plusmn10 ticks that is the maximum error issmaller than 20 ticks At the beginning of Region B about20 of the nodes chosen random in the grid are switchedoff and then switched on at different random times Oncea node is switched on it starts updating its estimated time

using TSMA protocol but does not transmit any messagefor the first three synchronization periods to avoid injectinglarge disturbances into the already synchronized networkand then it starts to transmitting and receiving messagesequally The plot in Figure 6 clearly shows that the nodesget synchronized as soon as they are turned on withoutperturbing the overall network behavior At the beginning ofRegion C about 20 of the nodes turned off their radio thatis they stop updating their parameters 1198961015840 1198871015840 then we turn onthe 20 nodesrsquo radio at about 35 minutes In this procedurewe can see that all nodes keep the synchronized state thereason is that their skew rates have already converged tothe maximum skew rate in the network these 20 nodesstill synchronize with others At the beginning of Region Dwe replace the node in the top left corner with one nodehaving 40 PPM drift which is the max skew rate in thenetwork now and then all the other nodes will compensatethemselves to this skew value From Figure 6 we can see thatthree synchronization period after the new node joining thenetwork it starts to transmitting messages to its neighborsafter a short transient the nodes quickly synchronize again

7 Conclusions

This paper presented a new synchronization algorithm forWSN the time synchronization using consensus protocolwhich is based on consensus algorithms whose main idea isto average local information to achieve a global agreementon a specific quantity of interest The proposed algorithmis fully distributed asynchronous includes skew compensa-tion and is computationally light Moreover it is robust todynamic network topologies due for example to node failureor replacement Finally a set of simulations are presentedto show the good performance of the proposed protocol

International Journal of Distributed Sensor Networks 9

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(a) Transmission Range = 1

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(b) Transmission Range = 2

Error from average time

200

400

600

Erro

r (tic

ks)

5 10 15 20 25Time (mins)

minus400

minus200

0

0

(c) Transmission Range = 3

Figure 5 Clock errors of 100 simulated nodes running the TSMA protocol in a 10 lowast 10 network with synchronization period of 1min intransmission ranges of 1 (a) 2 (b) and 3 (c)

0 5 10 15 20 25 30 35 40 45 50

0

200

400

600

Error from average time

Time (mins)

Erro

r (tic

ks)

A B C D

minus400

minus200

Figure 6 Clock errors of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 3 Region A all nodes are on Region B20 of the nodes are turned off and then turned on at random timesRegion C 20 of the nodes turned off their radio and then turnedon their radio after 5 synchronization periods Region D replace thenode in the top left corner with one node having 40 PPM drift

However extensive work is still necessary to compare theperformance of our proposed approach relative to FTSP [3]and other protocols over large scale multihop sensor networkand over longer periods

Acknowledgments

This paper is supported in part by ImportantNational Scienceamp Technology Specific Projects under Grants nos (2010ZX03006-002 2010ZX03006-007) National Basic Research Pro-gram of China (973 Program) (no 2011CB302803) andNational Natural Science Foundation of China (NSFC) underGrant no (6117313261003307) The authors alone are respon-sible for the content of the paper

References

[1] H Kopetz and W Ochsenreiter ldquoClock synchronization in dis-tributed real-time systemsrdquo IEEE Transactions on Computersvol 36 no 8 pp 933ndash940 1987

[2] S Ganeriwal R Kumar and M B Srivastava ldquoTiming-sync protocol for sensor networksrdquo in Proceedings of the 1st

10 International Journal of Distributed Sensor Networks

International Conference on Embedded Networked Sensor Sys-tems (SenSys rsquo03) pp 138ndash149 Los Angeles Calif USA Novem-ber 2003

[3] M Maroti B Kusy G Simon and A Ledeczi ldquoThe floodingtime synchronization protocolrdquo in presented at Proceedingsof the 2nd International Conference on Embedded NetworkedSensor Systems Baltimore Md USA 2004

[4] J Elson L Girod and D Estrin ldquoFine-grained network timesynchronization using reference broadcastsrdquo SIGOPSOperatingSystems Review vol 36 pp 147ndash163 2002

[5] W Su and I F Akyildiz ldquoTime-diffusion synchronizationprotocol for wireless sensor networksrdquo IEEEACMTransactionson Networking vol 13 no 2 pp 384ndash397 2005

[6] L Qun and D Rus ldquoGlobal clock synchronization in sen-sor networksrdquo in Proceedings of the Conference on ComputerCommunications -23th Annual Joint Conference of the IEEEComputer andCommunications Societies (IEEE INFOCOM rsquo04)pp 564ndash574 March 2004

[7] G Werner-Allen G Tewari A Patel M Welsh and R NagpalldquoFirefly-inspired sensor network synchronicity with realisticradio effectsrdquo in presented at the Proceedings of the 3rd Interna-tional Conference on Embedded Networked Sensor Systems SanDiego Calif USA 2005

[8] L Schenato and F Fiorentin ldquoAverage TimeSynch a consensus-based protocol for clock synchronization in wireless sensornetworksrdquo Automatica vol 47 pp 1878ndash1886 2011

[9] M K Maggs S G OrsquoKeefe and D V Thiel ldquoConsensus clocksynchronization for wireless sensor networksrdquo IEEE SensorsJournal vol 12 pp 2269ndash2277 2012

[10] D L Mills ldquoInternet time synchronization the network timeprotocolrdquo IEEE Transactions on Communications vol 39 no 10pp 1482ndash1493 1991

[11] C D Godsil and G Royle Algebraic Graph Theory Springer2001

[12] R Olfati Saber and R M Murray ldquoConsensus protocols fornetworks of dynamic agentsrdquo in Proceedings of the AmericanControl Conference pp 951ndash956 June 2003

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 6: Research Article Time Synchronization in Wireless Sensor …downloads.hindawi.com/journals/ijdsn/2013/192128.pdf · 2015-11-21 · powered sensors is quite limited, time synchronization

6 International Journal of Distributed Sensor Networks

We use max consensus protocol to compensate for clockskew For perfect skew compensation the skew rate of theconsensus clock is given by

119896119888= max (119896

1 1198962 119896

119899) (24)

Nodes execute the following algorithm to converge theirclock skew to the consensus value

Step 1 Before running the synchronization algorithm nodesset their skew estimation 1198961015840

119894

to 1 and set their respect life timelife119894to 0

Step 2 At the beginning of each synchronization round everynode increases their own life time life

119894by 1 If node 119894rsquos life time

life119894gt 3 then node 119894 broadcasts a synchronization packet

containing its own local clock value 120591119894and estimated skew 1198961015840

119894

using a CSMACA MAC scheme once per synchronizationround Like other synchronization techniques MAC layertimestamping is required to ensure that clock values aretransmitted instantly

Step 3 If node 119894 receives a synchronization packet from node119895 at time 119905 then this node should immediately record its ownlocal time 120591

119894(119905) and node 119895rsquos information (120591

119895(119905) 1198961015840

119895

(119905)) If node119894 has not stored a history local time pair before then createthe local time pair (120591

119894(old) 120591

119895(old)) and assign it with

(120591119894(old) 120591

119895(old)) = (120591

119894(119905) 120591119895(119905)) (25)

If the history local time pair has already existed andsatisfies 1198961015840

119894

(119905) lowast (120591119895(119905) minus 120591

119895(old)) gt 119896

1015840

119895

(119905) lowast (120591119894(119905) minus 120591

119894(old))

we will update this nodersquos estimated skew 1198961015840

119894

and the historylocal time pair (120591

119894(old) 120591

119895(old)) using

1198961015840

119894

(119905) = 1198961015840

119895

(119905) lowast120591119894(119905) minus 120591

119894(old)

120591119895(119905) minus 120591

119895(old)

(120591119894(old) 120591

119895(old)) = (120591

119894(119905) 120591119895(119905))

(26)

52 Offset Compensation After the skew compensation algo-rithm is applied all local estimators will eventually have thesame drift that is they will run at the same speed At thispoint it is only necessary to compensate for possible offseterrors To achieve this each node aims to accurately estimatethe instantaneous average time of all its neighborsrsquo clock inthe network and set their clocks to this time FromTheorem 5we can see that every node in the network will finally reachthe same status

119887 (119905) =1

1003816100381610038161003816119873119894

1003816100381610038161003816

sum

119895isin119873119894

119887119895(119905) (27)

In reality however it is not practically possible for nodesto calculate the instantaneous global average time of all itsneighborsrsquo clock in the network Since sensor networks mayconsist of a large number of nodes and one node may havelots of neighbors It is impossible for nodes to exchange clockvalues instantaneously and nodesmay suffer frompacket lossand other network dynamics

0 5 10 15

0

200

400

600Error from average time

Time (mins)

Erro

r (tic

ks)

minus400

minus200

Figure 1 Clock error of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 2

Instead the TSMA algorithm converges network clocksto an approximation of 119887(119905) using the locally availableinformationwithin the single-hop transmission range of eachnode Nodes execute the following algorithm to convergetheir clock offset to the consensus value

Step 1 Before running the synchronization algorithm nodesset their offset estimation 1198871015840

119894

to their current local time and settheir respect life time life

119894to 0

Step 2 At the beginning of each synchronization roundnodes reset their confidence parameter Conf

119894to 1 and

increase their life time life119894by 1 If node 119894rsquos life time life

119894gt 3

then node 119894 broadcasts a synchronization packet containingits estimated offset 1198871015840

119894

and confidence parameter Conf119894using

a CSMACA MAC scheme once per synchronization roundMAC layer timestamping is required to ensure that clockvalues are transmitted instantly

Step 3 For each broadcast all other nodes within receivingrange update their own clocks by combining this value withtheir own clocks using the confidenceweighted running aver-age equation and then increase their confidence parameterConf119894by 1

1198871015840

119894

(119905)=

1198871015840

119895

(119905) if life119894=1

Conf119894(119905)lowast1198871015840

119894

(119905)+Conf119895(119905)lowast1198871015840

119895

(119905)

Conf119894(119905)+Conf

119895(119905)

if life119894gt1

Conf119894(119905)=Conf

119894(119905) + 1

(28)

The confidence parameters give weighting to the clockvalues fromnodes that have already received synchronizationpackets in the current round These nodes are generallycloser to a local consensus than those who have not received

International Journal of Distributed Sensor Networks 7

1 2 3 4 5 6 7 8 9 10

12345678910

0100200300400500

Clock error from the average time before synchronization

50100150200250300350400450500550

∣Err

or∣

(tick

s)

119910119909

(a)

0

200

400

600

800

Clock error from the average time after the synchronization round

20

40

60

80

100

120

140

1 2 3 4 5 6 7 8 9 10

12345678910

∣Err

or∣

(tick

s)

119910

119909

(b)

Figure 2 Geographic distribution of synchronization error of a 10 lowast 10 sensor network for transmission range of 2 (a) before and (b) afterone round of offset compensation

any sync packets and this was found to increase the rateof convergence

6 Simulation

In this paper we use max consensus to compensate for clockskew and use average consensus to compensate for clockoffset To show the correctness and robustness of the TSMAalgorithm we make a simulation in MATLAB the followingis the simulation environment there are 100WSN nodes inthe 10 lowast 10 grid one grid one node and we place the nodein the center of the grid the base value of nodesrsquo oscillatoris 32768KHz the skew rates are assigned randomly from anormal distribution with mean = 1 and standard deviation =20 PPM nodes are given an initial error distribution between0 and 1000 ticks

61 Offset Compensation In this simulation we set the timesynchronization period to 1 minute Nodes broadcast onesync packet per round in random order with a transmissionrange of 2 which means if the distance between two nodesis less than 2 then they can communicate with each otherFigure 1 shows the clock errors from average time measuredin clock cycles In the first three synchronization periodsnodesrsquo life time is less than 3 so they do not transmit anysynchronization packet to their neighbors and then in 3min-utes nodes start to compensate for the clock skew and offsetAfter seven rounds compensation 100 nodes in the networkachieve the synchronization state the synchronization errorbetween any two nodes is included between plusmn10 ticks

The geographic distribution of clock errors in the networkis shown in Figure 2 It can be seen that before Figure 2(a)the first round of offset compensation the clock error relativeto the average time can reach up to 550 ticks but afterFigure 2(b) the first round offset compensation the clockerror reduces to 140 ticks Also we can see that the clock

error after compensation transfer smoothly in geographicdistribution the local error between any neighboring nodesis no larger than 50 ticks

A histogram of the clock errors is shown in Figure 3It can be seen that before Figure 3(a) the first round ofoffset compensation the standard deviation of clock errorreaches up to 28632 but after Figure 3(b) the first roundof offset compensation this value reduces to 7090 FromFigures 2 and 3 we can see that after the first round of offsetcompensation the clock errors among nodes are significantlyreduced

Figure 4 shows the convergence of the skew rates of 100nodes in this simulation From Figure 4 we can see that aftertwo synchronization periods all the 100 nodesrsquo skew ratesconverge on the maximum clock skew

62 Transmission Range Figure 5 shows the transmissionrangersquos effect to algorithm performance We set the trans-mission range to 1 2 and 3 respectively then comparetheir convergence speed with each other From Figure 5we can see that synchronization accuracy and convergencespeed are found to improve as the transmission range of thenodes increased since nodes could receive synchronizationpackets from a greater proportion of the network populationOn the other side to increase the transmission range wealso increase the energy consumption of nodes so in thepractical application we should make a tradeoff betweenenergy consumption and convergence speed

63 Dynamic Topology The simulation shown in Figure 6is intended to study the robustness properties of the TMSAprotocol subject to node failure and node replacement as wellas the performance in terms of convergence speed and steadystate synchronization errorThe synchronization period is setto 1 minute which is sufficiently large to exhibit the effectsof different clock speeds The simulation was run for about

8 International Journal of Distributed Sensor Networks

0 500 1000 15000

2

4

6

8

10

12

14

Clock error (ticks)

Num

ber o

f nod

esHistogram of sync error

120590 = 28632

minus1500 minus1000 minus500

(a)

0

5

10

15

20

25

30

35

40

45

Clock error (ticks)

Num

ber o

f nod

es

Histogram of sync error

120590 = 709

0 500 1000 1500minus1500 minus1000 minus500

(b)

Figure 3 Histogram of the synchronization errors from the instantaneous global average time of the sensor network (a) before and (b) afterone round of offset compensation

0 5 10 151

1

1

1

1

1

1

1

1

1Normalized skew

Time (mins)

Skew

Figure 4 Convergence of the skew rate of 100 simulated nodes run-ning the TSMA protocol in a 10 lowast 10 network with synchronizationperiod of 1min and transmission range of 2

50 minutes and presents 4 different regions of operationindicated by the letters A B C and D which model potentialnode failure or the addition of the new nodes In RegionA all nodes are turned on simultaneously with randominitial conditions of their local clocks After 2 synchronizationperiods the synchronization error between any two nodesis included between plusmn10 ticks that is the maximum error issmaller than 20 ticks At the beginning of Region B about20 of the nodes chosen random in the grid are switchedoff and then switched on at different random times Oncea node is switched on it starts updating its estimated time

using TSMA protocol but does not transmit any messagefor the first three synchronization periods to avoid injectinglarge disturbances into the already synchronized networkand then it starts to transmitting and receiving messagesequally The plot in Figure 6 clearly shows that the nodesget synchronized as soon as they are turned on withoutperturbing the overall network behavior At the beginning ofRegion C about 20 of the nodes turned off their radio thatis they stop updating their parameters 1198961015840 1198871015840 then we turn onthe 20 nodesrsquo radio at about 35 minutes In this procedurewe can see that all nodes keep the synchronized state thereason is that their skew rates have already converged tothe maximum skew rate in the network these 20 nodesstill synchronize with others At the beginning of Region Dwe replace the node in the top left corner with one nodehaving 40 PPM drift which is the max skew rate in thenetwork now and then all the other nodes will compensatethemselves to this skew value From Figure 6 we can see thatthree synchronization period after the new node joining thenetwork it starts to transmitting messages to its neighborsafter a short transient the nodes quickly synchronize again

7 Conclusions

This paper presented a new synchronization algorithm forWSN the time synchronization using consensus protocolwhich is based on consensus algorithms whose main idea isto average local information to achieve a global agreementon a specific quantity of interest The proposed algorithmis fully distributed asynchronous includes skew compensa-tion and is computationally light Moreover it is robust todynamic network topologies due for example to node failureor replacement Finally a set of simulations are presentedto show the good performance of the proposed protocol

International Journal of Distributed Sensor Networks 9

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(a) Transmission Range = 1

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(b) Transmission Range = 2

Error from average time

200

400

600

Erro

r (tic

ks)

5 10 15 20 25Time (mins)

minus400

minus200

0

0

(c) Transmission Range = 3

Figure 5 Clock errors of 100 simulated nodes running the TSMA protocol in a 10 lowast 10 network with synchronization period of 1min intransmission ranges of 1 (a) 2 (b) and 3 (c)

0 5 10 15 20 25 30 35 40 45 50

0

200

400

600

Error from average time

Time (mins)

Erro

r (tic

ks)

A B C D

minus400

minus200

Figure 6 Clock errors of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 3 Region A all nodes are on Region B20 of the nodes are turned off and then turned on at random timesRegion C 20 of the nodes turned off their radio and then turnedon their radio after 5 synchronization periods Region D replace thenode in the top left corner with one node having 40 PPM drift

However extensive work is still necessary to compare theperformance of our proposed approach relative to FTSP [3]and other protocols over large scale multihop sensor networkand over longer periods

Acknowledgments

This paper is supported in part by ImportantNational Scienceamp Technology Specific Projects under Grants nos (2010ZX03006-002 2010ZX03006-007) National Basic Research Pro-gram of China (973 Program) (no 2011CB302803) andNational Natural Science Foundation of China (NSFC) underGrant no (6117313261003307) The authors alone are respon-sible for the content of the paper

References

[1] H Kopetz and W Ochsenreiter ldquoClock synchronization in dis-tributed real-time systemsrdquo IEEE Transactions on Computersvol 36 no 8 pp 933ndash940 1987

[2] S Ganeriwal R Kumar and M B Srivastava ldquoTiming-sync protocol for sensor networksrdquo in Proceedings of the 1st

10 International Journal of Distributed Sensor Networks

International Conference on Embedded Networked Sensor Sys-tems (SenSys rsquo03) pp 138ndash149 Los Angeles Calif USA Novem-ber 2003

[3] M Maroti B Kusy G Simon and A Ledeczi ldquoThe floodingtime synchronization protocolrdquo in presented at Proceedingsof the 2nd International Conference on Embedded NetworkedSensor Systems Baltimore Md USA 2004

[4] J Elson L Girod and D Estrin ldquoFine-grained network timesynchronization using reference broadcastsrdquo SIGOPSOperatingSystems Review vol 36 pp 147ndash163 2002

[5] W Su and I F Akyildiz ldquoTime-diffusion synchronizationprotocol for wireless sensor networksrdquo IEEEACMTransactionson Networking vol 13 no 2 pp 384ndash397 2005

[6] L Qun and D Rus ldquoGlobal clock synchronization in sen-sor networksrdquo in Proceedings of the Conference on ComputerCommunications -23th Annual Joint Conference of the IEEEComputer andCommunications Societies (IEEE INFOCOM rsquo04)pp 564ndash574 March 2004

[7] G Werner-Allen G Tewari A Patel M Welsh and R NagpalldquoFirefly-inspired sensor network synchronicity with realisticradio effectsrdquo in presented at the Proceedings of the 3rd Interna-tional Conference on Embedded Networked Sensor Systems SanDiego Calif USA 2005

[8] L Schenato and F Fiorentin ldquoAverage TimeSynch a consensus-based protocol for clock synchronization in wireless sensornetworksrdquo Automatica vol 47 pp 1878ndash1886 2011

[9] M K Maggs S G OrsquoKeefe and D V Thiel ldquoConsensus clocksynchronization for wireless sensor networksrdquo IEEE SensorsJournal vol 12 pp 2269ndash2277 2012

[10] D L Mills ldquoInternet time synchronization the network timeprotocolrdquo IEEE Transactions on Communications vol 39 no 10pp 1482ndash1493 1991

[11] C D Godsil and G Royle Algebraic Graph Theory Springer2001

[12] R Olfati Saber and R M Murray ldquoConsensus protocols fornetworks of dynamic agentsrdquo in Proceedings of the AmericanControl Conference pp 951ndash956 June 2003

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 7: Research Article Time Synchronization in Wireless Sensor …downloads.hindawi.com/journals/ijdsn/2013/192128.pdf · 2015-11-21 · powered sensors is quite limited, time synchronization

International Journal of Distributed Sensor Networks 7

1 2 3 4 5 6 7 8 9 10

12345678910

0100200300400500

Clock error from the average time before synchronization

50100150200250300350400450500550

∣Err

or∣

(tick

s)

119910119909

(a)

0

200

400

600

800

Clock error from the average time after the synchronization round

20

40

60

80

100

120

140

1 2 3 4 5 6 7 8 9 10

12345678910

∣Err

or∣

(tick

s)

119910

119909

(b)

Figure 2 Geographic distribution of synchronization error of a 10 lowast 10 sensor network for transmission range of 2 (a) before and (b) afterone round of offset compensation

any sync packets and this was found to increase the rateof convergence

6 Simulation

In this paper we use max consensus to compensate for clockskew and use average consensus to compensate for clockoffset To show the correctness and robustness of the TSMAalgorithm we make a simulation in MATLAB the followingis the simulation environment there are 100WSN nodes inthe 10 lowast 10 grid one grid one node and we place the nodein the center of the grid the base value of nodesrsquo oscillatoris 32768KHz the skew rates are assigned randomly from anormal distribution with mean = 1 and standard deviation =20 PPM nodes are given an initial error distribution between0 and 1000 ticks

61 Offset Compensation In this simulation we set the timesynchronization period to 1 minute Nodes broadcast onesync packet per round in random order with a transmissionrange of 2 which means if the distance between two nodesis less than 2 then they can communicate with each otherFigure 1 shows the clock errors from average time measuredin clock cycles In the first three synchronization periodsnodesrsquo life time is less than 3 so they do not transmit anysynchronization packet to their neighbors and then in 3min-utes nodes start to compensate for the clock skew and offsetAfter seven rounds compensation 100 nodes in the networkachieve the synchronization state the synchronization errorbetween any two nodes is included between plusmn10 ticks

The geographic distribution of clock errors in the networkis shown in Figure 2 It can be seen that before Figure 2(a)the first round of offset compensation the clock error relativeto the average time can reach up to 550 ticks but afterFigure 2(b) the first round offset compensation the clockerror reduces to 140 ticks Also we can see that the clock

error after compensation transfer smoothly in geographicdistribution the local error between any neighboring nodesis no larger than 50 ticks

A histogram of the clock errors is shown in Figure 3It can be seen that before Figure 3(a) the first round ofoffset compensation the standard deviation of clock errorreaches up to 28632 but after Figure 3(b) the first roundof offset compensation this value reduces to 7090 FromFigures 2 and 3 we can see that after the first round of offsetcompensation the clock errors among nodes are significantlyreduced

Figure 4 shows the convergence of the skew rates of 100nodes in this simulation From Figure 4 we can see that aftertwo synchronization periods all the 100 nodesrsquo skew ratesconverge on the maximum clock skew

62 Transmission Range Figure 5 shows the transmissionrangersquos effect to algorithm performance We set the trans-mission range to 1 2 and 3 respectively then comparetheir convergence speed with each other From Figure 5we can see that synchronization accuracy and convergencespeed are found to improve as the transmission range of thenodes increased since nodes could receive synchronizationpackets from a greater proportion of the network populationOn the other side to increase the transmission range wealso increase the energy consumption of nodes so in thepractical application we should make a tradeoff betweenenergy consumption and convergence speed

63 Dynamic Topology The simulation shown in Figure 6is intended to study the robustness properties of the TMSAprotocol subject to node failure and node replacement as wellas the performance in terms of convergence speed and steadystate synchronization errorThe synchronization period is setto 1 minute which is sufficiently large to exhibit the effectsof different clock speeds The simulation was run for about

8 International Journal of Distributed Sensor Networks

0 500 1000 15000

2

4

6

8

10

12

14

Clock error (ticks)

Num

ber o

f nod

esHistogram of sync error

120590 = 28632

minus1500 minus1000 minus500

(a)

0

5

10

15

20

25

30

35

40

45

Clock error (ticks)

Num

ber o

f nod

es

Histogram of sync error

120590 = 709

0 500 1000 1500minus1500 minus1000 minus500

(b)

Figure 3 Histogram of the synchronization errors from the instantaneous global average time of the sensor network (a) before and (b) afterone round of offset compensation

0 5 10 151

1

1

1

1

1

1

1

1

1Normalized skew

Time (mins)

Skew

Figure 4 Convergence of the skew rate of 100 simulated nodes run-ning the TSMA protocol in a 10 lowast 10 network with synchronizationperiod of 1min and transmission range of 2

50 minutes and presents 4 different regions of operationindicated by the letters A B C and D which model potentialnode failure or the addition of the new nodes In RegionA all nodes are turned on simultaneously with randominitial conditions of their local clocks After 2 synchronizationperiods the synchronization error between any two nodesis included between plusmn10 ticks that is the maximum error issmaller than 20 ticks At the beginning of Region B about20 of the nodes chosen random in the grid are switchedoff and then switched on at different random times Oncea node is switched on it starts updating its estimated time

using TSMA protocol but does not transmit any messagefor the first three synchronization periods to avoid injectinglarge disturbances into the already synchronized networkand then it starts to transmitting and receiving messagesequally The plot in Figure 6 clearly shows that the nodesget synchronized as soon as they are turned on withoutperturbing the overall network behavior At the beginning ofRegion C about 20 of the nodes turned off their radio thatis they stop updating their parameters 1198961015840 1198871015840 then we turn onthe 20 nodesrsquo radio at about 35 minutes In this procedurewe can see that all nodes keep the synchronized state thereason is that their skew rates have already converged tothe maximum skew rate in the network these 20 nodesstill synchronize with others At the beginning of Region Dwe replace the node in the top left corner with one nodehaving 40 PPM drift which is the max skew rate in thenetwork now and then all the other nodes will compensatethemselves to this skew value From Figure 6 we can see thatthree synchronization period after the new node joining thenetwork it starts to transmitting messages to its neighborsafter a short transient the nodes quickly synchronize again

7 Conclusions

This paper presented a new synchronization algorithm forWSN the time synchronization using consensus protocolwhich is based on consensus algorithms whose main idea isto average local information to achieve a global agreementon a specific quantity of interest The proposed algorithmis fully distributed asynchronous includes skew compensa-tion and is computationally light Moreover it is robust todynamic network topologies due for example to node failureor replacement Finally a set of simulations are presentedto show the good performance of the proposed protocol

International Journal of Distributed Sensor Networks 9

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(a) Transmission Range = 1

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(b) Transmission Range = 2

Error from average time

200

400

600

Erro

r (tic

ks)

5 10 15 20 25Time (mins)

minus400

minus200

0

0

(c) Transmission Range = 3

Figure 5 Clock errors of 100 simulated nodes running the TSMA protocol in a 10 lowast 10 network with synchronization period of 1min intransmission ranges of 1 (a) 2 (b) and 3 (c)

0 5 10 15 20 25 30 35 40 45 50

0

200

400

600

Error from average time

Time (mins)

Erro

r (tic

ks)

A B C D

minus400

minus200

Figure 6 Clock errors of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 3 Region A all nodes are on Region B20 of the nodes are turned off and then turned on at random timesRegion C 20 of the nodes turned off their radio and then turnedon their radio after 5 synchronization periods Region D replace thenode in the top left corner with one node having 40 PPM drift

However extensive work is still necessary to compare theperformance of our proposed approach relative to FTSP [3]and other protocols over large scale multihop sensor networkand over longer periods

Acknowledgments

This paper is supported in part by ImportantNational Scienceamp Technology Specific Projects under Grants nos (2010ZX03006-002 2010ZX03006-007) National Basic Research Pro-gram of China (973 Program) (no 2011CB302803) andNational Natural Science Foundation of China (NSFC) underGrant no (6117313261003307) The authors alone are respon-sible for the content of the paper

References

[1] H Kopetz and W Ochsenreiter ldquoClock synchronization in dis-tributed real-time systemsrdquo IEEE Transactions on Computersvol 36 no 8 pp 933ndash940 1987

[2] S Ganeriwal R Kumar and M B Srivastava ldquoTiming-sync protocol for sensor networksrdquo in Proceedings of the 1st

10 International Journal of Distributed Sensor Networks

International Conference on Embedded Networked Sensor Sys-tems (SenSys rsquo03) pp 138ndash149 Los Angeles Calif USA Novem-ber 2003

[3] M Maroti B Kusy G Simon and A Ledeczi ldquoThe floodingtime synchronization protocolrdquo in presented at Proceedingsof the 2nd International Conference on Embedded NetworkedSensor Systems Baltimore Md USA 2004

[4] J Elson L Girod and D Estrin ldquoFine-grained network timesynchronization using reference broadcastsrdquo SIGOPSOperatingSystems Review vol 36 pp 147ndash163 2002

[5] W Su and I F Akyildiz ldquoTime-diffusion synchronizationprotocol for wireless sensor networksrdquo IEEEACMTransactionson Networking vol 13 no 2 pp 384ndash397 2005

[6] L Qun and D Rus ldquoGlobal clock synchronization in sen-sor networksrdquo in Proceedings of the Conference on ComputerCommunications -23th Annual Joint Conference of the IEEEComputer andCommunications Societies (IEEE INFOCOM rsquo04)pp 564ndash574 March 2004

[7] G Werner-Allen G Tewari A Patel M Welsh and R NagpalldquoFirefly-inspired sensor network synchronicity with realisticradio effectsrdquo in presented at the Proceedings of the 3rd Interna-tional Conference on Embedded Networked Sensor Systems SanDiego Calif USA 2005

[8] L Schenato and F Fiorentin ldquoAverage TimeSynch a consensus-based protocol for clock synchronization in wireless sensornetworksrdquo Automatica vol 47 pp 1878ndash1886 2011

[9] M K Maggs S G OrsquoKeefe and D V Thiel ldquoConsensus clocksynchronization for wireless sensor networksrdquo IEEE SensorsJournal vol 12 pp 2269ndash2277 2012

[10] D L Mills ldquoInternet time synchronization the network timeprotocolrdquo IEEE Transactions on Communications vol 39 no 10pp 1482ndash1493 1991

[11] C D Godsil and G Royle Algebraic Graph Theory Springer2001

[12] R Olfati Saber and R M Murray ldquoConsensus protocols fornetworks of dynamic agentsrdquo in Proceedings of the AmericanControl Conference pp 951ndash956 June 2003

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 8: Research Article Time Synchronization in Wireless Sensor …downloads.hindawi.com/journals/ijdsn/2013/192128.pdf · 2015-11-21 · powered sensors is quite limited, time synchronization

8 International Journal of Distributed Sensor Networks

0 500 1000 15000

2

4

6

8

10

12

14

Clock error (ticks)

Num

ber o

f nod

esHistogram of sync error

120590 = 28632

minus1500 minus1000 minus500

(a)

0

5

10

15

20

25

30

35

40

45

Clock error (ticks)

Num

ber o

f nod

es

Histogram of sync error

120590 = 709

0 500 1000 1500minus1500 minus1000 minus500

(b)

Figure 3 Histogram of the synchronization errors from the instantaneous global average time of the sensor network (a) before and (b) afterone round of offset compensation

0 5 10 151

1

1

1

1

1

1

1

1

1Normalized skew

Time (mins)

Skew

Figure 4 Convergence of the skew rate of 100 simulated nodes run-ning the TSMA protocol in a 10 lowast 10 network with synchronizationperiod of 1min and transmission range of 2

50 minutes and presents 4 different regions of operationindicated by the letters A B C and D which model potentialnode failure or the addition of the new nodes In RegionA all nodes are turned on simultaneously with randominitial conditions of their local clocks After 2 synchronizationperiods the synchronization error between any two nodesis included between plusmn10 ticks that is the maximum error issmaller than 20 ticks At the beginning of Region B about20 of the nodes chosen random in the grid are switchedoff and then switched on at different random times Oncea node is switched on it starts updating its estimated time

using TSMA protocol but does not transmit any messagefor the first three synchronization periods to avoid injectinglarge disturbances into the already synchronized networkand then it starts to transmitting and receiving messagesequally The plot in Figure 6 clearly shows that the nodesget synchronized as soon as they are turned on withoutperturbing the overall network behavior At the beginning ofRegion C about 20 of the nodes turned off their radio thatis they stop updating their parameters 1198961015840 1198871015840 then we turn onthe 20 nodesrsquo radio at about 35 minutes In this procedurewe can see that all nodes keep the synchronized state thereason is that their skew rates have already converged tothe maximum skew rate in the network these 20 nodesstill synchronize with others At the beginning of Region Dwe replace the node in the top left corner with one nodehaving 40 PPM drift which is the max skew rate in thenetwork now and then all the other nodes will compensatethemselves to this skew value From Figure 6 we can see thatthree synchronization period after the new node joining thenetwork it starts to transmitting messages to its neighborsafter a short transient the nodes quickly synchronize again

7 Conclusions

This paper presented a new synchronization algorithm forWSN the time synchronization using consensus protocolwhich is based on consensus algorithms whose main idea isto average local information to achieve a global agreementon a specific quantity of interest The proposed algorithmis fully distributed asynchronous includes skew compensa-tion and is computationally light Moreover it is robust todynamic network topologies due for example to node failureor replacement Finally a set of simulations are presentedto show the good performance of the proposed protocol

International Journal of Distributed Sensor Networks 9

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(a) Transmission Range = 1

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(b) Transmission Range = 2

Error from average time

200

400

600

Erro

r (tic

ks)

5 10 15 20 25Time (mins)

minus400

minus200

0

0

(c) Transmission Range = 3

Figure 5 Clock errors of 100 simulated nodes running the TSMA protocol in a 10 lowast 10 network with synchronization period of 1min intransmission ranges of 1 (a) 2 (b) and 3 (c)

0 5 10 15 20 25 30 35 40 45 50

0

200

400

600

Error from average time

Time (mins)

Erro

r (tic

ks)

A B C D

minus400

minus200

Figure 6 Clock errors of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 3 Region A all nodes are on Region B20 of the nodes are turned off and then turned on at random timesRegion C 20 of the nodes turned off their radio and then turnedon their radio after 5 synchronization periods Region D replace thenode in the top left corner with one node having 40 PPM drift

However extensive work is still necessary to compare theperformance of our proposed approach relative to FTSP [3]and other protocols over large scale multihop sensor networkand over longer periods

Acknowledgments

This paper is supported in part by ImportantNational Scienceamp Technology Specific Projects under Grants nos (2010ZX03006-002 2010ZX03006-007) National Basic Research Pro-gram of China (973 Program) (no 2011CB302803) andNational Natural Science Foundation of China (NSFC) underGrant no (6117313261003307) The authors alone are respon-sible for the content of the paper

References

[1] H Kopetz and W Ochsenreiter ldquoClock synchronization in dis-tributed real-time systemsrdquo IEEE Transactions on Computersvol 36 no 8 pp 933ndash940 1987

[2] S Ganeriwal R Kumar and M B Srivastava ldquoTiming-sync protocol for sensor networksrdquo in Proceedings of the 1st

10 International Journal of Distributed Sensor Networks

International Conference on Embedded Networked Sensor Sys-tems (SenSys rsquo03) pp 138ndash149 Los Angeles Calif USA Novem-ber 2003

[3] M Maroti B Kusy G Simon and A Ledeczi ldquoThe floodingtime synchronization protocolrdquo in presented at Proceedingsof the 2nd International Conference on Embedded NetworkedSensor Systems Baltimore Md USA 2004

[4] J Elson L Girod and D Estrin ldquoFine-grained network timesynchronization using reference broadcastsrdquo SIGOPSOperatingSystems Review vol 36 pp 147ndash163 2002

[5] W Su and I F Akyildiz ldquoTime-diffusion synchronizationprotocol for wireless sensor networksrdquo IEEEACMTransactionson Networking vol 13 no 2 pp 384ndash397 2005

[6] L Qun and D Rus ldquoGlobal clock synchronization in sen-sor networksrdquo in Proceedings of the Conference on ComputerCommunications -23th Annual Joint Conference of the IEEEComputer andCommunications Societies (IEEE INFOCOM rsquo04)pp 564ndash574 March 2004

[7] G Werner-Allen G Tewari A Patel M Welsh and R NagpalldquoFirefly-inspired sensor network synchronicity with realisticradio effectsrdquo in presented at the Proceedings of the 3rd Interna-tional Conference on Embedded Networked Sensor Systems SanDiego Calif USA 2005

[8] L Schenato and F Fiorentin ldquoAverage TimeSynch a consensus-based protocol for clock synchronization in wireless sensornetworksrdquo Automatica vol 47 pp 1878ndash1886 2011

[9] M K Maggs S G OrsquoKeefe and D V Thiel ldquoConsensus clocksynchronization for wireless sensor networksrdquo IEEE SensorsJournal vol 12 pp 2269ndash2277 2012

[10] D L Mills ldquoInternet time synchronization the network timeprotocolrdquo IEEE Transactions on Communications vol 39 no 10pp 1482ndash1493 1991

[11] C D Godsil and G Royle Algebraic Graph Theory Springer2001

[12] R Olfati Saber and R M Murray ldquoConsensus protocols fornetworks of dynamic agentsrdquo in Proceedings of the AmericanControl Conference pp 951ndash956 June 2003

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 9: Research Article Time Synchronization in Wireless Sensor …downloads.hindawi.com/journals/ijdsn/2013/192128.pdf · 2015-11-21 · powered sensors is quite limited, time synchronization

International Journal of Distributed Sensor Networks 9

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(a) Transmission Range = 1

0

200

400

600Error from average time

Erro

r (tic

ks)

0 5 10 15 20 25Time (mins)

minus400

minus200

(b) Transmission Range = 2

Error from average time

200

400

600

Erro

r (tic

ks)

5 10 15 20 25Time (mins)

minus400

minus200

0

0

(c) Transmission Range = 3

Figure 5 Clock errors of 100 simulated nodes running the TSMA protocol in a 10 lowast 10 network with synchronization period of 1min intransmission ranges of 1 (a) 2 (b) and 3 (c)

0 5 10 15 20 25 30 35 40 45 50

0

200

400

600

Error from average time

Time (mins)

Erro

r (tic

ks)

A B C D

minus400

minus200

Figure 6 Clock errors of 100 simulated nodes running the TSMAprotocol in a 10 lowast 10 network with synchronization period of 1minand transmission range of 3 Region A all nodes are on Region B20 of the nodes are turned off and then turned on at random timesRegion C 20 of the nodes turned off their radio and then turnedon their radio after 5 synchronization periods Region D replace thenode in the top left corner with one node having 40 PPM drift

However extensive work is still necessary to compare theperformance of our proposed approach relative to FTSP [3]and other protocols over large scale multihop sensor networkand over longer periods

Acknowledgments

This paper is supported in part by ImportantNational Scienceamp Technology Specific Projects under Grants nos (2010ZX03006-002 2010ZX03006-007) National Basic Research Pro-gram of China (973 Program) (no 2011CB302803) andNational Natural Science Foundation of China (NSFC) underGrant no (6117313261003307) The authors alone are respon-sible for the content of the paper

References

[1] H Kopetz and W Ochsenreiter ldquoClock synchronization in dis-tributed real-time systemsrdquo IEEE Transactions on Computersvol 36 no 8 pp 933ndash940 1987

[2] S Ganeriwal R Kumar and M B Srivastava ldquoTiming-sync protocol for sensor networksrdquo in Proceedings of the 1st

10 International Journal of Distributed Sensor Networks

International Conference on Embedded Networked Sensor Sys-tems (SenSys rsquo03) pp 138ndash149 Los Angeles Calif USA Novem-ber 2003

[3] M Maroti B Kusy G Simon and A Ledeczi ldquoThe floodingtime synchronization protocolrdquo in presented at Proceedingsof the 2nd International Conference on Embedded NetworkedSensor Systems Baltimore Md USA 2004

[4] J Elson L Girod and D Estrin ldquoFine-grained network timesynchronization using reference broadcastsrdquo SIGOPSOperatingSystems Review vol 36 pp 147ndash163 2002

[5] W Su and I F Akyildiz ldquoTime-diffusion synchronizationprotocol for wireless sensor networksrdquo IEEEACMTransactionson Networking vol 13 no 2 pp 384ndash397 2005

[6] L Qun and D Rus ldquoGlobal clock synchronization in sen-sor networksrdquo in Proceedings of the Conference on ComputerCommunications -23th Annual Joint Conference of the IEEEComputer andCommunications Societies (IEEE INFOCOM rsquo04)pp 564ndash574 March 2004

[7] G Werner-Allen G Tewari A Patel M Welsh and R NagpalldquoFirefly-inspired sensor network synchronicity with realisticradio effectsrdquo in presented at the Proceedings of the 3rd Interna-tional Conference on Embedded Networked Sensor Systems SanDiego Calif USA 2005

[8] L Schenato and F Fiorentin ldquoAverage TimeSynch a consensus-based protocol for clock synchronization in wireless sensornetworksrdquo Automatica vol 47 pp 1878ndash1886 2011

[9] M K Maggs S G OrsquoKeefe and D V Thiel ldquoConsensus clocksynchronization for wireless sensor networksrdquo IEEE SensorsJournal vol 12 pp 2269ndash2277 2012

[10] D L Mills ldquoInternet time synchronization the network timeprotocolrdquo IEEE Transactions on Communications vol 39 no 10pp 1482ndash1493 1991

[11] C D Godsil and G Royle Algebraic Graph Theory Springer2001

[12] R Olfati Saber and R M Murray ldquoConsensus protocols fornetworks of dynamic agentsrdquo in Proceedings of the AmericanControl Conference pp 951ndash956 June 2003

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 10: Research Article Time Synchronization in Wireless Sensor …downloads.hindawi.com/journals/ijdsn/2013/192128.pdf · 2015-11-21 · powered sensors is quite limited, time synchronization

10 International Journal of Distributed Sensor Networks

International Conference on Embedded Networked Sensor Sys-tems (SenSys rsquo03) pp 138ndash149 Los Angeles Calif USA Novem-ber 2003

[3] M Maroti B Kusy G Simon and A Ledeczi ldquoThe floodingtime synchronization protocolrdquo in presented at Proceedingsof the 2nd International Conference on Embedded NetworkedSensor Systems Baltimore Md USA 2004

[4] J Elson L Girod and D Estrin ldquoFine-grained network timesynchronization using reference broadcastsrdquo SIGOPSOperatingSystems Review vol 36 pp 147ndash163 2002

[5] W Su and I F Akyildiz ldquoTime-diffusion synchronizationprotocol for wireless sensor networksrdquo IEEEACMTransactionson Networking vol 13 no 2 pp 384ndash397 2005

[6] L Qun and D Rus ldquoGlobal clock synchronization in sen-sor networksrdquo in Proceedings of the Conference on ComputerCommunications -23th Annual Joint Conference of the IEEEComputer andCommunications Societies (IEEE INFOCOM rsquo04)pp 564ndash574 March 2004

[7] G Werner-Allen G Tewari A Patel M Welsh and R NagpalldquoFirefly-inspired sensor network synchronicity with realisticradio effectsrdquo in presented at the Proceedings of the 3rd Interna-tional Conference on Embedded Networked Sensor Systems SanDiego Calif USA 2005

[8] L Schenato and F Fiorentin ldquoAverage TimeSynch a consensus-based protocol for clock synchronization in wireless sensornetworksrdquo Automatica vol 47 pp 1878ndash1886 2011

[9] M K Maggs S G OrsquoKeefe and D V Thiel ldquoConsensus clocksynchronization for wireless sensor networksrdquo IEEE SensorsJournal vol 12 pp 2269ndash2277 2012

[10] D L Mills ldquoInternet time synchronization the network timeprotocolrdquo IEEE Transactions on Communications vol 39 no 10pp 1482ndash1493 1991

[11] C D Godsil and G Royle Algebraic Graph Theory Springer2001

[12] R Olfati Saber and R M Murray ldquoConsensus protocols fornetworks of dynamic agentsrdquo in Proceedings of the AmericanControl Conference pp 951ndash956 June 2003

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of

Page 11: Research Article Time Synchronization in Wireless Sensor …downloads.hindawi.com/journals/ijdsn/2013/192128.pdf · 2015-11-21 · powered sensors is quite limited, time synchronization

International Journal of

AerospaceEngineeringHindawi Publishing Corporationhttpwwwhindawicom Volume 2014

RoboticsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Active and Passive Electronic Components

Control Scienceand Engineering

Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

International Journal of

RotatingMachinery

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporation httpwwwhindawicom

Journal ofEngineeringVolume 2014

Submit your manuscripts athttpwwwhindawicom

VLSI Design

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Shock and Vibration

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Civil EngineeringAdvances in

Acoustics and VibrationAdvances in

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Electrical and Computer Engineering

Journal of

Advances inOptoElectronics

Hindawi Publishing Corporation httpwwwhindawicom

Volume 2014

The Scientific World JournalHindawi Publishing Corporation httpwwwhindawicom Volume 2014

SensorsJournal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Modelling amp Simulation in EngineeringHindawi Publishing Corporation httpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Chemical EngineeringInternational Journal of Antennas and

Propagation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

Navigation and Observation

International Journal of

Hindawi Publishing Corporationhttpwwwhindawicom Volume 2014

DistributedSensor Networks

International Journal of