340 likes | 498 Views
Computer Network Design. EEL 6785 Dr. Janusz Zalewski University of Central Florida. Network Time Protocol NTP stands for Network Time Protocol , and it is an Internet protocol used to synchronize the clocks of computers to some time reference.
E N D
Computer Network Design EEL 6785 Dr. Janusz Zalewski University of Central Florida
Network Time Protocol • NTP stands for Network Time Protocol, and it is an Internet protocol used to synchronize the clocks of computers to some time reference. • SNTP (Simple Network Time Protocol) is basically also NTP, but lacks some internal algorithms that are not needed for all types of servers.
Supported Operating Systems • The implementation works for most popular Unix operating systems. • Among these are: Aix, Hp-Ux, Iris, Linux, Sco Unix, Osf/1, Solaris, and • Windows.
Basic Concepts • The smallest possible increase of time the clock model allows is called resolution. • If your clock increments its value only once per second, your resolution is also • one second. • A high resolution does not help you anything if you can't read the clock. Therefore • the smallest possible increase of time that can be experienced by a program is • called precision. • When repeatedly reading the time, the difference may vary almost randomly. The • difference of these differences (second derivation) is called jitter.
A clock not only needs to be read, it must be set, too. The accuracy determines how • close the clock is to an official time reference like UTC. • Even if the systematic error of some clock model is known, the clock will never be • perfect. This is because the frequency varies over time, mostly influenced by • temperature, but it could also be air pressure or magnetic fields, etc. Reliability • determines the time a clock can keep the time within a specified accuracy.
Network Protocols used by NTP: • NTP uses UDP packets for data transfer because of the • fast connection setup and response times. • The official port number for the NTP (that ntpd and ntpdate listen and talk to) is 123.
NTP Configuration (“Stratum”) S3 S3 S3 S2 S2 S2 S2 * * S4 S3 S3 Workstation (a) Clients (b) S1 S1 S1 S1 S1 S1 * * * S2 S2 S2 * to buddy (S2) Clients (c)
NTP Configuration (“Stratum”) (a) Workstations use multicast mode with multiple department servers (b) Department servers use client/server modes with multiple campus servers and symmetric modes with each other (c) Campus servers use client/server modes with up to six different external primary servers and symmetric modes with each other and external secondary (buddy) servers
The stratum is a measure for synchronization distance. Opposed to jitter or delay, the stratum is a more static measure. Basically (and from the perspective of a client) it is the number of servers to a reference clock. So a reference clock itself appears at stratum 0, while the closest servers are at stratum 1.
A server operating at stratum 1 is the best NTP server available, because it has a reference clock attached to it. As accurate reference clocks are expensive, only rather few of these servers are publically available.
Time can be passed from one time source to another, typically starting from a reference clock connected to a stratum 1 server. Servers synchronized to a stratum 1 server will be stratum 2 . Generally the stratum of a server will be one more than the stratum of its reference.
NTP/Reference Clock • A reference clock is some device or machinery that provides the current time. Its special property is high accuracy. • Reference clocks must be accurately following some time standard.
A reference clock provides the current time. NTP computes some additional statistical values that describe the quality of time it sees: offset, jitter (or dispersion), frequency error, and stability.
Thus each NTP server will maintain an estimate of the quality of its reference clocks and of itself.
Basic Features: • NTP needs some reference clock that defines the true time to operate. All clocks are set towards that true time.
NTP uses UTC as reference time. • UTC ( Universal Time Coordinated, “Temps Universel Coordonne” ) is an official standard for the current time.
NTP is a fault-tolerant protocol that will automatically select the best of several available time sources to synchronize to. Multiple candidates can be combined to minimize the accumulated error. Temporarily or permanently insane time sources will be detected and avoided.
NTP is highly scalable: A synchronization network may consist of several reference clock. Each node of such a network can exchange time information either bi-directional or unidirectional.
Having available several time sources, NTP can select the best candidates to build its estimate of the current time. The protocol is highly accurate, using a resolution of less than a nanosecond.
Even when a network connection is temporarily unavailable, NTP can use measurements from the past to estimate current time and error.
For formal reasons NTP will also maintain estimates for the accuracy of the local time.
How NTP Works? Peer 1 Filter 1 Intersection and Clustering Algorithms Combining Algorithm Peer 2 Filter 2 Loop Filter P/F-Lock Loop Peer 3 Filter 3 VFO NTP Messages Timestamps
Multiple synchronization peers provide redundancy and diversity. • Clock filters select best from a window of eight clock offset samples. • Intersection and clustering algorithms pick best subset of servers believed to be accurate and fault-free.
Combining algorithm computes weighted average of offsets for best accuracy. • Phase/frequency-lock feedback loop disciplines local clock time and frequency to maximize accuracy and stability.
Implementations on NTP/Unix : • The software is available as C source and consists of the following components: • ntpd: • A daemon process that is both, client and server. • ntpdate: • A utility to set the time once, similar to the popular rdate command. • ntpq, ntpdc: • Monitoring and control programs that communicate via UDP with ntpd. • ntptrace: • A utility to back-trace the current system time, starting from the local server.
How will NTP discipline the Clock? • ntpd: The ntpd program is an operating system daemon which sets and maintains the system time of day in synchronism with Internet standard time servers. • xntpd: running xntpd will learn and remember the clock drift and it will correct it autonomously, even if there is no reachable server. Therefore large clock steps can be avoided while the machine is synchronized to some reference clock. In addition xntpd will maintain error estimates and statistics, and finally it can offer NTP service for other machines.
In order to keep the right time, xntpd must make adjustments to the system clock. • There are four mechanisms ( system calls ) an NTP implementation can use to discipline the system clock: settimeofday( ), adjtime( ), ntp_adjtime( ), hardpps( ).
1) settimeofday( ) to step (set) the time. This method is used if the time if off by more than 128ms. 2) adjtime( ) to slew (gradually change) the time. Slewing the time means to change the virtual frequency of the software clock to make the clock go faster or slower until the requested correction is achieved. Slewing the clock for a larger amount of time may require some time, too.
3) ntp_adjtime( ) to control several parameters of the software clock. 4) hardpps( ) is a function that is only called from an interrupt service routine inside the operating system. If enabled, hardpps( ) will update the frequency and offset correction of the kernel clock.
Is more than one clock needed? • NTP likes to estimate the errors of all clocks. • Therefore all NTP servers return the time together with an estimate of the current error. • When using multiple time servers, NTP also wants these servers to agree on some time, meaning there must be one error interval where the correct time must be.
Not all NTP servers work as designed in theory. Time sources that are reachable and have a dispersion smaller than the maximum become candidates for time synchronization, thus contributing an error interval.
If these candidates pass another validation test, they become survivors. Basically all values must lie within the error interval the majority of candidates defines. All other time sources are called falsetickers subsequently.
Among the survivors those with significant high dispersion are removed and tagged as outlyers. • The final synchronization source is the survivor with the smallestdispersion.
Just one time source will always be trusted • Two time sources cannot be split into two parties where one has a majority. • For a three-server configuration a failing server will cause the two-server problem to appear.