LightAtom

What Is NTP?

NTP keeps computer clocks accurate to within milliseconds by syncing with time servers. Here's why that matters and how your Mac does it.

NTP (Network Time Protocol) synchronises computer clocks with time servers over the network, using UDP port 123. It measures and compensates for network delay, keeping clocks accurate to within milliseconds. Your Mac uses it to sync with time.apple.com.

How it works

Stratum 0 atomic clocks and GPS feed stratum 1 servers, which feed stratum 2 servers like time.apple.com, which your Mac queries over UDP 123.

Strata

  • Stratum 0: reference clocks: atomic clocks, GPS receivers.
  • Stratum 1: servers directly attached to stratum 0.
  • Stratum 2, 3…: servers that sync from the level above.

Measuring the delay

A client records four timestamps: when it sent the request, when the server received it, when the server replied, and when the reply arrived. From these it calculates both the round-trip delay and the clock offset, assuming the delay is roughly symmetric. It then adjusts the clock gradually (slewing) rather than jumping, so time never runs backwards for running programs.

Why accurate time matters

  • TLS certificates are only valid between two dates; a clock far off breaks HTTPS everywhere.
  • Two-factor codes (TOTP) depend on matching clocks.
  • Logs from different machines can only be correlated with synced clocks.
  • Kerberos and other authentication systems reject large clock differences.

Examples

sntp time.apple.com on a Mac prints the offset between your clock and Apple's:

+0.073453 +/- 0.074971 time.apple.com 2a01:b740:a20:3000::1f2

Here the Mac's clock was 73 ms off, within the measurement's ±75 ms uncertainty: effectively correct.

On a Mac

System Settings › General › Date & Time: turn on Set time and date automatically; the source is time.apple.com by default and can be changed. The timed daemon does the syncing. Check your offset any time with sntp time.apple.com in Terminal.

See it in the app

LightAtom's connections view shows the timed daemon's small UDP exchanges with Apple's time servers on port 123.

Frequently asked questions

What port does NTP use?

UDP port 123.

What time server does a Mac use?

time.apple.com by default. You can choose another in System Settings › General › Date & Time.

How accurate is NTP?

Typically within a few milliseconds over the internet, and much better on a local network.

Why are my HTTPS sites failing after my clock changed?

Certificates are checked against your clock. If it's wrong by days or years, every certificate looks expired or not yet valid. Turn on automatic time.

LightAtom team

The people who build LightAtom, a network monitor for macOS.