21.12. Time Synchronization with xntp

The exact time plays an important role in many processes in a computer system. For this purpose, computers usually have a built-in clock. Unfortunately, these clocks often do not meet the requirements of applications like databases. Therefore, the local clock must regularly be corrected manually or over a network. In the best case, the computer clock should never be set back and the amount by which it is set forward should not exceed certain time intervals. The computer clock can easily be corrected with ntpdate from time to time. However, this causes a sudden time difference that may not be tolerated by all applications.

xntp provides an interesting approach for solving this problems. First, xntp regularly corrects the local computer clock on the basis of collected correction data. Second, it continuously corrects the local time with the help of time servers in the network. Third, it enables the management of local reference clocks, such as radio-controlled clocks.

21.12.1. Configuration in the Network

xntp is preset to use the local computer clock as time reference. The easiest way to use a time server in the network is to set “server” parameters. For example, if a time server called ntp.example.com is available in the network, this server can be added to the file /etc/ntp.conf in the form server ntp.example.com.

To add further time servers, insert additional lines with the keyword server. After initializing xntpd with the command rcxntpd start, it takes one hour until the time is stabilized and the “drift” file for correcting the local computer clock is created. In the long run, the advantage of the “drift” file is that the drift of the hardware clock can be projected as soon as the computer is powered on. The correction is activated immediately, resulting in a high stability of the computer time.

If the time server in your network can be reached via broadcast, you do not need the server name. In this case, enter the command broadcastclient in the configuration file /etc/ntp.conf. To avoid an incorrect time server in the network from changing the computer time, set up the authentication mechanisms.

Normally, every xntpd in the network can also be addressed as time server. To run xntpd with broadcasts, configure the broadcast option:

broadcast 192.168.0.255

Adjust the broadcast address to your circumstances. Make sure the time server uses the correct time. This can be done with reference clocks.

21.12.2. Setting up a Local Reference Clock

The software package xntp also contains drivers for connecting local reference clocks. A list of supported clocks is available in the xntp-doc package in the file /usr/share/doc/packages/xntp-doc/html/refclock.htm. Every driver is associated with a number. In xntp, the actual configuration takes place by means of pseudo IPs. The clocks are entered in the file /etc/ntp.conf as though they existed in the network.

For this purpose, they are assigned special IP addresses in the form 127.127.t.u. Refer to the above-mentioned file containing the list of reference clocks to get the value for t. u is the device number that is only higher than 0 if you use several clocks of the same type on the computer. For example, a “Type 8 Generic Reference Driver (PARSE)” has the pseudo IP address 127.127.8.0.

Normally, the individual drivers have special parameters that describe configuration details. The file /usr/share/doc/packages/xntp-doc/html/refclock.htm provides links to the respective driver pages describing these parameters. For example, the “Type 8” clock requires an additional mode that specifies the clock more precisely. For example, the Conrad DCF77 receiver module has mode 5. To make xntp accept this clock as a reference, specify the keyword prefer. Thus, the complete server line for a Conrad DCF77 receiver module would be:

server 127.127.8.0 mode 5 prefer

Other clocks follow the same pattern. Following the installation of the xntp-doc package, the documentation for xntp is available in the directory /usr/share/doc/packages/xntp-doc/html.