Time correction

General-purpose computers (like a PC or Mac) do not generally have a very accurate clock. However they can be corrected by referring to an external clock. The most common method of correction is Network Time Protocol (NTP), and the most common external clock is an atomic clock over the internet. NTP gives excellent long term accuracy. But is this correction sufficient to give you accurate times for a Head race?

Network Time Protocol

There are two main factors to consider when correcting the computer time with NTP:

  1. How often the time is corrected (combined with how innacurate the time is between corrections)
  2. The variations in accuracy of the time received from the time server(s)

NTP frequency of correction

NTP works by obtaining the time from a network or internet time server, and correcting the computer clock. The time comes ultimately from a caesium atomic clock. Every time you correct the clock, the time will be accurate to a very high degree. NTP is generally considered to give an accuracy to within a few milliseconds in the right circumstances.

In between synchronisations the computer clock runs at its normal level of (in)accuracy. So it is highly accurate every once in a while, and drifts off in between. The overall accuracy depends on how often it is corrected, and how far it wanders between corrections.

Windows by default will synchonise the clock once per week. This is sufficient for most computer operations but is far too infrequent for timing. You can use NTP software (on Windows, Mac, Linux, Android etc.) to manage the NTP process much more closely. The NTP project produces the source code, which is then compiled into different applications. Meinberg, who are specialists in precision timing hardware, provide a free NTP Windows client.

There is no fixed rule for how often to correct. We do not want a jump in time greater than one tenth of a second, and preferably (if possible) not greater than one hundredth if we are using video timing. An interval of 5 minutes seems about right. If the frequency is too high we might get blocked by the time server. If the frequency is too low we can expect bigger jumps each time the computer clock is corrected. See the test results below for an impression of how the corrections apply.

NTP variation in accuracy

The variation in accuracy of NTP time correction comes from the network used to connect to the NTP time server. Assuming we are connecting to an internet time server, such as time.microsoft.com, then we might connect over: a high speed commercial internet connection; a broadband or cable connection; or over a mobile network. These will have very different latency characteristics. Latency is the time it takes to make a request to a time server and receive the reply.

NTP uses algorithms to check and correct the time received from a time server. For example, you might use several time servers. If they disagree you need to choose. Another example is the correction method. When correcting, you can either jump straight to the correct time, or you can merge in with it by correcting a small amount at a time.

To account for the network delay the basic algorithm is to halve the round trip time. For example, if you make a time request to an internet time server, and it takes 100ms to receive the reply, you can take 50ms from the time you receive it, and assume that this was the time when it was sent.

This works if the latency is symmetrical. But the internet is not symmetrical. There is no reason to assume that a message going to the time server takes the same amount of time as the message coming back, since there is no reason to assume they would take the same path. So in the case of the 100ms round trip time, you might assume that there could be a margin of error in the algorithm of perhaps 50ms i.e. the message might get there in 25ms but take 75ms to get back. You have no way to know for sure.

The higher the latency, and the greater the lack of symmetry, then the larger the margin of error. Over a mobile network you might have an average latency of 500ms, and sometimes as high as 1 second. In this case the margin of error might be several tenths of a second. Sometimes the request might time out altogether, and so the time will be uncorrected. This level of accuracy would be unacceptable for Head race timing.

Testing NTP

There are plenty of studies showing the accuracy of NTP at the place the study was conducted. It is harder to test the accuracy of your own NTP connection, and the accuracy of your computer clock, without scientific equipment. Essentially you need two things:

  1. an accurate local time source to compare with the time received from the time server
  2. a way to request the time from the local time source and NTP, or the local time source and the computer clock, simultaneously. To do this you need an automated trigger that requests the time from both time sources.

Here is a simplified test of NTP accuracy. I have used a utility that: obtains the time from a time server; corrects the local clock; and measures the offset at each correction. I have measured the offset over a cable internet connection using wired ethernet; the same using a wireless connection; and using a mobile internet connection.

Caution: this test is using one NTP time server to correct the Windows clock, using the Windows Time Service. More accurate implementations of NTP are possible by: using more than one time server with an algorithm to select the most likely time; using a full NTP client with a more controllable clock, for example on UNIX or Linux.

In this simple test, although we cannot know the actual time at the measurement points we can see several interesting things:

  • The level of correction that takes place at 5 minute intervals, indicating how much the computer clock drifts in that time
  • The consistency of correction (most and least correction; loss of connection; standard deviation of correction etc.)
  • The difference in correction over wired, wireless and mobile connections. If we assume that both the time server and the computer clock are consistent between tests, then we can assume that the variation between tests is attributable to the network
  • The difference in correction between different computers.

The data is presented in a spreadsheet. A summary is:

  1. With wired ethernet over a cable internet connection the time jumps mostly in the range of 0 to 10 milliseconds per 5 minutes (say ±5 around a value of −5). There are a few time jumps outside of this range, with a maximum of 25ms. This should be fine for manual Head race timing, as long as the internet connection is reliable.
  2. A wireless connection to the internet router adds more variation. The average correction is still the same, but the range of corrections is wider. The maximum jump is 80ms (nearly one tenth of a second). This is still just about acceptable for hand timing.
  3. With a mobile internet connection the time jumps several tenths of a second. The connection occasionally drops altogether. This is unacceptable for Head race timing. With a wireless connection to a mobile internet router the error will probably be even higher.
  4. None of the methods are accurate enough for video or photo finish timing with an aimed-for accuracy of a few hundredths of a second.
  5. A high performance workstation showed smaller variation than a laptop. The average correction is the same, but the range of corrections is significantly narrower. This might reflect the quality of the clocks, or it might reflect the power saving characteristics of the laptop.
  6. The total time correction of the clocks over three hours amount to about two-tenths of a second. This is material if the network fails such that there is no correction.

NTP correction by wired ethernet over cable broadband

 

NTP correction by wireless ethernet over cable broadband

 

NTP correction by mobile internet

Better time correction

The accuracy of NTP time correction can be increased in several ways:

  • choose a nearby time server with low latency
  • use a low latency internet connection, for example a leased line (but this is probably not available to a Head race)
  • using multiple NTP servers
  • using a more controllable time service, for example on UNIX .

Alternatives to NTP are:

  1. Precision Time Protocol
  2. A local GP-based time server
  3. A replacement for the computer clock.

These options are described for reference. They may not offer a practical alternative for a Head race.

Precision Time Protocol

A new protocol, Precision Time Protocol (PTP) provides greater accuracy than NTP. PTP uses a network card to timestamp the incoming and outgoing time messages on client and server. It can therefore correct for network delay. However it requires a PTP server, and a software application on the client with the right network card drivers to use the precision time. Here is an example of a PTP network card from Symmetricom.

The computer clock will still need to be corrected, and will still be relatively inaccurate between corrections. However a PTP correction should keep the computer to roughly 5 milliseconds accuracy.

Local time server

Another option is to have a local time server, using either GPS or radio as a time source. You would need one at each timing point. The computer would still use NTP to connect to the local time server. An example is the LANTIME M200 from Meinberg.

Replacement clock

You could use a different clock, instead of the built in computer clock. The computer would output a request for time to one of these clocks, and receive back the precise time, obtained by synchronisation to GPS. An example of an external clock is the GPS170 from Meinberg.

Conclusions

  1. NTP provides a sufficiently accurate source of computer time correction for hand timing, provided that the connection is:
    • to a local time server (i.e. in the UK for a UK Head race)
    • over a broadband internet connection or better.
  2. NTP over a mobile internet connection is not sufficiently accurate for Head race timing in any circumstances. Indeed, the computer alone is more accurate than the "corrected" computer, because of the erratic nature of the corrections.
  3. NTP over broadband is still not really suitable for video or photo finish timing, where accuracy should be to one hundedth of a second or better. NTP is capable of accuracy to ±5 milliseconds, but only over low latency connections that are not likely to be available for a Head race. Even with this, if the connection were lost, then the timing would become inaccurate.

References

Windows Time Service

Microsoft: About Timers

Network Time Protocol (NTP) Project

IEEE 1588 Precision Time Protocol (PTP)

Meinberg NTP Time Server Monitor