NTP Network Time Protocol Nóirín Plunkett Network Time Protocol Nóirín Plunkett.

Slides:



Advertisements
Similar presentations
Synchronization.
Advertisements

Time in Distributed Systems
HIERARCHY REFERENCING TIME SYNCHRONIZATION PROTOCOL Prepared by : Sunny Kr. Lohani, Roll – 16 Sem – 7, Dept. of Comp. Sc. & Engg.
IED Time Synchronization John Levine, P.E. Levine Lectronics and Lectric.
Time and Clock Primary standard = rotation of earth De facto primary standard = atomic clock (1 atomic second = 9,192,631,770 orbital transitions of Cesium.
CS6223: Distributed Systems Distributed Time and Clock Synchronization (1) Physical Time.
Computer Science 425 Distributed Systems CS 425 / ECE 428  2013, I. Gupta, K. Nahrtstedt, S. Mitra, N. Vaidya, M. T. Harandi, J. Hou.
L-8 Synchronizing Physical Clocks 1 Announcements Proj1 checkpoint – due midnight tonight HW1 checkpoint – due 2/12 2.
Time in Embedded and Real Time Systems Lecture #6 David Andrews
Distributed Systems Fall 2010 Time and synchronization.
Network Time Protocol - NTP Speaker: Cheng-lin Tsai.
Teaching material based on Distributed Systems: Concepts and Design, Edition 3, Addison-Wesley Copyright © George Coulouris, Jean Dollimore, Tim.
Time and Global States Chapter 11. Why time? Time is an Important and interesting issue in distributes systems. One we can measure accurately. Can use.
Time in Distributed Systems Distributed Systems. Why Time is Important? If you work in the industry, you never have to worry about this You’ll rarely.
SynchronizationCS-4513, D-Term Synchronization in Distributed Systems CS-4513 D-Term 2007 (Slides include materials from Operating System Concepts,
Lecture 13 Synchronization (cont). EECE 411: Design of Distributed Software Applications Logistics Last quiz Max: 69 / Median: 52 / Min: 24 In a box outside.
Synchronization in Distributed Systems CS-4513 D-term Synchronization in Distributed Systems CS-4513 Distributed Computing Systems (Slides include.
Lecture 12 Synchronization. EECE 411: Design of Distributed Software Applications Summary so far … A distributed system is: a collection of independent.
Lecture 9: Time & Clocks CDK4: Sections 11.1 – 11.4 CDK5: Sections 14.1 – 14.4 TVS: Sections 6.1 – 6.2 Topics: Synchronization Logical time (Lamport) Vector.
1 Synchronization Part 1 REK’s adaptation of Claypool’s adaptation of Tanenbaum’s Distributed Systems Chapter 5.
Physical Clocks.
Lecture 2-1 CS 425/ECE 428 Distributed Systems Lecture 2 Time & Synchronization Reading: Klara Nahrstedt.
1 Physical Clocks need for time in distributed systems physical clocks and their problems synchronizing physical clocks u coordinated universal time (UTC)
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Jennifer Rexford Fall 2014 (TTh 3:00-4:20 in CS 105) COS 561: Advanced Computer Networks Locations.
Enhanced NTP IETF – TicToc BOF Greg Dowd – Jeremy Bennington –
A Security Analysis of the Network Time Protocol (NTP) Presentation by Tianen Liu.
A Security Analysis of Network Time Protocol Andy Hospodor COEN /03/03 Paper by Matt Bishop, 1991.
Traceability and Legal Metrology
Parallel and Distributed Simulation Synchronizing Wallclock Time.
Communication & Synchronization Why do processes communicate in DS? –To exchange messages –To synchronize processes Why do processes synchronize in DS?
Distributed Systems Principles and Paradigms Chapter 05 Synchronization.
Lecture 9: Time and clocks (Chap 11) Haibin Zhu, PhD. Assistant Professor Department of Computer Science Nipissing University © 2002.
Time This powerpoint presentation has been adapted from: 1) sApr20.ppt.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
Synchronization CSCI 4900/6900. Importance of Clocks & Synchronization Avoiding simultaneous access of resources –Cooperate to grant exclusive access.
Physical clock synchronization Question 1. Why is physical clock synchronization important? Question 2. With the price of atomic clocks or GPS coming down,
Time and global states Chapter 11. Outline Introduction Clocks, events and process states Synchronizing physical clocks Logical time and logical clocks.
Distributed Systems CS Synchronization – Part I Lecture 8, Sep 23, 2013 Mohammad Hammoud.
6 SYNCHRONIZATION. introduction processes synchronize –exclusive access. –agree on the ordering of events much more difficult compared to synchronization.
Hwajung Lee. Primary standard = rotation of earth De facto primary standard = atomic clock (1 atomic second = 9,192,631,770 orbital transitions of Cesium.
Computer Network Design EEL 6785 Dr. Janusz Zalewski University of Central Florida.
Distributed Systems Lecture 5 Time and synchronization 1.
Page 1 Clock Synchronization: Physical Clocks Minqi Zhou Distributed Systems Except as otherwise noted, the content of this presentation.
Distributed Web Systems Time and Global State Lecturer Department University.
Proof of liveness: an example
Distributed Computing
Distributed Systems CS
Infrastructure II NTP.
Lecture 5 Time and synchronization
Net 435: Wireless sensor network (WSN)
Time and Clock.
Logical time (Lamport)
Clock Synchronization: Physical Clocks
Presentation by Wyatt Zacharias
Distributed Systems CS
Time and Clock.
DISTRIBUTED SYSTEMS Principles and Paradigms Second Edition ANDREW S
Distributed Systems CS
Physical clock synchronization
CDK: Sections 11.1 – 11.4 TVS: Sections 6.1 – 6.2
Distributed Synchronization
NTP Architecture, Protocol and Algorithms
Logical time (Lamport)
Logical time (Lamport)
What’s the Time? Geoff Huston APNIC.
What’s the Time? Geoff Huston APNIC.
CSE 486/586 Distributed Systems Time and Synchronization
Logical time (Lamport)
Presentation transcript:

NTP Network Time Protocol Nóirín Plunkett Network Time Protocol Nóirín Plunkett

A Short French Lesson  TAI – Temps Atomique International  International Atomic Time  UTC – Temps Universel Coordonné  Universal Co-ordinated Time  BIH – Bureau International de l’Heure  International Time Bureau  TAI – Temps Atomique International  International Atomic Time  UTC – Temps Universel Coordonné  Universal Co-ordinated Time  BIH – Bureau International de l’Heure  International Time Bureau

Second  SI Unit  9,192,631,770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium-133 atom  SI Unit  9,192,631,770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the caesium-133 atom

Brief History of Time  Second defined in 1967  UTC started on 1st January 1972  RFC 778, Internet Clock Service  RFC 958, description of NTP  RFC 1059, NTPv1, protocol & algorithms  RFC 1305, NTPv3, formal correctness principles  NTPv4 in use, not yet formalised  Second defined in 1967  UTC started on 1st January 1972  RFC 778, Internet Clock Service  RFC 958, description of NTP  RFC 1059, NTPv1, protocol & algorithms  RFC 1305, NTPv3, formal correctness principles  NTPv4 in use, not yet formalised

Real World  “ Time is what prevents everything from happening at once. ” - J.A. Wheeler  Correlating logs of events  Cryptographic expiries  Air Traffic Control  GPS  Networking  “ Time is what prevents everything from happening at once. ” - J.A. Wheeler  Correlating logs of events  Cryptographic expiries  Air Traffic Control  GPS  Networking

Atomic Time  260 atomic clocks in 40 labs contribute to the international time standards contribute to TAI  Radio broadcasts  DCF77, Physikalisch-Technische Bundesanstalt, Braunschweig (77.5kHz)  GPS based on US Naval Observatory, DC  260 atomic clocks in 40 labs contribute to the international time standards contribute to TAI  Radio broadcasts  DCF77, Physikalisch-Technische Bundesanstalt, Braunschweig (77.5kHz)  GPS based on US Naval Observatory, DC

NTP and UTC  NTP is based on UTC  NTP has no memory  Every leap-second, NTP ‘resets’ itself to the current UTC value  Using a clock synchronised to UTC in 2005 to calculate the time of an event in early 1972 would result in 22 seconds difference  NTP is based on UTC  NTP has no memory  Every leap-second, NTP ‘resets’ itself to the current UTC value  Using a clock synchronised to UTC in 2005 to calculate the time of an event in early 1972 would result in 22 seconds difference

What NTP Does Provide most accurate time possible, based on ‘reference time’ - not just syncing to a common time Keep in sync with leap seconds Ignore ‘falsetickers’ - clocks it could use for reference, but which provide an apparently wrong time Use previous figures to estimate current difference between system time and reference time, in the absence of a network connection Provide most accurate time possible, based on ‘reference time’ - not just syncing to a common time Keep in sync with leap seconds Ignore ‘falsetickers’ - clocks it could use for reference, but which provide an apparently wrong time Use previous figures to estimate current difference between system time and reference time, in the absence of a network connection

What NTP Does Not  Convert NTP timestamps into system time format  Set the hardware clock  Handle time-zones/summer time  Recognise when the system clock is far off and accept apparent ‘falsetickers’ as true  Convert NTP timestamps into system time format  Set the hardware clock  Handle time-zones/summer time  Recognise when the system clock is far off and accept apparent ‘falsetickers’ as true

Some Definitions  Reference clock - a device which gives a known accurate time  Accuracy - the difference between the value of a measurement and the actual measurand  Precision - how close two measurements of the same value are  Reference clock - a device which gives a known accurate time  Accuracy - the difference between the value of a measurement and the actual measurand  Precision - how close two measurements of the same value are

Precision vs Accuracy  Exp I - Imprecise, inaccurate  Exp II - Imprecise, accurate  Exp III - Precise, inaccurate  Exp IV - Precise, accurate (image source)image source

NTP Packet  UDP Packet  Request  Time of client system clock at sending  Response  Time of client system clock at sending  Time of receipt at server  Time of server system clock at sending  UDP Packet  Request  Time of client system clock at sending  Response  Time of client system clock at sending  Time of receipt at server  Time of server system clock at sending

NTP Timestamp  64-bit number  First 32 bits represent seconds since 00:00, January 1st, 1900  Next 32 bits represent fractions of a second  Sat, Nov :27:  c729fb22.de8afc9d   64-bit number  First 32 bits represent seconds since 00:00, January 1st, 1900  Next 32 bits represent fractions of a second  Sat, Nov :27:  c729fb22.de8afc9d 

More Definitions  Latency - the time taken for a packet to reach its destination  Round trip time - the time taken between the client sending out a packet, and receiving a response to that packet from the server  Jitter - variability of latency over time  Latency - the time taken for a packet to reach its destination  Round trip time - the time taken between the client sending out a packet, and receiving a response to that packet from the server  Jitter - variability of latency over time

Timestamps in Packets  Client sends packet - T 1  Server receives packet, adds receipt timestamp - T 2  Server prepares packet to send to client, adds sending timestamp - T 3  Client receives packet - T 4  Latency client -> server = (T 2 -T 1 )  Latency server -> client = (T 4 -T 3 )  Client sends packet - T 1  Server receives packet, adds receipt timestamp - T 2  Server prepares packet to send to client, adds sending timestamp - T 3  Client receives packet - T 4  Latency client -> server = (T 2 -T 1 )  Latency server -> client = (T 4 -T 3 )

Round Trip Times  Actual RTT = (T 4 -T 1 )  Network RTT = (T 2 -T 1 ) + (T 4 -T 3 )  Latencies = (T 2 -T 1 ), (T 4 -T 3 )  If latencies are symmetric (within reason), (T 1 +T 4 ) = (T 2 +T 3 )  If (T 1 +T 4 ) != (T 2 +T 3 ), our estimate of clock offset is (T 1 +T 4 ) - (T 2 +T 3 )  Actual RTT = (T 4 -T 1 )  Network RTT = (T 2 -T 1 ) + (T 4 -T 3 )  Latencies = (T 2 -T 1 ), (T 4 -T 3 )  If latencies are symmetric (within reason), (T 1 +T 4 ) = (T 2 +T 3 )  If (T 1 +T 4 ) != (T 2 +T 3 ), our estimate of clock offset is (T 1 +T 4 ) - (T 2 +T 3 )

Truechimers & Falsetickers  Multiple servers providing time estimates  If the majority of servers provide a consistent time - they’re probably right  If there are one or two outliers - they’re probably wrong  Multiple servers providing time estimates  If the majority of servers provide a consistent time - they’re probably right  If there are one or two outliers - they’re probably wrong

Peering  Client should peer with multiple servers (image source)image source

Law of Averages  Peering with multiple servers makes for more reliable results  Falsetickers will be easier to identify  Truechimers will be more useful (because more servers means we can dismiss borderline true/false)  Assumptions become statistically more reliable  Latency symmetry  Clock regularity  Peering with multiple servers makes for more reliable results  Falsetickers will be easier to identify  Truechimers will be more useful (because more servers means we can dismiss borderline true/false)  Assumptions become statistically more reliable  Latency symmetry  Clock regularity

Problems with Peering  Loops  NTP prevents loops, through spanning-tree mechanism  Layers  NTP prevents there being more than fourteen layers, by using strata  Loops  NTP prevents loops, through spanning-tree mechanism  Layers  NTP prevents there being more than fourteen layers, by using strata

Strata  Radio clock - Stratum 0  Computer running NTP syncing from radio clock - Stratum 1  Computer syncing from Stratum n NTP server - Stratum n+1  Server unreachable - Stratum 16  Radio clock - Stratum 0  Computer running NTP syncing from radio clock - Stratum 1  Computer syncing from Stratum n NTP server - Stratum n+1  Server unreachable - Stratum 16

Lies, Damn Lies  NTP checks that values are consistent with previous measurements  Deals with sudden changes in network/system load  Allows NTP to ‘guess’, in case of network failure  If values are very different from previously, but remain consistent, NTP accepts that local clock may be falseticker  NTP checks that values are consistent with previous measurements  Deals with sudden changes in network/system load  Allows NTP to ‘guess’, in case of network failure  If values are very different from previously, but remain consistent, NTP accepts that local clock may be falseticker

Clocks  Hardware clock - quartz crystal  Software clock - interrupt-driven timer chips  Software clock more accurate for judging interval between two times  Both need to be set to correct time  Hardware clock - quartz crystal  Software clock - interrupt-driven timer chips  Software clock more accurate for judging interval between two times  Both need to be set to correct time

Problems  Inaccurate time needs to be corrected  Massive time changes are undesirable  Time travel is undesirable  Skipping seconds is bad  Going backwards is not allowed  Best way of balancing all this is to slow down/speed up time  This only works with computers, and in the movies!  Inaccurate time needs to be corrected  Massive time changes are undesirable  Time travel is undesirable  Skipping seconds is bad  Going backwards is not allowed  Best way of balancing all this is to slow down/speed up time  This only works with computers, and in the movies!

Exceptions  On system boot-up, time can be set, regardless of offset from previous time  init scripts are aware of this, bootup expects it, nothing should break  Computers do what they’re told - regardless of what the admin intended  If an admin tells the system to update its time, it updates. Things may break.  On system boot-up, time can be set, regardless of offset from previous time  init scripts are aware of this, bootup expects it, nothing should break  Computers do what they’re told - regardless of what the admin intended  If an admin tells the system to update its time, it updates. Things may break.

Phase Lock Loops  Raises (or lowers) frequency of an oscillator until it matches a reference frequency  Pauses oscillator as necessary to match ref. phase  Raises (or lowers) frequency of an oscillator until it matches a reference frequency  Pauses oscillator as necessary to match ref. phase

More on PLL  Seconds can be speeded up or slowed down, until they happen as often as reference clock - frequency is matched  NTP can also use this speed change to match the phase - some PLLs will stop the oscillator momentarily to do this  Seconds can be speeded up or slowed down, until they happen as often as reference clock - frequency is matched  NTP can also use this speed change to match the phase - some PLLs will stop the oscillator momentarily to do this

NTP Traffic  ntp.maths.tcd.ie  Stratum 1 server, syncing from radio clock  ntp.maths.tcd.ie  Stratum 1 server, syncing from radio clock

Daily Peak  Graph dates from IST - blip occurring at 1am local time

After IST Ends  Peak remains - still at midnight GMT

Daylight Savings Time  NTP is time-zone agnostic

Daylight Savings Time Ends  2005-W Daylight Savings Time ends

Strange Happenings

References  RFC 1305    ntp.maths.tcd.ie ntp.maths.tcd.ie  RFC 1305    ntp.maths.tcd.ie ntp.maths.tcd.ie