20151022 time and computers softshake -...

53
Time and Computers Nicolas Seriot 2015-10-22 A man with a watch knows what .me it is. A man with two watches is never sure.

Upload: others

Post on 10-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

TimeandComputersNicolasSeriot2015-10-22

Amanwithawatchknowswhat.meitis.Amanwithtwowatchesisneversure.

Page 2: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

Unesecondeaprèsle2015-06-3023:59,iln'étaitpas2015-07-0100:00mais2015-06-3023:60.Eneffet,leBureauInterna.onaldesPoidsetMesures(BIPM)a,commepresquechaqueannée,décidéd'ajouterunesecondeintercalaireautempscivilinterna.onal(UTC)pourtenircompteduralen.ssementdelarota.ondelaterre.

L'ajoutdeceSesecondeposed'importantsproblèmesdeprogramma.onetdesynchronisa.on.Plusieursplacesdeboursesuspendentainsileséchangesautourdelasecondefa.dique.CeSesecondeintercalaireestpassablementcontestée,aupointquel'UnionInterna0onaldesTélécommunica0on(UIT)seréuniraennovembreàGenèvepourdéciderounondesasuppression.Sitelestlecas,d'autresproblèmesrisquentalorsdesurvenir.Dansquelquessiècles,ilpourraitfairenuitàmidi!

CeSeréuniondel'UITestl'occasiond'examinercommentlessystèmesinforma.quesgèrentceSesecondeintercalaire,commentlesordinateurssynchronisentleurshorloges(NTP),quellessontleshorlogesderéférences,commentsontgéréslesfuseauxhorairesetl'heured'été,quelleserreursdeprogramma0onéviter(dis.nc.ondateetdurée),etc.Lesexemplesserontbaséssurl'environnementUnix/OSX.

Page 3: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

TimekeepingHistory

Page 4: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1
Page 5: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

GMT/UT-UniversalTime

• 19thcentury:railandtelegraphyimpliedneedtosynchroniseFmeinternaFonally

• 1884:GreenwichMeanTime(GMT)adoptedastheworld’sstandardFme,24Fmezones

• BasedonmeansolarFme,86400seconds/day

• Adoptedbyallcountriesbetween1848-1972

Page 6: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

• Atomicalclocksallowsub-secondprecision

• ScienFficandindustrialneeds,telecom,…

1960s

http://homepages.abdn.ac.uk/npmuseum/article/Astroimages/16image.jpg

Page 7: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

SISecond(Intl.SystemofUnits)

Thesecondisthedura.onof9192631770periodsoftheradia.oncorrespondingtothetransi.onbetweenthetwohyperfinelevelsofthegroundstateofthecaesium133atom.

(13thConférenceGénéraledesPoidsetMesures,1967)

…atsealevel(bewarerelaFvity…).

…referstoacaesiumatomatrestatatemperatureof0K.(1997)

Page 8: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

OtherphysicalunitssuchasampereandmeterrelyonthisaspartoftheirowndefiniFons.

Themeteristhelengthofthepathtravelledbylightinvacuumduringa.meintervalof1/299792458ofasecond.

(17thConférenceGénéraledesPoidsetMesures,1983)

ImportanceofSecondDefiniFon

Page 9: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

AtomicclockFOCS1,FederalOfficeofMetrology,Bern,SwitzerlandAsof2004,offby1sin30millionyears

Page 10: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

AtomicclockNIST-F2,Boulder,Colorado,USAAsof2014,offby1sin300millionyears

Page 11: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

OpFcalLaaceClock

Nature,March2015

SystemaFcevaluaFonofanatomicclockat2×10−18totaluncertainty

Themostpreciseatomicclockyet,usingstronFumatoms,keepsFmeaccuratelytowithinasecondper15billionyears.

Page 12: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

TAI–InternaFonalAtomicTime• StaFsFcalFmescalebasedon300+atomicclocksin60+labsworldwide.

• ContributorsinBIPMCircular-T,updatedmonthly.

• MoststableclocksreceivethemostweightinthecalculaFon.

• Timeisknownonlyaposteriori,afermeasurement.

Page 13: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

CIRCULAR T 333 ISSN 1143-1393 2015 OCTOBER 12, 14h UTC BUREAU INTERNATIONAL DES POIDS ET MESURES ORGANISATION INTERGOUVERNEMENTALE DE LA CONVENTION DU METRE PAVILLON DE BRETEUIL F-92312 SEVRES CEDEX TEL. +33 1 45 07 70 70 FAX. +33 1 45 34 20 21 [email protected] 1 - Coordinated Universal Time UTC and its local realizations UTC(k). Computed values of [UTC-UTC(k)] and uncertainties valid for the period of this Circular. From 2015 July 1, 0h UTC, TAI-UTC = 36 s. Date 2015 0h UTC AUG 30 SEP 4 SEP 9 SEP 14 SEP 19 SEP 24 SEP 29 Uncertainty/ns Notes MJD 57264 57269 57274 57279 57284 57289 57294 uA uB u Laboratory k [UTC-UTC(k)]/ns AOS (Borowiec) -0.3 -1.0 -1.5 -1.8 -1.5 0.4 1.1 0.3 5.0 5.1 APL (Laurel) -4.8 -2.6 -1.1 2.8 4.3 4.8 4.1 0.3 4.9 4.9 AUS (Sydney) -675.5 -647.2 -633.5 -614.1 -597.8 -581.3 -558.3 0.3 5.0 5.1 BEV (Wien) 0.8 -1.8 -8.4 -18.0 -28.6 -22.2 -11.3 0.3 3.1 3.1 BIM (Sofiya) 2693.2 2725.9 2765.9 2780.0 2784.9 2821.8 2847.7 1.5 7.0 7.2 BIRM (Beijing) - -97.6 -104.8 -118.2 -117.7 -119.1 -134.7 1.5 20.0 20.1 BY (Minsk) 4.3 4.2 3.7 5.8 4.5 8.1 8.1 1.5 7.0 7.2 CAO (Cagliari) -7595.2 -7696.5 -7797.3 -7898.8 -7988.6 -8084.2 -8188.0 8.0 7.0 10.7 CH (Bern-Wabern) 12.3 14.0 12.5 11.3 10.8 12.1 6.8 0.3 1.2 1.3 CNM (Queretaro) -1.9 -2.7 -1.4 -1.1 0.3 -1.0 -1.8 3.0 5.0 5.8 . . .2 - International Atomic Time TAI and Local atomic time scales TA(k). Computed values of [TAI-TA(k)]. 3 - Difference between the normalized frequencies of EAL (free atomic time scale) and TAI. 4 - Duration of the TAI scale interval. 5 - Relations of UTC and TAI with predictions of UTC(k) disseminated by GNSS and their System Times. 6 - Time links used for the computation of TAI and their uncertainties.

Page 14: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

USOfficialTime

hgp://tycho.usno.navy.mil/mc_to.html

UTC(NIST)andUTC(UNSO)bothkeeptheiratomicclocksnetworkandtheirownversionofUTC,inverycloseagreement(about20ns).TheycontributetoInternaFonalAtomicTime(TAI)andCoordinatedUniversalTime(UTC).

Page 15: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

EarthRotaFon• SIsecondbasedonEphemerisTimescalemeasuredin19thcentury,slightlyshorterthanthemeansolarsecond

• Earth'srotaBontendstobeslowing,becauseofFdes,climaFcandgeologicalevents.

• MeansolarBmedayingraduallyincreasing before1820:<86400seconds ~1820:86400seconds 2015:about86400.002seconds

Page 16: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

CurrentlytheEarthrunsslowatroughly2millisecondsperday.Afer500days,thedifferencebetweenUT1andTAIwouldbe1second.

hgp://tycho.usno.navy.mil/leapsec.html

Page 17: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

UTC-CoordinatedUniversalTime• Acronymstandsfor«CoordinatedUniversalTime»and«tempsuniverselcoordonné»nottofavoranylanguage.

• Createdinthe1950stodisplaythesameFmeworldwideandcoordinateFmeradiobroadcaststhroughtheworld.

• TimeissynchronisedthankstocoordinatedshiHstomatchUT.

Page 18: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

ephemerissecond+customsteps1second=1/31556925.9747ofthetropicalyear1900January0at12hoursephemeris.me

atomicsecond(SI) 1stJanuary1972:reset UTC00:00:00==1January197200:00:10TAI

UTCnowFcksinSIseconds,instepwithTAI.

Keptwithin0.9secondsofUT1withleapseconds.

UTC=TAI+int.nbofseconds,currently36

DifferentSecondDefiniBons,IrregularShiHs

Page 19: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

DUT1CorrecFon

hgp://www.nist.gov/pml/div688/grp50/leapsecond.cfm

Page 20: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

LeapSeconds• InternaFonalEarthRotaFonandReferenceSystemsServiceakaIERSaddsorremoves1secondtoUTCwheneverneededtokeepUTCwithinUT1+/-0.9s.

• IERSmonitorstheEarthrotaFon,calculatesandpublishesUT1inIERSBulleFnB.

• BulleFnBisusedfordecidingwhentoaddaleapsecondtoUTC,publishedinBulleFnC.

• Currentlyaboutevery18months,atendofDecemberorJune,orelseendofMarchorSeptember(neverhappened).

Page 21: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

Paris, 5 January 2015 Bulletin C 49 To authorities responsible for the measurement and distribution of time

UTC TIME STEP on the 1st of July 2015

A positive leap second will be introduced at the end of June 2015. The sequence of dates of the UTC second markers will be:

2015 June 30, 23h 59m 59s 2015 June 30, 23h 59m 60s 2015 July 1, 0h 0m 0s The difference between UTC and the International Atomic Time TAI is:

from 2012 July 1, 0h UTC, to 2015 July 1 0h UTC : UTC-TAI = - 35s from 2015 July 1, 0h UTC, until further notice : UTC-TAI = - 36s

hgps://hpiers.obspm.fr/iers/bul/bulc/bulleFnc.49

Page 22: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

LeapSecondsDebates• Withoutleapseconds,noonontheclockwillbemidnightintheskysome3,000yearsfromnow(unlessweadjustFmezones)

• Announced6+monthsinadvance,butnotallsourcesuseit(eg.GermanradiosignalDCF77doesannounceleapsecondsonlyonehouraheadofFme)

• Notaviablelong-termsoluBonNextcentury:aleapsecondwillberequiredeveryyear2600:3or4leapsecondswillberequiredeachyear4300:addleapsecondseverymonth

Page 23: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

StockExchanges

hgp://www.nasdaq.com/arFcle/markets-are-jumpy-over-coming-leap-second-20150518-01174

hgp://www.cmegroup.com/company/leap-second.html

«Toaccountfortheleapsecond,anextrasecondthatwillbeaddedtoCoordinatedUniversalTime(UTC)onJune30,2015,CMEGroupisdelayingtheCMEGlobexmarketopenfortradedateJuly1.»

«LargeU.S.stockexchangesincludingNewYorkStockExchange'sNYSEArca,NasdaqOMXGroupInc.'sNasdaqandBATSGlobalMarketswillclosetheirafer-hourssessions30minutesbeforetheirregular8p.m.close.»

Page 24: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

UTCCalculaFons• ReconstrucBngpastisamess

• NumberofSIsecondselapsedsinceanydatebeforeatomicFme?Noway!

• Nomberofsecondslegallyellapsedsincesomedateinthepast?DependsonjuridicFons! hgp://www.ucolick.org/~sla/leapsecs/epochFme.html

• Futureisimpossibletotellforsure

• NumberofSIsecondsbeforesomefutureUTCdate?Noway!

Page 25: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

DebatesinITU-R

• Since2001,ITU-Rhasbeenconsideringsuppressingleapseconds.

• In2015NovemberITU-RWRC-15willagaindiscussleapsecondsinUTC.

Page 26: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

POSIXTime• Easytodealwithformachines,nomonthsetc,basicallyasimplecounter

• POSIXFmestampactuallycountsthenumberofUTsecondssince1970-01-01

• Eachandeverydayisexactly86400seconds(POSIX.1-2008,4.15)

• Timezoneinanenvironmentvariablehgp://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html

• gettimeofday()obtainssecondsandmicrosecondssinceJanuary1,197000:00UTC.hgp://pubs.opengroup.org/onlinepubs/007908775/nottobeusedformeasuringBmeintervals!

Page 27: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

MeasuringTimeIntervals1445472703 - 157187 - 02:11:431445472704 - 157188 - 02:11:441445472705 - 157189 - 02:11:451445469104 - 157190 - 01:11:44 # time changes1445469105 - 157191 - 01:11:451445469106 - 157192 - 01:11:46

POSIXFmestamp

monotonousfuncFonmach_absolute_time() orCACurrentMediaTime(),equivalenttoLinuxclock_gettime() nbofsecondselapsedsinceunspecifiedevent,eg.reboot

Page 28: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

POSIXandLeapSeconds• Leapsecondsarejustignored

• AlignmentwiththeactualFmeisimplementaFondefined(POSIX.1-2008,4.15)

• PosiFveleapsecondshavenoUNIXFmestamprepresentaFon

UTC - timeIntervalSince1970

2015-06-30 23:59:59 - 14357087992015-06-30 23:59:60 - 1435708800 <- unknown2015-07-01 00:00:00 - 14357088002015-07-01 00:00:01 - 1435708801

Page 29: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

NSDate *dateFromString(NSString *s) { NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSLocale *posixLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; [dateFormatter setLocale:posixLocale]; [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; return [dateFormatter dateFromString:s]; }

/* Cocoa can't build date with leap second */

NSDate *date1 = dateFromString(@"2015-06-30 23:59:59"); NSLog(@"-- %@", date1); // 2015-06-30 23:59:59 +0000

NSDate *date2 = dateFromString(@"2015-06-30 23:59:60"); NSLog(@"-- %@", date2); // null

/* NSDate computations just ignores leap seconds */

NSDate *date3 = dateFromString(@"2015-01-01 00:00:00"); NSDate *date4 = dateFromString(@"2016-01-01 00:00:00"); NSLog(@"-- %f", [date4 timeIntervalSinceDate:date3]); // 31536000 = 365 * 24 * 60 * 60

Page 30: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

void printTimestampAndDate(const char* s) { struct tm tm; memset(&tm, 0, sizeof(struct tm)); strptime_l(s, "%Y-%m-%d %H:%M:%S", &tm, NULL);

time_t time = mktime(&tm);

char buf[255]; strftime(buf, sizeof(buf), "%d %b %Y %H:%M:%S", &tm); printf("-- %ld \t %s\n", time, buf); NSDate *date = [NSDate dateWithTimeIntervalSince1970:time]; NSLog(@"-- %@", date); }

/* time.h functions can represent leap second but same as next second */

printTimestampAndDate("2015-06-30 23:59:59"); // -- 1435705199 01 Jul 2015 00:59:59 printTimestampAndDate("2015-06-30 23:59:60"); // -- 1435705200 01 Jul 2015 01:00:00 printTimestampAndDate("2015-07-01 00:00:00"); // -- 1435705200 01 Jul 2015 01:00:00

Page 31: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

• POSIXwasdesignedbeforetheintroducBonofleapseconds.

• Duringleapseconds,time_tcannotrepresentUTCduringleapsecondsnon-ambiguously.

• POSIXbasicallypretendstocount86400SIsecondsperday,whichisnotpossible.

• MiFgaFon:don’tstoreUNIXbinaryBmestampsbutUTCdateFmeinstead.

POSIXDefiniFonisInconsistent

Page 32: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

POSIX32bitsoverflow

$ date -ur `echo $((2**31-1))`Tue Jan 19 03:14:07 UTC 2038

32bitstime_twilloverflowafer2038-01-19T03:14:07UTC

Page 33: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

GPS-GlobalPosiFoningSystem• Eachsatellitehasat2+onboardcaesiumatomicclocksand 2+rubidiumatomicclocksasback-up.

• TimemeasuredfromsatellitesisgatheredbymonitorstaBons,processedinColoradoanduploadedagain.

• PeriodiccorrecBonsareperformedontheon-boardclockstocorrectrelaFvisFceffectsandkeepthemsynchronizedwithgroundclocks.

• GPSreceivercomparessignalsfrom4satellites,computeslocaFononearthbyanalysingFmingdelays.

Page 34: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

Vandenberg AFB California

Alternate Master Control Station

Air Force Monitor Station

Hawaii

Master Control Station

Schriever AFB Colorado

NGA Monitor Station

South Korea

Australia

Bahrain

South Africa

United Kingdom

Argentina

Ecuador

USNO Washington

Alaska

New Zealand

AFSCN Remote Tracking Station

Ascension Diego Garcia

Cape Canaveral Florida

Kwajalein

Ground Antenna

New Hampshire

Greenland

Guam

Updated April 2014

GPS Control Segment

Page 35: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

GPSandLeapSeconds• SinceGPSEpochJanuary6,1980,GPSBme==TAI+19seconds

• AnUTCcorrecBonisprovidedaspartofthebroadcastmessage(currentlyUTC+17leapsecondssince1980)

• DeltaGPS/UTCissenton8bits,sothecounterwillprobablyoverflowaround2060-2090dependingonthenumberofleapseconds.

Page 36: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

NTP-NetworkTimeProtocol• InventedanddeveloppedbyProf.DavidMillsfirstRFCfrom1988

• NTP(RFC-5905,port123)isthemostcommonlyusedBmeprotocol.SupersedesDayFmeProtocol(port13)andTimeProtocol(port37).

• TheclientperiodicallypollsBmeservers,ignoresresponsesfromserversthatappeartobesendingthewrongFme,andaveragestheresultsfromthosethatappeartobecorrect.

• Mostdesktopclientsmakeasinglerequesttosetthecomputer’sclock.TheyareactuallySNTP(SimpleNetworkTimeProtocol)clients.

Page 37: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

SNTP–SimpleNetworkTimeProtocol

$ sntp time.euro.apple.com2015 Jul 07 22:44:26.122392 +6.184477 +/- 0.001022 secs

# fix local time by adding +6.184477 seconds# time is believed to be correct +/- 0.001022 secs

$ sudo sntp -s ch.pool.ntp.org # set time

$ sudo sntp -j time.nist.gov # adjtime

Page 38: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

ADJTIME(2) BSD System Calls Manual ADJTIME(2)

NAME adjtime -- correct the time to allow synchronization of the system clock

SYNOPSIS #include <sys/time.h>

int adjtime(const struct timeval *delta, struct timeval *olddelta);

DESCRIPTION Adjtime() makes small adjustments to the system time, as returned by gettimeofday(2), advancing or retarding it by the time specified by the timeval delta. If delta is negative, the clock is slowed down by incre- menting it more slowly than normal until the correction is complete. If delta is positive, a larger increment than normal is used. The skew used to perform the correction is generally a fraction of one percent. Thus, the time is always a monotonically increasing function. A time correc- tion from an earlier call to adjtime() may not be finished when adjtime() is called again. If olddelta is non-nil, the structure pointed to will contain, upon return, the number of microseconds still to be corrected from the earlier call.

Page 39: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

NTPandLeapSecondsRFC 958

5.4. Leap Seconds

A standard mechanism to effect leap-second correction is not a part of this specification. It is expected that the Leap Indicator bits would be set by hand in the primary reference clocks, then trickle down to all other clocks in the network, which would execute the correction at the specified time and reset the bits.

AsPOSIX,theNTPcounterignoresleapseconds. Since1972,NTPFcksinSIseconds,withUTCandTAI.

Butitaccumulatesmeansolarseconds.

Page 40: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

LeapSecond–Jumps1435708799 Tue Jun 30 23:59:59 UTC 20151435708799.5 Tue Jun 30 23:59:59.5 UTC 20151435708800 Tue Jun 30 23:59:60 UTC 2015 # leap second1435708800.5 Tue Jun 30 23:59:60.5 UTC 2015 # leap second1435708800 Wed Jul 1 00:00:00 UTC 20151435708800.5 Wed Jul 1 00:00:00.5 UTC 20151435708801 Wed Jul 1 00:00:01 UTC 20151435708801.5 Wed Jul 1 00:00:01.5 UTC 2015

Bad:youdon’tknowwhichFmestampcomesfirstduringleapsecond.Bad:youcan’tmeasureFmeaccuratelyduringleapsecondsBad:wriFngafileeachsecondnamedaccordingtoFmestampwouldoverwritedataBad:issuealsoexistewhensystemclockischangedaferbeingoutofsync

Page 41: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

LeapSecond–Smearing1435708799 Tue Jun 30 23:59:59 UTC 20151435708799.5 Tue Jun 30 23:59:59.5 UTC 20151435708800 Tue Jun 30 23:59:60 UTC 2015 # leap second1435708800.25 Tue Jun 30 23:59:60.5 UTC 2015 # leap second1435708800.50 Wed Jul 1 00:00:00 UTC 20151435708800.75 Wed Jul 1 00:00:00.5 UTC 20151435708801 Wed Jul 1 00:00:01 UTC 20151435708801.5 Wed Jul 1 00:00:01.5 UTC 2015

Good:Fmeisstretchedsothatgettimeofday()iskeptstrictlymonotonousBad:thisyieldsneitherSIsecondsnorUTCFme.NouniversalwaytosmearFme.Google’swayhgps://googleblog.blogspot.ch/2011/09/Fme-technology-and-leaping-seconds.html

Page 42: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+|LI | VN |Mode | Stratum | Poll | Precision |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Root Delay |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Root Dispersion |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Reference ID |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| |+ Reference Timestamp (64) +| |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| |+ Origin Timestamp (64) +| |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| |+ Receive Timestamp (64) +| |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| |+ Transmit Timestamp (64) +| |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Page 43: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+|0 1|1 0 0|0 1 1| Stratum | Poll | Precision |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Root Delay |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Root Dispersion |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| Reference ID |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| |+ Reference Timestamp (64) +| |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| |+ Origin Timestamp (64) +| |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| |+ Receive Timestamp (64) +| |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+| |+ Transmit Timestamp (64) +| |+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

ATiny,79charactersNTPClient

01100011 = 0x63 = ‘c’

$ date -r$((0x`printf c%47s|nc -uw1 ntp.metas.ch 123|xxd -s40 -l4 -p`-64#23GDW0))Thu Oct 22 01:24:34 CEST 2015

hgp://seriot.ch/ntp.php

Page 44: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

+------+----------------------------------------------------------+| ID | Clock Source |+------+----------------------------------------------------------+| GOES | Geosynchronous Orbit Environment Satellite || GPS | Global Position System || GAL | Galileo Positioning System || PPS | Generic pulse-per-second || IRIG | Inter-Range Instrumentation Group || WWVB | LF Radio WWVB Ft. Collins, CO 60 kHz || DCF | LF Radio DCF77 Mainflingen, DE 77.5 kHz || HBG | LF Radio HBG Prangins, HB 75 kHz || MSF | LF Radio MSF Anthorn, UK 60 kHz || JJY | LF Radio JJY Fukushima, JP 40 kHz, Saga, JP 60 kHz || LORC | MF Radio LORAN C station, 100 kHz || TDF | MF Radio Allouis, FR 162 kHz || CHU | HF Radio CHU Ottawa, Ontario || WWV | HF Radio WWV Ft. Collins, CO || WWVH | HF Radio WWVH Kauai, HI || NIST | NIST telephone modem || ACTS | NIST telephone modem || USNO | USNO telephone modem || PTB | European telephone modem |+------+----------------------------------------------------------+

Page 46: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1
Page 47: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

Timezones

NewZealand'sChathamIslands(UTC+12:45)

Nepal(UTC+05:45)

Page 48: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

Indiana,USA

• twoFmezones

• daylightsavingsince2006

• opposedbyruralcounFes

Page 50: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

Australia

Page 51: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

# Switzerland. . .# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/SRule Swiss 1941 1942 - MayMon>=1 1:00 1:00 SRule Swiss 1941 1942 - OctMon>=1 2:00 0 -# Zone NAME GMTOFF RULES FORMAT [UNTIL]Zone Europe/Zurich 0:34:08 - LMT1853 Jul 16 # See above comment.

0:29:46 - BMT1894 Jun # Bern Mean Time1:00 Swiss CE%sT 19811:00 EU CE%sT

/tzdata2015g/europetonsofhistoricaldataandcomments!

The tz database attempts to record the history and predicted future ofall computer-based clocks that track civil time.

The Time Zone Database (often called tz or zoneinfo) contains code anddata that represent the history of local time for many representativelocations around the globe. It is updated periodically to reflectchanges made by political bodies to time zone boundaries, UTC offsets,and daylight-saving rules.

IANATimeZoneDatabase

Page 52: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

Recap

• HowFmeismeasured(UT,SI)

• HowFmeisusedinPOSIXsystems

• HowFmeisdistributed(shortwaves,NTP,GPS)

• Ididn’tspeakaboutrelaFvity,exoFccalendarsorFmeonotherplanets…

Page 53: 20151022 time and computers softshake - Seriotseriot.ch/resources/talks_papers/20151022_time_and_computers_so… · removes 1 second to UTC whenever needed to keep UTC within UT1

ReferencesDavidW.Allan,NeilAshby,CliffordC.HodgeTheScienceofTimekeeping HewlegPackardApplicaFonNote1289,1997hgp://www.allansFme.com/PublicaFons/DWA/Science_Timekeeping/TheScienceOfTimekeeping.pdf

JamesJespersen,JaneFitz-Randolph FromSundialstoAtomicClocks:UnderstandingTimeandFrequencyNIST,1999hgp://~.boulder.nist.gov/general/pdf/1796.pdf

SteveAllen TheFutureofLeapSecondsinUTC hgp://www.ucolick.org/~sla/leapsecs/