Ever wondered how computers know what time it is?
It was a nightmare for people back in history to relate the correct time with computers. Time is deceptively complex in computing.
In early computing, there were no built-in Real Time Clocks (RTCs). Time was tracked by counting the CPU cycles. If your computer was rebooted or powered off, the time was lost.
Manual setting was a solution ,people used to manually set the time of their computer based on their physical watch or clocks.
Later came RTC chips, which were battery-backed clocks that kept track of time even if the computer was off.
Then, with the rise of networks and ARPANET, and the client-server model becoming popular, a major problem surfaced.
While communicating between two systems, if they each had even slightly different clocks, and you tried to merge logs or events between them, you’d get highly inconsistent timelines. This was a huge problem for debugging and security.
Then NTP (Network Time Protocol) was introduced. NTP became one of the oldest internet protocols still in use.
NTP uses a hierarchical system called stratum levels. The levels increase with a decrease in accuracy:
Stratum 0: Most accurate time sources, including atomic clocks and GPS clocks.
Stratum 1: NTP servers directly connected to Stratum 0 clocks via GPS/serial. These serve time to others.
Stratum 2+: NTP servers that sync from higher stratum servers.
Here's how NTP works when your system queries an NTP server:
- The client sends a request to an NTP server with a timestamp T1 (when the request left).
- The server receives it at T2, processes it, and sends back a response at T3.
- The client receives it at T4. Round-trip delay is calculated as an estimate of how long the packet took to go to the server and back: (T4 -T1) - (T3 - T2) Offset estimates how far ahead or behind your clock is compared to the server: ((T2 - T1) + (T3 - T4)) / 2
NTP picks the best servers, filters outliers, and gently disciplines your clock over time.
Even today, NTP is everywhere from your laptop to huge data centers. It keeps logs in order, TLS certificates valid, and systems running smoothly.
Modern Linux systems use daemons like ntpd, chronyd, or systemd-timesyncd to regularly sync time from multiple NTP servers.
They handle clock drift, prevent sudden time jumps, and adjust according to network conditions.
Despite being around for nearly 40 years, NTP still quietly powers the internet’s sense of reliable time silently, precisely, and beautifully.
Top comments (0)