How NTP Network Time Protocol is working

What is NTP?

Network Time Protocol (NTP) is a time synchronization protocol defined in RFC 1305. It is used to synchronize the time between distributed time servers and clients. NTP isolated based on UDP, and UDP port number 123 used.

The purpose of using NTP is to all devices on the clock with the network clock synchronization, so that all devices on the network clock consistent, so that the device can provide a plurality of application programs based on a uniform time.

Local system running NTP, which can be synchronized by another clock source, may also be used other synchronous clock source clock and other devices may be synchronized with each other.

How NTP work

The figure shows the basic operating principle of NTP. Devices A and B are connected via a network. They have independent system clocks, and they need to automatically synchronize its system clock via NTP. For ease of understanding, the following assumptions:

  1. Device A sends a message to the NTP apparatus B. When the message stamped leave the device A. Stamp is 10:00:00 am (T1).
  2. When the NTP message reaches the device B, the device B adds its own timestamps. Stamp is 11:00:01 am (T2).
  3. When the NTP message leaves the device B, the device B adds its own timestamps and change timestamp is 11:00:02 (T3).
  4. After the apparatus A receives the response message, the local time of the device A is 10:00:03 am (T4).
  5. At this point, device A has sufficient information to calculate the following two parameters:
    1. NTP packet round trip delay Delay = (T4-T1) - (T3-T2) = 2 seconds.
    2. The time between the devices A and B is a differential offset = ((T2-T1) + (T3-T4)) / 2 = 1 hour.

Thus, device A may set its own clock based on this information, and device B synchronized with the clock. This is only a rough description of the NTP works. For more detailed information, see RFC 1305.

NTP mode.

  1. Customer - server-based;
  2. In the peer to peer mode;
  3. Use broadcast / multicast transmission time.

The user can select the appropriate mode of operation according to their needs. When the server can not be determined or IP address of the terminal, and requires a lot of devices on the network synchronization, clock synchronization can be achieved by a broadcast or multicast mode. At the server and peer mode, it starts from the specified server or peer.

Guess you like

Origin www.linuxidc.com/Linux/2020-03/162610.htm