The NTP Daemon Network Time Distribution

Chapter 13: Time−Related UNIX Facilities

13.1 Network Time Distribution

UNIX supports the distribution of an accurate time throughout the network. This means that each host in the overall network is synchronized to a selected timeserver, or servers, which transmit a reference clock time to the time client hosts. A reference clock will generally though not always be a radio time code receiver that is synchronized to a source of standard time such as NIST in the U.S., or NRC in Canada. The time distribution is based on the network time protocol NTP, currently version 4 which is fully compliant with version 3 standard, defined by Request for Comments RFC 1305, and compatible with previous versions 2 and 1, defined by RFC 1119 and RFC 1059. The computation done in the protocol is fully provided in fixed−point arithmetic, and together with the clock adjustment code, brings a high precision that maintains accuracy comparable with even the most precise external time sources.

13.1.1 The NTP Daemon

A special NTP daemon, named xntpd, is responsible for maintaining a UNIX systems time−of−day; it is also known as the time server. The time server provides the time service, or acts as a time client. We will use the term the xntpd daemon or the NTP daemon, just to avoid any possible confusion. The xntpd daemon works in compliance with Internet standard time servers; it follows the distributed reference time. The xntpd daemon exits collapses if the difference in the system time and the reference time is more than 1000 sec; otherwise, it slowly brings the system time in line with the distributed reference time. The NTP daemon reads its configuration file etcntp.conf or etcinetntp.conf, as on Solaris 2.x at the startup time, and learns its duties. If any configuration change has been made, the daemon must be restarted. The daemon can be configured to act strictly as a time client by specifying appropriate configuration entries, which means it will only synchronize its own systems time, or it will act as a potential time server. The term potential is used to emphasize the fact that even when the local xntpd daemon is willing and ready to transfer the reference time over the network, the NTP daemons running on other hosts decide if they will use the offered service. This concept will be clearer once we explain basic configuration entries. The xntpd daemon is not mandatory on every system. It is easy to determine if it is running on your system by executing the command as in this example, from HP−UX 10.20: ps −ef | grep ntp | grep −v grep root 1284 1 0 Feb 25 ? 5:27 usrsbinxntpd Or, on Solaris 2.x: ps −ef | grep ntp | grep −v grep root 956 1 0 Mar 08 ? 0:03 usrlibinetxntpd The NTP daemon is started only if the configuration file is set appropriately. Here is the partial rc startup sequence on Solaris 2.6 from the etcinit.dxntpd rc script: start Only start if there is a config file if [ −r etcinetntp.conf ] ; then ARGS= cat etcinetntp.conf | usrbinnawk ….. ..... 301 If [ −z ARGS ] then wait until date is close before starting xntpd usrsbinntpdate ARGS ; sleep 2 ; usrlibinetxntpd else usrlibinetxntpd fi fi ;; This sequence is a part of the case statement. The way the xntpd daemon is started depends on the existence and contents of the configuration file. The start script lives in the etcrc2.d directory: ls −l etcrc2.d | grep xntpd 203745 −rwxr−−r−− 4 root sys 1266 Jul 16 1997 S74xntpd It is also the hard link to the rc script in the etcinit.d depot directory: ls −l etcinit.d | grep xntpd 203745 −rwxr−−r−− 4 root sys 1266 Jul 16 1997 xntpd

13.1.2 The NTP Configuration File