In order to establish synchronisation mechanisms within a local network, the first thing to do is choosing the right protocol. Indeed, many protocols are available for synchronising equipment within a network (PTP, NTP, SNTP, and so on). The first answer would be using the NTP protocol.
However, before choosing the NTP protocol, it is essential to understand its specificities and check if this solution matches the equipment to be synchronised. It is worth mentioning that the essence of NTP is time synchronisation with UTC time, and not time management, which is the responsibility of the machine's operating system.
How does NTP work?
The Network Time Protocol (NTP) has been invented in 1985. A technical description of the protocol’s original version can be found in the RFC 958. The most widely used version is the third one (RFC 1305), although a fourth version is available since 2010 (RFC 5905).
NTP is a time synchronisation protocol for network equipment which has a tree-like architecture. Each level of the hierarchy is called a stratum. The standard has a limit of 16 stratums. Servers from the same stratum share a common time reference that they send to the following stratrum.
Stratum 0 is made up of reference clocks which can be atomic clocks, GPS clocks, and so on. These are the root machines of the protocol, responsible for providing the exact time. They will maintain what is known as UTC time.
Stratum 0 is connected to stratum 1 via serial ports. Stratum 1 is made up of primary NTP servers. These will broadcast the synchronisation timestamps to the rest of the network. There are several stratum 1 servers available publicly both in France and internationally. However, it is not recommended to connect to them, and here’s why: From stratum 1 to stratum 15, servers can connect to servers from the same stratum or servers from the inferior stratum via network links, as shown in the diagram. To find out the stratum of a server, simply calculate the shortest path between the server and the reference clock.
The protocol works in client/server mode between two machines belonging to different stratums. The client asks for a timestamp to the server of the stratum above to which it has access. The server answers with enough information in order for the client to estimate the transmission delay and the offset between its clock and that of the server. At this stage, it is possible that the delay and/or the offset estimation is not correct. Then, the client will introduce a slight offset between its clock and that of the server. However, if the client itself acts as a server for the inferior stratum, this offset can be propagated and amplified further down the network. As a result, even if the NTP protocol has a limit of 16 stratums, it is not recommended to have servers which can be found at too great a distance from stratum 0. In practice, most of the final clients of the NTP protocol are to be found between stratums 3 and 4.
As such, when setting up the NTP protocol on a local network, it is tempting to connect to the highest level in the hierarchy in order to minimise the clock offset and obtain optimum accuracy.
As it is expensive and quite difficult to access an atomic or GPS clock to be on stratum 1, the ideal solution seems to be a direct connection to publicly accessible stratum 1 NTP servers. However, the latter are more likely to be used for synchronising stratum 2 public servers. Indeed, if everyone connected their machine to these servers, they would be completely saturated with requests, and would no longer be able to operate correctly. As a result, it is better to connect to a lower level in the hierarchy, since it is unlikely that your local network needs this level of accuracy. If so, NTP is probably not the best protocol to be used for your network.
How to organise stratums within an NTP network?
First of all, it is important to connect the network to several public NTP time sources. It is indeed recommended to be connected to at least 3 servers to obtain a reliable and accurate timestamp.
If the network is connected to a single source, that source may undergo an offset or stop responding. Two sources can be in conflict in one of them undergoes an offset. As a result, when using at least three sources, the network is protected against these potential failures. For the same reason, it is recommended to connect several network servers externally. Indeed, when using a single synchronisation server and in case of failure, the network will lose access to public servers.
In order to organise a network and its NTP stratums correctly, it is essential to understand the different ways in which machines within an NTP network can synchronise. Machines can retrieve a timestamp from a server in a higher stratum, but connected machines in the same stratum can also communicate to synchronise with each other. Servers use the same protocol as the client/server mode between different stratums, except that the response of the machine which acts as server is interpreted by the client as a request. Then they switch roles: the first machine responds to the second one by sending it enough information so that it can estimate its offset. The last way for NTP servers to simply communicate their timestamp is to broadcast their clock (global broadcast within the network).
The Network Time Protocol (NTP) operates in a hierarchical way. When one or several machines of a local network are connected to one or several public NTP servers, the question arises as to how the rest of the network is organised. Consequently, several recommendations are to be observed:
- If the whole network needs to be synchronised, it is important to reduce the number of internal stratums. Indeed, the deeper the network, the greater the offset between machines from the first and the last stratum.
- It is important that machines with an identical role in a network are placed in the same stratum (this avoids a time drift between machines with the same role).
- It is recommended to connect machines in a same stratum (peers) to each other. This doesn't have to be a full mesh if there are a large number of machines, but it should be dense enough to ensure accurate synchronisation across the network.
As a result, it is important to organise a network structure correctly and choose the right equipment so that critical applications can rely on efficient time synchronisation.
With more than 150 years of expertise in time management and present in more than 140 countries, Bodet Time is a major French leader in time synchronisation and time frequency. Our range of Netsilon NTP time servers allows synchronising all equipment present on a network in a secure way.