Professional Documents
Culture Documents
Clock Synchronization
Professor Jack Stankovic
University of Virginia
Or Use GPS!
Power hungry
Expensive per node
Outline
NTP (Network Time Protocol) for
Internet
RBS (Reference Broadcast Sync)
TPSN (Time-sync Protocol for Sensor
Networks)
FTSP (Flooding Time Sync Protocol)
Drift
Sync clocks
Handle clock drift (up to 40 microsec per
second on Mica platform; 7.37 MHz clock)
Solution: Re-sync (expensive)
Solution: Estimate clock drift and compensate
Resync infrequently
NTP
Network Time Protocol (NTP) on Internet
Included in OS code
Simple NTP (SNTP) exists for PCs
Runs as background process
Get time from best servers
NTP
Not (directly) usable for WSN
Ideal
Read
Clock
Propagates
Set
Clock
Real
Clock
Real
Clock
All Zero Costs/Delays
Read
Clock
What if Deterministic
Delays
.01
Propagates
Real
Clock
Set
Clock
5
5.21
5
.1
.1
5
5.21
Real
Clock
RBS
Reference message is broadcast
Receivers record their local time when message is
received
Timestamps are ONLY on the receiver side
This eliminates access and send times
RBS
Local Time
5
Exchange
6,7
Adjust
Plus 2
Send MSG
No Clock
Propagation Time = 0
5,7
Plus 1
5,6
OK
TPSN
Creates a spanning tree
Perform pairwise sync along edges of
the tree
Must be symmetric links
Recall radio irregularity paper
Synchronization Phase
Delta = clock drift
P = propagation delay
T2
Node B
(T1)
Node A
T1
P = ((T2-T1)+(T4-T3))/2
T2=T1+P+Delta
T3
(T1,T2,T3)
T4
Delta = ((T2-T1)-(T4-T3))/2
Example
5.3
Node B
Node A
T2=5.35
.05
T3=6.0
.05
5.05
T1= 5.0
P = ((T2-T1)+(T4-T3))/2
P= ((5.35-5.0)+(5.75-6))/2
P=((.35)+(-.25))/2
P= .1/2=.05
5.7 T4=5.75
Delta = ((T2-T1)-(T4-T3))/2
Delta= ((.35)-(-.25))/2
Delta= 0.6/2 =.3
TPSN
No broadcasting so TPSN is expensive
Timestamp the message in the MAC
layer multiple times and average those
times (improves accuracy over RBS by 2
times)
(16.9 microsec accuracy for 1 hop)
No clock drift corrections
TPSN
Assumes topology does not change
Not robust to failure of a node
Node fails must redo the spanning tree
Remove Uncertainties
Eliminate Send Uncertainty
Get time in the MAC layer
Remaining
(Mostly) Deterministic Times
Transmit
Propagation
Reception
Basic Idea
When to time stamp the message
Ready
Get timestamp
sender Mica2 uncertainties:
Interrupt:5us, 30us(<2%)
Encode+decode:110us -112us
Byte align: 0us 365us
Propagation: 1us
receiver
Set timestamp
Basic Idea
When to time stamp the message
Radio layer, after the second SYN sent out,
6 timestamps in row, take the average and
send only 1 timestamp
FTSP
Root maintains global time for system
All others sync to the root
Nodes form an ad hoc structure rather
than a spanning tree
Root broadcasts a timestamp for the
transmission time of a certain byte
Every receiver time stamps reception
of that byte
Account for deterministic times
Differences are the clock offsets
Summary of FTSP
So Far
(Below) MAC-layer timestamp
Correct sender timestamp to account
for known delays
Compute final offset error
Clock Drift
If local clocks all had exact same
frequency then no clock drift
corrections are needed and no re-syncs
needed either
MICA2 motes
Crystals used have drifts of up to 40
microseconds per second
Implication: resync every sec to maintain
40 microsec accuracy
Too costly - estimate clock drift and fix!
Basic Idea
8 entry linear regression table to
estimate clock skew (each entry derived from
1 clock sync protocol execution)
Example
10 seconds
1 sec
1
2
3
4
5
6
7
8
5 us offset
5 us offset
7 us offset
4 us offset
4 us offset
5 us offset
7 us offset
5 us offset
5 us over
Say a 10 sec
Resync period
Compensate .5 us
Each sec
Performance
Single hop, stop sync after 33 minutes
(where sync was run every 30 secs)
Root/Reference Point
Root/Reference Point
Step 1
Step 2
8 sync msgs
to perform
Linear regression
How to handle
messages from
multiple nodes
Processing Redundant
Messages
Place only first neighbor message for
each sequence number in linear
regression table
Other redundant messages (with same
sequence number) are ignored
Once 8 messages are obtained then can
perform linear regression
Note: the 8 messages may come from
different neighbors
Performance/Example
Multiple-hop, sync every 30 seconds
A) at 0:00 all motes were turned on;
ID2
Questions
How long does it take to clock sync the
entire system (of say 1000, or 10,000
nodes)?
60 nodes: 10 minutes to elect leader; 14
minutes for sync
Collisions
Questions
What if some nodes do not have
synchronized clocks?
Lost messages
Down nodes (and come back)
Summary
Very accurate clock sync is possible (in
microsec range)
Time to perform clock sync is important
Initial delay at system init time may be
important
Consider a system of 10,000 nodes
Multiple base stations issues
Summary
Consider costs
Energy
Congestion
Time