Home Search Center Intelligent Model Selection IP Encyclopedia

What Is NTP?

The Network Time Protocol (NTP) is an application layer protocol in the TCP/IP protocol suite. It is used to synchronize the clock between the client and the server to provide high-precision time correction. The NTP server receives accurate Coordinated Universal Time (UTC) from an authoritative clock source, such as an atomic clock or GPS. Then, the NTP client requests and receives time from the NTP server.
NTP relies on User Datagram Protocol (UDP) port 123.

Why Is Clock Synchronization Important?

Accurate time is critical to the network for many reasons, for example:

  • Network management: Analysis on logs collected from different network devices must be performed based on time. If the system time of different devices is inconsistent, accurately correlating log files between these devices is difficult, or even impossible.
  • Billing system: Billing services must know the time accurately and require consistent time on all devices. If these requirements are not met, inaccurate billing will occur and result in doubts and complaints of users.
  • Collaborative processing: When several systems work together to process the same complex event, they must use the same clock for reference to ensure correct sequencing of operations.
  • System time: Some applications or services require accurate time to mark user login and transaction information to ensure event traceability.

In conclusion, a unified standard time is of great significance to the network.

NTP is a protocol used to synchronize the clocks of hosts on a network to the UTC time. The precision of NTP can reach 1 ms on a LAN and tens of milliseconds on a WAN.

History of NTP

NTP is one of the earliest standards for clock synchronization on a network. It is designed by David L. Mills — a professor at the University of Delaware, and evolved from the Time Protocol and the ICMP Timestamp message. The following figure shows the evolution of NTP.

Evolution of NTP
Evolution of NTP

NTP Stratum

NTP allows a server to receive accurate UTC time from an authoritative clock source (such as an atomic clock or GPS) and a client to request and receive time from a server.

NTP uses a hierarchical structure of time sources. Each level of this hierarchy is termed a stratum. Generally, an NTP server synchronized to an authoritative clock runs at stratum 1. This NTP server functions as the primary time server to provide clock synchronization for other devices on the network. Stratum 2 servers obtain time from stratum 1 servers, stratum 3 servers obtain time from stratum 2 servers, and so on. The clock stratum ranges from 1 to 16. A smaller value indicates a higher precision. The clocks at stratums 1 to 15 are synchronized. The clocks at stratum 16 are not synchronized and cannot be used.

NTP model
NTP model

NTP Implementation

The most typical NTP mode is client/server mode, as shown in the following figure.

NTP implementation
NTP implementation
  1. The client sends an NTP request packet to the server. The packet contains the timestamp t1 when the packet leaves the client.
  2. The NTP server receives the NTP request packet at t2, and returns an NTP response packet to the client at t3. This response packet carries timestamps t1, t2, and t3.
  3. The client receives the NTP response packet at t4.

The client calculates the following key parameters based on the preceding four timestamps:

  • Round-trip delay of NTP packets between the client and the server

  • Time offset between the client and server

    Calculation formula:

    The time offset is calculated as follows:

The NTP client adjusts its clock based on the offset value, implementing time synchronization with the NTP server.

About This Topic
  • Author: Gao Yangyang
  • Updated on: 2021-09-30
  • Views: 13514
  • Average rating:
Share link to