About NTP

Why Computer Clocks Matter

You might think the clock on your computer is just for showing the time in the corner of your screen. But for computers, having the correct time is critical:

  • Security: Secure connections (HTTPS, VPN, banking) rely on certificates that are time-stamped. If your clock is too far off, secure connections fail or become vulnerable.
  • Log files: When something goes wrong, you check the logs. If different machines have different times, you can't reconstruct what happened in what order.
  • Scheduled tasks: Backups, updates, and scripts run at specific times. A wrong clock means they run too early or too late.
  • Databases: Many databases use timestamps to sort records and detect conflicts. Clock skew can corrupt data or cause lost updates.
  • Email: Email servers stamp messages with the sender's time. Wrong clocks cause messages to appear out of order or get rejected as spam.

The problem is that computer clocks are not very accurate. Computer clocks use quartz crystal oscillators that drift — typically a few seconds per day, affected by temperature and load. Left alone, a Raspberry Pi clock can drift a minute or more per week.

The Solution: NTP

NTP (Network Time Protocol) solves this by letting computers ask a trusted time source "What time is it?" and adjusting their clocks accordingly. When you enable "set time automatically" or "sync time automatically" on your phone, laptop, or router, that feature uses NTP behind the scenes — usually by contacting public time servers on the internet.

My setup does the same thing locally: the Pi 5 listens to GPS satellites carrying atomic clocks. A PPS (Pulse Per Second) signal — a single electrical pulse generated by the GPS receiver at the exact start of each second — is used to lock the Pi's clock precisely to the satellite time.

While the GPS data tells Chrony what time it is, the PPS pulse tells it exactly when each second begins. Together they provide sub-millisecond accuracy.

The hierarchy:

The protocol works in a hierarchy called strata:

  • Stratum 0 — Direct reference clocks: atomic clocks, GPS receivers, radio time signals. These are the most accurate.
  • Stratum 1 — Servers directly connected to a Stratum 0 source. My Pi 5 is a Stratum 1 server because it gets time directly from GPS satellites.
  • Stratum 2 — Servers that sync from Stratum 1 servers. Most public NTP servers (like pool.ntp.org) are Stratum 2.
  • Stratum 3+ — Each step down adds a small amount of delay, but the difference is typically milliseconds.

Most computers on the internet get their time from public Stratum 2 servers.
My setup goes one better: the Pi 5 listens directly to GPS satellites carrying atomic clocks, making the Pi 5 a Stratum 1 time server for my home network.

My setup

GPS Satellite
Atomic clock signal
GPS + GLONASS
GPS Antenna
Active patch antenna
SMA connector
Raspberry Pi 5
Adafruit module #2324
decode GPS signal →
Time & PPS pulse
System Clock
Adjusted by Chrony
using GPS data & PPS
Network
Computers, switches,...
Time synced
with NTP

How It Works

  • GPS Satellite — Equipped with an atomic clock, it sends its time signal continuously toward Earth.
  • GPS Antenna — Placed outside, it catches the signal and passes it through a cable into the Adafruit module on the Raspberry Pi.
  • Raspberry Pi 5 — A small computer with a basic internal clock. Like most computers, its clock drifts — running slightly fast or slow depending on temperature and load.
  • Chrony — This is the key part. Chrony is software that analyzes the GPS data and regulates the Pi's clock to match the satellite time precisely. It then provides this synchronized time to the NTP protocol.
  • Network Devices — Once the Pi has locked onto the perfect time, it becomes a trusted time server. It tells every device on the network: "It is exactly 12:00:00.000." Computers, laptops, switches all ask the Pi for the time.

In short: Space clock → antenna → Pi → Chrony corrects the drift → all devices on the network get perfect time, even without internet.