Computer Time Synchronization
A Beginner's Guide to Network Time Protocol (NTP)
Warning! This page contains obsolete information.
What NTP Does and How It Works
Before getting to the mechanics of setting an NTP server up, it's
necessary to provide an explanation of how NTP works. This is
going to be very basic; if you want the details go to the
official site.
The Executive
Summary gives background on the protocol and the
Notes on Configuring NTP and Setting up a NTP Subnet
explains how NTP works and gives details on server organization
and interrelationships. The Executive Summary is heavy reading
with subheadings like "Computer Clock Modelling and Error
Analysis", "Correctness Principles" and "Data Grooming
Algorithms."
The reorganized NTP site includes a new
Official
NTP Documentation page.
NTP is based on a multi tiered system where each layer is called
a stratum. Servers at each level peer with each other and
provide time services to lower levels. Servers at the top or in
stratum 1 are directly connected to atomic clocks or radio based
time receivers. By compensating for their distance from the
authoritative time sources these, receivers provide highly
accurate time services to stratum 1 servers.
Because clocks can fail like any hardware, stratum 1 servers peer
with other stratum 1 servers. NTP assumes that there is a
correct time value and that by using multiple sources,
unreasonable values can and should be discarded. This is not
simple or weighted averaging like UNIX's timed provides. If
their clock diverges from the times provided by the peers by more
than the reasonable amount, stratum 1 servers will stop using
their own clock. There are approximately 100 public and semi
public stratum 1 servers.
Below stratum 1, NTP servers are supposed to obtain time from
servers above them as well as at their own level (stratum). The
configuration instructions say that each top level server within
a specific domain should be a client to at least two servers at
the level directly above it and peer with all the other servers
in their own domain at their same level as well as at least one
other outside peer on the same level. The client servers receive
time from but never provide time to the servers at the next
higher stratum. Peers receive time from and provide it to other
peers. There should be at least three coordinated top level
servers in each domain so each network should communicate with at
least 6 outside servers at the next higher (numerically lower)
stratum and at least 3 outside peers in the same stratum.
There are somewhat more than 100 public stratum 2 NTP servers. See
Public
NTP Time Servers for the rules for accessing these servers and the
lists of public NTP servers. Because of the load placed on
stratum 1 servers, only NTP servers providing time services to
more than a hundred clients should connect directly to stratum 1
servers. Individual computers and small LANs should use the
public stratum 2 servers provided in the list.
When acting as a client and obtaining time from another NTP
server, the NTP server measures the total time it takes to get a
response. It assumes that the network delay is one half the total
and calculates the offset (amount to adjust the local clock)
based on this. Because of variable network conditions the actual
delay may be different on the two legs of the trip. By talking
to several servers, it should get a fairly tight clustering of
valid times and discard the times that are clearly off because
the return leg was much longer or shorter than the outgoing leg
or for other reasons.
When the NTP server is first run on a computer, it is very active
in talking to the servers from which it obtains its time so it
can determine the network delay and a reasonable starting offset.
It also starts to calculate the local computer's drift (the
amount by which the clock is fast or slow). After the drift is
calculated the normal behavior is to save it in an ntp.drift file
so that following computer or server restarts it doesn't need to
repeat all the work it does the first time it runs. The
Quick
Start page gives details of what an NTP server does when it
first starts.
The first time an NTP server runs, after calculating the offset,
it typically makes a single large time adjustment. Since this
could result in moving the clock back by a significant amount
which might cause problems for some applications, the large
adjustment can be prevented with a command line argument. Not
using the large adjustment may result in the NTP server taking a
very long time to adjust the computer's time to a correct value.
After the large adjustment is made or if it's not allowed, the NTP
server makes a series of very small clock adjustments.
The NTP server calculates the local computer's drift and uses
this to continuously adjust the clock to compensate for the
drift. It also adjusts the drift calculation as necessary. As
long as the NTP server is running (up to a point), the computer
gets an increasingly accurate clock. Since it only slowly adjusts
the time based on multiple outside sources, over time each
computer running an NTP server should have a clock that gets
closer to actual Coordinated Universal Time (UTC) which is NTP's
goal. If an NTP server has several sources, it's less likely to
be pushed away from the correct time by problems on a single
server that it synchronizes with. Once NTP has been running for a
while and as long as it remains running, a computer should be
able to maintain accurate time for hours or longer if it's cut
off from it's time sources.
Top of Page -
Site Map
Copyright © 2000 - 2014 by George Shaffer. This material may be
distributed only subject to the terms and conditions set forth in
https://geodsoft.com/terms.htm
(or https://geodsoft.com/cgi-bin/terms.pl).
These terms are subject to change. Distribution is subject to
the current terms, or at the choice of the distributor, those
in an earlier, digitally signed electronic copy of
https://geodsoft.com/terms.htm (or cgi-bin/terms.pl) from the
time of the distribution. Distribution of substantively modified
versions of GeodSoft content is prohibited without the explicit written
permission of George Shaffer. Distribution of the work or derivatives
of the work, in whole or in part, for commercial purposes is prohibited
unless prior written permission is obtained from George Shaffer.
Distribution in accordance with these terms, for unrestricted and
uncompensated public access, non profit, or internal company use is
allowed.
|