Clock Synchronisation for RTS Dr Hugh Melvin Dept

  • Slides: 41
Download presentation
Clock Synchronisation for RTS Dr. Hugh Melvin, Dept. of IT, NUI, G 1

Clock Synchronisation for RTS Dr. Hugh Melvin, Dept. of IT, NUI, G 1

Importance of RTS Clocks • Real. Time implies need for accurate timekeeping • Examples

Importance of RTS Clocks • Real. Time implies need for accurate timekeeping • Examples – Hard RTS • Distributed Control Systems • Power System / Fly-by-wire – Soft/Firm RTS • TDM within GSM/POTS – POTS : SONET/SDH » Synchronous Opt. Network /Synch. Digital Hierarchy • MM applications Dr. Hugh Melvin, Dept. of IT, NUI, G 2

Power System Control • AS station – Token Bus Synchronisation via Master Clock •

Power System Control • AS station – Token Bus Synchronisation via Master Clock • Critical for chronological data logging / fault diagnosis – Timeslicing for token management – Synchronising 2 v 3 voter systems • Need to deliver verdicts simultaneously • Fault Diagnosis – Impossible without Chronological Data • Generator Earth Fault / Overcurrent. . – Which came first. . msec level data required • Power Line Fault Monitoring – Noise burst travels in both directions. . usec level synch Dr. Hugh Melvin, Dept. of IT, NUI, G 3

Token Bus : Master Clock U/IA U/IB U/IA 125 N 16 R 30 U/IA

Token Bus : Master Clock U/IA U/IB U/IA 125 N 16 R 30 U/IA U/IB 103 N 8 AS 220 E 102 N 8 AS 220 E 101 N 8 AS 220 E U/IA U/IB 123 N-UHR M-Clock U/IA 141 NAT-24 Synogate U/IA Master Clock 127 N-BK Bus 1 126 N-BK Bus 0 U/IB U/IA U/IB 104 N 8 AS 220 E 105 N 8 AS 220 E U/IB U/IA 121 N 16 OS 254 U/IA U/IB 160 NS 5 NAT PG 750 U/IB 106 N 8 AS 220 E U/IB 112 N 8 AS 220 E U/IA U/IB 133 N 8 AS EHF Dr. Hugh Melvin, Dept. of IT, NUI, G U/IA U/IB 107 N 8 AS 220 E U/IB 111 N 8 AS 220 E U/IA U/IB 132 N 8 AS EHF U/IA U/IB 108 N 8 AS 220 E U/IB 110 N 8 AS 220 E U/IA U/IB 131 N 8 AS EHF U/IA U/IB 109 N 8 AS 220 E U/IA U/IB 128 N 8 AS 231 4

Soft-Firm RTS • POTS operation based on TDM – PCM E 1 E 2.

Soft-Firm RTS • POTS operation based on TDM – PCM E 1 E 2. . E 4 SDH/SONET – Precise synchronisation reqd throughout the network for correct system operation • GSM : FDM + TDM – Each FDM channel divided out to 8 users via TDM • Multimedia Applications – Delay / Jitter Measurement increasingly imp in packet (IP) networks – More advanced Qo. S through synchronised time • Recall G. 1010 – Basis of SLA measurement important – Skew Issues between various system/media clocks Dr. Hugh Melvin, Dept. of IT, NUI, G 5

Dr. Hugh Melvin, Dept. of IT, NUI, G 6

Dr. Hugh Melvin, Dept. of IT, NUI, G 6

Dr. Hugh Melvin, Dept. of IT, NUI, G 7

Dr. Hugh Melvin, Dept. of IT, NUI, G 7

Audio-System Clock Skew Dr. Hugh Melvin, Dept. of IT, NUI, G 8

Audio-System Clock Skew Dr. Hugh Melvin, Dept. of IT, NUI, G 8

Computer Clocks • Most commonly consist of quartz crystal and a counter • Crystal

Computer Clocks • Most commonly consist of quartz crystal and a counter • Crystal oscillates at defined rate (Hz) which generates a consistent tick and increments a software counter • Counter value translated to time standard – UTC (Univ. Coord. Time). . Based on GMT • Primary Source: Atomic Clocks TAI (International Atomic Time) – But requires leap seconds every few years! – UTC = TAI + Leap_Seconds • Crystal Quality described by Accuracy & Stability Dr. Hugh Melvin, Dept. of IT, NUI, G 9

Computer Clocks • Accuracy relates to how close the crystal freq is to rated

Computer Clocks • Accuracy relates to how close the crystal freq is to rated value – Determined by manufacturing process • Get what you pay for! • Stability relates to how frequency varies – Influenced by parameters such as: • Temperature. . Eg. 2 ppm /C • Ageing – Eg. Cesium Beam: 3 x 10 -12 / year • Noise Dr. Hugh Melvin, Dept. of IT, NUI, G 10

Computer Clocks • Improved Quality Timekeeping ? – Option A: Stick with crystals •

Computer Clocks • Improved Quality Timekeeping ? – Option A: Stick with crystals • Precision manufacturing costly • Temperature Compensated Crystal Osc. (TCXO) • Oven Controlled Crystal Osc. (OCXO) – Option B : • Buy an Atomic Clock –. . or GPS Receiver (based on atomic clock) • Most popular approach to providing accurate/stable time – Option C : Cheaper Approach • Software based approach to discipline cheap crystal clocks Dr. Hugh Melvin, Dept. of IT, NUI, G 11

Clock Terminology • Confusion with terms in literature – Paxson/Mills terminology used here –

Clock Terminology • Confusion with terms in literature – Paxson/Mills terminology used here – Offset • Difference between time reported by clock C, C(t) and true clock (UTC) at true time t. • Also relative offset between clocks C 1 and C 2 – C 1(t) - C 2(t) – Skew • Difference in frequency between clock C and a true clock (UTC) , C’(t) • Defined in ppm (usec per sec) • +/-12 ppm approx = +/- 1 sec/day • Also relative skew between clocks C 1 and C 2 – C 1’(t) - C 2’(t) Dr. Hugh Melvin, Dept. of IT, NUI, G 12

Dr. Hugh Melvin, Dept. of IT, NUI, G 13

Dr. Hugh Melvin, Dept. of IT, NUI, G 13

Clock Terminology • Skew – A large skew rate rapidly increasing offset frequent resynchronisation

Clock Terminology • Skew – A large skew rate rapidly increasing offset frequent resynchronisation – If specify max abs skew rate for clock C of – Clock should operate within cone of acceptability • Drift – Rate of change of frequency C’’(t) • Eg. Ageing influence or change in temperature – Not usually that significant except over long timescales – Note linear relationship in previous slide Dr. Hugh Melvin, Dept. of IT, NUI, G 14

Cone of Acceptability Slope = 1 + Slope = 1 = True Clock Time

Cone of Acceptability Slope = 1 + Slope = 1 = True Clock Time Slope = 1 - Real Time Dr. Hugh Melvin, Dept. of IT, NUI, G 15

Clock Synchronisation • Perfect clocks do not exist • Eg. PC System Clock NTP

Clock Synchronisation • Perfect clocks do not exist • Eg. PC System Clock NTP Server GPS Receiver GPS Atomic Clock GPS Master Atomic Clock ? ? • Examine two separate scenarios • Localised Cluster of Clocks – Eg. Power System Control / Fly-by-wire Systems – Also widely distributed clocks over deterministic network » Propagation time known (can be compensated for) » Eg. POTS • Widely distributed clocks over non-deterministic network – More difficult scenario – Eg. Internet Synchronisation Dr. Hugh Melvin, Dept. of IT, NUI, G 16

Clock Synchronisation • Some General Principles – Fault Tolerance critical • Identify and isolate

Clock Synchronisation • Some General Principles – Fault Tolerance critical • Identify and isolate faulty clocks • Note: A faulty clock is one that does not operate within cone of acceptability – Cf Clock Quality: May be stable but inaccurate – Avoid setting clocks backward – Event processing nightmare – OS problems eg. Timers / timeslicing – Avoid large step changes • Amortize the required change (+/-) over a series of short intervals (eg. over multiple ticks) Dr. Hugh Melvin, Dept. of IT, NUI, G 17

Localised Cluster of Clocks • Hardware-based Phase Locked Loops (PLL) – Oscillator output is

Localised Cluster of Clocks • Hardware-based Phase Locked Loops (PLL) – Oscillator output is aligned to the input signal. – Input signal can come from a • Master Clock • Combination of outputs from all other clocks – Input signal used to drive its PLL – Can also compensate for Propagation Delay variations – Expensive but precise approach • Similar approach used in widely distributed scenario – GPS / POTS / GSM all use variants of this approach Dr. Hugh Melvin, Dept. of IT, NUI, G 18

PLL Input Signal Comparator VCO = Voltage Controlled Oscillator Freq controlled by applied input

PLL Input Signal Comparator VCO = Voltage Controlled Oscillator Freq controlled by applied input voltage Dr. Hugh Melvin, Dept. of IT, NUI, G 19

Widely Distributed Clocks • More difficult environment if underlying network non deterministic • Expense

Widely Distributed Clocks • More difficult environment if underlying network non deterministic • Expense of hardware based approach cannot be justified for many Soft-Firm RTS • Cheap software based approach – Network Time Protocol (NTP) – RFC 1305 (www. ietf. org) Dr. Hugh Melvin, Dept. of IT, NUI, G 20

Clock Synchronisation : NTP • Network Time Protocol (NTP) synchronises clocks of hosts and

Clock Synchronisation : NTP • Network Time Protocol (NTP) synchronises clocks of hosts and routers in the Internet • Increasingly deployed in the Internet – Increased need for time synchronisation – Facilitated via always-on Internet connection • Provides nominal accuracies of low milliseconds on WANs, submilliseconds on LANs, and submicroseconds on workstations using a precision time source such as a cesium oscillator or GPS receiver • Unix-based NTP daemon now ported to most OS Dr. Hugh Melvin, Dept. of IT, NUI, G 21

NTP The NTP architecture, protocol and algorithms have evolved over the last twenty years

NTP The NTP architecture, protocol and algorithms have evolved over the last twenty years to the latest NTP Version 4 • Internet standard protocol for time synchronisation and coordinated time distribution using UTC • Fault tolerant protocol – automatically selects the best of several available time sources to synchronise with • Highly scalable – nodes form a hierarchical structure with reference clock(s) at the top – Stratum 0: Time Reference Source • GPS / GOES (Geo. Sat) / LORC (Loran. C) / ATOM / DTS – Stratum 1: Primary Time Server Dr. Hugh Melvin, Dept. of IT, NUI, G 22

Dr. Hugh Melvin, Dept. of IT, NUI, G 23

Dr. Hugh Melvin, Dept. of IT, NUI, G 23

NTP Operation Peer 1 Filter 1 Peer 2 Filter 2 Peer 3 Filter 3

NTP Operation Peer 1 Filter 1 Peer 2 Filter 2 Peer 3 Filter 3 Intersection and Clustering Algorithms Combining Algorithm Loop Filter P/F-Lock Loop VFO NTP Messages • Complex Software comprising various algorithms • Filtering Alg. • Clustering and Intersection Alg. • Combining Alg. • Clock Discipline Dr. Hugh Melvin, Dept. of IT, NUI, G 24

Client Server Mode • UDP/IP packets for data transfer – Several packet exchanges between

Client Server Mode • UDP/IP packets for data transfer – Several packet exchanges between client/server – Client • originate timestamp A within packet being sent. – Server receives such a packet: • receive timestamp B • transmit timestamp C – Client • Processes A, B, C as well as final packet arrival D • Determine offset and Round Trip Delay (RTD) • Note: RTD != RTT Dr. Hugh Melvin, Dept. of IT, NUI, G 26

NTP Operation B 3. 59. 020 C 3. 59. 022 15 ms A 3.

NTP Operation B 3. 59. 020 C 3. 59. 022 15 ms A 3. 59. 000 15 ms D 3. 59. 032 Symmetric Network : 15 ms each way (actual delay) RTD = (D - A) – (C – B) = 32 – 2 = 30 msec (RTT =? ) Offset = ½[(B-A) - (D-C)] = (20 – 10)/2 = 5 ms Dr. Hugh Melvin, Dept. of IT, NUI, G 27

Clock Discipline • Recall – No time reversal! – Avoid step changes • Hybrid

Clock Discipline • Recall – No time reversal! – Avoid step changes • Hybrid phase/frequency-lock (PLL/FLL) feedback loop • PLL/FLL Mode: Depends on polling interval Dr. Hugh Melvin, Dept. of IT, NUI, G 35

Clock Models • Unix Clock Model • settimeofday( ), adjtime( ) • Kernel variables

Clock Models • Unix Clock Model • settimeofday( ), adjtime( ) • Kernel variables tick , tickadj • adjtime adjusts clock every tick – Can amortise reqd change gradually by making adjustment every tick eg. every 10 msec – Note: Newer Unix/Linux kernels 1000 Hz 1 msec • 3 clock rates – Normal rate. . Add 10 msec every tick (100 Hz) – Normal Rate +/- tickadj – Eg. If tickadj = 5 us Normal Rate +/- 500 ppm Dr. Hugh Melvin, Dept. of IT, NUI, G 37

NTP Operation • NTP adjusts every sec via adjtime – Eg. If clock skew

NTP Operation • NTP adjusts every sec via adjtime – Eg. If clock skew is +100 ppm & tickadj=5 us • NTP will operate to keep clock effectively running at correct rate – Normal Rate - 500 ppm over 0. 2 sec – Normal Rate for 0. 8 sec – Effective skew = 0 ppm – Results in sawtooth – pattern • Newer Unix Kernels have advanced NTP features – ntp_adjtime( ), ntp_gettime() – Eliminates the sawtooth pattern Dr. Hugh Melvin, Dept. of IT, NUI, G 38

NTP Implementation • Install NTP • Set up ntp. conf file – List of

NTP Implementation • Install NTP • Set up ntp. conf file – List of servers that you wish to connect to – Redundancy & Path Diversity & Low RTD • Start up NTP daemon ntpd • File ntp. drift records clock skew • Other utilities – ntpq, ntpdate – See www. ntp. org Dr. Hugh Melvin, Dept. of IT, NUI, G 39

Refid: DCF: 77. 5 KHz Radio Signal PTB: German time signal Dr. Hugh Melvin,

Refid: DCF: 77. 5 KHz Radio Signal PTB: German time signal Dr. Hugh Melvin, Dept. of IT, NUI, G 40

Dr. Hugh Melvin, Dept. of IT, NUI, G 41

Dr. Hugh Melvin, Dept. of IT, NUI, G 41

Time difference Dr. Hugh Melvin, Dept. of IT, NUI, G 42

Time difference Dr. Hugh Melvin, Dept. of IT, NUI, G 42

Server Details • when: no of sec since last response • poll : interval

Server Details • when: no of sec since last response • poll : interval between queries • reach : Reachability in octal – 1111 = 3778 = max – 1110 = 3568 last + 5 th probe lost • Symbol to LHS of server – * : Synch Source – survivor with smallest dispersion – + : other candidates included in final combination alg – - : Discarded by clustering alg – x : Falseticker acc to intersection alg Dr. Hugh Melvin, Dept. of IT, NUI, G 43

Dr. Hugh Melvin, Dept. of IT, NUI, G 44

Dr. Hugh Melvin, Dept. of IT, NUI, G 44

NTP Robustness Issues • • Redundancy Path Diversity Symmetric Networks Proximity to Primary Reference

NTP Robustness Issues • • Redundancy Path Diversity Symmetric Networks Proximity to Primary Reference Sources – See results • OS & Network Load – Platform Dependencies Dr. Hugh Melvin, Dept. of IT, NUI, G 45

NTP Operation : Asymmetry B 3. 59. 015 C 3. 59. 017 10 ms

NTP Operation : Asymmetry B 3. 59. 015 C 3. 59. 017 10 ms A 3. 59. 000 20 ms D 3. 59. 032 Offset still 5 ms but Asymmetric Network RTD = (D - A) – (C – B) = 32 – 2 = 30 msec Offset = ½[(B-A) - (D-C)] = (15 – 15)/2 = 0 ms. . Error Dr. Hugh Melvin, Dept. of IT, NUI, G 46

NTP Operation : Asymmetry B 3. 59. 015 C 3. 59. 017 15 ms

NTP Operation : Asymmetry B 3. 59. 015 C 3. 59. 017 15 ms A 3. 59. 000 15 ms D 3. 59. 032 NTP’s Symmetric view of Asymmetric Network RTD = (D - A) – (C – B) = 32 – 2 = 30 msec Offset = ½[(B-A) - (D-C)] = (15 – 15)/2 = 0 ms ! Exercise: What is the maximum error in this calculation? Dr. Hugh Melvin, Dept. of IT, NUI, G 47

Dr. Hugh Melvin, Dept. of IT, NUI, G 48

Dr. Hugh Melvin, Dept. of IT, NUI, G 48

Dr. Hugh Melvin, Dept. of IT, NUI, G 49

Dr. Hugh Melvin, Dept. of IT, NUI, G 49

Server Offsets: Problem? Dr. Hugh Melvin, Dept. of IT, NUI, G 50

Server Offsets: Problem? Dr. Hugh Melvin, Dept. of IT, NUI, G 50