time-service-intro.adoc 16 KB

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