1 / 20

Clock Synchronization

Clock Synchronization. Problem. 5:33. 5:57. 5:20. 6:01. 4:53. Why is this hard?. Hard to set the clocks simultaneously Hardware clocks have a small drift rate Network messages have random delay This delay is unbounded Various types of faults are possible: Process failure

samuele
Download Presentation

Clock Synchronization

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Clock Synchronization

  2. Problem 5:33 5:57 5:20 6:01 4:53

  3. Why is this hard? • Hard to set the clocks simultaneously • Hardware clocks have a small drift rate • Network messages have random delay • This delay is unbounded • Various types of faults are possible: • Process failure • Communication failure

  4. Making it Tractable • Clocks have higher resolution than needed e.g. clocks measure microseconds, but we only care about milliseconds • Drift rate ρ of clock H is known • ρ is very small • Small bounded error in measurement allowable: (1 - ρ)(t - t’) ≤ H(t) - H(t’) ≤ (1 + ρ)(t - t’) • A message is on-time if sent and delivered within maxp time units • Minimum transmission time min is known

  5. Reading a Remote Clock Real time P Q P sends “Time = ?” to Q 5:31 5:30 5:33

  6. Reading a Remote Clock Real time P Q P sends “Time = ?” to Q 5:31 5:30 5:33 Q receives “Time = ?” from P 5:37 Q sends “Time = 5:41” to P 5:35 5:41

  7. Reading a Remote Clock Real time P Q P sends “Time = ?” to Q 5:31 5:30 5:33 Q receives “Time = ?” from P 5:37 Q sends “Time = 5:41” to P 5:35 5:40 P receives “Time = 5:41” from Q 5:44 5:42 5:46

  8. Reading a Remote Clock Real time P Q P sends “Time = ?” to Q 5:31 5:30 5:33 Q receives “Time = ?” from P P measures the roundtrip delay to be 12 = 2D 5:37 Q sends “Time = 5:41” to P 5:35 5:40 P receives “Time = 5:41” from Q 5:44 5:42 5:46

  9. What does P know about Q? • P sends “Time = ?” to Q at P(t) • P receives “Time = T” from Q at P(t’) • Roundtrip delay = P(t’) – P(t) = 2D • Drift rate ρfor P and Q • Minimum message travel time min • At P(t’), Q(t’) in interval [T + min(1 - ρ), T + 2D(1 + 2ρ) - min(1 + ρ)]

  10. What does P know about Q? • P sends “Time = ?” to Q at P(t) = 5:30 • P receives “Time = 5:41” from Q at P(t’) = 5:42 • Roundtrip delay = 12 minutes = 2D • Drift rate ρ= 0.25 for P and Q • Minimum message travel time min = 4 minutes • At P(t’) = 5:42, Q(t’) in interval [T + min(1 - ρ), T + 2D(1 + 2ρ) - min(1 + ρ)] = ?

  11. What does P know about Q? • P sends “Time = ?” to Q at P(t) = 5:30 • P receives “Time = 5:41” from Q at P(t’) = 5:42 • Roundtrip delay = 12 minutes = 2D • Drift rate ρ= 0.25 for P and Q • Minimum message travel time min = 4 minutes • At P(t’) = 5:42, Q(t’) in interval [5:41 + 4(1– .25), 5:41 + 12(1 + .5) - 4(1 +.25)] = [5:44, 5:54]

  12. P’s Best Guess For Q(t’) • At P(t’), Q(t’) in interval [T + min(1 - ρ), T + 2D(1 + 2ρ) - min(1 + ρ)] • In example: [5:44, 5:54] • To P, Q(t’) could be anywhere in the interval • What should P guess that Q(t’) is equal to?

  13. P’s Best Guess For Q(t’) • At P(t’), Q(t’) in interval [T + min(1 - ρ), T + 2D(1 + 2ρ) - min(1 + ρ)] • In example: [5:44, 5:54] • To P, Q(t’) could be anywhere in the interval • What should P guess that Q(t’) is equal to? • The midpoint! • Q(t’) = T + D(1 + 2ρ) - minρ • Q(t’) = 5:41 + 6(1 + .5) – 4(.25) = 5:49

  14. How Precise is the Measurement? • Max error e = D(1 + 2ρ) - min • P wants to know Q(t’) within error ε • Only guaranteed if D ≤ U where U = (1 - 2ρ)(ε + min) • Then P reaches rapport with Q • Pick ε such that U > min(1+ ρ) • If D > U then need to try again

  15. Time Service Q P4 Master Slave 5:33 5:57 P1 P3 P2 Slave 5:20 Slave 6:01 Slave 4:53

  16. Time Service Q P4 Master Slave 5:33 5:57 All slaves try to maintain rapport with Q P1 P3 P2 Slave 5:20 Slave 6:01 Slave 4:53

  17. How Should P Change it’s Clock? • At P(t’) = 5:42, P estimates Q(t’) = 5:49 • What should P do?

  18. How Should P Change it’s Clock? • At P(t’) = 5:42, P estimates Q(t’) = 5:49 • What should P do? • Gradually adjust clock to eventually match Q • Let P(t) = H(t) + A(t) • H(t) is the value of the hardware clock • A(t) = mH(t) + N is an adjustment to P’s clock • Set m and N so P(t’ + x) = Q(t’ + x) • x is the amortization parameter • m = (Q(t’) - P(t’)) / x • N = P(t’) - (1 + m)×H(t’)

  19. Master-Slave Synchronization • Slave tries up to k syncs with master • Remember: rapport means D ≤ U • Sync retry every W time units until rapport • W > 2U • At rapport, gradually adjust according to P(t) = H(t) + A(t) • Slave knows it is out of sync after k tries

  20. Importance • Reliable Clock Synchronization required for: • Synchronous Atomic Broadcast • http://www.cs.utexas.edu/~schrum2/cs386c/sab.php • Processor Group Membership Agreement • Any distributed system needs accurate Clock Synchronization

More Related