Lecture 10: Clocks and Time

Similar documents
Lecture 12: Time Distributed Systems

Distributed Systems COMP 212. Lecture 17 Othon Michail

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

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

Distributed Systems. Clock Synchronization: Physical Clocks. Paul Krzyzanowski


Clock-Synchronisation

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

Synchronization. Distributed Systems IT332

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

Time Synchronization and Logical Clocks

Time in Distributed Systems

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

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

Time Synchronization and Logical Clocks

CSE 5306 Distributed Systems. Synchronization

Last Class: Naming. DNS Implementation

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

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

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

CSE 5306 Distributed Systems

DISTRIBUTED REAL-TIME SYSTEMS

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

Chapter 6 Synchronization (1)

Distributed Coordination 1/39

Verteilte Systeme (Distributed Systems)

殷亚凤. Synchronization. Distributed Systems [6]

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

Synchronization. Clock Synchronization

Basic vs. Reliable Multicast

INTERNATIONAL JOURNAL OF ENGINEERING SCIENCES & RESEARCH TECHNOLOGY

Proseminar Distributed Systems Summer Semester Paxos algorithm. Stefan Resmerita

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

Distributed Systems COMP 212. Revision 2 Othon Michail

Selected Questions. Exam 2 Fall 2006

Ad hoc and Sensor Networks Time Synchronization

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

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

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

Time in Distributed Systems

OUTLINE. Introduction Clock synchronization Logical clocks Global state Mutual exclusion Election algorithms Deadlocks in distributed systems

TIME AND SYNCHRONIZATION. I. Physical Clock Synchronization: Motivation and Challenges

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

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

Experiment on Cristian s and Berkeley Time Synchronization Algorithms

System Models 2. Lecture - System Models 2 1. Areas for Discussion. Introduction. Introduction. System Models. The Modelling Process - General

2017 Paul Krzyzanowski 1

Chapter 6 Synchronization

Lecture 7: Logical Time

Implementing NTP. Release 3.8.0

Wireless Communication Bluetooth, Timing

Distributed Operating Systems. Distributed Synchronization

Chapter 6 Ti T me m s ynchronization

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

Byzantine Fault Tolerance and Consensus. Adi Seredinschi Distributed Programming Laboratory

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

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

Process groups and message ordering

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

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

Network Time Protocol

Distributed systems. Lecture 6: distributed transactions, elections, consensus and replication. Malte Schwarzkopf

Clock Synchronization

Distributed Systems Synchronization

Replication in Distributed Systems

The Flooding Time Synchronization Protocol

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

Time Handling in Programming Language

Synchronization. Chapter 5

CSE 486/586 Distributed Systems

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

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

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

DISTRIBUTED MUTEX. EE324 Lecture 11

Configuring Precision Time Protocol (PTP)

Distributed Systems. Day 7: Time and Snapshots [Part 1]

Distributed Systems. replication Johan Montelius ID2201. Distributed Systems ID2201

Table of Contents 1 NTP Configuration 1-1

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

Multi-threaded programming in Java

IEEE 1588 PTP clock synchronization over a WAN backbone

Operation Manual NTP. Table of Contents

THE TRANSPORT LAYER UNIT IV

Timing in Packet Networks. Stefano RUffini 9 March 2015

Coordination 1. To do. Mutual exclusion Election algorithms Next time: Global state. q q q

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

Frequently asked questions from the previous class survey

CS455: Introduction to Distributed Systems [Spring 2018] Dept. Of Computer Science, Colorado State University

Parallel and Distributed Systems. Programming Models. Why Parallel or Distributed Computing? What is a parallel computer?

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

Distributed Deadlock

Configuring NTP. Information About NTP NTP. This chapter describes how to configure the Network Time Protocol (NTP) on Cisco MDS 9000 Series switches.

Distributed Systems. coordination Johan Montelius ID2201. Distributed Systems ID2201

Practical Byzantine Fault

Time and Coordination in Distributed Systems. Operating Systems

Recent Work on OSC Timetags at CNMAT

HP 6125 Blade Switch Series

HP 6125G & 6125G/XG Blade Switches

Arranging lunch value of preserving the causal order. a: how about lunch? meet at 12? a: <receives b then c>: which is ok?

Introduction to Real-Time Communications. Real-Time and Embedded Systems (M) Lecture 15

Transcription:

06-06798 Distributed Systems Lecture 10: Clocks and Time Distributed Systems 1

Time service Overview requirements and problems sources of time Clock synchronisation algorithms clock skew & drift Cristian algorithm Berkeley algorithm Network Time Protocol Logical clocks Lamport s timestamps Distributed Systems 2

Why needed? Time service to measure delays between distributed components to synchronise streams, e.g. sound and video to establish event ordering causal ordering (did A happen before B?) concurrent/overlapping execution (no causal relationship) for accurate timestamps to identify/authenticate business transactions serializability in distributed databases security protocols Distributed Systems 3

Internal hardware clock built-in electronic device Clocks counts oscillations occurring in a quartz crystal at a definite frequency store the result in a counter register interrupt generated at regular intervals interrupt handler reads the counter register, scales it to convert to time units (seconds, nanoseconds) and updates software clock Distributed Systems 4

Clock skew and drift Clock skew difference between the readings of two clocks Clock drift Network difference in reading between a clock and a nominal perfect reference clock per unit of time of the reference clock typically 10-6 seconds/second = 1 sec in 11.6 days Distributed Systems 5

Sources of time Universal Coordinated Time (UTC, from French) based on atomic time but leap seconds inserted to keep in phase with astronomical time (Earth s orbit) UTC signals broadcast every second from radio and satellite stations land station accuracy 0.1-10ms due to atmospheric conditions Global Positioning System (GPS) broadcasts UTC Receivers for UTC and GPS available commercially used to synchronise local clocks Distributed Systems 6

Clock synchronisation External: synchronise with authoritative source of time the absolute value of difference between the clock and the source is bounded above by D at every point in the synchronisation interval time accurate to within D Internal: synchronise clocks with each other the absolute value of difference between the clocks is bounded above by D at every point in the synchronisation interval clocks agree to within D (not necessarily accurate time) Distributed Systems 7

Clock compensation Assume 2 clocks can each drift at rate R msecs/sec maximum difference 2R msecs/sec must resynchronise every D/2R to agree within D Clock correction get UTC and correct software clock Problems! what happens if local clock is 5 secs fast and it is set right? timestamped versions of files get confused time must never run backwards! better to scale the value of internal clock in software without changing the clock rate Distributed Systems 8

Synchronisation methods Synchronous systems simpler, relies on known time bounds on system actions Asynchronous systems intranets Cristian s algorithm Berkeley algorithm Internet The Network Time Protocol Distributed Systems 9

Synchronous systems case Internal synchronisation between two processes know bounds MIN, MAX on message delay also on clock drift, execution rate Assume One sends message to Two with time t Two can set its clock to t + (MAX+MIN)/2 (estimate of time taken to send message) then the skew is at most (MAX-MIN)/2 why not t + MIN or t + MAX? maximum skew is larger, could be MAX-MIN Distributed Systems 10

Cristian s algorithm T0 T1 Client Request UTC Time Time server h = interrupt handler time Time Server with UTC receiver gives accurate current time Estimate message propagation time by p=(t 1 -T 0 -h)/2 (=half of round-trip of request-reply) Set clock to UTC+p Make multiple requests, at spaced out intervals, measure T 1 -T 0 but discard any that are over a threshold (could be congestion) or take minimum values as the most accurate Distributed Systems 11

Cristian s algorithm Probabilistic behaviour achieves synchronisation only if round-trip short compared to required accuracy high accuracy only for message transmission time close to minimum Problems single point of failure and bottleneck could multicast to a group of servers, each with UTC an impostor or faulty server can wreak havoc use authentication agreement protocol for N > 3f clocks, f number of faulty clocks Distributed Systems 12

The Berkeley algorithm Choose master co-ordinator which periodically polls slaves Master estimates slaves local time based on round-trip Calculates average time of all, ignoring readings with exceptionally large propagation delay or clocks out of synch Sends message to each slave indicating clock adjustment 3:00:00 0 +5 3:00:00 3:00:01 3:00:02 3:00:00 3:00:00-10 +25 +15-20 2:59:50 3:00:25 2:59:51 3:00:26 2:59:52 3:00:27 Query Response Adjust Synchronisation feasible to within 20-25 msec for 15 computers, with drift rate of 2 x 10-5 and max round trip propagation time of 10 msec. Distributed Systems 13

The Berkeley algorithm Accuracy depends on the round-trip time Fault-tolerant average: eliminates readings of faulty clocks - probabilistically average over the subset of clocks that differ by up to a specified amount What if master fails? elect another leader Distributed Systems 14

Network Time Protocol (NTP) Multiple time servers across the Internet Primary servers: directly connected to UTC receivers Secondary servers: synchronise with primaries Tertiary servers: synchronise with secondary, etc Scales up to large numbers of servers and clients 1 2 2 3 3 3 = active synchronisation = backup synchronisation (exchange timing information, but do not use it to synchronise clocks) Copes with failures of servers e.g. if primary s UTC source fails it becomes a secondary, or if a secondary cannot reach a primary it finds another one. Authentication used to check that time comes from trusted sources Distributed Systems 15

NTP Synchronisation Modes Multicast one or more servers periodically multicast to other servers on high speed LAN they set clocks assuming small delay Procedure Call Mode similar to Cristian s algorithm: client requests time from a few other servers used for higher accuracy or where no multicast Symmetric protocol used by master servers on LANs and layers closest to primaries highest accuracy, based on pairwise synchronisation Distributed Systems 16

Logical time For many purposes it is sufficient to agree on the same time (e.g. internal consistency) which need not be UTC time Can deduce causal event ordering a b (a occurs before b) Logical time denotes causal relationships but the relationship may not reflect real causality, only accidental Distributed Systems 17

Event ordering Define a b (a occurs before b) if a and b are events in the same process and a occurs before b, or a is the event of message sent from process A and B is the event of message receipt by process B If a b and b c then a c. is partial order. For events such that neither a b nor b a we say a, b are concurrent, denoted a b. Distributed Systems 18

Example of causal ordering p 1 a b m 1 p 2 c d m 2 Physical time p 3 e a b, c d b c, d f a e f Distributed Systems 19

Logical clocks [Lamport] Logical clock = monotonically increasing software counter (not real time!) one for each process P, used for timestamping How it works L P incremented before assigning a timestamp to an event when P sends message m, P timestamps it with current value t of L P (after incrementing it), piggybacking t with m on receiving message (m,t), Q sets its own clock L Q to maximum of L Q and t, then increments L Q before timestamping the message receive event Note a b implies T(a) < T(b) Distributed Systems 20 What about converse?

Totally ordered logical clocks 1 2 p 1 a b m 1 p 2 3 4 c d m 2 Physical time p 3 1 e Problem: T(a) = T(e), and yet a, e distinct. Create total order by taking account of process ids. Then (T(a),pid) < (T(b),qid) iff T(a) < T(b) or T(a)=T(b) and pid < qid. Distributed Systems 21 f 5

Vector clocks Totally ordered logical clocks arbitrary event order, depends on order of process ids i.e. (T(a),pid) < (T(b),qid) does not imply a b, see a, e Vector clocks array of N logical clocks in each process, if N processes vector timestamps piggybacked on the messages rules for incrementing similar to Lamport s, except processes own component in array modified componentwise maximum and comparison Problems storage requirements Distributed Systems 22

Vector timestamps (1,0,0) (2,0,0) p 1 a b m 1 p 2 (2,1,0) (2,2,0) c d m 2 Physical time p 3 (0,0,1) e f (2,2,2) VT(b) < VT(c), hence b c neither VT(b) < VT(e), nor VT(b) < VT(e), hence b e Distributed Systems 23

Summary Local clocks drift! but needed for timestamping Synchronisation algorithms must handle variable message delays Clock compensation estimate average delays adjust clocks can deal with faulty clocks Logical clocks sufficient for causal ordering Distributed Systems 24