410 likes | 563 Views
Clock Synchronisation for RTS. Importance of RTS Clocks. RealTime 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
E N D
Clock Synchronisation for RTS Dr. Hugh Melvin, Dept. of IT, NUI,G
Importance of RTS Clocks • RealTime 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
Power System Control • AS station • Token Bus Synchronisation via Master Clock • Critical for chronological data logging / fault diagnosis • Timeslicing for token management • Synchronising 2v3 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
U/IA U/IA U/IA U/IA U/IA U/IA U/IA U/IA U/IA U/IA U/IA U/IA U/IA U/IA U/IA U/IA U/IA U/IA U/IA U/IA 103 N8 AS220E 104 N8 AS220E 106 N8 AS220E 102 N8 AS220E 105 N8 AS220E 107 N8 AS220E 101 N8 AS220E 108 N8 AS220E U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB U/IB 127 N-BK Bus 1 Token Bus : Master Clock U/IA 125 N16 R30 123 N-UHR M-Clock 141 NAT-24 Synogate 121 N16 OS254 111 N8 AS220E 112 N8 AS220E 110 N8 AS220E 109 N8 AS220E Master Clock 126 N-BK Bus 0 160 NS5NAT PG750 132 N8 AS EHF 133 N8 AS EHF 131 N8 AS EHF 128 N8 AS231 Dr. Hugh Melvin, Dept. of IT, NUI,G
Soft-Firm RTS • POTS operation based on TDM • PCME1E2..E4 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 QoS 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
Audio-System Clock Skew Dr. Hugh Melvin, Dept. of IT, NUI,G
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
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. 2ppm /C • Ageing • Eg. Cesium Beam: 3 x 10-12 / year • Noise Dr. Hugh Melvin, Dept. of IT, NUI,G
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
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 C1and C2 • C1(t) - C2(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 C1and C2 • C1’(t) - C2’(t) Dr. Hugh Melvin, Dept. of IT, NUI,G
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
Cone of Acceptability Slope = 1 + Slope = 1 = True Clock Clock Time Slope = 1 - Real Time Dr. Hugh Melvin, Dept. of IT, NUI,G
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
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
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
PLL VCO Input Signal Comparator VCO = Voltage Controlled Oscillator Freq controlled by applied input voltage Dr. Hugh Melvin, Dept. of IT, NUI,G
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
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
NTP The NTP architecture, protocol and algorithms have evolvedover the last twenty years to the latest NTP Version 4 • Internet standard protocolfor 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 (GeoSat) / LORC (LoranC) / ATOM / DTS • Stratum 1: Primary Time Server Dr. Hugh Melvin, Dept. of IT, NUI,G
NTP Operation Peer 1 Filter 1 Intersection and Clustering Algorithms • Complex Software comprising various algorithms • Filtering Alg. • Clustering and Intersection Alg. • Combining Alg. • Clock Discipline Combining Algorithm Peer 2 Filter 2 Loop Filter P/F-Lock Loop Peer 3 Filter 3 VFO NTP Messages Dr. Hugh Melvin, Dept. of IT, NUI,G
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
NTP Operation B 3.59.020 C 3.59.022 15 ms 15 ms A 3.59.000 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
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
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 1000Hz 1msec • 3 clock rates • Normal rate .. Add 10 msec every tick (100 Hz) • Normal Rate +/- tickadj • Eg. If tickadj = 5us Normal Rate +/- 500 ppm Dr. Hugh Melvin, Dept. of IT, NUI,G
NTP Operation • NTP adjusts every sec via adjtime • Eg. If clock skew is +100 ppm & tickadj=5us • 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
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
Refid: DCF: 77.5 KHz Radio Signal PTB: German time signal Dr. Hugh Melvin, Dept. of IT, NUI,G
Time difference Dr. Hugh Melvin, Dept. of IT, NUI,G
Server Details • when: no of sec since last response • poll : interval between queries • reach : Reachability in octal • 11111111 = 3778 = max • 11101110 = 3568 last + 5th 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
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
NTP Operation : Asymmetry B 3.59.015 C 3.59.017 10 ms 20 ms A 3.59.000 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
NTP Operation : Asymmetry B 3.59.015 C 3.59.017 15 ms 15 ms A 3.59.000 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
Server Offsets: Problem? Dr. Hugh Melvin, Dept. of IT, NUI,G