Computer System Time and Network Time Synchronization How to Handle Leap Seconds
Total Page:16
File Type:pdf, Size:1020Kb
SGNOG7 @One Farrer Hotel & Spa Computer System Time and Network Time Synchronization How To Handle Leap Seconds July 12th, 2019 Junko Nozaki Seiko Solutions Inc. ©2019 Seiko Solutions Inc. All rights reserved. Seiko as Time Solution Provider The origin of Seiko as time solution provider dates back to 1881 when K. Hattori started a clock shop. We have more than 130 years of history providing precise time solution with cutting edge products such as clock, watch and electronic. Company SEIKO SOLUTIONS INC. Established December 13, 2012 Business Starting Date April 1, 2013 Location 1-8 Nakase, Mihama-ku, Chiba City Capital 500 million yen Stockholder 100% by Seiko Holdings Corporation Employee Approx. 700 CEO President Mr. Jun Sekine Head Office in Japan ©2019 Seiko Solutions Inc. All rights reserved. Accurate time and frequency are the foundation of information and communications, as well as the foundation of academic, industrial, and safe social life. Tetsuya Ido Director of NICT Space-Time Standards Laboratory (NICT: Japan National Institute of Information and Communications Technology) 正確な時刻と周波数は、情報通信の基盤であるとともに、学術、産業、安心安全な社会生活の基盤です。 http://www2.nict.go.jp/sts/lab/index.html ©2019 Seiko Solutions Inc. All rights reserved. What is Computer Time ? Question : What is the definition of time to computers? We start from this point??? Yes, we need some abstraction to explore! (POSIX.1 A.4.16, ITU-T G.810, IEEE1588-2008 etc.) Answer : A continuously and truly monotonically increasing value that does not jump or regress. ©2019 Seiko Solutions Inc. All rights reserved. What is Computer Time? It is measured by the elapsed time from Epoch Epoch Starting point to measure the elapsed time 12:00:00 am of January 1st, 1970 in UTC Elapsed time SI second is used to measure elapsed time from Epoch SI second Physical quantity determined by a certain change time of cesium atom ©2019 Seiko Solutions Inc. All rights reserved. What is Computer Time? In fact, computers (i.e. OS) do NOT comprehend any calendar as we do. Q: What is a calendar? A: Something we use like “12th of July, 2019.” Q: What calendar are we currently using? A: Gregorian Calendar. ©2019 Seiko Solutions Inc. All rights reserved. What is Computer Time? But my computer tells me the correct date and time. root@ubuntu:~$ date Fri Jul 12 10:45:44 SGT 2019 It seems it understands our calendar. Doesn’t it? Answer: It is because of the smart one (tz database) who translates computer time to the calendar we are familiar with. ©2019 Seiko Solutions Inc. All rights reserved. What is Computer Time? OS recognizes the time as root@ubuntu:~$ date +%s 1562899544 Which tells us Friday 12th of July, 2019 10:45:44 SGT = 1562899544 (s) (1,562,899,544 seconds have been passed since 1st of January, 1970 12:00:00 am (UTC)) We call this UNIX time (POSIX time) as it is the elapsed time from Epoch. ©2019 Seiko Solutions Inc. All rights reserved. TZ Database (1) Most OS from UNIX family understand calendar via tz database. It translates UNIX time to calendar time. Linux (OS) July, 2019 Oscillator-driven UNIX time holding H/W counter tz database variable (User land) Read periodically Singapore (SGT) or on request and UNIX time add to the UNIX time July 12th, 2019 1562899544 10:45:44 ©2019 Seiko Solutions Inc. All rights reserved. TZ Database (2) TZ database, as its primary job, translates UNIX time into standard time for each region. July, 2019 Japan Standard Time (JST) July 12th, 2019 11:45:44 am Linux (OS) UNIX time holding July, 2019 Greenwich Mean Time variable tz database (GMT) th (User land) July 12 , 2019 02:45:44 am UNIX time July, 2019 Eastern Standard Time 1562899544 (EST) Singapore (SGT) July 11th, 2019 July 12th, 2019 10:45:44 am 10:45:44 pm ©2019 Seiko Solutions Inc. All rights reserved. TZ Database TZ Database can handle Daylight Saving Time correctly. UNIX time EST : : Sun Feb 11, 2018 Sun Nov 4, 2018 1520751598 01:59:58 am (EST) 1541311198 01:59:58 am (EDT) Sun Feb 11, 2018 Sun Nov 4, 2018 1520751599 01:59:59 am (EST) 1541311199 01:59:59 am (EDT) Sun Feb 11, 2018 Sun Nov 4, 2018 1520751600 03:00:00 am (EDT) 1541311200 01:00:00 am (EST) Sun Feb 11, 2018 Sun Nov 4, 2018 1520751601 03:00:01 am (EDT) 1541311201 01:00:01 am (EST) : : : : UNIX time retains continuity without a jump! ©2019 Seiko Solutions Inc. All rights reserved. Leap Second and UNIX time Question: Isn’t Leap Second the same as Daylight Saving Time? Answer: TZ database doesn’t deal with leap second. Leap second is directly handled by OS. So, it DOES have an impact on UNIX time continuity. 11 ©2019 Seiko Solutions Inc. All rights reserved. Leap Second and UNIX time Question: Calculate below as UNIX time July 1, 12:00:00 am UTC 1972 Answer : 78796800 •1970 is not a leap year ⇒ 31536000 s (86400 s x 365 d) •1971 is not a leap year ⇒ 31536000 s •1st of January to 1st of July in 1972 ⇒ 15724800 s (86400 s x (31 d x 3 m+30 d x 2 + 29 d)) •31536000×2+15724800 = 78796800 12 ©2019 Seiko Solutions Inc. All rights reserved. Leap Second and UNIX time June 30,1972 was the first day with a leap second UNIX time UTC What should we do when there is no Fri Jun 30, 1972 appropriate integer to put in “????” ? 78796798 11:59:58 pm Fri Jun 30, 1972 78796799 A) Repeat “78796799” 11:59:59 pm B) Adjust by changing the rate of Fri Jun 30, 1972 increase in value beforehand ???? 11:59:60 pm Fri Jul 1, 1972 78796800 However A) cannot retain time 12:00:00 am continuity. Fri Jul 1, 1972 78796801 12:00:01 am ©2019 Seiko Solutions Inc. All rights reserved. Leap Second and UNIX time Key Features of leap second Cannot avoid since our daily life is based on UTC Go into effect irregularly • Future implementation date is unknown • Out of scope of UNIX time calculation Contrary to the definition of computer time continuity • Discontinuity directly affects time difference calculation • Unprepared computer programs get affected Pre-testing is important for leap second handling! ©2019 Seiko Solutions Inc. All rights reserved. What Happened with the Extra Second in 2012 A leap second “11:59:60” inserted between “11:59:59” on June 30 and “12:00:00” on July 1 in UTC 11:59:58 11:59:59 11:59:60 12:00:00 12:00:01 2012/6/30 2012/7/1 What happened? A glitch in the Linux kernel caused problems for various services, such as Reddit, Mozilla, Yelp, Foursquare, LinkedIn and etc. Passengers of Qantas and Virgin Australia were required manual check-ins causing flights delays. Even the latest kernel versions ! couldn’t prevent system failure. https://en.wikipedia.org/wiki/Leap_second / https://www.wired.com/2012/07/leap-second-glitch-explained/ / https://www.theregister.co.uk/2015/01/09/leap_second_bug_linux_hysteria/ ©2019 Seiko Solutions Inc. All rights reserved. How to Handle Leap Second without Time Server (Linux System) NTP daemon : transfers leap second announcement / Linux OS : handles leap second When NTP daemon detects Schedules Linux OS to handle it on designated moment leap second announcement Passes the announcement on to its clients as “Leap Indicator (LI bit)” Client receives LI bit and repeat the routine Leap second happening! 11:59:59 And Linux OS repeat/skip 11:59:59 Got it! 11:59:59 11:59:59Got it! 11:59:59Got it! Got it! Scheduled! 11:59:59 Stratum0 LI bit LI bit LI bit (GPS, Atomic Clock) Scheduled! Scheduled! Scheduled! Stratum4 Stratum1 Stratum2 Stratum3 (Public NTP Server) Repeating / skipping time may cause system failure What’s the problem? Requires all the computers in the system to support LI bit to realize time synchronization of the whole system ©2019 Seiko Solutions Inc. All rights reserved. How to Handle Leap Second with Time Server With Time Server as your own Stratum1 server, leap second handling is complete within it. The LI bit is not advertised to lower NTP clients, so only the time server knows the leap second is happening. Leap second happening! Each device recognizes time by referring the information from upper layer. LI bit Gradual AdjustmentGot it! Time Mode! Stratum0 Speed X (GPS, Atomic Clock) 1.0 Time Scheduled! Speed 0.99986 Stratum1 Time Server Stratum2 Stratum3 Stratum4 Time Server with “Gradual Adjustment Mode” is recommended in the following situations. • The system needs to hold time continuity (no jumping and repeating) • The system includes devices which doesn’t support Leap second indicator Set to Gradual Adjustment Mode, divided leap second starts to be inserted 2 hours before it really occurs. ©2019 Seiko Solutions Inc. All rights reserved. Case Study : Tokyo Stock Exchange, Inc, Tokyo Stock Exchange conducted a pre-test to confirm system stability throughout the upcoming leap second of July, 2015. What were done for handling Prepared the environment with simulated leap second occurring once a day with private NTP server. Checked that any failure caused by leap second would not occur in the on-premise environment. The verification process took six months to complete the detailed test items. TSE Market Center Tokyo Stock Exchange also notified relevant parties of the points of concern in advance. The Tokyo Stock Exchange, which starts trading at 9 AM, will insert dispersed 1 second in 2 hours from 7 AM (7200 seconds) to avoid the sudden insertion of the whole 1 second. In March, the TSE notified relevant companies of a note of caution, as orders are flowing in 1/1000 second increments, although it is not expected to have a major impact on the market.