Tiny-Sync: Tight Time Synchronization For Wireless Sensor Networks
Tiny-Sync: Tight Time Synchronization For Wireless Sensor Networks
Time synchronization is a fundamental middleware service for any distributed system. Wireless
sensor networks make extensive use of synchronized time in many contexts (e.g., data fusion,
TDMA schedules, synchronized sleep periods, etc.). We propose a time synchronization method
relevant for wireless sensor networks. The solution features minimal complexity in network band-
width, storage and processing, and can achieve good accuracy. Especially relevant for sensor
networks, it also provides tight, deterministic bounds on offset and clock drift. A method for
synchronizing the entire network is presented. The performance of the algorithm is analyzed the-
oretically and is validated on a realistic testbed. The results show that the proposed algorithm
outperforms existing algorithms in terms of precision and resource requirements.
Categories and Subject Descriptors: C.2.4 [COMPUTER-COMMUNICATION NETWORKS]:
Distributed Systems; C.2.2 [COMPUTER-COMMUNICATION NETWORKS]: Network
Protocols
General Terms: Algorithm, Design, Experimentation, Performance
Additional Key Words and Phrases: Sensor networks, Time synchronization
1. INTRODUCTION
Recent technological advances in low power radios, sensors and microcontrollers
enable a new monitoring paradigm for large geographical areas. The vision involves
a large number of inexpensive nodes equipped with one or more sensors, a small
microcontroller and transceivers capable of short-range communications. Wireless
sensor networks (WSNs) [Akyildiz et al. 2002a; 2002b; Asada et al. 1998] have the
potential to truly revolutionize the way we monitor and control our environment.
Many (if not most) WSN applications either benefit from, or require, time syn-
chronization. Sensed data is typically forwarded over multiple hops to one or more
base stations and encounters delays ranging from a few tens of milliseconds to sev-
eral minutes [Xu et al. 2004]. Many energy-efficient algorithms trade power savings
for increased delays. Therefore, without time synchronization, the time that sensed
Author’s address: Suyoung Yoon, Chanchai Veerarittiphan and Mihail L. Sichitiu, Dept. of
Electrical and Computer Eng. North Carolina State University Raleigh, NC 27695-7911.
Permission to make digital/hard copy of all or part of this material without fee for personal
or classroom use provided that the copies are not made or distributed for profit or commercial
advantage, the ACM copyright/server notice, the title of the publication, and its date appear, and
notice is given that copying is by permission of the ACM, Inc. To copy otherwise, to republish,
to post on servers, or to redistribute to lists requires prior specific permission and/or a fee.
c 20YY ACM 0000-0000/20YY/0000-0001 $5.00
data reached the base station is often a poor approximation of the time the data was
sensed. If the entire sensor network is time-synchronized (with respect to the base
station), meaningful time-stamps can accompany sensed data. Target tracking, one
of the most popular sensor network applications, requires tight time synchroniza-
tion for beam-forming. Many WSN protocols (e.g., power-saving sleep schedules
[Lu et al. 2005], TDMA schedules for maximizing the networks’ capacity, security
mechanisms for preventing replay attacks, etc.) also rely on time synchronization.
In this paper, we present two closely-related algorithms suitable for pair-wise
time synchronization. In those algorithms, one node determines (tight) bounds
of the relative offset and drift of its clock with respect to the one of the other
node. We also present a scheme building on these algorithms, which is capable of
synchronizing the clocks of an entire sensor field. To avoid confusion between the
two algorithms, we will name them mini-sync and tiny-sync as they use limited and
very limited resources, respectively. The two algorithms feature:
—Drift awareness: The algorithms not only take the drift of the clock into account,
but also find tight bounds on the drift.
—Deterministic bounds on the precision: Most other algorithms provide best es-
timates for the offset and drift of the clocks, and possibly probabilistic bounds
on these estimates. Our approach delivers tight, deterministic bounds on these
estimates, such that absolute information can be deduced about ordering and
simultaneous events.
—Precision: Given small uncertainty bounds on the delays exchanged messages
undergo, the precision of the synchronization can be arbitrarily good.
—Low computation and storage complexity: Wireless sensor nodes typically feature
low computational power microcontrollers with small amounts of RAM. Both
algorithms have low computational and storage complexity.
—Low sensitivity to communication errors: Wireless communications are notori-
ously error prone, and thus one cannot rely on correct receipt of all messages.
The presented approach works correctly even if a large percentage of the messages
is lost.
—Hardware independence: The two-way data collection exchange does not require
hardware-dependent calibration, and allows the proposed algorithms to detect
and discard outliers.
The main contribution of the paper is the development and performance eval-
uation of two simple algorithms that deliver accurate offset and drift information
together with tight bounds on them. In short, the two algorithms select a bounding
box on the relative drift and offset that, in most cases, outperforms linear re-
gression by rejecting outliers while continuously monitoring and adapting to clock
non-linearity.
The two algorithms presented in this paper are not limited to wireless sensor
networks. They can synchronize the nodes on any communication network which
allows bidirectional data transmission. However, the algorithms provide very good
precision (microsecond if crafted carefully) and bounds on the precision while using
very limited resources, thus being especially well suited for wireless sensor networks.
ACM Journal Name, Vol. V, No. N, Month 20YY.
Tiny-Sync: Tight Time Synchronization for Wireless Sensor Networks · 3
The rest of the paper is organized as follows. Section 2 presents a brief overview
of the related work. In Section 3, two time synchronization algorithms are presented
and their theoretical performance is analyzed. Section 4 presents the experimental
results on the performance of the two proposed algorithms. Section 6 concludes the
paper.
2. RELATED WORK
Time synchronization is a key service for many applications and operating systems
in distributed computing environments. Many protocols have been proposed and
used for time synchronization in wired and wireless networks. Mill’s Network Time
Protocol (NTP) [Mills 1991; 1994] has been widely used in the Internet for decades.
Nodes could also be equipped with a global positioning system (GPS) [Hofmann-
Wellenhof et al. 1997] to synchronize them. However, traditional synchronization
schemes and GPS-equipped systems are not suitable for use in WSNs due to the
specific requirements of those networks:
—Precision: Depending on the considered application, WSNs may require far better
precision than traditional networks. For example, a precision of a few milliseconds
is considered satisfactory for NTP, while in a WSN beam-forming application,
microsecond precision can significantly improve the performance of the appli-
cation [Simon et al. 2004]. Furthermore, when coordinating synchronized time
schedules, the higher the precision of the synchronization algorithm, the smaller
the guard times have to be (and, hence, the higher the efficiency of the scheduling
approach).
—Cost: Cost is of primary concern in WSNs as, typically, nodes have limited bat-
teries, computational and storage resources. Most of the protocols designed for
wired environments exchange many messages for statistical processing. Further-
more, the protocols also need to store the messages to process them.
Recently, a significant amount of research on time synchronization for wireless
sensor networks has been published [Sivrikaya and Yener 2004; Sundararaman et al.
2005]. An interesting approach called post facto synchronization was proposed by
Elson and Estrin [Elson and Estrin 2001]. In this approach, each node’s clock is
normally unsynchronized with the rest of the network; a beacon node periodically
broadcasts beacon messages to the sensor nodes in its wireless range. When an
event is detected, each node records the time of the event (time-stamp with its
own local clock). After the event (hence, the name), upon receiving the reference
beacon message, nodes use it as time reference and adjust their event timestamps
with respect to that reference.
The reference broadcast synchronization (RBS) protocol [Elson et al. 2002], uses a
data collection mechanism similar to the one in the post facto synchronization: one
node acts as a beacon by broadcasting a reference packet. All receivers record the
packet arrival time. The receiver nodes then exchange their recorded timestamps
and estimate their relative phase offsets. RBS also estimates the clock skew by using
a least-squares linear regression. The interesting feature of RBS is that it records
the timestamp only at the receivers. Thus, all timing uncertainties (including MAC
medium access time) on the transmitter’s side are eliminated. This characteristic
ACM Journal Name, Vol. V, No. N, Month 20YY.
4 · Suyoung Yoon, Chanchai Veerarittiphan and Mihail L. Sichitiu
makes it especially suitable for hardware that does not provide low-level access to
the MAC layer (e.g., 802.11). Although RBS synchronization only involves one
hop neighbors, the mechanism can be extended to synchronize a multi-hop network
[Karp et al. 2003]. In such a system, timestamps in messages can be reconciled as
they are being forwarded by the intermediate nodes (according to their next-hop
destination and its time difference to the current node) [Girod 2005]. The main
disadvantage of RBS is that it does not synchronize the sender with the receiver
directly and that, when the programmers have low-level access at the MAC layer,
simpler methods (e.g., TPSN) can achieve a similar precision to RBS.
Römer [Römer 2001] presented a synchronization protocol for ad hoc networks.
The authors assume clocks with known upper-bounds on the clock drift. The
basic idea of the algorithm is to compute timestamps using unsynchronized local
clocks. When a local time-stamp is transferred between two nodes, the timestamp is
transformed to the local time of the receiving node with guaranteed bounds based on
the assumed maximum clock drift. These protocols focus on temporal relationships
between the events such as ”event X happened before event Y” and ”event X and
Y happened within a certain time interval.” [Meier et al. 2004] enhanced Römer’s
algorithm and achieved higher accuracy while reducing computation.
When implementing time synchronization protocols, significant challenge is mini-
mizing timestamping uncertainties. RBS reduces these uncertainties by timestamp-
ing only at the receivers. The time synchronization protocol for sensor network
(TPSN) [Ganeriwal et al. 2003] reduces the uncertainties by using timestamps at
the medium access control (MAC) layer. This eliminates the (large) uncertain-
ties introduced by the MAC layer, e.g., retransmissions, backoffs, medium access,
etc. TPSN takes advantage of the availability of the MAC layer code in TinyOS
[Hill et al. 2000]. For a single beacon, TPSN offers a two-fold increase in precision
in comparison to RBS (although, asymptotically, as more beacons are sent, they
achieve the same precision ).
The Flooding Time Synchronization Protocol (FTSP) [Maróti et al. 2004] was
designed for a sniper localization application requiring very high precision [Simon
et al. 2004]. FTSP achieves the required accuracy by utilizing a customized MAC
layer time-stamping and by using calibration to eliminate unknown delays. FTSP
is robust to network failures, as it uses flooding both for pair-wise and for global
synchronization. Linear regression from multiple timestamps is used to estimate the
clock drift and offset. The main drawback of FTSP is that it requires calibration
on the hardware actually used in the deployment (and thus, it is not a purely
software solution independent of the hardware). FTSP also requires intimate access
to the MAC layer for multiple timestamps. However, if well calibrated, the FTSP’s
precision is impressive (less than 2µs).
Lightweight Time Synchronization (LTS) [Greunen and Rabaey 2003] was pro-
posed for applications where the required time accuracy is relatively low. The
pair-wise synchronization on LTS is similar to TPSN except for the treatment of
the uncertainties (LTS adopts a statistical model for handling the errors). The
simulation results show that the accuracy of LTS is about 0.5 seconds.
Li and Rus [Li and Rus 2004] presented a high-level framework for global syn-
chronization. The authors proposed three methods for global synchronization in
ACM Journal Name, Vol. V, No. N, Month 20YY.
Tiny-Sync: Tight Time Synchronization for Wireless Sensor Networks · 5
3. PROPOSED ALGORITHMS
In this section, we present the two proposed algorithms and their expected perfor-
mance.
3.1 Data Collection
For the proposed algorithms, we will use a classical data collection algorithm
[Ganeriwal et al. 2003; Cristian 1989; Mills 1991; Lemmon et al. 2000; Römer
2001]; however, we will process the data differently.
ACM Journal Name, Vol. V, No. N, Month 20YY.
6 · Suyoung Yoon, Chanchai Veerarittiphan and Mihail L. Sichitiu
Consider a wireless node i with its hardware clock ti (t), where t is the Coordinated
Universal Time (UTC). In general, the hardware clock of node i is a monotonically
non-decreasing function of t. In practice, a quartz oscillator is often used to generate
the real-time clock. The oscillator’s frequency depends on the ambient conditions,
but for relatively extended periods of time (minutes - hours), the hardware clock
can be approximated with good accuracy by an oscillator with fixed frequency:
ti (t) = ai t + bi , (1)
where ai and bi are the drift and the offset of node i’s clock. In general, ai and bi
will be different for each node and approximately constant for an extended period
of time.
Consider two wireless nodes 1 and 2 with their hardware clocks t1 (t) and t2 (t),
respectively. From (1), it follows that t1 and t2 are linearly related:
tb t2
to tr t1
Fig. 1. A probe message from node 1 is immediately returned by node 2 and time-stamped at
each send/receive point resulting in the data-point (to , tb , tr ).
The three time-stamps (to , tb , tr ) form a data-point which effectively limits the
possible values of parameters a12 and b12 in (2). Indeed, since to happened before
tb , and tb happened before tr , the following inequalities should hold:
to < a12 tb + b12 , and (3)
tr > a12 tb + b12 . (4)
The data collection procedure described above is repeated several times; and each
probe that returns, provides a new data-point and, thus, new constraints on the
admissible values of a12 and b12 .
The linear dependence between t1 and t2 and the constraints imposed by the
data-points can be represented graphically as shown in Fig. 2. Each data-point can
ACM Journal Name, Vol. V, No. N, Month 20YY.
Tiny-Sync: Tight Time Synchronization for Wireless Sensor Networks · 7
t1
data
point 3
data
point 2
data
point 1
tr
1
t o1
a 12
b 12
a12
b12
a 12
b 12
tb t2
1
Fig. 2. The linear dependence (2) and the constraints imposed on a12 and b12 by three data-points.
where a12 (a12 ) is the maximum (minimum) of the slopes of lines that satisfy the
constraints, and b12 (b12 ) is the value on the y-axis at the intersection with the line
corresponding to a12 (a12 ).
Not all combinations of a12 and b12 satisfying (5) and (6) are valid, but all valid
combinations satisfy (5) and (6). The real values of a12 and b12 can be estimated
as the midpoint of the range of possible values ac c
12 and b12 :
∆a12 ∆a12
a12 ∈ ac 12 − ; c
a12 + , and (7)
2 2
ACM Journal Name, Vol. V, No. N, Month 20YY.
8 · Suyoung Yoon, Chanchai Veerarittiphan and Mihail L. Sichitiu
c ∆b12 c ∆b12
b12 ∈ b12 − ; b12 + , (8)
2 2
where
a12 + a12
ac
12 = , (9)
2
∆a12 = a12 − a12 , (10)
b12 + b12
bc
12 = , and (11)
2
∆b12 = b12 − b12 . (12)
The goal of the algorithms is to determine a12 , a12 , b12 and b12 as tight as possible
(such that it minimizes ∆a12 and ∆b12 ). Once a12 and b12 are estimated, node 1
can always correct the reading of the local clock (using (2)) to have it match the
readings of the clock at node 2.
To decrease the overhead of this data-gathering algorithm, the probes can be
piggy-backed on data messages. Since most MAC protocols in wireless networks
employ an acknowledgment (ACK) scheme, the probes can be piggy-backed on the
data and the responses on the ACKs. Elaborate schemes with optional headers can
be devised to reduce the length of the header when probes do not need to be sent.
This way, synchronization can be achieved almost “for free” (i.e., with very little
overhead in terms of communication bandwidth).
3.1.1 Relaxing the Immediate Reply Assumption. In Fig. 1, we assumed that
node 2 replies immediately to node 1 when it receives a probe. The correctness of
the presented approach is not affected in any way even if node 2 does not respond
immediately. Node 2 can delay the reply as long as it wants; the relations (3) and
(4), and, thus the rest of the analysis will still hold.
However, as the delay between to and tr increases, the precision of the estimates
will decrease. In practice, node 2 may have to delay the reply due to any number
of reasons (e.g., it has something more important to send, it has to postpone its
transmission due to medium access contention, etc.).
tb t2
tbr
probe probe−reply
ts to tr t1
Fig. 3. A probe message from node 1 may be returned by node 2 after being time-stamped at
both the send and receive points.
To counteract the possible loss in precision, node 2 can time-stamp the probe
message upon receipt (tbr ) as well as upon reply (tb ) (as depicted in Fig. 3). In this
case, node 1 can adjust to as follows:
to = ts + ac
12 (tb − tbr ) , (13)
ACM Journal Name, Vol. V, No. N, Month 20YY.
Tiny-Sync: Tight Time Synchronization for Wireless Sensor Networks · 9
where to is the latest time at node 1 that is known to have occurred before tb . The
same inequalities (3) and (4) hold for this case as well.
3.1.2 Increasing Precision by Considering Minimum Delay. If no information
about delays encountered by the probe messages is available, nothing else can be
done to increase the precision. However, if the minimum delay a probe encounters
between the nodes is known, the data-points can be adjusted for an increase in the
precision of the results.
To determine the minimum delay, one can take into account the minimum length
of such a probe and the time it takes to transmit such a probe (at the transmission
rate of the sensor node), and, eventually, other operations that have to be completed
before the probe is sent or upon receiving such a probe (e.g., encryption/decryption,
CRC calculation, etc.).
Assume that we are able to determine the minimum delay δ12 that the probe
encounters between to (ts ) at node 1 and tb (tbr ) at node 2. Also, denote with δ21 ,
the minimum delay between the moment tb at node 2 and the moment tr at node
1. Then, (to + δ12 , tb , tr − δ21 ) should be used as a data-point as this will offer
increased accuracy over the data-point (to , tb , tr ).
If, for two probes, both minimums δ12 and δ21 are reached, the method presented
in this paper can achieve perfect synchronization (i.e., there will be no uncertainties
for relative offset and relative drift: ∆a12 = ∆b12 = 0).
stored. We will name the algorithm described in this paragraph “tiny-sync.” The
four constraints that are stored at any one time instant may belong to two, three
or four different data-points. With the four constraints, the bounds of the clock
offset and drift are easily computed from the two lines that can be constructed with
the two lower bound and two upper bound constraints: the first line is determined
by the first lower bound constraint and the second upper bound constraint and
the other line is determined by the first upper bound constraint and second lower
bound constraint. The values of a12 , b12 , a12 and b12 are the slope and offset of
those two lines respectively.
t1
A2 is discarded B4
B3 Tighter constraining line
only possible if A2 is stored
B2 A4
B1
A3
A2
A1
t2
Fig. 4. In this situation, after receiving data-point A3 − B3 , tiny-sync will discard constraints
A2 and B2 . However, after receiving A4 − B4 , it turns out that the most constraining constraint
would have been A2 − B4 .
Unfortunately, while tiny-sync is very efficient, it does not always produce the op-
timal solution. Consider the situation depicted in Fig. 4. For clarity, we labeled each
constraint individually, that is, for data-point i, Ai represents constraint (tbi , toi ),
and Bi represents constraint (tbi , tri ). After the first two data-points (A1 -B1 ) and
(A2 -B2 ) are received, the first estimates for the drift and offset may be computed.
After the third data-point (A3 -B3 ) is received, the bounds on the estimates improve
(i.e., ∆a12 and ∆b12 are smaller); so, the constraints A1 ,B1 ,A3 and B3 are stored,
while A2 and B2 are discarded. The next data point (A4 -B4 ) could have used con-
straint A2 to construct a better estimate. Unfortunately, A2 was already discarded
at this point; and thus, a less than ideal estimate for b12 will now be imposed by A1
and A4 . Thus, while producing correct results, tiny-sync might miss the optimum
result. We will compare the performance of tiny-sync with the optimal solution in
Section 4.
In Fig. 4, the constraint A2 was discarded by tiny-sync because it was not im-
mediately useful, but rather only potentially useful in the future. By a potentially
useful constraint we mean a constraint that, with the current data points, is not one
ACM Journal Name, Vol. V, No. N, Month 20YY.
Tiny-Sync: Tight Time Synchronization for Wireless Sensor Networks · 11
of the constraints that is determining the values of a12 , a12 , b12 and b12 , but which
may do so given future data points. This does not mean that all the constraints
are potentially useful. In fact, only the constraints Aj (e.g., A2 ) that satisfy the
condition
m(Ai , Aj ) > m(Aj , Ak ) (14)
for some integers 1 ≤ i < j < k are potentially useful in the future (by m(X, Y ),
we denote the slope of the line going through the points X and Y ).
Theorem 1 Any constraint Aj which satisfies
m(Ai , Aj ) ≤ m(Aj , Ak ) (15)
for at least one set of integers 1 ≤ i < j < k can be safely discarded as it will never
constrain the bounds a12 , a12 , b12 and b12 more than any existing constraints.
The proof is presented in the Appendix. Similar conditions for discarding upper-
bound constraints (Bi ) exist.
The resulting algorithm (called “mini-sync”), upon the receipt of a new-data
point, will check if the new constraints can eliminate any of the old constraints.
Potentially, many old constraints can be eliminated with one new data-point. We
use all the remaining constraints to obtain the (still optimal) solution using the
same procedure as in [Lemmon et al. 2000]. Since we only eliminate constraints
(inequalities) that are irrelevant, we still obtain the optimal solution with only a few
points (solving the set of all inequalities is shown to result in the optimal solution
[Lemmon et al. 2000]).
Storing only four points, as in tiny-sync, does not produce the optimal solution.
How many points have to be stored for the optimal solution? Theoretically, a
potentially large number. If the delay between nodes 1 and 2 is monotonically
increasing, (14) can hold for all of the constraints Aj . In practice, the delays do
not continuously increase monotonically; therefore, only several constraints need to
be stored to obtain the optimal result.
—The variation of the round-trip delays is typically very small (microseconds) when
compared to the sampling intervals (seconds to tens of seconds); and
—As shown in Section 4.2, the theoretical analysis matches the experimental results
exceedingly well.
With assumption (16), the data points that define the best approximation are
always the first and last data-points collected. All of the other data-points can be
safely discarded. Thus, with this assumption, tiny-sync’s performance is identical
to the performance of mini-sync (the optimal algorithm). Denote with (to1 , tb1 , tr1 )
and (to2 , tb2 , tr2 ) the first and last collected data-points, respectively.
t1
t1
m
tr
2 RTT
to
2
∆ to
∆ t 2m
tr
1
RTT
t o1
a 12
b 12
a 12
∆ tb
b 12
tb t b2 t2 t2
1 m
Figure 6 depicts the evolution of the uncertainty bound on the relative clock
drifts ∆a12 , which remains constant between data-points, and improves upon the
receipt of a new data-point.
∆ a12
2RTT
tb − tb1
t b1 tr tr tr tr t1
2 3 4 5
Fig. 6. Evolution of the uncertainty bound on the relative clock drifts ∆a12 as new data-points
are received.
Theoretically, the precision on the relative drift for the two clocks ∆a12 can be
made arbitrarily small. In practice, assumption (1) only holds for limited time T0 ,
and, thus, the achievable precision is on the order of 2RT T
T0 .
Equation (24) implies that the precision on the relative offset ∆b12 is limited by
the round-trip time RT T :
lim ∆b12 = RT T. (26)
∆tb →∞
The second implication of (24) is that the performance of the algorithm depends
on the choice of origin: if tb1 is large, the precision of the offset will initially be poor
(it will improve as ∆a12 → 0). To avoid the initial loss in precision, the origin can
be shifted:
tb1 = 0. (27)
This shift can be easily achieved by subtracting tb1 from every component of all
data-points and keeping the rest of the algorithms unchanged.
The goal of the synchronization is to be able to estimate the clock of the remote
machine t2 given the local clock t1 after the two clocks have been synchronized. In
Fig. 5, node 1 estimates the value of node 2’s clock t2m at the same real time that
node 1’s clock is reading t1m .
Using (2) and writing t2m as:
∆t2m
t2m = td
2m ± , (28)
2
we can find:
∆a12 a12 b12 − a12 b12
∆t2m (t1m ) = t1m + . (29)
a12 a12 a12 a12
Using (19)-(22), (29) becomes:
∆a12 (t1m − to1 ) RT T
∆t2m (t1m ) = + . (30)
a12 a12 a12
Fig. 7 depicts the qualitative evolution of the uncertainty bound ∆t2m as more
data-points are received, (i.e. a sketch of ∆t2m as a function of t1m as in (30)).
∆ t 2m
∆ t 2m(t ri)
tr tr tr tr t1
2 3 4 5 m
Equation (30) implies that the uncertainty in computing t2m increases linearly
with the increase of t1m . Intuitively, this can be observed in Fig. 5: the later the
moment t1m is chosen, the larger ∆t2m gets (i.e., the precision degrades). Since the
uncertainty of the relative clock drift ∆a12 decreases inversely proportionally with
∆tb , the uncertainty in estimating t2m , ∆t2m returns to an (almost) fixed base-line
with each new data point:
2∆to 1
∆t2m (tri ) = RT T − ≈ const, ∀i ≥ 2 (31)
a12 a12 ∆tb a12
∆to
(because ∆tb ≈ 1, a12 ≈ 1, a12 ≈ 1).
ACM Journal Name, Vol. V, No. N, Month 20YY.
Tiny-Sync: Tight Time Synchronization for Wireless Sensor Networks · 15
After each new data-point, the precision on the relative clock drift improves (i.e.,
∆a12 decreases), and, therefore, the slope of the increase of ∆t2m decreases.
3.3.1 Enforcing the Linear Clock Drift Assumption. The assumption of per-
fectly linear clock drifts (1) only holds for limited time, as a number of factors
(temperature, humidity, power source voltage, etc.) may change the oscillator’s
frequency over time. Thus, it is important to detect when assumption (1) no longer
holds since tiny-sync assumes linear drifts.
The analysis presented in this section can be used to determine when the linear
drift assumption (1) no longer holds: the expected bound on the relative drift ∆a12
should decrease as 2RT T
∆tb (according to (23)). If the linearity assumption on the
clock drifts does not hold, ∆a12 will decrease faster than 2RT T
∆tb (and, eventually,
if nothing is made to correct the situation, it will become negative as a12 and a12
intersect).
The reason for this decrease in ∆a12 can be understood if one imagines the set
of constraints imposed by all data points as a flexible pipe and the two lines that
determine a12 , a12 , b12 and b12 as two thin rods inside the pipe, spanning the
diagonals of the pipe. If the flexible pipe bends (i.e., the clock drift changes), the
two rods will get closer to a parallel position, corresponding to a reduction in ∆a12
(with respect to ∆a12 for the perfectly straight pipe).
Thus, in practical terms, in the algorithm, after each probe, the computed ∆a12
is compared with 2RT T
∆tb , where RT T is the minimum RT T of the stored data-points,
and ∆tb is the difference between the tb timestamps of the stored data-points. If
2RT T
∆a12 < , (32)
∆tb
the oldest constraint is discarded and a new constraint is acquired. In essence, the
algorithm restarts upon detection of the failure of assumption (1).
s u v
Consider the situation depicted in Fig. 8 where node s synchronizes with node u
that, in turn, synchronizes with node v. Node s is able to determine the bounds
asu ≤ asu ≤ asu , and (33)
bsu ≤ bsu ≤ bsu , (34)
ACM Journal Name, Vol. V, No. N, Month 20YY.
16 · Suyoung Yoon, Chanchai Veerarittiphan and Mihail L. Sichitiu
time-stamp the packet just before the first byte of the packet is transmitted and
immediately after the last byte of the packet is received. Thus, all of the non-
deterministic delays (RT T in Section 3.3) are due to the transceiver and scheduling
of TinyOS. Our measurements showed that the one-way delay is approximately
1.419 ms (2.838 ms round-trip time).
4.1.3 Synchronization Errors Measurements. We define the time synchroniza-
tion error as the time difference between the real clock reading of a sensor node and
the estimated clock value by the other sensor node. There are two distinct sources
of errors when measuring the synchronization error:
—the synchronization algorithm and
—the measurement procedure itself.
As previously mentioned, in the experimental setup, the base station triggers
simultaneous interrupts at the two nodes running tiny-sync. This measurement
method eliminates the radio transceiver delay uncertainties from the measurement
process. However, it introduces other sources of non-deterministic delays that may
result in erroneous measurements. Figure 11 shows the possible sources of delays
affecting the measurements. When an interrupt occurs, unless interrupts are sus-
pended, the processor first completes the current executing instruction, saves the
program counter (PC) and the status register (SR), then jumps to the correspond-
ing interrupt service routine (ISR). In our case, the ISR reads the current clock.
Unfortunately, if the processor is in the middle of a non-interruptible operation
at the time the interrupt arrives (i.e., the interrupts were suspended), or there
are other pending interrupts, the measurement interrupt will be delayed for an
unknown time (in our experiments, we found it to be up to 61 µs).
There can be several ways to define the measurement error. Assume we measure
the synchronization error for each interrupt j, where j = 1, 2, 3, .... We define the
measurement error Ej of the synchronization error between node n1 and n2 at
measurement j as
Ej = xn1 ,j − xn1 ,j−1 − ac
12 (xn2 ,j − xn2 ,j−1 ), (48)
where node n1 estimates the clock of node n2 , and xni ,j is the time-stamp of node ni
at measurement j, and ac12 is defined in (9). That is, the measurement error is the
inter-measurement time difference between participating nodes. The measurement
errors can be reduced by discarding the data-points whose measurement errors are
ACM Journal Name, Vol. V, No. N, Month 20YY.
Tiny-Sync: Tight Time Synchronization for Wireless Sensor Networks · 19
−3
10
∆a12
2.0*MIN(RTT)/(sample times)
−4
10
∆a12
−5
10
−6
10
−7
10
0 1000 2000 3000 4000 5000 6000 7000 8000
Time (s)
Fig. 13. The evolution of the bound on the relative drift ∆a12 and the predicted evolution (23)
for the first experiment.
−4
x 10
1.5
1 Avg(abs(sync. error)):1.2075e−005
0.5
−0.5
−1
−1.5
synchronization error
moving average of synchronization error in magnitude
−2
0 1000 2000 3000 4000 5000 6000 7000 8000
Time (s)
0.9
0.8
0.7
0.6
Probability
0.5
0.4
0.3
0.2
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Synchronization error (s) x 10
−4
we did not filter out the measurement errors for any synchronization protocol (i.e.,
all measurement data were included in comparison).
TPSN uses a similar probing method as tiny-sync to estimate the clock of the
target sensor node. It also exploits the MAC layer time-stamping to reduce the
timing uncertainties. Thus, we used the same data collection to determine the time
synchronization error of tiny-sync and TPSN. For FTSP, we downloaded the latest
version of FTSP source code from [Maróti et al. 2005] and implemented it on the
same Telos motes. We used a test program provided by FTSP to evaluate time
synchronization errors of the sensor nodes running FTSP.
For the linear fit we used least square to minimize the error between a linear
fit and the data points (both (to , tb ) and (tb , tr )). We also tested the performance
ACM Journal Name, Vol. V, No. N, Month 20YY.
22 · Suyoung Yoon, Chanchai Veerarittiphan and Mihail L. Sichitiu
−5
x 10
2
Sync_interval=4
Sync_interval=8
1.9 Sync_interval=16
Sync_interval=32
Sync_interval=64
Sync_interval=128
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1 1.5 2 2.5 3 3.5 4
Hops
of a one-way linear fit (that only considers forward probes (to , tb )) and the results
were nearly identical. However, while a one-way linear fit only requires one probe
packet, it also requires hardware-dependent calibration. Thus, in what follows, we
present the results of the two-way fit (again, practically identical with the one-way
fit), as the two way fit match the properties of the proposed scheme (in terms of
need for calibration).
Since the results of the linear fit are sensitive to the number of data points
considered, we plotted synchronization error of the linear fit as a function of the
number of data points considered for the fit. The results are shown in Fig. 17. The
graph shows that the linear fit has a an optimum number of points - both a lower
and a higher number of points lead to a decrease in accuracy. Intuitively, if only
a small number of points are used, the accuracy of the linear fit is limited by the
quality of the data provided by these points. However, if the drift is non-linear, as
the number of data-points considered for the linear fit increases, the fit necessarily
becomes an increasingly poor approximation of the current relationship between
the two clocks (as it minimizes the error to all considered points). In the following
comparisons we use both 128 points that optimizes the performance of the fit for
our experimental setup as well as a 2 point fit that has a comparable computational
and storage complexity with tiny-sync.
Figure 18 shows the comparison of the synchronization errors as a function of
the number of hops between sensor nodes. When the synchronization interval is 4
s, tiny-sync and TPSN show similar results. However, when the synchronization
interval is 128 s, tiny-sync clearly outperforms TPSN and FTSP. Furthermore, the
synchronization error of FTSP increases faster than tiny-sync and TPSN with the
number of hops. The linear fit that uses 128 points (optimal for this data-set) at
four second synchronization interval, slightly outperforms tiny-sync for all number
of hops. This slight improvement is attained at a price of higher computational and
storage resources as well as at a loss of generality: the linear fit has to be optimized
for the particular degree of the non-linearity of the clock drift. When only two
ACM Journal Name, Vol. V, No. N, Month 20YY.
Tiny-Sync: Tight Time Synchronization for Wireless Sensor Networks · 23
−4
10
−5
10
0 1 2 3
10 10 10 10
# of data−points
Fig. 17. Synchronization errors as a function of the number of points considered for the linear fit
and tiny-sync.
0
10
Linear−fit with 2 data−points(sync_interval=4)
Linear−fit with 2 data−points(sync_interval=128)
Linear−fit with 128 data−points(sync_interval=4)
Linear−fit with 128 data−points(sync_interval=128)
−1 Tiny−sync(sync_interval=4)
10 Tiny−sync(sync_interval=128)
Average Synchronization Error (s)
TPSN(sync_interval=4)
TPSN(sync_interval=128)
FTSP(sync_interval=4)
FTSP(sync_interval=128)
−2
10
−3
10
−4
10
−5
10
points are used for the linear fit or when the synchronization interval is higher (128
seconds), tiny-sync outperforms the linear fit.
Figure 19 shows the comparison of the synchronization errors as a function of
the synchronization intervals. Tiny-sync outperforms TPSN and FTSP in terms of
synchronization error, and it shows reduced variation with the increase in the syn-
chronization interval. Synchronization error of TPSN increases faster than others
as the synchronization interval increases because TPSN does not compensate for
the clock drift. The synchronization error of FTSP increases slowly as the number
of hops increases, as FTSP uses the linear regression to compensate for the drift.
The accuracy of the linear fit decreases slightly with the increase in the synchro-
nization interval, as the number of points is also correspondingly reduced. The 128
ACM Journal Name, Vol. V, No. N, Month 20YY.
24 · Suyoung Yoon, Chanchai Veerarittiphan and Mihail L. Sichitiu
0
10
Linear−fit with 2 data−points(1 hop)
Linear−fit with 2 data−points(4 hops)
Linear−fit with 128 data−points(1 hop)
Linear−fit with 128 data−points(4 hops)
−1 Tiny−sync(1 hop)
10 Tiny−sync(4 hops)
−3
10
−4
10
−5
10
1 2
10 10
Synchronization Interval (s)
points linear fit outperforms all synchronization algorithms for a single hop, and a
small synchronization interval.
−3
10
∆a12
3e−005
2.0*MIN(RTT)/(sample times) 10
Upper bound of a12
Lower bound of a12
Estimation of a12
2e−005
10
−4
10
12
1e−005
10
Upper/lower bound of a
0
10
12
−5
10
∆a
−1e−005
10
−6 −2e−005
10 10
−7
10
0 2000 4000 6000 8000 10000 12000 14000 16000 0 2000 4000 6000 8000 10000 12000 14000 16000 18000
Time (s) time (s)
(a) (b)
Fig. 20. Behavior of tiny-sync when the clocks are forced to change their relative clock drift
by sudden changes in the temperature of one of them (by temporary placing it in an ice-box).
During the cool-down and warm-up period, tiny-sync restarts several times. (a) the evolution of
the bound on the relative drift ∆a12 and the predicted evolution (23); (b) the evolution of the
bounds on the drift.
−4
x 10
1.5
1 Avg(abs(sync. error)):1.0788e−005
0.5
Synchronization Error (s)
−0.5
−1
Node 2 Node 2 Node 2
outside the ice−box inside the ice−box outside the ice−box
−1.5
synchronization error
moving average of synchronization error in magnitude
−2
0 2000 4000 6000 8000 10000 12000 14000 16000
Time (s)
Fig. 21. The synchronization error when nodes were subjected to variation of the relative drift.
−3
10
4 sec
8 sec
16 sec
32 sec
64 sec
128 sec
−5
10
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
Synchronization Packet Loss Rate (round trip)
−5
x 10
2
Tiny−sync(sync_interval=4)
Tiny−sync(sync_interval=128)
1.9 Mini−sync(sync_interval=4)
Mini−sync(sync_interval=128)
Average Synchronization Error (s)
1.8
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1 1.5 2 2.5 3 3.5 4
Hops
Fig. 23. Synchronization error of tiny-sync and mini-sync as a function of the number of hops.
−5
x 10
3
Tiny−sync(1 hop)
Tiny−sync(4 hops)
2.8 Mini−sync(1 hop)
Mini−sync(4 hops)
2.6
2.2
1.8
1.6
1.4
1.2
1 2
10 10
Synchronization Interval (s)
Fig. 24. Synchronization error of tiny-sync and mini-sync as a function of the synchronization
interval.
close to the accuracy of FTSP (tiny-sync is slightly better). It is likely that both
approaches reached the lower bound of achievable accuracy on the Mica2 platform
(due to non-deterministic delays, most likely introduced by the transceiver and/or
clock inaccuracies).
Figure 25 shows the pair-wise synchronization errors for tiny-sync using Telos and
Mica2 motes. In this experiment, we varied the synchronization interval from 4 s to
1024 s. When the synchronization interval is short, the synchronization error on the
Mica2 platform is better than that on Telos due to the clock resolution on the Mica2
platform; however, the external crystal clock of the Telos platform is more stable
than the internal clock of Mica2 in the long run. Thus, for short synchronization
intervals, the synchronization errors on Mica2 are smaller than on the Telos motes;
however, the situation is reversed when the synchronization interval is longer than
128 s.
2
10
−4
x 10
1.5
1 Avg(abs(sync. error)):1.8555e−005
0.5
Synchronization Error (s)
−0.5
−1
−1.5
−2
−2.5
synchronization error
moving average of synchronization error in magnitude
−3
0 1000 2000 3000 4000 5000 6000 7000 8000
Time (s)
5. ACKNOWLEDGMENTS
We would like to sincerely thank the anonymous reviewers. Their comments truly
improved this paper from more than one standpoint. We also thank NSF and the
Center for Advanced Computing and Communication at NCSU for funding this
work.
6. CONCLUSION
In this paper, we proposed and evaluated the performance of two simple time
synchronization algorithms suitable for wireless sensor networks. The algorithms
perform pair-wise synchronization and can be used as the basic building block for
synchronizing an entire network. While the performance of the two algorithms may
ACM Journal Name, Vol. V, No. N, Month 20YY.
Tiny-Sync: Tight Time Synchronization for Wireless Sensor Networks · 29
−4
x 10
1.5
1 Avg(abs(sync. error)):1.4249e−005
0.5
−0.5
−1
−1.5
−2
−2.5
synchronization error
moving average of synchronization error in magnitude
−3
0 1000 2000 3000 4000 5000 6000 7000
Time (s)
Fig. 27. Synchronization errors of tiny-sync when the best two out of the first ten data-points are
used to initialize the algorithm.
vary in theory, in practice, they yield very similar results. Thus, the simplest one,
tiny-sync, is likely to be practically implemented. The main advantage of tiny-
sync is its simplicity and parsimonious resources requirements. Other advantages
include robustness to large variations in clock drift and its ability to achieve fast
synchronization of an entire network. Experimental results show that it performs
as well or better than existing time synchronization approaches for wireless sensor
networks.
REFERENCES
Akyildiz, I., Su, W., Sankarasubramaniam, Y., and Cayirci, E. 2002a. A survey on sensor
networks. IEEE Communication Magazine 40, 8 (Aug.), 102–116.
Akyildiz, I., Su, W., Sankarasubramaniam, Y., and Cayirci, E. 2002b. Wireless sensor net-
works: A survey. IEEE Computer 38, 4 (Mar.), 393–422.
Asada, G., Dong, T., Lin, F., Pottie, G., Kaiser, W., and Marcy, H. 1998. Wireless integrated
network sensors: Low power systems on a chip. In Proc. of the 24th European Solid-State
Circuits Conference. The Hague, Netherlands.
Cristian, F. 1989. Probabilistic clock synchronization. Distributed Computing 3, 3, 146–158.
Crossbow. Mica2 wireless measurement system. http://www.xbow.com/Products/productsdetails.aspx?sid=72.
Dai, H. and Han, R. 2004. Tsync: a lightweight bidirectional time synchronization service for
wireless sensor networks. ACM SIGMOBILE Mobile Computing and Communications Re-
view 8, 1, 125–139.
Elson, J. and Estrin, D. 2001. Time synchronization for wireless sensor networks. In Proc.
of the 2001 International Parallel and Distributed Processing Symposium (IPDPS), Workshop
on Parallel and Distributed Computing Issues in Wireless Networks and Mobile Computing.
San Francisco, CA.
Elson, J., Girod, L., and Estrin, D. 2002. Fine-grained network time synchronization using
reference broadcasts. In UCLA Technical Report 020008.
Ganeriwal, S., Kumar, R., and Srivastava, M. B. 2003. Timing-sync protocol for sensor
networks. In Proc. of the First ACM Conference on Embedded Networked Sensor System
(SenSys). 138–149.
ACM Journal Name, Vol. V, No. N, Month 20YY.
30 · Suyoung Yoon, Chanchai Veerarittiphan and Mihail L. Sichitiu
Girod, L. D. 2005. A self-calibrating system of distributed acoustic arrays. Ph.D. thesis, Uni-
versity of California Los Angeles.
Greunen, J. V. and Rabaey, J. 2003. Lightweight time synchronization for sensor networks. In
WSNA’03.
Hill, J., Szewczyk, R., Woo, A., Hollar, S., Culler, D. E., and Pister, K. S. J. 2000.
System architecture directions for networked sensors. In Architectural Support for Programming
Languages and Operating Systems. 93–104.
Hofmann-Wellenhof, B., Lichtenegger, H., and Collins, J. 1997. Global Positioning System:
Theory and Practice, 4th ed. Springer-Verlag.
Karp, R., Elson, J., Estrin, D., and Shenker, S. 2003. Optimal and global time synchronization
in sensornets. Tech. Rep. 0012, CENS.
Lemmon, M., Ganguly, J., and Xia, L. 2000. Model-based clock synchronization in networks
with drifting clocks. In Proc. of the 2000 Pacific Rim International Symposium on Dependable
Computing. Los Angeles, CA, 177–185.
Li, Q. and Rus, D. 2004. Global clock synchronization in sensor network. In INFOCOM.
Lu, G., Sadagopan, N., Krishnamachari, B., and Goel, A. 2005. Delay efficient sleep schedul-
ing in wireless sensor networks. In Proc. of Infocom 2005.
Maróti, M., Kusy, B., Simon, G., and Lédeczi, A. 2004. The flooding time synchronization pro-
tocol. In SenSys ’04: Proceedings of the 2nd international conference on Embedded networked
sensor systems. ACM Press, 39–49.
Maróti, M., Kusy, B., Simon, G., and Lédeczi, A. 2005. Implementation of flooding
time synchronization protocol. http://cvs.sourceforge.net/viewcvs.py/tinyos/tinyos-1.
x/contrib/vu/.
Meier, L., Blum, P., and Thiele, L. 2004. Internal synchronization of drift-constraint clocks in
ad-hoc sensor networks. In MobiHoc.
Mills, D. L. 1991. Internet time synchronization: the network time protocol. IEEE Trans.
Communications 39, 10 (Oct.), 1482–1493.
Mills, D. L. 1994. Improved algorithms for synchronizing computer network clocks. In Proc. of
ACM Conference on Communication Architectures (ACM SIGCOMM’94). London, UK.
PalChaudhuri, S., Saha, A., and Johnson, D. B. 2004. Adaptive clock synchronization in sensor
networks. In ISPN ’04: Proceeding of The Third International Symposium on Information
Processing in Sensor Networks. 340–348.
Ping, S. 2003. Delay measurement time synchronization for wireless sensor networks. In Intel
Research, IRB-TR-03-013.
Polastre, J., Szewczyk, R., and Culler, D. 2005. Telos: Enabling ultra-low power wireless
research. In In Proceedings of IPSN/SPOTS. Los Angeles, CA.
Römer, K. 2001. Time synchronization in ad hoc networks. In Proc. of ACM Mobihoc. Long
Beach, CA.
Simon, G., Maróti, M., Lédeczi, A., Balogh, G., Kusy, B., Nádas, A., Pap, G., Sallai, J., and
Frampton, K. 2004. Sensor network-based countersniper system. In SenSys ’04: Proceedings
of the 2nd international conference on Embedded networked sensor systems. ACM Press.
Sivrikaya, F. and Yener, B. 2004. Time synchronization in sensor networks: A survey. IEEE
Network 18, 45–50.
Su, W. and Akyildiz, I. F. 2005. Time-diffusion synchronization protocol for wireless sensor
networks. IEEE/ACM Transactions on Networking 13, 384–397.
Sundararaman, B., Buy, U., and Kshemkalyani, A. D. 2005. Clock synchronization in wireless
sensor networks: A survey. Ad-Hoc Networks 3, 281–323.
Xu, N., Rangwala, S., Chintalapudi, K. K., Ganesan, D., Broad, A., Govindan, R., and
Estrin, D. 2004. A wireless sensor network for structural monitoring. In SenSys ’04: Proceed-
ings of the 2nd international conference on Embedded networked sensor systems. ACM Press,
13–24.
ACM Journal Name, Vol. V, No. N, Month 20YY.
Tiny-Sync: Tight Time Synchronization for Wireless Sensor Networks · 31
A. PROOF OF THEOREM 1
In this section we provide the proof for Theorem 1. Let us denote with (A, B)
the line determined by the points A and B and with m(A, B) the slope of the line
(A, B). We start by proving the following lemma:
y
k Ak
C
y0
yj
Aj
yi Ai
xi xj xk x
Proof Denote with y0 the y-coordinate of point C where the vertical line from
Aj intersects the line (Ai , Ak ):
(yk − yi )xj + yi xk − yk xi
y0 = . (51)
xk − xi
The expression “Aj is below the line (Ai , Ak )” is shorthand for yj < y0 . With
this notation, if and only if yj < y0 , then
yj − yi y0 − yi yk − y0 yk − yj
m(Ai , Aj ) = < = m(Ai , Ak ) = < = m(Aj , Ak ),
xj − xi xj − xi xk − xj xk − xj
(52)
which is (49). By a similar argument it can be shown that (50) holds if and only if
y j > y0 .
Theorem 1 Any constraint Aj which satisfies
m(Ai , Aj ) ≤ m(Aj , Ak ) (53)
ACM Journal Name, Vol. V, No. N, Month 20YY.
32 · Suyoung Yoon, Chanchai Veerarittiphan and Mihail L. Sichitiu
for at least one set of integers 1 ≤ i < j < k can be safely discarded as it will never
constrain the bounds a12 , a12 , b12 and b12 more than any existing constraints.
t1
Bx2
Bx1
Ak
Aj
Ai
t2
Fig. 29. Aj can be safely discarded as Ai or Ak will result in better estimates in all cases.
Proof
Consider the situation depicted in Fig. 29. The constraints Ai , Aj and Ak
satisfy condition (53). Consider a constraint Bx of coordinates (t2x , t1x ) such that
t1x > t1k and t2x > t2k . Constraint Bx and one of the constraints Ai , Aj or Ak
may determine the upper bound a12 ). Denote with a12 (Ay , Bx ) the upper bound
on a12 determined by the constraints Ay and Bx . We can distinguish two cases:
1. When Bx is below the line (Ai , Ak ) (e.g., position Bx1 in Fig. 29). In this
case, because both Aj and Bx1 are under the line (Ai , Ak ), Ak is above the line
(Aj , Bx1 ). From lemma 2 it follows that
m(Ak , Bx1 ) < m(Aj , Bx1 ), (54)
which is equivalent with
a12 (Ak , Bx1 ) < a12 (Aj , Bx1 ). (55)
Thus, the constraint (Ak , Bx ) is tighter than the constraint (Aj , Bx ) for the case
when Bx is below the line (Ai , Ak ).
2. When Bx is above the line (Ai , Ak ) (position Bx2 in Fig. 29). In this case, by a
similar logic, it can be shown that
a12 (Ai , Bx2 ) < a12 (Aj , Bx2 ), (56)
i.e., the constraint (Ai , Bx ) is tighter than the constraint (Aj , Bx ) for the case
when Bx is above the line (Ai , Ak )
ACM Journal Name, Vol. V, No. N, Month 20YY.
Tiny-Sync: Tight Time Synchronization for Wireless Sensor Networks · 33
Thus, in both cases, one of the upper bounds a12 (Ai , Bx2 ) or a12 (Ak , Bx1 ) is
tighter than the upper bound introduced by Aj , a12 (Aj , Bx ), showing that con-
straint Aj will always results in a looser upper bound than Ai or Ak , and, thus,
enabling its disposal without any possible reduction in optimality of the solution.