1 / 17

ECE 428/CS 425 Distributed Systems

ECE 428/CS 425 Distributed Systems. Lecture 2 Time & Synchronization. Why synchronization?. Two sharpshooters in a multiplayer online game kill the same target. Which one gets the points? Synchronization required for Fairness Correctness!. Processes and Events.

otis
Download Presentation

ECE 428/CS 425 Distributed Systems

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. ECE 428/CS 425Distributed Systems Lecture 2 Time & Synchronization

  2. Why synchronization? • Two sharpshooters in a multiplayer online game kill the same target. Which one gets the points? • Synchronization required for • Fairness • Correctness!

  3. Processes and Events • A DS consists of a number of processes. • Each process has a state (values of variables). • Each process takes actions to change its state, ortocommunicate (send, receive). • An event is the occurrence of an action. • Events within a process can be ordered by the time of occurrence. • In DS we also need to know the time order of events on different processors & between different processes.

  4. Physical Clocks & Synchronization • In DS each processor has its own timer. • Timers drift from true real time at different rates. • Drift versus Skew • Maximum Drift Rate (MDR) of a clockdepends on clock characteristics and the environment. PPM Stability over Oscillator 0-70°C Year NCXO / VCXO 5-100 1-10 TCXO 0.1-5 0.1-2 OCXO <0.001-1 0.02-2 MCXO <0.05-2 0.02-2 Source: http://www.isotemp.com/146-010.html

  5. Synchronizing to Meet Skew Limits • Max difference between two clocks with similar MDR is 2 * MDR Max-Synch-Interval = (Max-Acceptable-Diff) / (MDR * 2)

  6. Synchronizing Physical Clocks • Ci(t): the reading of the software clock i when the real time is t. • External synchronization: For a synchronization bound D>0, and for source S of UTC time, for i=1,2,...,N and for all real times t in I. Clocks Ci are accurate to within the bound D. • Internal synchronization: For a synchronization bound D>0, for i, j=1,2,...,N and for all real times t in I. Clock Ciagree within the bound D.

  7. m r m t p Time server,S Clock Synchronization Using a Time Server

  8. Cristian’s Algorithm • Uses a time server to synchronize clocks • Time server keeps the reference time • Clients ask the time server for time & adjust their clock, based on the response For links with symmetrical latency: RTT = response-received-time – request-sent-time adjusted-local-time = server-timestamp t + (RTT / 2) or= server-timestamp + (RTT – server-latency) /2 local-clock-error = adjusted-local-time – local-time

  9. Cristian’s Algorithm • Message arrives at time T as per the server’s clock. Then: T >= t + min (min for message from server) T <= t + (RTT-min) (min for msg to server) • Client makes its clock = t + RTT/2  Error is bounded by | RTT/2 – min |

  10. Cristian’s Algorithm Caveat • RTT estimated by the client using its own clock • RTT measurement affected by client’s clock drift • But this effect small if clock drift small relative to real RTT value

  11. Berkeley Algorithm • Uses a elected master to synchronize • The elected master pools or broadcasts to all machines for their time, adjusts times received for RTT & latency, averages times, and tells each machine how to adjust. • In some systems multiple time servers are used. • Avg. time is more accurate, but still drifts

  12. The Network Time Protocol (NTP) • Uses a network of time servers to synchronize all processors on a net. • Time servers are connected by a synchron- ization subnet tree. The root is adjusted directly. Each node synchronizes its children nodes. Primary server, direct synch. 1 Secondry servers, synched by the primary server 2 2 2 Strata 3, synched by the secondary servers 3 3 3 3 3 3

  13. Server B T T i -2 i-1 Time m m' Time Server A T T i - 3 i Messages Exchanged Between a Pair of NTP Peers Each message bears timestamps of recent message events: the local time when the previous NTP message was sent and received, and the local time when the current message was transmitted.

  14. Server B T T i -2 i-1 Time m m' Time Server A T T i - 3 i Theoretical Base for NTP • oi: estimate of the actual offset • between the two clocks • o: true offset of the clock at B • relative to that at A •  B’s clock = A’clock + o • t and t’: actual transmission times • for m and m’ • di: estimate of accuracy of oi ; • total transmission times for m • and m’; d=t+t’

  15. Logical Clocks • We are interested in relative time between events (their order), define relation, Happens-Before (): • On the same process:a  b, if time(a) < time(b) • If p1 sends m to p2:send(m)  receive(m) • Ifa  b and b  cthena  c • Lamport Algorithm uses this relationship to provide a partial ordering of events: • All processes use a counter (clock) with initial value of zero • The counter is incremented by and assigned to each event, as its timestamp. • A send (message) event carries its timestamp • For a receive (message) event the counter is updated by Max(receiver-counter, message-timestamp) + 1

  16. Events Occurring at Three Processes

  17. Lamport Timestamps

More Related