Why a Network Clock Can Jump

A network clock estimates time across an uncertain path. The clock you use to timestamp a receipt can correct itself, which makes it a risky choice for timing an interval.

The NIST-F1 cesium fountain atomic frequency standard
In this story 5 sections

A computer records the start of a task at noon. When it records the finish, the clock says that the task started two seconds in the future. Nothing peculiar had to happen to the task. Between the two readings, the time shown by the computer can have been corrected. This is a small argument for treating the answer to “what time is it here?” differently from the answer to “how long did this take?” Both can be served by a clock. A good answer to the first sometimes has to adjust something that a good answer to the second would rather leave alone.

Network Time Protocol, or NTP, is one way equipment estimates time using remote sources. NIST offers an internet time service that can be consulted by ordinary systems. Contacting a time server does not give a computer an instantaneous path to the reference. A message spends time traveling to and from it. The local computer needs to estimate its offset despite the path and decide how to adjust the clock it will use in between. Turning those observations into a useful result takes more care than copying the numbers that a faraway device reports.

A reference and a local clock have different jobs

The official photograph here shows a NIST cesium fountain standard. This is part of the story of how institutions obtain reference measurements of time and frequency. It is not a picture of the internet server or a part inside a household machine. In a computer, a local oscillator and operating system keep time between communications. An interval of accurate time needs this local continuity. A service on the other side of a network is of no use to a machine that cannot remember how its own clock has been running since the most recent observation.

A clock can disagree with a reference in two fairly different ways. Put two clocks side by side. At the first comparison one is ahead by one second. If an hour later it is still a second ahead, you have seen an offset without much evidence in that interval of a difference in rate. If it has gained another second, their rates were not quite the same. The second comparison makes it easier to predict what will happen if you leave them alone. A service that measures time on several occasions can learn something about the pattern rather than treating each readout as an isolated disagreement.

Think of a laptop that spent a long time disconnected. It may come back in a state where its best local estimate is appreciably off. A machine receiving frequent and consistent comparisons can have a different problem: small errors have to be handled smoothly while time remains useful for applications. How and when the clock adjusts is a matter of software and configuration. It could correct abruptly or pace a correction over some time, depending on the system and size of the discrepancy. You cannot infer which policy a particular device uses merely from knowing it supports network time.

A timestamp came by a route

In a familiar NTP exchange, a client can record when it sent a request and when it received a response, with server timestamps representing reception and transmission at the other end. This gives the systems information about the interval and lets an algorithm estimate a timing difference. Two ends of the transaction give a useful comparison. They do not separate everything that happened in transit. If one direction took longer than the other, a calculation that assumes the delays were roughly balanced can be biased. That bias belongs to the measurement path, not to the quality of the reference standard.

A stripped-down example shows the problem. Suppose a message travels out for 10 milliseconds and returns for 10 milliseconds, ignoring any time spent at the server for purposes of the example. On a later exchange the outward route takes 3 and the return takes 17 milliseconds. The total delay is 20 milliseconds in both examples. If we infer from the total alone that each side took 10 milliseconds, that assumption is much worse for the second exchange. An accurate measurement at the remote end does not tell the local machine how it got from one timestamp to the next.

A later observation on a less busy or differently routed path can provide better evidence than the first one. Repeated measurements and more than one appropriate reference can give a time system a way to assess which comparisons agree. It still needs criteria for using them. A confident-looking output with many digits is not a report of how long the unknown part of the path was. Where subsecond comparisons between systems matter, look for an account of the time source, the way time was transferred and what accuracy is actually supported.

A date is not an interval

Applications often need a clock for stating when something happened. A customer receipt has to give a date and time that someone can use in a real conversation. A log shared between several machines has to be understandable across them. These uses typically need some relationship to civil time, with timestamps and clear handling of time zones. A clock designed to serve that relationship can be corrected as its estimate changes. A display’s local time may also change for reasons separate from synchronization, such as an intentional change to the time zone.

Measuring how long the current machine took to do a job can use a different facility. Operating systems often expose monotonic clocks for elapsed-time measurements: the reading does not jump backward in response to ordinary changes to the civil clock. It has an origin that need not be a date anyone recognizes. The interval comes from subtracting two readings of the same suitable clock, not by printing either reading as noon on an invoice. The behavior across sleep or suspension can vary by clock and system. That distinction matters if sleeping time belongs in the duration being measured.

Write a pretend record for the task at the beginning. In one field record the date-time of the start as understood by the system. In another keep the starting reading of its monotonic clock. At the finish, record the corresponding fields again. If the civil time was corrected during the job, the two dates can be awkward to compare. The difference between the interval readings can still be useful for the elapsed duration the clock was designed to track. Having both records lets the service tell which part of the evidence uses which convention.

Crossing time zones without turning the clocks

Civil timestamps are easier to reconcile when they carry an explicit offset or give their relationship to UTC. If you receive a list of events with the time 01:30 printed twice, two lines may refer to different absolute times where the local time zone has returned to an earlier hour. Nothing needs to have gone wrong with synchronization. A list can preserve the offset or an unambiguous reference value and give readers the local display separately. Conversely, subtracting two printed local times across a zone change will not give a dependable estimate of time spent inside an operation.

Look for the interval itself if someone reports processing time for both machines. A start and end from the same monotonic source can give a sensible duration on that machine, and a server timestamp can locate the surrounding record in civil time. Values from two unrelated monotonic clocks cannot be subtracted as though they share an origin. The pair of measurements gives you two useful types of evidence as long as there is a label keeping their origins straight.

Put the measurements back on a chart

Errors become visible when several machines tell one story. One log might say it sent a message a little after another says it received it. This can happen when the clocks have different offsets, especially if the two events were close. Compare identifiers and local event order before using a list sorted by timestamp as an authoritative global sequence. A synchronized timestamp has value, but the last few digits may claim more order than the system and measurement path can establish. The shorter the interval, the more important that limitation can become.

For a simple local check, note whether a discrepancy concerns a device that was offline, a change of display time zone, or different actual time settings on machines. Those possibilities require different observations. If the question is about a slow task, measure it directly with a suitable elapsed-time facility. If it is about the time assigned to a stored record, inspect how the record represents dates and whether its time source was healthy. In either case, report what you were trying to compare. That prevents “the clock jumped” from being treated as a complete account of an unrelated delay.

A service can record evidence that helps later interpretation: which clock supplied the timestamp, which zone or reference the format expresses, and whether the system reported a time correction. None of this requires clocks to be perfect. It asks that a record show enough of its construction that people do not mistake a timebase correction for a remarkable fact about a task. The equipment at NIST and a tiny date field on a receipt are connected by a series of estimates. The useful skill is knowing which estimate the number in your hand represents.

Further reading