NTP offers the following functionality:
It allows a reference time (Universal Coordinated Time, UTC) to be distributed within a network, and
also coordinates the clocks within networks of any size.
In order to feed the UTC time into the network, it is recommended that the network computer on which NTP is installed be equipped with a radio-controlled hardware clock which receives a time signal generated by an atomic clock. With its DCF77 time signal, the authoritative source for disseminating time in Germany is the Federal Institute for Physical Technology in Braunschweig (Physikalisch-Technische Bundesanstalt in Braunschweig).
A computer equipped in this way synchronizes its own system clock with the externalhardware clock, thus becoming the primary time server on the network. The precision of this time server is determined by the resolution of its own system clock.
Time servers have hierarchical relationships. A secondary time server receives its time via the network from a primary time server. The position of this time server in the hierarchy is identified by a number called the stratum. A primary time server has a stratum of 1, a secondary time server has a stratum of 2, etc. The higher the stratum, the further the time server is from the primary time source and the higher the probability that this time server is inaccurate.
In simple terms, time is synchronized between the client and the server as follows:
The client sends an NTP message to the server as a datagram.
The server replaces the IP addresses and some of the message fields in the arriving datagram and sends it back.
The server sends the modified datagram back to the client.
The result of this process is four timestamps from which the following two measurements can then be calculated:
the time the NTP message spent travelling through the network (delay)
the time difference between the clocks of the two computers (offset)
Both measurements are approximated. The offset contains an average delay, i.e. NTP assumes that the arrival route and the return route of the NTP packets are the same length. Any deviations therefore cause errors in the calculation of the offset. In LANs, the round trip delay is only a fraction of the offset, so the offset calculation is very precise. However, this does not apply to WANs.
To minimize the effect of runtime fluctuations, the calculated offset and delay values are put through an additional filtering procedure. Of the last eight received NTP messages of a time server, the message with the lowest delay determines the current offset value. An additional measurement is also calculated from the same list - the dispersion. This is the weighted mean value of the offset deviations of the last eight NTP messages from the current offset value. The offset values with a low delay value are given a greater weight than those with large delay values. Dispersion is the measurement used to evaluate the quality of a time server.
A client/server configuration is entirely dependent on the availability of its components. In NTP, two major techniques are used to prevent any possible sources of failure:
Redundancy:
Each time server or each client is in contact with at least three other time servers of the same or a higher stratum. If a computer’s current synchronization source fails, another time server automatically takes over.
Selection:
A selection mechanism is applied, in which the best time server of those available in the list is chosen as the current synchronization source.
The selection criterion are:
stratum (the lower, the better)
delay (the smaller, the better)
dispersion (the smaller, the better)
(Time) servers and clients are differentiated according to who receives the correct time from whom. The client requests an NTP message with the already described timestamps from the server and uses this to synchronize its own clock if the server proves to be the best available. In the NTP protocol, the five different operating states in which a time server operates are defined in terms of "associations" between time servers.
Association | Host1 | Host2 |
Peer to Peer | Symmetrically active | Symmetrically passive |
Client to Server | Client | Server |
Server | Client | |
Broadcast | Client | Broadcast server |
Broadcast server | Client |
Symmetrical associations (Peer to Peer) between time servers use the full range of functions of the NTP protocol. In particular, a peer host receives status information about the corresponding peer and is prepared, if necessary, to use it as a synchronization source. In client/server associations, by contrast, the roles are fixed. The server supplies the client with the precise time, but is never ready to synchronize with the client. Symmetrical associations are usually between time servers with low stratum values, whereas client/server associations are normally between time servers with high stratum values. Broadcast associations can be used in LANs in which a server provides several clients with NTP messages in the broadcast procedure.
Not every client requiring the time service should be synchronized directly with the stratum-1 server(s), as this would overload the server and prevent it from providing a precise time. It is better to distribute the time among a group of selected stratum-2 servers.