CS410/510SensorNetworksWinter2009
PortlandStateUniversity
Lecture7TimeSynchronization
Acknowledgements
• UCLACenterforEmbeddedNetworkedSensing(UCLACENS)
• JeremyElson,DeborahEstrin,SaurabhGaneriwal,ManiSrivastava
2/2/09
TimeSynchronization• Timesynciscriticalatmanylayers
2/2/09
TimeSynchronization• Timesynchronizationiscriticalatmanylayers
– Beam‐forming,localization,distributedDSP
2/2/09
TimeSynchronization• Timesynchronizationiscriticalatmanylayers
– Beam‐forming,localization,distributedDSP
– Dataaggregation&caching
2/2/09
t=0 t=1
t=2
t=3
TimeSynchronization• Timesynchronizationiscriticalatmanylayers
– Beam‐forming,localization,distributedDSP
– Dataaggregation&caching– TDMAguardbands
2/2/09
Radio Off
Radio On
Time
Sender
Radio Off Receiver
Guard band due to clock skew; receiver can’t predict exactly when packet will arrive
TimeSynchronization• Timesynchronizationiscriticalatmanylayers
– Beam‐forming,localization,distributedDSP
– Dataaggregation&caching– TDMAguardbands
– ClocksyncforTDMAismoreimportantinsensornets,comparedtotraditionalnets:
– ListeningisEXPENSIVE– Infrequentdatameansinfrequentsync
– Smalldatameansguardbandisrelativelybig
2/2/09
TimeSynchronization• Timesynchronizationiscriticalatmanylayers
– Beam‐forming,localization,distributedDSP
– Dataaggregation&caching– TDMAguardbands
– “Traditional”uses(debugging,userinteraction,certaincryptoalgorithms,databaseconsistency,etc.)
2/2/09
TimeSynchronization• Timesynchronizationiscriticalatmanylayers
– Beam‐forming,localization,distributedDSP
– Dataaggregation&caching– TDMAguardbands
– “Traditional”uses(debugging,userinteraction…)• Buttimesyncneedsarenon‐uniform
– MaximumError
– Lifetime
– Scope&Availability– Efficiency(useofpowerandtime)
– Costandformfactor
2/2/09
RelatedWork
• Clocksyncovercomputernetworks– Protocols:NTP,Berkeley,Cristian’sprobabilisticalg
• Stablefrequencystandards– Cesium,Rubidium,temperature‐controlled…
• Nationaltimestandards– USNO’stime,UTC/TAI– Two‐waysatellitetimetransfer,GPS
• Virtualclocks(Lamport)2/2/09
LimitationsofTraditionalApproaches
• Energy– e.g.,wecan’talwaysbelisteningorusingCPU!
• Widerangeofrequirementswithinasingleapp;nomethodoptimalonallaxes
• Costandformfactor:candisposablemoteshaveGPSreceivers,expensiveoscillators?Completelychangestheeconomics…
2/2/09
TraditionalSynchronization
2/2/09
Sender Receiver
At the tone: t=1
NIC
Physical Media
NIC
Send time
Access Time
Propagation Time
Receive Time
Problem: Many sources of unknown, nondeterministic latency between timestamp and its reception
Sender‐ReceiverSynchronization(asinNTP)
2/2/09
Recv at T2
Send at T3
A
Send at T1
Recv at T4
B
TIME
SynchronizingNeighboringNodes
2/2/09
A
Send at T3 Recv at T4
T4 = T3 + DELAY- OFFSET
Send at T1 Recv at T2
T2 = T1 + DELAY + OFFSET
B
OFFSET = {(T2-T1)-(T4-T3)}/2
DELAY = {(T2-T1)+(T4-T3)}/2
VariabilityinPacketDelay
2/2/09
software MAC propagation TX RX software
sender receiver
ALL DELAYS ARE VARIABLE !
Sender uncertainty Propagation
uncertainty Receiver
uncertainty
Variabilityinclockoffset
2/2/09
t4 Real Time
Ideal clock
Node B clock
Node A clock
t1
Local node time
Relative drift
NewApproach• Usemultiplemodes
– Extendexistingsynchronizationmethods– Developnewmethods,andcompositionsofmethods– Characterizethesemethods
• Usetieredarchitectures– Notasinglehardwareplatformbutarangeofhardware– Analogy:memoryhierarchy
• Thesetasawholecanbenecessaryandsufficient,tominimizeresourcewaste– Don’tspendenergytogetbettersynchronizationthanapplicationneeds
2/2/09
NewSynchronizationMethods• Reference‐broadcastsynchronization:Veryhighprecisionsyncwithslowradios– Beaconsaretransmitted,usingphysical‐layerbroadcast,toasetofreceivers
– Timesyncisbasedonthedifferencebetweenreceptiontimes;don’tsyncsenderw/receiver!
• Post‐factosynchronization:Don’twasteenergyonsyncwhenitisnotneeded– Asetofreceiverswaitsforanevent– Locallytimestampaneventwhenithappens
– Afterthefact,reconcileclocks2/2/09
ReferenceBroadcastSynchronization
2/2/09
Sender Receiver
NIC
Physical Media
NIC
Propagation Time
Receive Time
Synchronize 2 receivers with each other, NOT sender with receiver
Receiver
NIC I saw it at t=4 I saw it
at t=5
2/2/09
NIC Sender
Receiver
Critical Path
NIC Sender
Receiver 1
Receiver 2
Critical Path Time
RBS reduces error by removing much of it from the critical path
Traditional critical path: From the time the sender
reads its clock, to when the receiver reads its clock
RBS: Only sensitive to the differences in receive time
and propagation delay
ReceiverDeterminism
2/2/09
Testbed: Berkeley motes with narrowband (19.2K) radios
Gaussian=good!
• Wellbehaveddistributionsareuseful– Errorcanbereducedstatistically,bysendingmultiplepulsesovertimeandaveraging
– Also,easiertomodel/simulate
• Problem:Clockskew– Ittakestimetosendmultiplepulses– Bythetimewedo,clockswillhavedrifted– Solution:don’taverage;fitalineinstead!
2/2/09
2/2/09 Time
RBSAdvantages
• 11usecprecisionover19.2Kradios:wow!• localorrelativetime:“peertopeersync”
– allowsseamlessexchangeofmessagesaboutthelocalarea;noerrorduetothemastersyncserverbeingfaraway
– (NTPallowssyncwithoutanexternalref.,butsomenodestillneedstobedefinedas“time”)
• Gracefulhandlingoflostpackets,outliers
2/2/09
Post‐factoSynchronization
• Traditionalprotocolskeepclockssynchronizedallthetime;thisisexpensive!(CPU,radio)
• Solution:timestampaneventwithyourlocalclock;synchronizeafterwards
• Bigwinifappneedssynchronizedtimeoccasionallyandunpredictably– Youcanneverpredictthefutureaswellasyoucanpredictthepast
2/2/09
Canpost‐factowork?
2/2/09
Test pulses
Sync pulses
Drift Estimate
7usec error after 60 seconds of silence
Multi‐hopRBS• SomenodesbroadcastRFsynchronizationpulses
• Receiversinaneighborhoodaresyncedbyusingthepulseasatimereference.(Thepulsesendersarenotsynced.)
• Nodesthathearbothcanrelatethetimebasestoeachother
2/2/09
“Here 0 sec after red pulse!”
“Here 1 sec after red pulse!”
“Here 3 sec after blue pulse!”
“Here 1 sec after blue pulse!”
“Blue pulse 2 sec after red pulse!”
TimeRouting
2/2/09
1
3
2
A 4
8
C
5
7
6 B
10
D 11
9
1
3
2
4
8
5
7
6
10 11
9
Summary• Timesynchronizationiscriticalforsensornetworks
• Existingsolutionsareinadequate:– Insufficientprecision– Wastefulofenergy
• NewIdeas– Leveragethebroadcastchannel– Uselocaltimescales– Synchronizeaftertheevent
• Newfield=newproblems=newsolutions!
2/2/09
Timing‐syncProtocolforSensorNetworks(TPSN)
SaurabhGaneriwal,RamKumar,ManiB.Srivastava
S‐Rv/sR‐R
2/2/09
A B
S – R
A
A A
B
B B
R – R
Sources of error – variation in packet delays and clock drift Complexity – Two packet exchanges
Beacon
Errorcomparison
2/2/09
R-R: eliminates impact of sender side jitters S-R: reduces by 2x the impact of propagation and receiver
side jitters, and variations in clock drift.
So use R-R when sender side jitters are huge. Typical Wavelan networks.
Whataboutsensornetworks?
2/2/09
Wavelan Networks -> MAC delay becomes the bottleneck.
Strong coupling exist between application layer and MAC layer.
Key to the solution Time stamp the packets below MAC layer.
As a result: Sender uncertainty is neglgible. S-R schemes should give roughly 2x better performance than R-R.
Implementationonmotes• EnabletimestampingbelowMAClayer
• Experimentalsetup Motesstartrandomly
Theyperiodicallytogglinganoutputpintogenerateasquarewaveform.
2/2/09
BEFORE SYNCHRONIZATION AFTER SYNCHRONIZATION
ComparisonwithR‐R
2/2/09
RBS uses R-R synchronization to synchronize a pair of nodes.
Implemented RBS in the exactly the same simulation set up.
MAC layer time stamping is enabled for both TPSN and RBS.
Resultsonasinglehop
2/2/09
Average Error (in microseconds)
All results have been obtained via 100 independent experimental runs.
Only consider the magnitude of synchronization error.
Histogramoferror(MICA1)
2/2/09
TPSN RBS TPSN gives a 2x better performance than RBS
Error (microseconds) Error (microseconds)
Perc
enta
ge
Perc
enta
ge
AuxiliarybenefitofTPSN
2/2/09
Ad-hoc Localization
Step 1 -> Do a instant synchronization between neighboring nodes.
Step 2 -> Transmit the ultra sound signal.
Accuracy -> Average case (0.28 cm), Worst case (1.38 cm)
Periodicsynchronization?
2/2/09
Mote clocks continuously drift apart
Given : Worst case accuracy requirement -> 10ms Known: Worst case error -> 50 µs, Relative drift -> 5 µs/s. Period of TPSN can be calculated -> around 33 minutes
Worst case relative drift 4.75 microseconds/s
Time (seconds)
Err
or
Multipleobservations!
2/2/09
Results so far were presented for a single observation.
Better results can be obtained by averaging over multiple observations. Do a curve fitting offline to
estimate the relative drift between nodes.
Of the order of 1-3 microseconds attainable !
Asymptotically the error will go to
APIonMICA2
2/2/09
Timer3 SPI
Protocol Stack
SClockC
TPSNsyncC
CC1000 Radio
Data Interface Prog. Interface
HPL-SPI HPL-Timer3
TimeStamp SClock
TPSNsync
Application uint16_t getTime();
void periodicSync(uint16_t period);
result_t instantSync();
void setTimer(uint16_t interval, uint8_t attribute);
result_t setAlarm(uint16_t alarm);
Multihopondemandsynchronization
2/2/09
Synchronize after an event has been detected Needed by light weight applications.
Data packet
TPSN time synchronization packets
MultihopresultsonMICA1
2/2/09
Experiments done on a 5 hop network of MICA1 motes
Theoretically error increases with hop distance. Observed a dip beyond 3 hop distance. Randomness of drift and sign of error helps.
Mic
rose
cond
s
Networkwidetimesynchronization
2/2/09
Objective is to create a unique global timescale for all the sensor nodes in the network. Always-on model.
Create a self configuring system similar to NTP. Set up a multi level hierarchy such that each node acts as both
the client and the server.
Works in two phases Level Discovery phase -> Create a hierarchical topology Synchronization phase -> Every node synchronizes to a node
belonging to a node in one level above.
Needed for coordinated actuation
LevelDiscoveryPhase
2/2/09
Use simple flooding Root node initiates the phase Assign a level one higher than
the lowest level you received.
Incorporates addition of new nodes New nodes explicitly broadcast
a level request message.
Not an exclusive overhead of TPSN !
Synchronizationphase
2/2/09
Node synchronize to a node belonging to one upper level Use pair wise synchronization. Needs symmetric links!
Incorporates dying of existing nodes Child node times out and seek
for another level.
Simulationtesting
2/2/09
Simulation set up NESLsim – PARSEC based platform Extremely dense networks -> Average number of neighbors go
from 20 to 40.
Intent is to see the scaling properties!
Close to reality ? We explicitly model the clock drifts. No software jitters ! Error is just due to variability in clock offsets.
Whatwillhappeninfixed‐areanetworks?
2/2/09
Overhead Energy expenditure
per node remains a constant
Error Just increases by
10% even after doubling the total number of nodes.
Number of nodes
Tim
e ta
ken
Whatwillhappeninexpandingnetworks?
2/2/09
Error increases as distance from root node increases
Optimal results will be obtained if we instead establish a minimum spanning tree structure Energy v/s
Accuracy tradeoff
Position of root node
X coordinate Y coordinate
Summary:TPSN
2/2/09
TPSN uses the classical approach of sender-receiver synchronization in sensor networks. It performs 2x better than RBS (receiver-receiver synchronization) Verified this via analysis as well as real time experiments.
Synchronizes a pair of MICA2 motes to an average accuracy of 8 µs. Better accuracy can be obtained via multiple observations.
Available modes of TPSN API on motes. Instant synchronization between a pair of nodes. On-demand multihop synchronization. Periodic network-wide synchronization.
Can be tuned to meet the meet the desired levels of accuracy and energy overhead.
Long‐termTimeSynchronization
• Complexrelationshipsbetween– samplingrate
– windowofpastsamples
– estimationscheme.
• Optimaltimewindowofhistoricalsynchronizationdatathatprovidesbestestimationanderrorprediction.
• Complementshort‐termtimesynchronizationwithlong‐termtimesynchronization!
2/2/09
Top Related