1 / 21

CLOCK SYNCHRONIZATION

CLOCK SYNCHRONIZATION. Sai deepika gopala. AGENDA. Introduction Clock Synchronization Physical Clocks Global Positioning System Algorithms References. Introduction: Synchronization.

eara
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 Sai deepikagopala

  2. AGENDA • Introduction • Clock Synchronization • Physical Clocks • Global Positioning System • Algorithms • References

  3. Introduction: Synchronization • Communication is important, but how processes synchronize and cooperate with each other is also important. • With the introduction of distributed systems, synchronization has become more difficult compared to that in uniprocessor systems. • Why Synchronization? • To order events produced by concurrent processes. • To coordinate between senders and receivers of messages. • To serialize the concurrent access of shared objects.

  4. Synchronization: Examples • Printer • Multiple processes do not simultaneously access a shared resource. • Instead, they cooperate to grant each other temporary exclusive access. • Producer- Consumer problem. • One process trying to modify data in the memory which is being read by another process

  5. Clock Synchronization • In a centralized system, a process gets to know the time by making a system call to the kernel. • It is not so simple for distributed systems. • To understand this, consider the UNIX file system where large programs are split into multiple source file in order to avoid unnecessary recompilation. • When “make” command is executed, it checks for the last modified time of each source and corresponding object files and recompiles the source files if necessary. • For example, say the time for source file is say 2151, and for its object file is 2150, the file is recompiled. If the reverse occurs, no compilation is done further. • Now, imagine a distributed system with no global time and the time returned on execution of “make” is 2144 for object file and 2143 for its source file because the clock is slightly behind. The resulting executable file is an incorrect one.

  6. So, how to synchronize all the clocks in the distributed system???

  7. Physical Clocks • All computers have circuits to track time. These clocks can be better termed as Timers. • It is a precisely machined quartz crystal which oscillate at a defined frequency depending on the kind of the crystal and the tension it is subjected to. • Each crystal has a Counter and Holding Register. • Each oscillation of the crystal decrements the counter by one and when it reaches 0, an interrupt is generated and counter is reloaded from the holding register. This interrupt is called a clock tick. • When counter decrements to 0, interrupt is generated and counter is reloaded from holding register. • If it’s a single computer & a single clock, it doesn'tmatter even if the clock is off by a small amount because all the times are relative. How about the distributed systems?

  8. Physical Clocks in Distributed Systems • With multiple CPUs each with its own clock, it is impossible to guarantee that all the crystals will run at the same frequency. • The difference in time values is called as Clock Skew. • Programs that expect time associated with a file, process, object or message may fail. • I real world systems, physical clocks are needed to increase efficiency and redundancy. • Problems: • How to synchronize these clocks with real world clocks? • How to synchronize the clocks with each other?

  9. How is the time measured?? • Mechanical clocks: time is measured astronomically based on the transit of the sun. • 2 consecutive transits = 1 solar day • After measuring the length of large number of days • Mean solar second = average length of day / 86,400

  10. Atomic Clock – time is measured by counting the transitions of Cesium 133 atom. • 1 second = time to make exactly 9,192,631,770. • TAI = mean number of ticks of Cesium 133 since midnight of Jan 1, 1958 / 9,192,631,770. • TAI is highly stable but it is about 3 msec less than a mean solar day. • Problem?? • Solution: • This system of stable TAI with leap seconds is named as UTC. • Number of leap seconds introduced till now is 30.

  11. Global Positioning System (NavStar) Problem: Determining the geographical position anywhere on the earth. Solution: Global Positioning System, a satellite based distributed system. • Developed by the US government for military navigation. • Uses 31 satellites circulating in an orbit at a height of approximately 20,000 km in a way that there are always 6 satellites in view from most places on earth. Each satellite has 4 clocks. It is assumed that all the clocks on the satellites and receivers are synchronized. • A satellite continuously broadcasts its position, and timestamps messages with local timeso that every receiver on earth can accurately predict its position. 4. Trilateration:

  12. Why do we need 4 satellites to get the correct position? • Challenges: • Delay in receiving the satellite’s position by the receiver. • Receiver's clock is not in sync with that of satellite’s. Delay = Tnow = time on the receiver’s clock Ti = Timestamp from the satellite Distance travelled by signal = where b = delay measured by the receiver. Drawbacks: GPS does not take lap seconds into account.

  13. Clock Synchronization Algorithms • Each machine has a timer that causes H interrupts in a second. When the timer goes off, interrupt handler adds 1 to a software clock that keeps track of the number of ticks / interrupts. • Let the value of the clock is C. When UTC time is t, value of clock on machine p is Cp = t. Frequency is dC/dt. Let skew = • So, the timer range can be given by : • If two clocks are drifting from UTC in the opposite directions, then we may have to re-synchronize them.

  14. Network Time Protocol • Common approach: client contacts server and server provides current time as it has WWV or an accurate clock. • Problem: When contacting server, message delays will have outdated reported time. • If A’s clock is fast, offset <0, meaning A should set its clock backward. • This can be a serious issue such as an object file compiled after clock change having a time earlier than the source which was just modified before the clock change.

  15. Algorithm: The Berkeley Algorithm • The time server is active. It asks the clients for their time. • The time server, computes the average time. • Tells all the other machines to advance their clocks to the new time. May also, ask to slow their clocks down until some specified reduction has been achieved.

  16. How do we overcome this problem??? • Suppose if the clock generates 100 interrupts/sec. Each interrupt would add 10msec to the time. • Slowing down should add 9msec to the time till the correction. Similarly, to advance, 11msec should be added. • In NTP, even B can request A for its current time. So the delay is: • Applying NTP symmetrically should let B adjust its clock according to A. • But if B is more accurate this adjustment is foolish. • So, NTP assigns strata to the server. When A contacts B, it will adjust its clock only if its strata is higher than B and vice-versa.

  17. Algorithm: The Berkeley Algorithm • This method is suitable for a system in which no machine has a WWV receiver. WWV is a shortwave radio station by NIST to provide UTC. • The time daemon's time must be set manually by the operator periodically. • This is sufficient for all machines that agree on the same time.

  18. Clock Synchronization in Wireless Networks • In traditional distributed systems, time servers can be easily and efficiently deployed. • Machines can contact each other, with relatively simple dissemination of information. • In sensor networks, nodes are resource constrained. • Also, multi-hop routing is expensive. • In addition, it is often important to optimize algorithms for energy consumption. • These and other observations have led to the design of very different clock synchronization algorithms for wireless networks.

  19. Reference Broadcast Synchronization: • Does not assume that there is a single node with accurate time. All nodes are provided with UTC by internally synchronizing the clocks. • Only receivers adjust their clocks. • Sender broadcasts a reference message that will allow receivers to adjust their clocks. • Time is measured from the moment a message leaves the sender interface, thereby eliminating the delay to construct a message and access the network. • If this offset is stored, clocks need not be adjusted. Tp,k = Time when message m is received by node p. M = Total number of reference messages sent.

  20. References • Distributed Systems, Principles and paradigms, Second Edition- Andrew S.Tanenbaum, Maarten Van Steen. • Leslie Lamport, “Time, Clocks, and the Ordering of Events in a Distributed System”, In: Communications of the ACM, July 1978, Volume 21, Number 7, pp. 558-565. • https://www.maptoaster.com/maptoaster-topo-nz/articles/how-gps-works/how-gps-works.html • http://www.physics.org/article-questions.asp?id=55 • https://www.youtube.com/watch?time_continue=3&v=3zRlbboMvb0

  21. Thank you!

More Related