CPSC 689: Discrete Algorithms for Mobile and Wireless Systems

25
CPSC 689: Discrete Algorithms for Mobile and Wireless Systems Spring 2009 Prof. Jennifer Welch

description

CPSC 689: Discrete Algorithms for Mobile and Wireless Systems. Spring 2009 Prof. Jennifer Welch. Lecture 8. Topics: Time Synchronization Lower Bounds Sources: Fan, Chakraborty & Lynch paper Fan & Lynch paper Lenzen, Locher & Wattenhofer paper MIT 6.885 Fall 2008 slides. - PowerPoint PPT Presentation

Transcript of CPSC 689: Discrete Algorithms for Mobile and Wireless Systems

Page 1: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

CPSC 689: Discrete Algorithms for Mobile and Wireless Systems

Spring 2009

Prof. Jennifer Welch

Page 2: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 2

Lecture 8 Topics:

Time Synchronization Lower Bounds Sources:

Fan, Chakraborty & Lynch paper Fan & Lynch paper Lenzen, Locher & Wattenhofer paper MIT 6.885 Fall 2008 slides

Page 3: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 3

Clock Synchronization Model (Again)

Nodes have physical (hardware) clocks Hi(t), with bounded drift rate Rate of physical clock, relative to real time, always in the

range [1-, 1+]. Some nodes may have periodic access to external

sources of reliable real time signals (GPS). Nodes communicate by passing messages (point-

to-point or broadcast). Message delay from i to j is variable, within [0, di,j]. Call di,j the distance from i to j; may be related to

Euclidean distance. Adversary controls clock drift and message delay.

Page 4: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 4

Clock Synchronization Problem (Again)

Nodes compute logical clock Li(t) based on physical clock and messages received.

Logical clocks should be synchronized with each other and with real time: (Well-behaved) Don’t move backwards. (Agreement) Minimize difference (skew) between

nodes’ logical clocks. (Internal validity) Logical clocks remain (approximately)

within range of physical clocks. (External validity) Logical clocks remain close to real

time (closeness depends on

Page 5: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 5

Gradient Clock Synchronization

Nearby nodes should have small worst-case logical clock skew, nodes that are further away may have larger clock skews. E.g., can we ensure that all i,j always have O(di,j) skew ? Or find some small function f such that, for every i, j, and

t, | Li(t) – Lj(t) | f(di,j) ? Gradient synchronizaton good enough for many

uses: Nearby nodes comparing observations at nearby points

in time, e.g., for determining speed of object observed by two nodes.

For collision-avoidance algorithms based on time, e.g., reservation-based protocols, or TDMA.

Page 6: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 6

Gradient Clock Synchronization Motivation Anyway, it’s impossible to guarantee too-close

synchronization between distant network nodes: Consider a line network G with D nodes.

Distance between neighbors is 1, diameter is D-1. Can’t achieve better than (D-1) / 2 worst-case

logical clock skew between nodes 1 and D.

1 2 3 D

1 1 1 1

Page 7: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 7

Lower Bound on Skew for a Line First let's consider a simpler case when

there is no clock drift but clocks start unsynchronized

Use a simple shifting argument: nodes on the line are 1, 2, 3, …, D In reference execution , message delay from

k to k+1 is 0 and from k+1 to k is 1 Shift to create new execution ':

shift node 1 by 0, node 2 by 1, node 3 by 2, …, and node D by (D-1)

Page 8: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 8

Lower Bound on Skew for a Line Check that msg delays in ' are in range:

msg from i to i+1:new delay = old delay – i's shift + (i+1)'s shift

= 0 – (i – 1) + i = 1 msg from i+1 to i:

new delay = old delay – (i+1)'s shift + i's shift = 1 – i + (i – 1) = 0

After algorithm terminates in both executions: L1' = L1 since node 1 shifted by 0

≥ LD – since is max skew

= (LD' + D – 1) – since node D shifted by D – 1

≥ (L1' – ) + D – 1 – since is max skew Implies ≥ (D – 1)/2

Page 9: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 9

Lower Bound on Skew for a Line

Can modify the previous argument for the case when clocks start synchronized but there is clock drift: Execution :

Delays from left-to-right are always 0. Delays from right-to-left are always 1. Physical clocks don’t drift.

': Shift , keeping drift rate within bounds, so that after a while:

Delays from left-to-right are always 1. Delays from right-to-left are always 0.

Then for large t, | L1(t) – LD(t) | ≤ in both executions. But LD(t) differs by D-1 in the two executions, contradiction.

Page 10: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 10

Shifting to Get 'Slow down the clocks, until enough skew is created

time

1 D

'

1 D

Page 11: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 11

Gradient Clock Synchronization

So, it seems we are forced to settle for gradient clock synchronization.

Now describe: A simple almost-gradient algorithm A surprising impossibility result for gradient

synchronization---says that worst-case skews between neighbors must depend on the size of the network!

A new algorithm that matches the lower bound.

Page 12: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 12

An Algorithm [Fan, Chakraborty, Lynch]

A good attempt at a practical wireless network algorithm that “usually” satisfies the gradient property.

Best/newest version in [Fan, PhD thesis 2008]. Accommodates external clock inputs. Tolerates node failures/recoveries, changing network. Assume symmetric link delays: dij = dji. GPS service.

Periodically (at least every time G) delivers correct real times to nodes in a designated subset VG of the nodes V.

Propagate through network (as part of the GPS service) using local broadcasts.

Stability: Analyze what happens when network stops changing (for sufficiently long).

Page 13: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 13

Algorithm Guarantees External accuracy lower bound:

In any execution, sufficiently long after stabilization, each node i’s logical clock is at least the real time, minus a quantity that depends on the GPS period G and closest distance from i to a GPS source.

External accuracy upper bound: Sufficiently long after stabilization, i’s logical clock is at most the real

time, plus a quantity that depends on G and the diameter of the network.

Need diameter here, because time information could arrive via roundabout paths.

Gradient accuracy: After stabilization, except during certain “synchronization periods”,

logical clocks satisfy gradient property. Can translate this claim to say that, under reasonable assumptions, the

gradient property holds “most of the time”.

Page 14: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 14

The Algorithm [Fan’s thesis, p. 62] Based on earlier algorithm of [Kaynar et al. 2005]:

Each node i estimates time using a local clock, which is the same as its physical clock.

Estimates maximum of all nodes’ local clocks using a global clock. Increases global clock, but at a slower rate than the physical clock, to be

sure it never exceeds the maximum local clock. Everyone sends around maximum known local clock. Logical clock = max (local clock, global clock)

Modify the algorithm to incorporate GPS inputs, tolerate network changes:

For each known GPS input value g, node i maintains: local(g), for the best local estimate of real time based on GPS input g. global(g), for the best estimate of the maximum of all nodes’ local(g).

Page 15: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 15

The Gradient Lower Bound[Fan, Lynch 04]

A surprising lower bound result expressing an inherent limitation for gradient algorithms.

Best/newest version in [Fan, PhD thesis 2008]. System model (simpler setting than previous

algorithm): Static graph network, no failure, no GPS inputs Symmetric link delays: dij = dji

Hardware clock, Hi(t) Initially 0, rate in [1-, 1+], for non-zero drift

Adversary controls hardware clock rates (drift) and message delays.

Page 16: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 16

The Gradient Lower Bound

Logical clock, Li(t), determined by the algorithm.

Requirements: Well-behavedness: Logical clocks always

advance at rate ½. Agreement (f-gradient property): For every i, j,

and t,

Li(t) – Lj(t) f(di,j)

Page 17: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 17

The Gradient Lower Bound Theorem

Theorem: For any f-gradient clock synchronization algorithm, we have: f(1) = (log D / log log D).

More precisely, for every D, there is some graph G of diameter D, and some execution in which two neighbors in G exhibit skew (log D / log log D).

Thus, the skew depends on the total size of the network: as the network grows, neighboring nodes will have weaker synchronization guarantees. Surprising that the skew between neighbors should depend

on the size of the entire network

Page 18: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 18

Discussion of Assumptions Requires a non-zero drift

In the case of no drift, with a one-shot algorithm, this result does not hold

Only applies to a class of algorithms in which logical clocks always increase at some minimum rate rules out algorithms which set clocks

backwards (e.g., average algorithms) but also rules out algorithms that can "smooth"

out negative adjustments

Page 19: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 19

Overview of the Proof

Construct explicit executions in which we adversarially control the hardware clock rates and message delays.

Uses “shifting” ideas as in the earlier example. Use line graph for nodes 1,…,D, with dij = 1 for all pairs of neighbors;

actually, diameter = D -1, but ignore this detail here.

Begin with execution in which hardware clock rates and message delays have specially-chosen values.

Then transform in stages into another execution with high skew between two neighbors, using two lemmas:

Add Skew Lemma (ASL) Bounded Increase Lemma (BIL)

…1 2 3 D

1 1 1 1

Page 20: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 20

Overview of the Proof

Create a series of executions 0, 1,… s.t. for each k, there are 2 nodes ik and jk: distance b/w ik and jk is (D–1)/(c*f(1))k = nk

skew b/w ik and jk at end of k is at least k*nk/24

k satisfies preconditions of Add Skew Lemma (ASL)

k satisfies preconditions of Bounded Increase Lemma (BIL)

Page 21: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 21

Inductive Construction Start with carefully chosen 0

Suppose k satisfying the above properties has been constructed. To create k+1:

k-1

k

k-1

k

apply ASL to scrunchASL implies skew b/w ik and jk has increased

then add a suffix to k to get:

k-1

k+1

'

k+1 satisfies precond. of BIL, so skew b/w ik and jk decreases

in ' only half as much as it increased

Page 22: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 22

Limits to the Construction

We can continue creating new executions in the inductive process as long as nk, the distance b/w ik and jk, is greater than 1, i.e., the two nodes identified are not the same

Set 1 = nk and solve for k:

1 = (D–1)/(c*f(1))k

k = logc*f(1) (D–1)

Page 23: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 23

Finishing Up In the final k, there are nodes ik and jk:

So there are nodes i and i+1 such that the skew between them is at least k/24

So f(1) ≥ k/24 Since k = (logf(1)D), algebra gives us that f(1) = (log D / log log D).

ik ik+1 i i+1 jk

distance is nk, skew is ≥ k*nk/24

distance is 1, skew is ≥ k/24

Page 24: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 24

Significance Lower bound result says that, for any gradient

clock synchronization algorithm, the worst-case skew between neighbors must depend on the diameter D of the network, (log D / log log D).

Significance in practice? Maybe not so serious, because the constants in

the (log D / log log D) lower bound are extremely small.

Also, how long does the large skew persist?

Page 25: CPSC 689:  Discrete Algorithms for Mobile and Wireless Systems

Discrete Algs for Mobile Wireless Sys 25

A New Gradient Algorithm[Lenzen, Locher, Wattenhofer 08]

Algorithm ensures close-to-optimal gradient and network-wide bounds. O(log D) local skew (cf. lower bound O(log D/log log D) O(D) global skew

Uses an interesting strategy of sending very carefully crafted demands for neighbors to increase their clocks.

Can this algorithm be a practical synchronization strategy for real ad hoc networks?