This section describes the NTP principles.
Figure 1 shows the principles of NTP. FW_A and FW_B are connected through a WAN. They both have their own system clocks. NTP implements automatic synchronization of their clocks.
Suppose:
Before the system clocks of FW_A and FW_B are synchronized, the clock of FW_A is set to 10:00:00 am and the clock of FW_B is set to 11:00:00 am.
FW_B functions as an NTP time server. That is, FW_A synchronizes its clock with that of FW_B.
One-way transmission of data packets between FW_A and FW_B takes one second.
Processing of data packets on the FW_A or the FW_B takes one second.
The process of synchronizing system clocks is as follows:
FW_A sends an NTP packet to FW_B. The packet carries the originating timestamp when it leaves FW_A, which is 10:00:00 am (T1).
When the NTP packet reaches FW_B, FW_B adds its receiving timestamp to the NTP packet, which is 11: 00:01 am (T2).
When the NTP packet leaves FW_B, FW_B adds its transmitting timestamp to the NTP packet, which is 11:00:02 am (T3).
When FW_A receives the response packet, it adds a new receiving timestamp to it, which is 10:00:03 am (T4).
FW_A uses the received information to calculate the following two important values:
Delay for the NTP message cycle: Delay = (T4 - T1) - (T3 - T2).
Offset of FW_A relative to FW_B: Offset = ((T2 - T1) + (T3 - T4))/2.
According to the delay and the offset, FW_A sets its own clock again to synchronize with the clock of FW_B.
The preceding example is only a simple description of the NTP operating principle. As described in RFC 1305, NTP uses a complex algorithm to ensure the precision of clock synchronization.
As shown in Figure 2, the networking of NTP is composed of the primary time server, secondary time servers, clients, and interconnections in between.
The primary time server is directly synchronized with a primary reference source which is usually a radio clock or Global Positioning System (GPS).
A secondary time server synchronizes its clock with the clock of the primary time server or another secondary time server on the network and transmits the time information to other hosts on the network through NTP.
Under normal circumstances, primary and secondary time servers on the synchronization subnet assume a hierarchical structure, with the primary server at the root and the secondary server at successive stratums toward the leaf node. The higher the stratum level is, the less accurate the clock.
The NTP supports the following working modes:
Unicast Client/Server Mode
In this mode, you need to configure only the client. The server needs to be configured with only one NTP primary clock.
Note that the client can be synchronized to the server but the server cannot be synchronized to the client.
After the configurations:
The client sends a synchronization request packet to the server, with the mode field being set to 3. The value 3 indicates the client mode.
Upon receiving the request packet, the server automatically works in the server mode and sends a response packet with the mode field being set to 4. The value 4 indicates the server mode.
After receiving the response packet, the client performs clock filtering and selection, and finally, is synchronized with the optimal server.
Peer Mode
In this mode, you need to configure NTP only on the symmetric active end. The symmetric active end and symmetric passive end can be synchronized with each other.
Note that the clock with a lower stratum is synchronized to the one with a higher stratum.
After the configurations:
The symmetric active end sends a synchronization request packet to the symmetric passive end with the mode field being set to 1. The value 1 indicates the symmetric active mode.
Upon receiving the request packet, the symmetric passive end automatically works in symmetric passive mode and sends a response packet with the mode field being set to 2. The value 2 indicates the symmetric passive mode.
Broadcast Mode
In this mode, you need to configure both the server and the client.
After the configurations:
The server periodically sends clock synchronization packets to the broadcast address 255.255.255.255.
The client senses broadcast packets from the server.
After receiving the first broadcast packet, to estimate the network delay, the client enables a temporary client/server model for exchanging messages with the remote server.
The client then works in broadcast client mode, and continues to sense the incoming broadcast packets to synchronize the local clock.
Multicast Mode
In this mode, you need to configure both the server and the client.
After the configurations:
The server periodically sends clock synchronization packets to the multicast address 224.0.1.1.
The client senses multicast packets from the server.
After receiving the first multicast packet, to estimate the network delay, the client enables a temporary client/server model for exchanging messages with the remote server.
The client works in multicast client mode, and continues to sense the incoming multicast packets to synchronize the local clock.
Manycast Mode
In this mode, you need to configure both the server and the client.
After the configurations, the following actions occur:
NTP provides two security mechanisms: access authority and NTP authentication to guarantee the network security.
Access Authority
The device protects local NTP services by setting access authority. This is a simple measure to ensure security.
The device provides four access authority levels. When an NTP access request message reaches the local end, the device matches it with the access authority from level 1 to level 4. The first matched authority level takes effect. The matching sequence is as follows:
Authentication
NTP authentication can be enabled on networks demanding high security.
When configuring NTP authentication, note the following rules: