Gradient Clock Synchronization

6
Com S 611 Spring Semester 2007 Gradient Clock Synchronization Lecture 9: Tuesday, 13th February 2007 Instructor: Soma Chaudhuri Scribe: Danyu Liu 1 Topic In this lecture, the professor discussed the paper: Gradient Clock Synchronization by Rui Fan and Nancy Lynch in PODC’04, July 25-28, 2004, St. John’s, Newfoundland, Canada. 2 Background First, let us consider the target tracking problem in a sensor network. Suppose two sensor nodes want to measure the speed of an object. Each node records the time when the object crosses within its vicinity. Then the nodes exchange their time readings, and compute t, the difference in their readings. The amount of error in t is related to the clock skew between the nodes. The object’s velocity is computed as v = d t , where d is the known Euclidean distance between the nodes. Suppose the nodes do not need to compute v exactly, but only to an accuracy of 1%. Since v = d t , then the larger the Euclidean distance is between the nodes, the more error is acceptable in t, while still computing v to 1% accuracy. Thus, the acceptable clock skew of the nodes forms a gradient. Note that here we are assuming the Euclidean distance between two nodes corresponds to the uncertainty in their message delay. This is the case if, for example, there are multiple network hops between the nodes, with the number of hops proportional to the Euclidean distance between the nodes. N is a network with n nodes P 1 ,P 2 ,...,P n and is complete so that all nodes in this network can communicate with each other. Let d ij be the distance between two nodes P i and P j and D be the diameter of the network N (i.e. D = max P i ,P j N {d ij }). The main result from this paper is that given any clock synchronization algorithm, there exists an execution in which two nodes that are distance d apart, for an arbitrary d, have Ω(d + logD loglogD ) clock skew. From the result, we can see that both the distance d and the diameter D determine the time skew of the two nodes. Lundelius-Welch and Lynch [1984] proved that in a complete network of n nodes where the distance between each pair of nodes is d, nodes cannot synchronize their clocks to closer than d(1 - 1 n ) and gave Ω(D) as the low bound of the clock skew. Srikanth and Toueg [1987] gave an optimal clock synchronization algorithm, where optimal means that the maximum skew between any pair of nodes is as small as possible given the hardware clock drift. Their algorithm ensures that any pair of nodes have O(D) clock skew. However, it does not guarantee a gradient in the clock skew, because even nodes that are O(1) distance apart can have O(D) skew. 2.1 Definition. Given an execution α of a CS algorithm A, the execution α 0 = shif t(α, < a 0 ,a 1 >) where every event P 0 is shifted later by a 0 and every event of P 1 is shifted later by a 1 . L i (t) is the local clock time on P i when the global time is t. 1

description

Gradient Clock Synchronization

Transcript of Gradient Clock Synchronization

Com S 611 Spring Semester 2007Gradient Clock Synchronization

Lecture 9: Tuesday, 13th February 2007

Instructor: Soma Chaudhuri Scribe: Danyu Liu

1 Topic

In this lecture, the professor discussed the paper: Gradient Clock Synchronization by Rui Fanand Nancy Lynch in PODC’04, July 25-28, 2004, St. John’s, Newfoundland, Canada.

2 Background

First, let us consider the target tracking problem in a sensor network. Suppose two sensor nodeswant to measure the speed of an object. Each node records the time when the object crosseswithin its vicinity. Then the nodes exchange their time readings, and compute t, the differencein their readings. The amount of error in t is related to the clock skew between the nodes. Theobject’s velocity is computed as v = d

t, where d is the known Euclidean distance between the

nodes. Suppose the nodes do not need to compute v exactly, but only to an accuracy of 1%.Since v = d

t, then the larger the Euclidean distance is between the nodes, the more error is

acceptable in t, while still computing v to 1% accuracy. Thus, the acceptable clock skew of thenodes forms a gradient. Note that here we are assuming the Euclidean distance between twonodes corresponds to the uncertainty in their message delay. This is the case if, for example,there are multiple network hops between the nodes, with the number of hops proportional to theEuclidean distance between the nodes.

N is a network with n nodes P1, P2, . . . , Pn and is complete so that all nodes in this network cancommunicate with each other. Let dij be the distance between two nodes Pi and Pj and D bethe diameter of the network N (i.e. D = max

Pi,Pj∈Ndij). The main result from this paper is that

given any clock synchronization algorithm, there exists an execution in which two nodes that aredistance d apart, for an arbitrary d, have Ω(d + logD

loglogD) clock skew. From the result, we can see

that both the distance d and the diameter D determine the time skew of the two nodes.

Lundelius-Welch and Lynch [1984] proved that in a complete network of n nodes where thedistance between each pair of nodes is d, nodes cannot synchronize their clocks to closer thand(1− 1

n) and gave Ω(D) as the low bound of the clock skew. Srikanth and Toueg [1987] gave an

optimal clock synchronization algorithm, where optimal means that the maximum skew betweenany pair of nodes is as small as possible given the hardware clock drift. Their algorithm ensuresthat any pair of nodes have O(D) clock skew. However, it does not guarantee a gradient in theclock skew, because even nodes that are O(1) distance apart can have O(D) skew.

2.1 Definition. Given an execution α of a CS algorithm A, the execution α′ = shift(α, <a0, a1 >) where every event P0 is shifted later by a0 and every event of P1 is shifted later by a1.Li(t) is the local clock time on Pi when the global time is t.

1

d

P0

P1

P0 P1 P0

0 d

L0(t)

L1(t)

P0

P1

t1

(global time)

L0(t) +d

L1(t)

d

P0 P1 P0

d 0

t2

(global time)

t3

(global time)

t

(global time)

T0

T0 T0+d

T0+d

Figure 1: At global time t, both executions of algorithm α and α′ stop.

Lemma 2.1. Consider two processors, P0 and P1 at distance d apart (so message delay is in[0, d]), the worst case clock skew of any algorithm is Ω(d).

Proof. Please refer to Figure 1. Let A be a clock synchronization algorithm and α be an executionof A, in which the delay of all messages from P0 to P1 is 0 and P1 to P0 is d. Let α′ be an executionof A and defined as shift(α,< −d, 0 >), in which the delay of all messages from P0 to P1 is dand P1 to P0 is 0. Suppose algorithm A has clock skew ε (i.e. |L0(t)− L1(t)| ≤ ε).

Execution α′ is similar as execution α except all events happened in α have been shifted d timeearly in α′. In order to disable P1’s abilities to distinguish between these two executions, P0

should send the message to P1 with delay time of d at global time t1. Otherwise, P1 will receivethe message from P0 at a local time that is d time earlier than it does in execution α. Similarly,P1 should send a reply message to P0 with delay time of 0 such that P0 can receive the messagefrom P1 at the local time of T0 + d. As we can see in execution α′, the delay time is in the rangeof [0, d] so α′ is legal. P0 is in final state after the global time t3 and P1 is in final state afterthe global time t2 so both processors are in final states at the global time t. At global time tin execution α, the algorithm A has clock skew ε (i.e. |L0(t) − L1(t) ≤ ε|). At global time t inexecution α′, the algorithm A has clock skew ε (i.e. |L0(t) + d− L1(t) ≤ ε|). So we can get the

2

inequalities as follows:

L1(t) ≤ L0(t) + ε, for execution of αL0(t) + d ≤ L1(t) + ε, for execution of α′

L0(t) + d ≤ L0(t) + 2εd ≤ 2εε ≥ d

2

So the lower bound of the clock skew is Ω(d).

Theorem 2.2. Given a set of n processors that are at distance d from each other, the worst caseclock skew is Ω(d(1− 1

n)).

Proof. Let A be a CS algorithm. Let α be an execution of A in which the delay of all messagesfrom pi to pj is 0, if i < j and d, if i > j. Let algorithm A have skew ε and Li(t) is the localclock time on Pi when the global time is t.

Ln−1(t) ≤ L0(t) + ε≤ L1(t)− d + 2ε by using the lemma 2.3≤ L2(t)− 2d + 3ε...≤ Ln−1(t)− (n− 1)d + nε

(n− 1)d ≤ nεε ≥ (1− 1

n)d

[Homework 4] This proof is completed using the following lemma. Prove the lemma and thencomplete the proof.

Lemma 2.3. For any k, 1 ≤ k ≤ n − 1, Lk−1(t) ≤ Lk(t) − d + ε where Li(t) is the local clocktime on Pi when the global time is t.

Let us consider the algorithm from Srikanth and Toueg [1987] in the following two cases:

Algorithm 1 An CS algorithm in which the distance d is known. Please refer to Figure 2.

1: P0 sends a message with time stamp T0 to P1 at global time t12: when P1 receives the message from P0 at global time t2, P1 sets its local time as T0 + d

2

Now the value of L0(t2) is equal to T0 + d and the value of L1(t2) is equal to T0 + d2, so the clock

skew between P0 and P1 at global time t2 is d2.

3

d

P0

P1

T0 (local time)

t2 (global time)

(1) L0(t1) = T0

(2) L0(t2) = T0 + d

(3) L1(t2) = T0 + d/2

So clock skew is d/2

t1 (global time)

Figure 2: Compute the clock skew when we do know the distance d

Algorithm 2 An CS algorithm in which the distance d is unknown.

1: P0 sends a ”hello” message to P1

2: when P1 receives ”hello” message at local time T1, P1 sends a reply message with time stampT1 to P0

3: when P0 receives the message from P1, P0 sets σ to be the difference in P0’s local time fromstep 1 to step 3 and sets its local time as T1 + σ

2

In order to compute the clock skew between P0 and P1, we need to consider four different casesthat have been listed in Figure 3.

For example:In Figure 3(A), the value of L0(t2) is equal to T1 + σ

2(i.e. T1 + d) and the value of L1(t2) is equal

to T1 + d, so the clock skew between P0 and P1 at global time t2 is 0.

We can extend the two processors algorithm to get the following result:

Theorem 2.4. Given n processors and messages with delay in range [0, d], there is a CS algorithmwith clock skew d(1− 1

n).

Each node i is equipped with a hardware clock. We define the value of the hardware clock interms of its rate of change. Specifically, we denote i’s hardware clock rate at real time t of anexecution α by hα

i (t). We define i’s hardware clock value at time t in α to be Hαi (t) =

∫ t0 hα

i (t)dr.We assume all the hardware clocks have bounded drift. That is, we assume that there exists aconstant ρ, where 0 ≤ ρ < 1, such that for any execution the following holds.

∀i∀t : 1− ρ ≤ hαi (t) ≤ 1 + ρ

Let us describe a validity condition which we require any CSA to satisfy. Let A be a CSA, andconsider any execution α of A. Then we require the following.

4

d

P0

P1

dT

1(lo

cal tim

e)

t2(g

lob

al tim

e)

(1) L

0 (t2 ) = T

1+

/2 =

T1

+ d

(2) L

1 (t2 ) = T

1+

d

So c

lock s

kew

is 0

P0

P1

P0

dd

d

P0

P1

T1

(local tim

e)

t’ (glo

ba

l time)

(1) L

0 (t’) = T

1+

/2 =

T1

+ d

/2

(2) L

1 (t’) = T

1+

d

So c

lock s

kew

is d

/2

P0

P1

P0

0d

d

P0

P1

T1

(local tim

e)

t’ (glo

ba

l time)

(1) L

0 (t’) = T

1+

/2 =

T1

+ d

/2

(2) L

1 (t’) = T

1

So c

lock s

kew

is d

/2

P0

P1

P0

d0

P0

P1

T1

(local tim

e)

t’ (glo

ba

l time)

(1) L

0 (t’) = T

1

(2) L

1 (t’) = T

1

So c

lock s

kew

is 0

P0

P1

P0

00

(A)

(C)

(B)

(D)

t1(g

lob

al tim

e)

Figure 3: Compute the clock skew when we do not know the distance d

5

∀i∀t∀r > 0 :r

2≤ Lα

i (t + r)− Lαi (t).

where Lαi (t) is denoted as the logical clock value of node i at time t in an execution α. This

requirement says that the rate of increase of each node’s logical clock must be at least 12, at all

times.

dLαi (t)

dt≥ 1

2.

2.2 Definition. (Gradient Property). Let n be any positive integer, and let N be any networkwith nodes 1, . . . , n, and distances between the nodes di,j|1 ≤ i, j ≤ n. In every execution α ofA in N , we have

∀t∀i, j : |Lαi (t)− Lα

j (t)| ≤ f(di,j).

Theorem 2.5. For any f −GCG algorithm, f(d) = Ω(d + logDloglogD

).

Proof. Let A be an arbitrary f-GCS algorithm. To prove the lower bound, we show the following:

1. For every real number d ≥ 1, there exists a network containing two nodes at distance dfrom each other, such that the two nodes have Ω(d) clock skew in some execution of A inthe network. This implies f(d) = Ω(d). The reason why we only consider d ≥ 1 is becausewe defined 1 as the minimum distance between any two nodes, for each network.

2. For every integer D ≥ 1, there exists a network of diameter D and an execution of A in thenetwork, such that two nodes at distance 1 from each other in the network have Ω( logD

loglogD)

clock skew in the execution. This implies f(1) = Ω( logDloglogD

).

[Homework 5] In a network which is a chain of n processors p1, p2, . . . , pn, Fan and Lynch showthat the worst case clock skew between neighbors depends on the size of n, even though thedistance between them is 1!. Consider the following algorithm:

At real time t, neighboring nodes pi and pi+1 send their local times Li(t) and Li+1(t) to eachother. When they receive the message, each node sets its clock to the larger of its own clockvalue and the received timestamp.

Prove that at real time t + 1, the local clocks of pi and pi+1 differ by at most 1. Argue why thisdoes not contradict the lower bound by Fan and Lynch.

6