In many Administration and Reference Guides for our software products the reader will find the laconic comment that system times of Remote Probe Systems and the Management Server should be synchonized using e.g. NTP. This article describes how to implement this.

Background

Usually a computer is equipped with two clocks. A CMOS clock which can be set in the setup-menu of the particular computer system and a operating system or kernel based clock. The CMOS clock is queried during system boot and is used to set the operating system clock during the boot phase. Afterwards the kernel will usually not refer any more to the CMOS clock (at least until system shutdown). During system up-time the CMOS clock and the kernel based system clock will drift apart. There are many reasons for this starting with fabrication based inaccurateness of quarz crystals and ending with exhausted mainboard batteries. During shut down the operating system might update the CMOS clock with the current operating system clock timestamp. Goal of this is that the CMOS clock should be set to the mots close date- and timestamp.

The operating system based clock is steered by timer interrupts. Usually this allows very precise timekeeping. If this does not apply for your computer there might be chipset based reasons - like e.g. the APIC interrupt arbitration mode or overclocked processors. Before you try to apply any system time synchronisation measures you should sort out such a problem.

From our daily experience we know that watch times are drifting away. Some clocks lose or win some seconds or milliseconds per month, but at the end any clock time will differ from the other at the end of the year. Same applies for computer clocks.

Setting the local clock

The first solution to deal with this problem is to synchronize the local cloxk at regular intervals with the system time of a - let's say - local computer group leading server. Numerous applications have been developed to fulfill this need. They are usually executed during night hours and will synchronize the local clock time to the time of a server. Outcome is, that local time deviation to server time is limited.

As long as the local clock is behind the server clock, this is a straight-forward soluion for nomal business computers being used to write documents and e-mail. At some point during the night, the local clock makes a jump and everything is in sync again, only some seconds or milliseconds passed away. Well, and if our local clock is ahead of server time? In this case, the local clock will be set back. This means that system time looses it's continuity. Several points in time have the same clock time. To summarize, this is not really what we want to achieve.

Another issue with this practice is that computer clocks on most systems will loose or win to much time even in a time period of only one day. Apart from other reasons this applies especially for systems under high CPU and interrupt load.

Therefore we discourage the use of "setting the local clock" practice for systems being used in measurement applications and service management systems.

Discipline local clocks

A better approach is to discpline the local clock to beceome more exact. If our local clock is behind server time, the clock will be accelerated, resulting in time passing by faster. If the local clock is ahead of server time, the local clock will be slowed down a bit, resulting in time passing by slower.

Based on this the local clock should be disciplined to run in sync with the leading server and will have the same clock time as the server. The check intervals can be increased and the clock frequency will get stabilized. In fact there are a number of rasons that stabilization is limited but basically it is possible to discipline the local clock quite well for most purposes.

There basically two standards being used for clock synchronization over the network.

  • Network Time Protocol (NTP) and
  • Simple Network Time Protocol (SNTP)

For both implementations are avialable. Micrososft Windows Operating Systems (e.g. Windows 2000 Pro, 2000 Server, XP Pro, 2003 Server) have built in supoort for SNTP.

Most UNIX systems including Linux inlcude support for NTP. If not delivered with the particular distribution, the NTP implementing "ntpd" and supporting tools can be received as binary packages or can be built using the original NTP software sources with little effort. It is also possible to run NTP on Windows systems. Binary versions with easy usable installers are avialable here as well.

General remarks on time synchronization over the Internet

To sucessfully use time synchronization over the Internet a permanent connection to the Internet should be available. ADSL connections can be used, but don't allow the same level of accuracy like symmetric internet connections allow.

It should be pointed out explicitly that time synchronization over the Internet will cause IP traffic and might leading to additional connection costs. It should be also clear that (S)NTP packets might trigger the setup of an IP connection to the internet in some configurations (especially with time based tariff plans of your Internat access provider).

Finally the Internet connection should provide some level of quality in terms of packet jitter and packet loss rates.

Configure SNTP on Windows 2000 Pro

On Windows 2000 Pro there is no GUI available to configure SNTP. Two other way exist to configure SNTP support: a) editing the registry withe "regedit" or b) using the command line interface. We recommend to use option b.

  • Open a Command Prompt (On German Windows 2K:Start/Programme/Zubehör/Eingabeaufforderung) (On english Windows 2K: Start/Programs/Accessories/Command Prompt).
  • Enter "net time /setsntp:'NTP server name'" to configure the name of a NTP time server, e.g. "ptbtime2.ptb.de" in Germany.
  • Enter "net stop w32time" to stop the Windows Time Service.
  • Enter "w32tm -once" to set the local clock to the time of the time server.
  • Enter "net start w32time" to start the Windows Time Service (again).

Configure SNTP on XP or Server 2003

A GUI can be used to configure the Time Service.

  • Select "Start/Settings/Control Panel". The "Control Panel" opens.
  • Select "Date and Time".
  • Select the Tab "Internet Time".
  • Activate the check box "Automatically synchronize with an Internet time server"
  • Enter the name of the time server and click the "Update Now" button.

Configure NTP on a Linux/UNIX system

Some system distributions like Suse Linux allow to configure NTP configuration via system management tools (like "yast"). If such tools are available, please use them.

However, at the end also this tools create a configuration file being used by the time service deamon "ntpd". An example configuration is given below:

server ptbtime1.ptb.de
server ptbtime2.ptb.de
server 127.127.1.0
fudge 127.127.1.0 stratum 10

driftfile /var/lib/ntp/drift/ntp.drift
logfile /var/log/ntp

Two internet time servers are given here. A third pseudo server entry defines to use the local clock as synchronisation source if everything else fails. The "fudge" statement defines this behavior. Finally the configuration file includes some log file statements.

Whether the time server daemon is running or not can be determined by entering "ps ax | grep -i ntpd". To start the time server daemon there is usually a rc-file avialable in "/etc/rc.d" or "/etc/init.d" named "ntpd" or "xntpd". In this directory the daemon can be started with "./ntpd -start", with "./ntpd -restart" it can be restarted etc.

The startup of time server daemon is usually controlled by configuration files in the "/etc" directory, e.g. for Suse it is "insserv.conf" and for FreeBSD it is "/etc/rc.conf". Please refer to your system distribution documentation for details.

Using NTP on Windows

For one or another reason also Windows users might considerate to use NTP in combination with the NTPD. Basically it is possible to retrieve the current NTP distribution from www.ntp.org and to compile it. Another more convenient way to get an executable of NTPD for Windows is to download and install a pre-compiled version, e.g. from Meinberg, a leading supplier of time servers.

The Windows installer for NT, 2000, XP, 2003 and Vista can be downloaded from http://www.meinberg.de/english/sw/ntp.htm. On the same page you'll find a handsome NTP time server monitor for Windows.

Improving NTPD's accuracy when synchronizing clocks over the Internet Today a significant number of people maintains a continious connection to the Internet, mostly using DSL or Cable-TV links. Obviously this link type is also used for time synchronization. While this is logical in principal, some restrictions should be taken into consideration:

Most links provide different packet delays for up- and downlink. NTPD assumes symmetric behaviour. At some points in time congestion can be observed on these links, e.g. during downloads casued by the subscriber. While the congestion itself is not visible to NTPD, the thereby caused variations of packet round trip times might lead to larger time deviations. Especially in case of long lasting downloads NTPD might get confused by packet delay variations. To avoid this, newer versions of NTPD include options to filter packet delay variations. To limit the effect on packet delay variations, the "tinker huffpuff" option in the configuration file of NTPD should be used. Tinker huffpuff will cause NTPD to trigger on the minimum of packet round trip times for NTP communication with servers and peers.

To improve NTPD's accuracy you should considerate to set

tinker huffpuff 7200

in your NTP configuration file.