Time synchronization using the NTP protocol
This article is about how to synchronize the time using the NTP protocol. The NTP client application for download shows the entire process of time synchronization.
Structure of time sources (Stratum)
The NTP protocol uses a hierarchical structure of time sources. The originate time source, which consists of high-precision timekeeping devices such as atomic clocks, is called Stratum 0. The next level (Stratum 1) are servers whose system time is synchronized with a Stratum 0 time source. The next level (Stratum 2) has synchronized the time with Stratum 1 servers. That goes until Stratum 15.
How it works
1. The client application sends a data packet to the server, which consists mainly of 4 timestamp. The first timestamp, in our example T1, also called as the reference timestamp, is set by the client with the time of the client side.
2. The server receives this data packet and sets the second timestamp, in our example T2, also called as the receive timestamp. The package will then be set to a queue for further processing.
3. The server sets the third timestamp, in our example T3, also called as the transmit timestamp and sends the data packet back to the client.
4. The client receives this data packet and sets the fourth timestamp, in our example T4, also called as the reference timestamp.
The round trip delay
The round trip delay briefly referred as delay, is important to calculate the time difference between server and client. The delay consists of the time between T1 and T4 with the exception of the time between T2 and T3. The formula looks like this:
(T4 - T1) - (T3 - T2)
The time difference
The time difference is briefly referred as offset. Since the timestamp (T4) of the server is no longer up to date, when receiving the data packet, the time has to be added, which the data packet needed, to get from the server to the client. Suppose the time between client and server is approximately the same as from the server to the client, we can divide the delay by 2 and get the time, that have to be added to T4. The whole formula looks like this:
((T2 - T1) + (T3 - T4)) / 2
The example application for download shows the state of the timestamps in every step of the synchronization. Press the button "Get Time" to get the time difference between server and client. Press the button "Set Time" to change the system time according the difference. Note, that administrator rights are required to change the system time. All values in the application are according RFC 5905 in milliseconds since 1st January 1900, 00:00 GMT.
- Version 22.214.171.124: Initial version
Categories: Windows Tools Internet