File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / ntp / html / extern.html
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:08:38 2012 UTC (12 years, 7 months ago) by misho
Branches: ntp, MAIN
CVS tags: v4_2_6p5p0, v4_2_6p5, HEAD
ntp 4.2.6p5

    1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    2: 
    3: <html>
    4: 
    5: 	<head>
    6: 		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    7: 		<meta name="generator" content="HTML Tidy, see www.w3.org">
    8: 		<title>External Clock Discipline and the Local Clock Driver</title>
    9: 		<link href="scripts/style.css" type="text/css" rel="stylesheet">
   10: 	</head>
   11: 
   12: 	<body>
   13: 		<h3>External Clock Discipline and the Local Clock Driver</h3>
   14: 		<p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:38</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
   15: 		<hr>
   16: 		<p>The NTPv4 implementation includes provisions for an external clock, where
   17: 			the system clock is implemented by some external hardware device.
   18: 			One implementation might take the form of a bus peripheral with a high resolution
   19: 			counter disciplined by a GPS receiver, for example. Another implementation
   20: 			might involve another synchronization protocol, such as the Digital Time Synchronization
   21: 			Service (DTSS), where the system time is disciplined to this protocol and
   22: 			NTP clients of the server obtain synchronization indirectly via the server.
   23: 			A third implementation might be a completely separate clock discipline algorithm
   24: 			and synchronization protocol, such as the <tt>Lockclock</tt> algorithm used
   25: 			with NIST Automated Computer Time Service (ACTS) modem synchronized time.</p>
   26: 		<p>When external clocks are used in conjunction with NTP service, some way needs to be provided for the external clock driver and NTP daemon <tt>ntpd</tt> to communicate and determine which discipline is in control. This is necessary in order to provide backup, for instance if the external clock or protocol were to fail and synchronization service fall back to other means, such as a local reference clock or another NTP server. In addition, when the external clock and driver are in control, some means needs to be provided for the clock driver to pass on status information and error statistics to the NTP daemon.</p>
   27: 		<p>Control and monitoring functions for the external clock and driver are implemented using the <a href="drivers/driver1.html">Local Clock (type 1) driver</a> and the <tt>ntp_adjtime()</tt> system call. This system call is implemented by special kernel provisions included in the kernel of several operating systems, including Solaris, Tru64, FreeBSD and Linux, and possibly others. When the external clock is disabled or not implemented, the system call is used to pass time and frequency information, as well as error statistics, to the kernel. Besides disciplining the system time, the same interface can be used by other applications to determine the operating parameters of the discipline.</p>
   28: 		<p>When the external clock is enabled, <tt>ntpd</tt> does not discipline the system clock, nor does it maintain the error statistics. In this case, the external clock and driver do this using mechanisms unknown to <tt>ntpd</tt>; however, in this case the kernel state variables are retrieved at 64-s intervals by the Local Clock driver and used by the clock selection and mitigation algorithms to determine the system variables presented to other NTP clients and peers. In this way, downstream clients and servers in the NTP subnet can make an intelligent choice when more than one server is available.</p>
   29: 		<p>In order to implement a reliable mitigation between ordinary NTP sources and the external clock source, a protocol is necessary between the local clock driver and the external clock driver. This is implemented using Boolean variables and certain bits in the kernel clock status word. The Boolean variables include the following:</p>
   30: 		<p><tt>ntp_enable</tt>. set/reset by the <tt>enable</tt> command. enables ntpd
   31: 			clock discipline</p>
   32: 		<p><tt>ntp_contro</tt>l. set during initial configuration if kernel support is available</p>
   33: 		<p><tt>kern_enable</tt> Set/reset by the <tt>enable</tt> command</p>
   34: 		<p>If the <tt>kern_enable</tt> switch is set, the daemon computes the offset,
   35: 			frequency, maximum error, estimated error, time constant and status bits,
   36: 			then provides them to the kernel via <tt>ntp_adjtime()</tt>. If this switch
   37: 			is not set, these values are not passed to the kernel; however, the daemon
   38: 			retrieves their present values and uses them in place of the values computed
   39: 			by the daemon.</p>
   40: 		<p>The <tt>pps_update</tt> bit set in the protocol routine if the prefer peer has survived and has offset less than 128 ms; otherwise set to zero.</p>
   41: 		<p>The <tt>PPS control</tt> Updated to the current time by kernel support if
   42: 			the PPS signal is enabled and working correctly. Set to zero in the adjust
   43: 			routine if the interval since the last update exceeds 120 s.</p>
   44: 		<p>The <tt>ntp_enable</tt> and <tt>kern_enable</tt> are set by the configuration module. Normally, both switches default on, so the daemon can control the time and the kernel discipline can be used, if available. The <tt>pps_update</tt> switch is set by the protocol module when it believes the PPS provider source is legitimate and operating within nominals. The <tt>ntp_control</tt> switch is set during configuration by interrogating the kernel. If both the <tt>kern_enable</tt> and <tt>ntp_control</tt> switches are set, the daemon disciplines the clock via the kernel and the internal daemon discipline is disabled.</p>
   45: 		<p>The external clock driver controls the system time and clock selection in the following way. Normally, the driver adjusts the kernel time using the <tt>ntp_adjtime()</tt> system call in the same way as the daemon. In the case where the kernel discipline is to be used intact, the clock offset is provided in this call and the loop operates as specified. In the case where the driver steers only the frequency, the offset is specified as zero.</p>
   46: 		<hr>
   47: 		<script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
   48: 	</body>
   49: 
   50: </html>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>