In association with heise online

30 June 2008, 14:56

Computer network time synchronisation

Ernst Ahlers

The Network Time Protocol (NTP) ensures that the clocks of computers over a network are in sync

No one notices if the time is wrong during a game of Minesweeper, but people notice when emails seemingly disappear or there are problems with the log files during troubleshooting. After a quick tweak to the configuration and perhaps the help of some freeware tools your PC will always know exactly what time it is.

Image 1

Time not only plays an important role in emails or when the date is automatically inserted in a data processing application, but it is also crucial in other applications or system functions. For example, it is used in log files, Kerberos tickets, SSL certificates, differential backups or data synchronisation with a PDA. It also has a direct effect on timed actions such as planned tasks under Windows, cron under Unix or when operating a digital video recorder under Linux.

Once the time has been set, the real-time clock that is integrated in PCs and Macs starts to drift from the actual time, just as it does in wall clocks or wristwatches. Some drift will occur even if you adjust it once a month.For many applications it may not be critical if the system clock deviates from real time by a few minutes and, as long as the battery on the motherboard is relatively new, the system runs reasonable accurately. But after a few years the battery begins to weakens and the on-board clock starts to run slow. Deviations of hours or even and days are not unusual. As soon as you are confronted with the possibility of losing the BIOS configuration, it becomes high time to replace the battery.

However, sometimes to-the-minute accuracy is not enough. If you are looking for errors in a network, the log files on the different computers involved can often be very useful. However, if the computers' internal clocks are slowly drifting apart, it is almost impossible to reconstruct whether event A on computer X triggered the problem that occurred before or after event B, on server Y.

In a research experiment where several computers work together in a joint measurement, synchronisation that is as accurate as possible is usually essential. Long-term measurements in which a computer continually records data over weeks or months would also be affected by drift on a PCs internal clock.

For individual computers it may be enough to connect to an atomic clock that receives the DCF77 long-wave time code signal, which evaluates the encoded time signal and ensures the clock is accurate down to the second. More complex systems use Global Positioning System (GPS) satellite signals. Both solutions are expensive, and may require a separate power supply and a port on the PC.

Atomic clock
Zoom One of the atomic clocks that keep UK time at the NPL. This shows the vacuum chamber for the atomic fountain. "Courtesy of NPL (c) Crown copyright 2005".
Long-wave receivers usually work inside buildings, but metal blinds can interfere with the DCF77 signal and cause dropped connections. If you place a DCF77 clock next to a television set, the radiation from the television will interfere with the transmission, because the fifth harmonic wave of television's horizontal deflection (5 × 15.625 = 78.125 kHz) is close to the time signal (77.5 kHz) and interferes with its reception. With certain combinations of resolution and refresh rate, for example 1280 x 1024 pixels and 75 Hertz, a CRT PC monitor can also transmit a frequency within that range. This does not affect a GPS clock, but a GPS system requires a correctly aligned antenna with an unobstructed view of the sky to receive the GPS satellite signals.

There are other ways of getting the exact time, such as the telephone time service offered by the UK's National Physical Laboratory (NPL). The NPL is the official home of the UK's precision time-keeping, and "offers a range of services that provide access to a reliable and trusted source of time: the Time from NPL."

ISDN is another alternative time source; however, it is not the best solution. ISDN time can deviate from the standard time by up to a minute, with varying differences between the different switching centers. Also, the ISDN system only transmits the time once you have successfully connected to it. You can use a toll-free number, but the ISDN network only transmits the time when a connection has been established. The displayed time in the telecommunication installations can also deviate significantly from the transmitted time.

Alternatively, anyone who has an internet connection and is occasionally on line can access the exact time without a lot of work and additional cost.

Time line

Back when the internet was still in its infancy, one of the questions that arose was how to transmit the time between network computers. The first set-ups were pretty simple. A server can transmit its time in ASCII plain text over port 13 (DAYTIME protocol, RFC 867). It can also transmit the number of seconds that have passed since January 1, 1900 as a 32-bit binary value over port 37 (time, RFC 868). Time cannot be transmitted using these services in increments that are less than a second.

Simple time protocols such as DAYTIME and TIME are only really accurate in a LAN environment, because the IP packets are sent with millisecond delays. There can be large differences (jitter) that vary during the day when accessing the time over the internet with its unpredictable latencies. Some servers have to start a new process each time they query the time using the DAYTIME or TIME protocols, so if a lot of clients frequently access these services, the system load increases considerably. That is why you should only use these functions under special circumstances.

The time counter will overflow in 2036, but, just as with DAYTIME, the accuracy mainly depends on the server's internal clock. It can vary considerably over time if the admin does not adjust it on a regular basis. Back in 1988, David L. Mills, the original developer of the NTP, discovered that, of the 1,158 servers he examined, sixty per cent differed from the true time by more than one minute and ten per cent differed by more than 13 minutes.

The deficiencies of DAYTIME and TIME led to the development of the hierarchical Network Time Protocol or NTP – port 123, RFC 1305 and others –, which allows servers to communicate a common time with one another. NTP measures and then largely compensates for the packet delays on the internet. At the same time the NTP process of a server acts as a clock and does not rely on the system clock.

Print Version | Permalink: http://h-online.com/-747388
  • Twitter
  • Facebook
  • submit to slashdot
  • StumbleUpon
  • submit to reddit
 


  • July's Community Calendar





The H Open

The H Security

The H Developer

The H Internet Toolkit