NTP
The Network Time Protocol (NTP) is a protocol used to synchronize the clocks of computers on a network. NTP is designed to synchronize time with Coordinated Universal Time (UTC), which is the world’s standard time reference. NTP is designed to be highly accurate and reliable, and can synchronize clocks with an accuracy of a few milliseconds or less.
NTP uses a hierarchical system of time servers to ensure accurate time synchronization. At the top of the hierarchy are stratum 0 time servers, which are highly accurate time sources such as atomic clocks or GPS receivers. Stratum 1 servers synchronize with the stratum 0 servers, and then act as time servers for stratum 2 servers, which synchronize with stratum 1 servers, and so on.
To synchronize time with NTP, a computer sends a request to a time server, which responds with the current time. The computer then adjusts its clock to match the time received from the server. NTP uses a sophisticated algorithm to adjust the clock gradually over time to avoid sudden jumps in time, which can cause problems for applications that rely on accurate time information.
NTP uses UDP port 123.
Server
The tasks of an NTP (Network Time Protocol) server can be broadly divided into two categories: time synchronization and time distribution.
Time synchronization: The primary task of an NTP server is to synchronize the time of a client computer with a highly accurate time source. The server does this by exchanging time information with the client using NTP packets. The server may synchronize its own clock with a stratum 0 time source such as an atomic clock or GPS receiver, or it may synchronize with another NTP server that is more closely connected to a stratum 0 source. The synchronization process involves measuring the round-trip delay and processing time between the client and server, and adjusting the client’s clock accordingly. The NTP server also employs various algorithms to filter out errors and provide stable, accurate time information to the client.
Time distribution: Once the NTP server has synchronized the time of a client computer, it may also act as a time distributor for other computers on the network. The server broadcasts the time information it has received from the stratum 0 source or another NTP server, allowing other computers to synchronize their clocks with the accurate time source.
Example to configure server mode:
set system ntp master prefer
set system ntp master stratum 3
Client
An NTP (Network Time Protocol) client is a software component that runs on a computer or device and is responsible for synchronizing its local clock with an NTP server. The tasks of an NTP client can be broadly divided into three categories: time synchronization, monitoring, and configuration.
The primary task of an NTP client is to synchronize its local clock with an NTP server. The client does this by sending a request for time information to the server and adjusting its local clock to match the time information received. The client may also adjust its clock over time to compensate for clock drift and maintain accurate time.
The client may be configured to use multiple NTP servers for redundancy, or to use a specific NTP server that is known to be highly accurate.
Example to configure client mode:
set system ntp server address pool.ntp.org
Authentication
NTP (Network Time Protocol) authentication is the process of verifying the identity of an NTP server and ensuring that the time information it provides is authentic and has not been tampered with. NTP authentication is important because inaccurate or malicious time information can have serious consequences for applications that rely on accurate time synchronization.
NTP authentication can be accomplished through the use of symmetric key cryptography. Symmetric key authentication involves the use of a shared secret key between the client and server to verify the authenticity of NTP packets.
The shared key value in that example is “secret” and that value gets the index/id “1”:
set system ntp authentication-key 1 md5 secret
A server uses that index to accept the shared key for received packets:
set system ntp trusted-key 1
Broadcast
NTP (Network Time Protocol) broadcast is a method used by NTP servers to distribute time information to multiple NTP clients on a network simultaneously. In an NTP broadcast, the NTP server sends a time information packet to all devices on the network, without requiring each client to make a separate request for time information.
NTP broadcast is typically used in situations where many client devices need to be synchronized with an accurate time source, such as in a large-scale enterprise network. By using NTP broadcast, the server can efficiently distribute time information to all clients on the network, reducing network traffic and minimizing the load on the server.
In NTP broadcast mode, the NTP server sends a time information packet to the broadcast address of the local network. This packet contains the current time information, as well as other information such as the stratum level of the server, the precision of the clock, and other parameters related to the time synchronization process.
NTP broadcast packets are usually sent at regular intervals, which can be configured by the server administrator. The NTP clients on the network receive the broadcast packet and use the information contained in it to synchronize their local clocks with the server.