How NTP Works: Stratum Levels, Time Sync, and Clock Drift Correction

Precise timekeeping is the life force of modern computing— even a millisecond discrepancy can make or break financial transactions, security protocols, and distributed systems. To address these challenges, Network Time Protocol (NTP) is the ideal solution for time syncing across computer networks.

NTP uses a hierarchical structure of stratum levels, where lower-stratum devices synchronize their time with higher-stratum sources, synchronizing computer clock timings to Coordinated Universal Time (UTC).

This blog details how NTP works, examining its hierarchical structure, the mechanics of time synchronization, and the function of stratum levels in maintaining network harmony.

What Is An NTP Server?

To achieve accurate time synchronization, NTP relies on dedicated NTP servers, a specialized system, that distribute precise timestamps across the network.

These servers act like digital clock managers for computers and devices on a network. They ensure that all devices on the network run on the same schedule- meaning they are synchronized to Coordinated Universal Time (UTC), the global time standard.

While UTC can be obtained through GPS or other satellite-based services, installing receivers on every computer may not be cost-effective and a practical choice.

So, NTP servers act as intermediaries, using a hierarchical structure of "stratum" levels: Stratum 0, Stratum 1, and Stratum 2 and beyond.

Key Aspects of an NTP Server

  • Purpose: Synchronizes the clocks of networked systems to Coordinated Universal Time (UTC).
  • Utility: Essential for log file accuracy, financial transactions, authentication protocols, and overall system coordination.
  • Protocol: Uses the User Datagram Protocol (UDP) on port 123 for efficient time synchronization.
  • Data Format: Transmits time data in a binary format, following RFC 1305 (NTPv3) and RFC 2030 (SNTPv4).

How Does NTP Work?

NTP operates by exchanging timestamped packets between clients and servers, calculating time offsets and delays to adjust clocks accurately.

To enhance accuracy, high-stratum NTP servers utilize Marzullo's algorithm. This algorithm helps determine the most precise time by analyzing multiple time sources and filtering out inconsistencies.

Packets Exchange Steps in NTP

1. Client Request: 

The client sends a request packet to the NTP server, embedding its current timestamp (T1) into the packet.

2. Server Reception:

Upon receiving the client's request, the server records the exact arrival time as timestamp T2.

3. Server Response: 

The server prepares a response packet that includes three critical timestamps:

  • T1: The original timestamp from the client's request.
  • T2: The server's receive time of the client's request.
  • T3: The time at which the server sends the response back to the client.

4. Client Reception:

The client receives the server's response and notes the arrival time as timestamp T4.

NTP Timestamp Format

Now that we understand how timestamps are exchanged, let's look at how they are structured in NTP packets.

NTP does not store or transmit time in a traditional YY/MM/DD format. Instead, it represents time in seconds since January 1, 1990. NTP timestamps are 64-bit in size:

  • The first 32 bits store the number of whole seconds.
  • The remaining 32 bits store the fractional part of a second.

Network Uses of NTP

  • NTP operates efficiently with minimal data exchange.
  • Each NTP server communicates using small packet pairs every 64-1024 seconds.
  • Despite its global use, NTP traffic accounts for only 0.01% of total internet traffic (less than 5GB/day).

NTP Stratum Levels: Synchronization Hierarchy

A stratum in NTP refers to the distance from the most accurate time source, with Stratum-0 being the most accurate and the starting point of the hierarchy.

Moving down the hierarchy, servers at higher stratum levels (Stratum-1, Stratum-2, etc.) synchronize with servers at lower stratum levels, introducing small delays as they are further from the Stratum-0 source, continuing down to Stratum-15.

Stratum-0: Primary Time Reference Devices

  • Stratum-0 is the foundation of the NTP hierarchy.
  •  It contains high-precision time sources like atomic clocks, GPS clocks, and other reference devices.
  • These devices are highly accurate but cannot be used directly as NTP servers on the network. They synchronize Stratum-1 servers.
  • Critical for systems requiring extreme accuracy, such as satellite communication and GPS synchronization.

Stratum 1: Primary NTP Servers

  • Stratum-1 servers are directly connected to Stratum-0 devices and distribute time to the network.
  • These servers are the first level of time distribution, but due to the synchronization delay, they are slightly less precise than Stratum-0.
  • Commonly called "major NTP time servers," Stratum-1 servers are the primary time sources in the network.
  • It is used in data centers and enterprise networks that require reliable, high-precision time synchronization.

Stratum-2: Secondary Time Servers

  • Stratum-2 servers synchronize with Stratum-1 servers and act as the second level of time distribution.
  • These servers are slightly less precise due to the added synchronization delay.
  • Used in large organizations or service providers that need time distribution across many systems but don't require the precision of Stratum-1 servers.

Stratum-3: Third-Level Time Servers

  • Stratum-3 servers synchronize with Stratum-2 servers, offering third-level time distribution.
  • These servers have even less precision but are still accurate enough for most common applications.
  • It is found in smaller networks or end-user systems, where time accuracy is necessary but not critical.

How does NTP Calculate Clock Offset and Network Delay?

NTP calculates time adjustments based on round-trip delays and clock offsets. These calculations consider network delays (latency) and server processing time.

Time Synchronization Algorithm in NTP

Initial Parameters:

  • t1 (A) = Client's transmit timestamp = 100s
  • t2 (X) = Server's receive timestamp = 150s (affected by network delay)
  • t3 (Y) = Server's transmit timestamp = 160s (affected by server processing time)
  • t4 (B) = Client's receive timestamp = 120s (affected by network delay)

Delay Factors:

1. Network Propagation Delay:

  • Internet connectivity introduces variable latency.
  • Affects transmission time from client to server (t1 → t2)
  • Affects transmission time from server to client (t3 → t4)
Network Delay = (t2 - t1) for request
                (t4 - t3) for response

2. Server Processing Delay:

  • The server might be busy handling multiple requests
  • Time difference between receiving and responding
Processing Delay = t3 - t2 = 160 - 150 = 10 seconds

Algorithm Steps:

With the four timestamps (T1, T2, T3, T4), the client computes:

1. Calculate Round-Trip Delay (δ):

δ = (t4 - t1) - (t3 - t2)
δ = (120 - 100) - (160 - 150)
δ = 20 - 10
δ = 10 seconds

2. Estimate One-Way Network Delay (ε):

ε = δ/2
ε = 10/2
ε = 5 seconds

3. Calculate True Reference Time (T):

T = t3 + ε
T = 160 + 5
T = 165 seconds

4. Determine Clock Offset (θ):

θ = T - t4
θ = 165 - 120
θ = 45 seconds

Considerations:

  • Total delay includes both network propagation and server processing time
  • Network delays are assumed to be symmetric for calculation purposes
  • Server processing time (10 seconds in this case) is accounted for in the round-trip delay calculation
  • The final clock offset (θ) of 45 seconds represents the required adjustment

Note: NTP uses multiple samples and statistical analysis to account for variations in network and processing delays in real-world implementations.

Clock Drift In NTP: How They Handle It?

Clock Drift refers to the slight, inherent discrepancy between a system's internal clock and the precise time from an NTP server.

This drift occurs naturally due to environmental factors, component imperfections, and variations in system workload, causing the clock to run slightly faster or slower than UTC.

The Drift File: Your Clock's Report Card

NTP keeps a drift file, which serves as a record of how your system clock operates. This file contains a single value measured in PPM (Parts Per Million) that communicates a significant story:

  • A positive value implies that your clock operates quicker than the reference time.
  • A negative number indicates that your clock operates slower than the reference time.

For example, a drift value of +2.0 PPM means that your clock acquires 2 microseconds per second compared to the reference time.

Precision in Modern Systems

The most recent version of NTP (Version 4) demonstrates incredible precision. Under ideal conditions, it can keep the clock accurate to within 233 picoseconds, or less than a quarter of a billionth of a second!

This level of precision is critical for many modern applications, including financial transactions and scientific research.

NTP works by checking your computer’s clock and correcting for clock drift—the natural way hardware clocks can run a bit too fast or slow over time. By making small adjustments, it ensures your computer’s time stays spot-on, no matter what.

Conclusion:

The Network Time Protocol (NTP) ensures synchronized time across networked systems by using a hierarchical stratum structure, precise algorithms, and drift correction. It accounts for network delays, server processing time, and clock drift, providing reliable time synchronization in diverse environments.

NTP is crucial for applications like log file timestamping, secure financial transactions, and seamless data exchanges. Despite minimal network impact, NTP plays a vital role in maintaining global synchronization. By continuously refining timekeeping methods, NTP supports the deep interconnection of digital systems, forming the foundation for modern technology and innovation

Read More:


How NTP Works: Stratum Levels, Time Sync, and Clock Drift Correction

Written By Milan Dangol

Feb 13, 2025

A skilled DevOps Engineer with expertise in cloud computing, CI/CD pipelines, automation, and containerization tools like Docker and Kubernetes. He specializes in system optimization, network security, and streamlining development-to-deployment workflows.

Latest Blogs

Recent Development In AWS: April 2025

AWS never stops pushing the envelope, and the updates for April 2025 are no exception. This month br...


Chandra Rana

May 02, 2025

Outsourced IT Services for Small Business

With limited in-house resources and growing technology demands, small and medium-sized businesses (S...


Adex International

Apr 30, 2025

Docker Bridge Networking: In-Depth Guide to Setup, Connection, and Troubleshooting

Docker has changed the way we build and run applications by using lightweight, portable containers....


Ujwal Budha

Apr 30, 2025