NTP (Network Time Protocol) is the standard Internet protocol used to synchronize the time in Internet. NTP is to synchronize the device time to the standard time. Currently, the adopted time standard is UTC (Universal Time Coordinated).
The design of NTP fully considers the complexity of the time synchronization on Internet. NTP provides the strict, practical, and valid mechanism, applicable to the Internet environments with various scales and speeds. NTP not only corrects the present time, but also continuously tracks the time change and can adjust automatically. Even if the network fails, it can maintain the time stability. The network cost generated by NTP is small and has the measures of ensuring the network security. The measures can make NTP get the reliable and correct time synchronization on Internet.
In the actual application, select the appropriate NTP work mode according to the network deployment, so as to meet the network clock synchronization requirement in different environments. NTP supports the following three work modes:
In the client/server mode, the client sends the clock synchronization packet with Mode field 3 (client mode) to the server. After receiving the packet, the server automatically works in the server mode and sends the response packet with Mode field 4 (server mode). After receiving the response packet, the client synchronizes the system clock. In the mode, the client can synchronize the clock from the server, while the server cannot synchronize the clock from the client.
In the peer mode, the active peer and passive peer first interact the NTP packet with the Mode field 3 (client mode) and 4 (server mode). And then, the active peer sends the clock synchronization packet with the M ode field 1 (the active peer mode) to the passive peer. After receiving the packet, the passive peer automatically works in the passive peer mode and sends the clock synchronization packet with the Mode field 2 (passive peer mode). In this way, the peer mode is set up. In the mode, the active peer and the passive peer synchronize the clock mutually. If the clocks of the two parties are already synchronized, be subject to the clock with smaller layers.
In the broadcast mode, the broadcast server periodically sends the clock synchronization packet with the Mode field 5 (broadcast server mode) to the broadcast address 255.255.255.255, and the broadcast client monitors the broadcast packet from the broadcast server. When the broadcast client receives the first broadcast packet, the broadcast client and broadcast server interact the NTP packet with the Mode field 3 (client mode) and 4 (server mode), so as to get the network delay of the broadcast client and broadcast server. And then, the broadcast client continues to monitor the broadcast packet and synchronizes the system clock according to the received broadcast packet.