time-service-intro.adoc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. = Introduction to Time Service
  2. Eric S. Raymond <esr@thyrsus.com>
  3. v1.6, Jan 2021
  4. :author: Eric S. Raymond
  5. :date: 13 January 2021
  6. :description: A primer on precision time sources and services.
  7. :email: <esr@thyrsus.com>
  8. :keywords: time, UTC, atomic clock, GPS, NTP
  9. :robots: index,follow
  10. :sectlinks:
  11. :toc: macro
  12. include::inc-menu.adoc[]
  13. This document is mastered in asciidoc format. If you are reading it in HTML,
  14. you can find the original at the GPSD project website.
  15. == Introduction
  16. This is a background paper on technological means for high-precision
  17. time measurement. We discuss time source types, relative accuracy,
  18. relative cost, and how those figures of merit have changed in recent
  19. decades. A brief introduction to NTP (Network Time Protocol) is
  20. included.
  21. == Use cases for precision time service
  22. More applications than are commonly realized require precise time;
  23. which, in practice, means time accurate to a tenth of a second or
  24. less. While sub-millisecond time requirements are rare outside of
  25. scientific work and the sharper end of industrial process control,
  26. the range between 0.1sec and 0.001sec has a lot of customers.
  27. As one large example, the Payment Card Industry (PCI) standards used
  28. by the credit card industry mandate "correct and consistent time" and
  29. gives NTP as an example of qualifying synchronization technology
  30. <<PCI3>>.
  31. The Financial Industry Regulatory Authority (FINRA) currently requires
  32. that clocks used for business must be synchronized to within one second
  33. of NIST time. The synchronization must occur at least once a day and
  34. before the start of business. A pending rule change <<FINRA_14-47>>
  35. proposes to tighten that to just 50 ms.
  36. Modern cryptographic systems, such as Kerberos, require accurate time.
  37. So do cellular networks and navigation systems for autonomous
  38. vehicles. As these cases suggest, the economic value of
  39. high-precision time is likely to rise significantly in the future.
  40. There are several equivalent ways to state the precision of a clock.
  41. In the remainder of this introduction we will use "jitter" - the
  42. width of its short-term random variation from its "correct" time -
  43. (commonly Universal Coordinated Time or UTC); usually in nanoseconds
  44. (ns), microsconds (&mu;s), or milliseconds (ms). In these units the
  45. range of interest for most precision time applications is from 100 ms
  46. down to 1000 ns.
  47. == Time service types
  48. A "primary time source" is a very high-precision, very stable
  49. oscillator (popularly called an "atomic clock") used as a source
  50. standard by a national time authority. By international agreement,
  51. the U.S. and other major national time authorities use primary
  52. standards based on electronic transitions between the two hyperfine
  53. energy levels of the ground states of Cesium-133 atoms.
  54. National time standards are synchronized (essentially, averaged after
  55. removing outliers and consistent errors) to yield an international
  56. reference called Universal Coordinated Time. The US national time
  57. standard, UTC(NIST), normally tracks UTC to within 5 ns <<BIPM-T>>.
  58. In practice, the U.S. has another time standard; UTC(USNO),
  59. military clock time propagated through the GPS system. As the skew
  60. between UTC(NIST) and UTC(USNO seldom if ever exceeds 10ns
  61. <<TIMESCALE>> they are for practical purposes identical.
  62. GPS enables receivers to generate a pulse-per-second
  63. signal ("1PPS" or just "PPS") accurate to the top of the current
  64. UTC second within 50 ns.
  65. National time standards are also propagated through time radios. In
  66. the U.S., digital time signal is provided by WWVB in Colorado, driven
  67. directly by the NIST (National Institute of Standards and Technology)
  68. master civil time standard. Propagation delay to U.S. receivers
  69. varies but is constant by location and no more than 20 ms; being
  70. fixed, this can be easily compensated out. The jitter added to NIST
  71. time by the WWVB transmission system is about 6 ns,
  72. for a total jitter relative to UTC of about 26 ns at the
  73. transmitter. Atmospheric conditions and signal-processing jitter in
  74. the receiver may degrade this considerably, to the tune of 10-100ns
  75. - however some of that is fixed delay that can be compensated out by
  76. knowing your distance from the transmitter. Accuracy is better at night.
  77. National time authorities may also offer a digital time reference via
  78. landline phone; the U.S.'s has two, supported by NIST and the U.S.
  79. Naval Observatory. NIST has a claimed accuracy of "a few milliseconds"
  80. <<ACTS1>>; USNO says 4 ms <<ACTS2>>.
  81. == Clock types
  82. A clock, in this context, is a device for delivering an approximation
  83. of a national time standard at a user's location.
  84. High-end precision clocks are based on rubidium oscillators (close
  85. relatives of the cesium time standards). Less expensive ones are based
  86. on a temperature-compensated crystal oscillator or TCXO, sometimes also
  87. seen as OCXO for "oven-compensated crystal oscillator"; these are more
  88. closely related to the non-temperature-stabilized oscillator in a
  89. quartz-crystal watch.
  90. Due to frequency drift (induced mainly by temperature variations), all
  91. such clocks need to be periodically conditioned by an external signal
  92. from a time authority. The cost of a clock correlates with its
  93. "holdover" performance - how stable the oscillator's frequency is and
  94. thus how little the time drifts between conditioning signals.
  95. A "time radio" or "time receiver" is a clock that is conditioned by a
  96. national time radio source. High-end dedicated time receivers can
  97. achieve 50 ns accuracy <<RADIO>>; consumer-grade "atomic clocks" (not
  98. actually atomic at all but using a radio time signal) achieve a much
  99. less impressive 30 ms <<HARCC>> or even as poor as 150 ms <<JUNGHANS>>.
  100. Both are often constrained by siting problems and poor longwave
  101. propagation, leading to frequent loss of signal. In some parts of the
  102. U.S., most notably the Boswash corridor and the southern tip of
  103. Florida, coverage is so intermittent <<WWVBMAP>> as to make the WWVB
  104. signal nearly unusable. The technology works better for smaller,
  105. European-sized countries.
  106. Time receivers' model designations often include the call sign of
  107. their radio source; for example, a 'WWVB' receiver uses the
  108. U.S. national time radio, a 'DCF77' receiver uses the German national
  109. time radio, an 'MSF' receiver uses the British national time radio,
  110. and a 'JJY' receiver uses the Japanese national time radio. Some time
  111. receivers (especially those made for the European market) can use
  112. multiple stations. A useful table of national time radio stations is
  113. at <<WIKISOURCE>>.
  114. Devices described as "GPS clocks" (or more technically as "GPS
  115. Disciplined Oscillators" or GPSDOs) are conditioned by the 1PPS output
  116. of a GPS receiver. Worst-case accuracy depends on the accuracy of the
  117. 1PPS and vendor data sheets commonly claim 100 ns, sometimes even 20 ns.
  118. The GPS system standard <<IS-GPS-200G>> Section 3.3.4 specifies that
  119. GPS satellite clock (MSC) from each satellite be within 90 ns of USNO
  120. time to a certainty of one sigma. Adding in GPS satellite position
  121. uncertainty widens the time uncertainty as broadcast from the GPS Sat
  122. to 97 ns at one sigma. Any GPS propagation and reception errors will
  123. add to that uncertainly. Thus one needs to assume a GPSDO will track
  124. USNO time to better than to about 120-200 ns.
  125. A plain GPS, without a stabilized crystal, can serve as a clock
  126. source. However, it will generally be unable to deliver time at all when
  127. it lacks memory of a previous 3D position fix and current lock on at
  128. least one satellite. In other words, it has no "holdover". (NTP
  129. patches around this by using the system clock for holdover.)
  130. GPSes actually deliver two times: 1PPS at top of second, and in-band
  131. time expressed in a message packet over the serial or USB link. In
  132. consumer-grade GPSes, 1PPS may not be shipped to the serial connector;
  133. if it is, it becomes a pulse on a handshake line, usually DCD.
  134. In-band time is usually delivered accurate to the second only and is
  135. shipped with significant and variable delay after 1PPS, typically on
  136. the order of 100 ms. By contrast, 1PPS time output total error will
  137. typically be close to 1&mu;s.
  138. == Basics of NTP
  139. NTP (Network Time Protocol) is a set of protocols that attempts to
  140. synchronize computer clocks across the Internet - ultimately, Universal
  141. Coordinated Time (UTC) as defined by several scale-related atomic clocks
  142. run by national standards institutes. NTP Version 4 is defined in
  143. <<RFC-5905>>.
  144. NTP service daemons running on each host do clock synchronization in
  145. the presence of variable network latency by monitoring those delays in
  146. real time and passing around messages that say, essentially, "I
  147. received your request at time X, I'm sending the reply at time Y and
  148. the propagation delay to my source of time is Z". Each daemon then
  149. uses rather complex algorithms that we won't attempt to describe here
  150. to digest incoming messages into a composite "NTP time".
  151. NTP conditions your system clock by noticing how your system clock time
  152. differs from deduced NTP time, then speeding up or slowing down your
  153. clock's tick rate until it is synchronized. These tick-rate changes
  154. are usually extremely small, much too small for a human or even most
  155. software timing loops to ever notice. But large changes are possible.
  156. NTP's technique exploits the fact that while the quartz crystals used
  157. in PC clocks are not very accurate, they are quite stable - that is,
  158. their frequency drift in response to environmental changes is slow.
  159. Most computers are just NTP clients. They send NTP requests to a set
  160. of servers and use the replies to adjust the local clock. It is
  161. generally expected that NTP clients will have an accuracy (that is,
  162. maximum divergence from the master atomic clock) of of "a few tens of
  163. milliseconds" <<RFC-5905>>; however, problems such as asymmetric
  164. routing, bufferbloat, or large time jitter (especially likely on cable
  165. networks) can degrade accuracy to around 100 ms and even worse in
  166. extreme cases.
  167. Some NTP hosts are time *servers*. They respond to NTP clients with
  168. time read from high-precision reference clocks (often abbreviated
  169. "refclocks") synchronized to national time standards. The refclocks
  170. are all the kinds of precision time source discussed earlier in this
  171. document.
  172. You will hear time service people speak of "Stratum 0" (the reference
  173. clocks) "Stratum 1" (NTP servers directly connected to reference
  174. clocks) and "Stratum 2" (servers that get time from Stratum
  175. 1). Stratum 3 servers redistribute time from Stratum 2, and so
  176. forth. There are defined higher strata up to 15, but you will probably
  177. never see a public time server higher than Stratum 3 or 4.
  178. Jitter induced by variable WAN propagation delays
  179. (including variations in switch latency and routing) makes it
  180. impractical to try to improve the accuracy of NTP time to much better
  181. than the "a few tens of milliseconds" of <<RFC-5905>>.
  182. == Cost-effective clocks
  183. There is about three orders of magnitude between the best achievable
  184. wide-area-network accuracy and even the lowest-end GPS-constrained
  185. clock or time radio. Of all the time sources described here, the only
  186. one not precise enough to drive WAN NTP is in-band time from a GPS
  187. without 1PPS footnote:[Actually, a non-1PPS GPS with sufficiently
  188. clever firmware can be good enough - but they almost never are in
  189. practice, and never in consumer-grade hardware.].
  190. Since the year 2000 GPSes have drastically decreased in price and
  191. improved in performance. For time-service purposes the important
  192. performance metric is weak-signal performance and ability to operate
  193. indoors.
  194. A 1PPS-capable plain GPS that can operate reliably near a window is
  195. for NTP purposes nearly as good as a time radio or GPS clock, and
  196. orders of magnitude less expensive. Even the USB 1.1 polling interval
  197. of 1 ms does not introduce a disqualifying amount of jitter for WAN
  198. service.
  199. LANs are a different matter. Because their propagation delays are
  200. lower and less variable, NTP can do about two orders of magnitude better
  201. in this context, easily sustaining 1 ms accuracy. The combination of
  202. NTP and <<PTP>> can achieve LAN time service another two orders of
  203. magnitude better.
  204. GPS clocks and time radios remain, therefore, cost effective for
  205. driving NTP over LAN. This is significant in many scientific,
  206. industrial, and government deployments.
  207. While pressure from plain GPSes has eroded the competitiveness of both
  208. GPS clocks and time radios, time radios have suffered more. While
  209. theoretically more accurate than GPS clocks, they have not improved in
  210. weak-signal performance in the dramatic way GPSes and GPS clocks
  211. have; they remain finicky and nearly as vulnerable to siting and
  212. skyview problems as the GPSes of decades ago.
  213. Furthermore, the U.S. radio-clock industry was impacted when <<WWVB>>
  214. changed its modulation scheme at 2012-10-29T15:00:00Z. This didn't
  215. affect consumer-grade "atomic" clocks, which resynchronize once a day
  216. and don't use the fine details of the signal, but it obsolesced all
  217. the high-end equipment that conditioned on shorter time scales. At
  218. least one major timing-systems vendor (Spectracom) bailed out of the
  219. time-radio market entirely, and it is not clear there are any high-end
  220. vendors at all left in the U.S.
  221. == Summary
  222. Some figures in this table are from <<GPSD-HOWTO>> and are explained
  223. in more detail there.
  224. .Summary of worst-case deviation from UTC
  225. |==============================================================
  226. |National primary time standard | 20 ns
  227. |WWVB time radio broadcast | 26 ns
  228. |GPS 1PPS top of second | 50 ns
  229. |Dedicated time receiver | 50 ns
  230. |GPS-constrained clock | 100 ns
  231. | |
  232. |1PPS delivered by OS kernel | 1 &mu;s (1000 ns)
  233. |Serial 1PPS | 5 &mu;s (5000 ns)
  234. |1PPS over USB 1.1 | 1 ms (1000000 ns)
  235. |1PPS over USB 2.0 | 100 &mu;s (100000 ns)
  236. | |
  237. |NIST/USNO modem time | 4 ms (4000000 ns)
  238. |Consumer-grade time radio | 30-150 ms
  239. |Normal accuracy of NTP | ~ 30 ms (3000000 ns)
  240. |Jitter of in-band GPS time | > 100 ms (100000000 ns)
  241. |==============================================================
  242. == Further Reading
  243. You can find a practical how-to on setting up a local Stratum 1 time
  244. server using GPSD and an inexpensive GPS at <<GPSD-HOWTO>>.
  245. == References
  246. [bibliography]
  247. - [[[PCI3]]] https://www.pcisecuritystandards.org/documents/PCI_DSS_v3-2-1.pdf[Requirements and Security Assessment
  248. Procedures]
  249. - [[[FINRA_14-47]]]
  250. http://www.finra.org/sites/default/files/notice_doc_file_ref/Notice_Regulatory_14-47.pdf[14-47]
  251. - [[[RFC-5905]]] http://www.ietf.org/rfc/rfc5905.txt[Network Time Protocol Version 4: Protocol and Algorithms Specification]
  252. - [[[BIPM-T]]] ftp://ftp2.bipm.org/pub/tai/publication/cirt/[See latest Circular T from BIPM]
  253. - [[[WWVBMAP]]] http://tf.nist.gov/stations/wwvbcoverage.htm[WWVB Coverage Area]
  254. - [[[WIKISOURCE]]] https://en.wikipedia.org/wiki/Radio_clock[Radio Clock]
  255. - [[[IS-GPS-200G]]] https://www.gps.gov/technical/icwg/IS-GPS-200G.pdf[IS-GPS-200G]
  256. - [[[TIMESCALE]]] https://www.nist.gov/pml/time-and-frequency-division/atomic-standards/nist-usno[NIST Time Scale Data Archive]
  257. - [[[ACTS1]]] http://www.nist.gov/pml/div688/grp40/acts.cfm[NIST Automated Computer Time Service (ACTS)]
  258. - [[[ACTS2]]] http://tycho.usno.navy.mil/modem_time.html[USNO Master
  259. Clock via Modem]
  260. - [[[RADIO]]] https://en.wikipedia.org/wiki/Radio_clock[Radio clock]
  261. - [[[HARCC]]] http://tf.nist.gov/general/pdf/2429.pdf[How Accurate is a Radio Controlled Clock?]
  262. - [[[JUNGHANS]]] http://www.leapsecond.com/pages/Junghans/[Junghans Solar WWVB watch]
  263. - [[[PTP]]] https://en.wikipedia.org/wiki/Precision_Time_Protocol[PTP]
  264. - [[[GPSD-HOWTO]]] link:gpsd-time-service-howto.html[GPSD Time Service HOWTO]
  265. - [[[WWVB]]] http://www.nist.gov/pml/div688/grp40/wwvb.cfm[NIST Radio Station WWVB]
  266. == History
  267. v1.0, 2015-03-10::
  268. Initial version.
  269. v1.1, 2015-03-11::
  270. Lots of tiny corrections from G+ and the blog. Use the NTP
  271. accuracy estimate from RFC 5905.
  272. v1.2, 2015-03-15::
  273. Clarifying language, proof-reading, and minor corrections.
  274. v1.3, 2015-03-16::
  275. Text polishing, terminological cleanup.
  276. v1.4, 2015-07-11::
  277. Text polishing, note upcoming change in FINRA, more about GPSDO precision.
  278. v1.5, 2015-12-10::
  279. Fix typo in WWVB delay figure and date of modulation change.
  280. v1.6, 2019-06-02::
  281. Fix linkrot, and link to https where possible.
  282. v1.7, 2021-01-13::
  283. Add Table of Contents. Cleanup markup.
  284. == COPYING
  285. This file is Copyright 2010 by the GPSD project +
  286. SPDX-License-Identifier: BSD-2-clause
  287. //end