Distributed Systems. Clock Synchronization: Physical Clocks. Paul Krzyzanowski

Similar documents
Distributed Systems. 05. Clock Synchronization. Paul Krzyzanowski. Rutgers University. Fall 2017

Clock-Synchronisation

INTERNATIONAL JOURNAL OF ENGINEERING SCIENCES & RESEARCH TECHNOLOGY

Distributed Systems. Time, clocks, and Ordering of events. Rik Sarkar. University of Edinburgh Fall 2014

Lecture 12: Time Distributed Systems

Middleware and Distributed Systems. Time. Martin v. Löwis. Mittwoch, 22. Februar 12

Lecture 10: Clocks and Time

Time Synchronization and Logical Clocks

CSE 124: TIME SYNCHRONIZATION, CRISTIAN S ALGORITHM, BERKELEY ALGORITHM, NTP. George Porter October 27, 2017

Synchronization Part 1. REK s adaptation of Claypool s adaptation of Tanenbaum s Distributed Systems Chapter 5

Time. COS 418: Distributed Systems Lecture 3. Wyatt Lloyd

Distributed Systems COMP 212. Lecture 17 Othon Michail


Time Synchronization and Logical Clocks

TIME ATTRIBUTION 11/4/2018. George Porter Nov 6 and 8, 2018

Last Class: Naming. Today: Classical Problems in Distributed Systems. Naming. Time ordering and clock synchronization (today)

殷亚凤. Synchronization. Distributed Systems [6]

Distributed Coordination 1/39

CSE 5306 Distributed Systems. Synchronization

Time in Distributed Systems

Clock and Time. THOAI NAM Faculty of Information Technology HCMC University of Technology

Last Class: Naming. DNS Implementation

Verteilte Systeme (Distributed Systems)

Synchronisation in. Distributed Systems. Co-operation and Co-ordination in. Distributed Systems. Kinds of Synchronisation. Clock Synchronization

Synchronization. Distributed Systems IT332

DISTRIBUTED REAL-TIME SYSTEMS

Synchronization of Network Devices Time by GPS Based Network Time Protocol Output

Implementing a NTP-Based Time Service within a Distributed Middleware System

Distributed Systems Exam 1 Review Paul Krzyzanowski. Rutgers University. Fall 2016

Network Time Protocol

Implementing NTP. Release 3.8.0

CSE 5306 Distributed Systems

Distributed Systems. Pre-Exam 1 Review. Paul Krzyzanowski. Rutgers University. Fall 2015

Wireless Communication Bluetooth, Timing

2017 Paul Krzyzanowski 1

Distributed Systems Exam 1 Review. Paul Krzyzanowski. Rutgers University. Fall 2016

Implementing NTP. Support was added for IPv6 addresses, VRFs, multicast-based associations, and burst and iburst modes for poll-based associations.

Chapter 6 Synchronization (1)

Network Working Group. Obsoletes: 1361 March 1995 Category: Informational

Table of Contents 1 NTP Configuration 1-1

The ISP Column A monthly column on things Internet. Protocol Basics: The Network Time Protocol. NTP, Time, and Timekeeping. March 2014 Geoff Huston

Advanced Topics in Distributed Systems. Dr. Ayman A. Abdel-Hamid. Computer Science Department Virginia Tech

Operation Manual NTP. Table of Contents

Synchronization. Clock Synchronization

Network Time Service SY-GPS-1-A

Distributed systems Lecture 3: Further RPC and OOM systems; Clocks

Distributed Clock Synchronization Algorithms: A Survey

GPS IRIG-B/NTP Time Server GPS-2-E-NTP

CS 417: the one-hour study guide for exam 2

2. Time and Global States Page 1. University of Freiburg, Germany Department of Computer Science. Distributed Systems

This chapter describes how to configure the Network Time Protocol (NTP) on Cisco NX-OS devices. This chapter includes the following sections:

Clock Synchronization

Chapter 6 Ti T me m s ynchronization

2. Clock Accuracy and Synchronization

Time Handling in Programming Language

Ad hoc and Sensor Networks Time Synchronization

Virtualize Everything but Time

The Flooding Time Synchronization Protocol

Time Scales and Time Keeping in the 21 st Century

Distributed Operating Systems. Distributed Synchronization

Implementing NTPv4 in IPv6

19: I/O Devices: Clocks, Power Management

Irish NTP Subnet. Performance Issues. Hugh Melvin & Paraic Quinn. Dept. of Information Technology NUI,G

Distributed systems Lecture 11: Object-Oriented Middleware (OOM), clocks and distributed time. Dr. Robert N. M. Watson.

µtasker Document µtasker SNTP (Simple Network Time Protocol)

HP 6125 Blade Switch Series

- Network Time Protocol -

Lecture 21 Disk Devices and Timers

HP 6125G & 6125G/XG Blade Switches

Reliable Time Synchronization Protocol for Wireless Sensor Networks

SETTING UP AN NTP SERVER AT THE ROYAL OBSERVATORY OF BELGIUM

The Timed Asynchronous Distributed System Model By Flaviu Cristian and Christof Fetzer

CSE 123: Computer Networks Alex C. Snoeren. HW 2 due Thursday 10/21!

Network Time Protocol

HP 5920 & 5900 Switch Series

Synchronization. Chapter 5

Proseminar Distributed Systems Summer Semester Paxos algorithm. Stefan Resmerita

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Clock Synchronization. Synchronization. Clock Synchronization Algorithms. Physical Clock Synchronization. Tanenbaum Chapter 6 plus additional papers

Wireless Sensor Networks: Clustering, Routing, Localization, Time Synchronization

The IEEE 1588 Standard

SICLOCK TC 400 / TC100 and Redundancy

Basic System Management Configuration Guide, Cisco IOS XE Release 3SE (Catalyst 3850 Switches)

Delivering Sub-Microsecond Accurate Time to Linux Applications Around the World

Configuring Precision Time Protocol (PTP)

Time. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 37

Time in Distributed Systems

Primary-Backup Replication

18-642: Time and Date

SETTING UP AN NTP SERVER AT THE ROYAL OBSERVATORY OF BELGIUM

Distributed Systems 11. Consensus. Paul Krzyzanowski

Selected Questions. Exam 2 Fall 2006

Configuring NTP. Information About NTP. This chapter contains the following sections:

18 Distributed Time. Distributed Embedded Systems Philip Koopman Nov. 9, Copyright , Philip Koopman

Timing in Packet Networks. Stefano RUffini 9 March 2015

Configuring NTP. Information About NTP. This chapter contains the following sections:

Experiment on Cristian s and Berkeley Time Synchronization Algorithms

Distributed Synchronization. EECS 591 Farnam Jahanian University of Michigan

Distributed Systems COMP 212. Revision 2 Othon Michail

SYNCHRONIZATION. DISTRIBUTED SYSTEMS Principles and Paradigms. Second Edition. Chapter 6 ANDREW S. TANENBAUM MAARTEN VAN STEEN

Transcription:

Distributed Systems Clock Synchronization: Physical Clocks Paul Krzyzanowski pxk@cs.rutgers.edu Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License. Page 1

What s it for? Temporal ordering of events produced by concurrent processes Synchronization between senders and receivers of messages Coordination of joint activity Serialization of concurrent access for shared objects Page 2

Physical clocks Page 3

Logical vs. physical clocks Logical clock keeps track of event ordering among related (causal) events Physical clocks keep time of day Consistent across systems Page 4

Quartz clocks 1880: Piezoelectric effect Curie brothers Squeeze a quartz crystal & it generates an electric field Apply an electric field and it bends 1929: Quartz crystal clock Resonator shaped like tuning fork Laser-trimmed to vibrate at 32,768 Hz Standard resonators accurate to 6 parts per million at 31 C Watch will gain/lose < ½ sec/day Stability > accuracy: stable to 2 sec/month Good resonator can have accuracy of 1 second in 10 years Frequency changes with age, temperature, and acceleration Page 5

Atomic clocks Second is defined as 9,192,631,770 periods of radiation corresponding to the transition between two hyperfine levels of cesium-133 Accuracy: better than 1 second in six million years NIST standard since 1960 Page 6

UTC UT0 Mean solar time on Greenwich meridian Obtained from astronomical observation UT1 UT0 corrected for polar motion UT2 UT1 corrected for seasonal variations in Earth s rotation UTC Civil time measured on an atomic time scale Page 7

UTC Coordinated Universal Time Temps Universel Coordonné Kept within 0.9 seconds of UT1 Atomic clocks cannot keep mean time Mean time is a measure of Earth s rotation Page 8

Physical clocks in computers Real-time Clock: CMOS clock (counter) circuit driven by a quartz oscillator battery backup to continue measuring time when power is off OS generally programs a timer circuit to generate an interrupt periodically e.g., 60, 100, 250, 1000 interrupts per second (Linux 2.6+ adjustable up to 1000 Hz) Programmable Interval Timer (PIT) Intel 8253, 8254 Interrupt service procedure adds 1 to a counter in memory Page 9

Problem Getting two systems to agree on time Two clocks hardly ever agree Quartz oscillators oscillate at slightly different frequencies Clocks tick at different rates Create ever-widening gap in perceived time Clock Drift Difference between two clocks at one point in time Clock Skew Page 10

8:00:00 8:00:00 Sept 18, 2006 8:00:00 Page 11

8:01:24 8:01:48 Skew = +84 seconds +84 seconds/35 days Drift = +2.4 sec/day Oct 23, 2006 8:00:00 Skew = +108 seconds +108 seconds/35 days Drift = +3.1 sec/day Page 12

Perfect clock Computer s time, C UTC time, t Page 13

Drift with slow clock Computer s time, C skew UTC time, t Page 14

Drift with fast clock Computer s time, C skew UTC time, t Page 15

Dealing with drift Assume we set computer to true time Not good idea to set clock back Illusion of time moving backwards can confuse message ordering and software development environments Page 16

Dealing with drift Go for gradual clock correction If fast: Make clock run slower until it synchronizes If slow: Make clock run faster until it synchronizes Page 17

Dealing with drift OS can do this: Change rate at which it requests interrupts e.g.: if system requests interrupts every 17 msec but clock is too slow: request interrupts at (e.g.) 15 msec Or software correction: redefine the interval Adjustment changes slope of system time: Linear compensating function Page 18

Compensating for a fast clock Computer s time, C skew Clock synchronized Linear compensating function applied UTC time, t Page 19

Computer s time, C Compensating for a fast clock UTC time, t Page 20

Resynchronizing After synchronization period is reached Resynchronize periodically Successive application of a second linear compensating function can bring us closer to true slope Keep track of adjustments and apply continuously e.g., UNIX adjtime system call Page 21

Getting accurate time Attach GPS receiver to each computer ± 1 msec of UTC Attach WWV radio receiver Obtain time broadcasts from Boulder or DC ± 3 msec of UTC (depending on distance) Attach GOES receiver ± 0.1 msec of UTC Not practical solution for every machine Cost, size, convenience, environment Page 22

Getting accurate time Synchronize from another machine One with a more accurate clock Machine/service that provides time information: Time server Page 23

RPC Simplest synchronization technique Issue RPC to obtain time Set time client what s the time? 3:42:19 server Does not account for network or processing latency Page 24

Cristian s algorithm Compensate for delays Note times: request sent: T 0 reply received: T 1 Assume network delays are symmetric server client T server request reply T 0 T 1 time Page 25

Cristian s algorithm Client sets time to: server request T server reply client T 0 T 1 time = estimated overhead in each direction Page 26

Error bounds If minimum message transit time (T min ) is known: Place bounds on accuracy of result Page 27

Error bounds server client request Earliest time message arrives reply T 0 T 1 T min T server T min range = T 1 -T 0-2T min accuracy of result = time Latest time message leaves Page 28

Cristian s algorithm: example Send request at 5:08:15.100 (T 0 ) Receive response at 5:08:15.900 (T 1 ) Response contains 5:09:25.300 (T server ) Elapsed time is T 1 -T 0 5:08:15.900-5:08:15.100 = 800 msec Best guess: timestamp was generated 400 msec ago Set time to T server + elapsed time 5:09:25.300 + 400 = 5:09.25.700 Page 29

Cristian s algorithm: example If best-case message time=200 msec server client T server request reply T 0 T 1 200 200 T 0 = 5:08:15.100 T 1 = 5:08:15.900 T s = 5:09:25:300 T min = 200msec time Error = 800 Page 30

Berkeley Algorithm Gusella & Zatti, 1989 Assumes no machine has an accurate time source Obtains average from participating computers Synchronizes all clocks to average Page 31

Berkeley Algorithm Machines run time dæmon Process that implements protocol One machine is elected (or designated) as the server (master) Others are slaves Page 32

Berkeley Algorithm Master polls each machine periodically Ask each machine for time Can use Cristian s algorithm to compensate for network latency When results are in, compute average Including master s time Hope: average cancels out individual clock s tendencies to run fast or slow Send offset by which each clock needs adjustment to each slave Avoids problems with network delays if we send a time stamp Page 33

Berkeley Algorithm Algorithm has provisions for ignoring readings from clocks whose skew is too great Compute a fault-tolerant average If master fails Any slave can take over Page 34

Berkeley Algorithm: example 3:00 2:50 3:25 2:50 9:10 1. Request timestamps from all slaves Page 35

Berkeley Algorithm: example 3:00 2:50 3:25 2:50 9:10 2. Compute fault-tolerant average: Page 36

Berkeley Algorithm: example 3:00 +0.15 +0:15 3:25 2:50 9:10 3. Send offset to each client Page 37

Network Time Protocol, NTP 1991, 1992 Internet Standard, version 3: RFC 1305 Page 38

NTP Goals Enable clients across Internet to be accurately synchronized to UTC despite message delays Use statistical techniques to filter data and gauge quality of results Provide reliable service Survive lengthy losses of connectivity Redundant paths Redundant servers Enable clients to synchronize frequently offset effects of clock drift Provide protection against interference Authenticate source of data Page 39

NTP servers Arranged in strata 1 st stratum: machines connected directly to accurate time source 2 nd stratum: machines synchronized from 1 st stratum machines 1 2 3 4 SYNCHRONIZATION SUBNET Page 40

NTP Synchronization Modes Multicast mode for high speed LANS Lower accuracy but efficient Procedure call mode Similar to Cristian s algorithm Symmetric mode Intended for master servers Pair of servers exchange messages and retain data to improve synchronization over time All messages delivered unreliably with UDP Page 41

NTP messages Procedure call and symmetric mode Messages exchanged in pairs NTP calculates: Offset for each pair of messages Estimate of offset between two clocks Delay Transmit time between two messages Filter Dispersion Estimate of error quality of results Based on accuracy of server s clock and consistency of network transit time Use this data to find preferred server: lower stratum & lowest total dispersion Page 42

NTP message structure Leap second indicator Last minute has 59, 60, 61 seconds Version number Mode (symmetric, unicast, broadcast) Stratum (1=primary reference, 2-15) Poll interval Maximum interval between 2 successive messages, nearest power of 2 Precision of local clock Nearest power of 2 Page 43

NTP message structure Root delay Total roundtrip delay to primary source (16 bits seconds, 16 bits decimal) Root dispersion Nominal error relative to primary source Reference clock ID Atomic, NIST dial-up, radio, LORAN-C navigation system, GOES, GPS, Reference timestamp Time at which clock was last set (64 bit) Authenticator (key ID, digest) Signature (ignored in SNTP) Page 44

NTP message structure T 1 : originate timestamp Time request departed client (client s time) T 2 : receive timestamp Time request arrived at server (server s time) T 3 : transmit timestamp Time request left server (server s time) Page 45

NTP s validation tests Timestamp provided last timestamp received duplicate message? Originating timestamp in message consistent with sent data Messages arriving in order? Timestamp within range? Originating and received timestamps 0? Authentication disabled? Else authenticate Peer clock is synchronized? Don t sync with clock of higher stratum # Reasonable data for delay & dispersion Page 46

SNTP Simple Network Time Protocol Based on Unicast mode of NTP Subset of NTP, not new protocol Operates in multicast or procedure call mode Recommended for environments where server is root node and client is leaf of synchronization subnet Root delay, root dispersion, reference timestamp ignored RFC 2030, October 1996 Page 47

SNTP server T 2 T 3 request reply client T 1 T 4 time Roundtrip delay: Time offset: d = (T 4 -T 1 ) - (T 2 -T 3 ) Page 48

SNTP example server T 2 =800 T 3 =850 client Offset = request reply time T 1 =1100 T 4 =1200 ((800-1100) + (850-1200))/2 =((-300) + (-350))/2 = -650/2 = -325 Time offset: Set time to T 4 + t = 1200-325 = 875 Page 49

Cristian s algorithm server client request T 1 =1100 T 2 =800 T s =825 T 3 =850 reply time T 4 =1200 Offset = (1200-1100)/2 = 50 Set time to T s + offset = 825 + 50 = 875 Page 50

Key Points: Physical Clocks Cristian s algorithm & SNTP Set clock from server But account for network delays Error: uncertainty due to network/processor latency: errors are additive ±10 msec and ±20 msec = ±30 msec. Adjust for local clock skew Linear compensating function Page 51

The end. Page 52