Time Synchronization

Download Report

Transcript Time Synchronization

CPSC 689: Discrete Algorithms
for Mobile and Wireless Systems
Spring 2009
Prof. Jennifer Welch
Lecture 6
 Topics:
 Time Synchronization
 Sources:
 Elson et al. paper
 Karp et al. paper
 MIT 6.885 Fall 2008 slides
Discrete Algs for Mobile Wireless Sys
2
Clock Synchronization
 Nodes have individual clocks
 Synchronizing the time on the various clocks is
essential for many applications
 Coordination of wake-up and sleeping times (energy
efficiency)
 TDMA schedules
 Ordering of collected sensor data/events
 Co-operation of multiple sensor nodes (e.g. object
tracking)
 Estimation of position information
Discrete Algs for Mobile Wireless Sys
3
The Clock Synchronization Problem
 Every node has a local (hardware) clock
 Logical clock is some function of the
hardware clock
 add some computed value to hardware clock
 Goal: Compute local logical clocks to
 Compensate for offset or skew between
clocks: values are not the same
 Compensate for drift between clocks: rates are
not the same
Discrete Algs for Mobile Wireless Sys
4
Clock Synchronization Algorithm
 Distributed algorithm that computes logical
local clock for every node
 Logical clocks should be as close together
as possible
 Logical clocks should also run at
approximately the same rate as the
hardware clocks
 Don't keep them always synchronized to time 0
Discrete Algs for Mobile Wireless Sys
5
External vs. Internal Synchronization
External synchronization: Nodes
synchronize with an external clock source
 Ex: GPS
Internal synchronization: Nodes synchronize
to a common time within themselves
to a leader, to an averaged time, or to
anything else
Discrete Algs for Mobile Wireless Sys
6
Other Types of Clock Synchronization
One-shot versus periodic synchronization
 Periodic synchronization required to
compensate for clock drift
A-priori versus a-posteriori
 A-posteriori clock synchronization triggered by
an event
Local versus global synchronization
Discrete Algs for Mobile Wireless Sys
7
Clock Sources
Radio Clock Signal:
 Clock signal from a reference source
(atomic clock)
is transmitted over a longwave radio signal
 WWVB station in Colorado transmits at 60
kHz, can be received all over US
 Accuracy limited by the distance to the
sender
 Special antenna/receiver hardware
required
Discrete Algs for Mobile Wireless Sys
8
Clock Sources
Global Positioning System
(GPS):
 Satellites continuously transmit own
position and
time code
 Line of sight between satellite and
receiver required
 Special antenna/receiver hardware
required
 Accuracy: a few 100 ns
Discrete Algs for Mobile Wireless Sys
9
Clock Devices in Sensor Nodes
Structure
 External oscillator with a nominal frequency
(e.g. 32 kHz)
 Counter register which is incremented with
oscillator pulses
 Works also when CPU is in sleep stateOscillator
Discrete Algs for Mobile Wireless Sys
10
Clock Devices in Sensor Nodes
 Accuracy
Measured Time
 Clock drift: random deviation from the nominal rate
dependent on power supply, temperature, etc.
 E.g. TinyNodes have a maximum drift of 30-50 ppm at
room temp. temperature
Clock with
Drift
Perfect
Clock
Jittering
Clock
This is a drift of up
to 50 μs per second
or 0.18s per hour
Clock
with Offset
Actual Time
Discrete Algs for Mobile Wireless Sys
11
GPS?
 What if all nodes had a GPS receiver?
 High accuracy
 Nodes would even get position information for
free…
 Problems:
 GPS needs unobstructed access to satellite
(e.g., GPS does not work indoors)
 Too complex hardware, too expensive for
small, simple wireless (sensor) devices
Discrete Algs for Mobile Wireless Sys
12
Time Synchronization in the Internet with NTP







Several levels of time servers
Servers on same level coordinate among
themselves and with servers on adjacent
levels
Round-trip time used to get
estimate on latency
Heuristic method to best compute time
estimate based on different estimates
Jitter buffer to account for
variance in message delays
Clients connect to NTP server(s)
Accuracy at clients highly dependent
on symmetry of message delay
between client and server
(typical: 1 – 30 ms)
Discrete Algs for Mobile Wireless Sys
Figure: Wikipedia
13
Su, Akyildiz Time-Diffusion
 Practical paper, does not give theoretical
guarantees
 Uses similar ideas as NTP but adapted to
wireless scenario:





Multi-hop network (topology cannot be “chosen”)
Dynamic, possibly mobile network
Nodes might fail often
Energy constraints (e.g., need load balancing)
Should be a more symmetric protocol
Discrete Algs for Mobile Wireless Sys
14
Su, Akyildiz Time-Diffusion
 Two cases: With / without outside sources
of time.
 With: Outside sources tell the time to some
special “master” nodes, who diffuse it
through the network.
 Without: Master nodes broadcast their
timing info to their neighbors, who continue
the time diffusion.
Discrete Algs for Mobile Wireless Sys
15
Su, Akyildiz Time-Diffusion
 Load Balancing / Fault Tolerance:
 Master nodes are elected by random decisions
 Frequent reelection of master nodes
 Time information is propagated in an “ad-hoc”
way through the network
 Nodes adjacent to master/leader nodes may be
chosen as leader nodes to further diffuse the info
 Use statistical heuristics to compute time
estimates based on info of neighbors (cf. NTP)
 Also uses jitter buffers to compensate for varying
msg. delays
Discrete Algs for Mobile Wireless Sys
16
Sender/Receiver Synchronization
 Roundtrip-Based Synchronization
B
t2
R
e
q
u
e
s
t
f
r
o
m
A
A
t1
T
im
e
a
c
c
o
r
d
in
g
t
o
B
d1
t3
d2
T
im
e
a
c
c
o
r
d
in
g
t
o
A
A
n
s
w
e
r
f
r
o
m
B
t4
 Message delays: d1, d2 unknown to A and B
 Clock offset (B – A): t2 – (t1 + d1) = t3 – (t4 – d2)
 Average the two expressions and rearrange terms to get
(t2 – t1 + t3 – t4)/2 + (d2 – d1)/2
 Approximating it with (t2 – t1 + t3 – t4)/2 gives an estimate of B – A
whose error is half the difference in the delays
Discrete Algs for Mobile Wireless Sys
17
Influences on Packet Latency
–
–
–
–
–
Sending Time S
Medium Access Time A
Transmission Time T
Propagation Time PA,B
Reception Time R
S
A
(up to 100ms)
(up to 500ms)
(tens of ms, depending on size)
(s, depending on distance)
(up to 100ms)
T
Timestamp TA
PA,B
R
Critical path
Timestamp TB
• Asymmetric packet delays due to non-determinism
• Solution: timestamp packets at MAC layer
Discrete Algs for Mobile Wireless Sys
18
Reference Broadcast Synchronization (RBS)
[Elson,Girod,Estrin]
 Observation: sender side delay > receiver side delay
 Also much higher variability on sender side (needs to
wait for free channel)
 Exploit local broadcast nature of wireless
communication
 Each signal simultaneously received by many
nodes
 Synchronize between receivers of the same message
(instead of between sender and receiver)
 Large part of delay is the same for all receivers
Discrete Algs for Mobile Wireless Sys
19
Reference Broadcast Synchronization
• A sender synchronizes a set of receivers with one another
t2
• Point of reference: beacon’s arrival time
A
t2
t

S
A
P

R
1
S
S
S
,A
A
t
t

S
A
P

R
3
1
S
S
S
,B
B

t2
t
(
P

P
)
(
R

R
)
3
S
,A
S
,B
A
B
S
t1

B
t3
• Only sensitive to the difference in propagation and reception
time
• Time stamping at the interrupt time when a beacon is received
• After a beacon is sent, all receivers exchange their reception
times to calculate their clock offset
Discrete Algs for Mobile Wireless Sys
20
RBS Extensions
 Idea can be used to synchronize over many hops
 Synchronization can be improved by doing several
broadcasts.
 Clock Drift: Paper assumes that each local clock runs
at a fixed rate (rates of different clocks can be different)
 Uses least-squares linear regression to cope with clock
drift
 Experiments of Elson et al. indicate that the variation in
receive time roughly follows a Gaussian distribution
Discrete Algs for Mobile Wireless Sys
21
RBS: Discussion
 RBS gives method to synchronize between two receivers
of the same message
 Synchronization by nodes without common neighbor done
by considering path of receiver-pairs  Skew proportional
to length of path
 Method does not give globally consistent estimates of pairwise clock offsets
 Lj(t)  Li(t)*ai,j + bi,j and Lk(t)  Lj(t)*aj,k + bj,k and
Lk(t)  Li(t)*ai,k + bi,k but
ai,j*aj,k ≠ ai,k and bi,j*aj,k + bj,k ≠ bi,k
 Pairwise synchronizations are not optimally precise (do not
have minimal variance from the truth)
Discrete Algs for Mobile Wireless Sys
22
Global Synchronization of Sensornets
[Karp, Elson,Papadimitriou,Shenker]
 Tries to exploit full potential of reference broadcasts, ensure
globally consistent pairwise translations and optimal precision
 Model:
 No clock drift (only clock offsets)
 Given: set of receiver-broadcast pairs (ri, sk)
(ri: receiver node, sk: signal)
 Offset of clock of node ri: Ti (offset w.r.t. universal time)
 Signal sk sent at real time Uk, received by ri at clock time
yi,k = Uk + Ti + ei,k
 The ei,k are independent random variables with zero mean and
variance Vi,k
 Goal: Find best globally consistent estimate of offsets Ti
Discrete Algs for Mobile Wireless Sys
23
Two Problems
 To find the optimal (minimum-variance) pairwise
synchronization between nodes i and j, find the
minimum-variance estimate of Tj – Ti.
 Can be posed as a flow problem
 To produce a globally consistent synchronization,
esimate all the Ti's independently and find a
maximum likelihood joint choice of all the Ti's.
 Can be reduced to a linear system of least-squares
equations
 These two problems have the same solution!
Discrete Algs for Mobile Wireless Sys
24
Minimum Variance Pairwise
Synchronization
 Goal: Estimate T1 – T2.
 Use differences in receive times of signals
 Consider signal sk received by r1 and r2.
 Estimate T1 – T2 with
y1,k – y2,k = (T1 – T2) + (e1,k – e2,k)
r1
sk
r2
Discrete Algs for Mobile Wireless Sys
25
Minimum Variance Pairwise
Synchronization
 Consider signal sk1 received by r1 and ri,
and signal sk2 received by ri and r2.
 Since T1 – T2 = (T1 – Ti) + (Ti – T2), estimate
T1 – T2 with
y1,k1 – yi,k1+ yi,k2 – y2,k2 =
(T1 – T2) + (e1,k1 – e2,k1) + (ei,k2 – e2,k2)
r1
sk1
ri
sk2
Discrete Algs for Mobile Wireless Sys
r2
26
Minimum Variance Pairwise
Synchronization
 Similarly, if you have an arbitrary length chain of alternating
receivers and signals, the error is the expression given at
top of p. 5 of paper.
 Since each ei,k has zero mean, this estimator is unbiased.
 By considering all possible paths between a pair of
receivers, and weighting them appropriately, we get an
estimator with much lower variance than any single path
can provide.
 This approach is pursued using flow theory on a
corresponding resistor network
 Show that the minimum variance estimators for pairs are
globally consistent.
Discrete Algs for Mobile Wireless Sys
27
Maximum Likelihood Offset
Assignment
 Find the maximally likely set of offset assignments Ti
 Will be globally consistent, but why should they be minimum
variance?
 Assume yi,k's (local clock time when ri receives signal sk)
are independent Gaussian random variables with mean Uk
+ Ti and variance Vi,k
 Show the joint probability density of the yi,k's is an
expression involving the Uk's and Ti's
 Derive a system of linear equations for the Ti's that
maximize this joint probability density
 Show that a solution to the linear system is obtained when
Ti is set equal to the value from the resistor network
formulation
Discrete Algs for Mobile Wireless Sys
28
Computing the Estimators
 Set up and solve system of linear
equations for quantities in the resistive
network corresponding to the minimum
variance estimators
OR
 Use a new approximation algorithm based
on minimum-cost flow presented in the
paper
Discrete Algs for Mobile Wireless Sys
29
Use in Practice?
 Estimator for two nodes at distance L in infinite
grid has variance O(log L), exponential
improvement over RBS, which uses only one path
and thus has variance O(L)
 An efficient PTAS for computing the effective
resistance is given by the paper.
 Not clear whether this can be made distributed
 Cost seems to be rather high
Discrete Algs for Mobile Wireless Sys
30