Our NTP Stratum 1 Server: Raspberry Pi, GPS and Lessons Learned
Our NTP Stratum 1 server: a Raspberry Pi with a GPS module and PPS signal, at the heart of the RDEM Systems infrastructure.
At the heart of our time synchronization infrastructure lies a small device with remarkable capabilities: a Raspberry Pi equipped with a GPS receiver that provides time with microsecond-level accuracy. This Stratum 1 server serves as the absolute reference for all other NTP servers in our network.
Stratum 0: Atomic Time References
Stratum 0 sources are not NTP servers per se. They are physical devices that provide an absolute time reference:
- Atomic clocks: Use vibrations of cesium or rubidium atoms. Accuracy on the order of nanoseconds over millions of years.
- GPS/GNSS receivers: GPS satellites carry atomic clocks and broadcast a time signal. The PPS (Pulse Per Second) signal offers sub-microsecond accuracy.
- Radio signals: DCF77 (Germany), MSF (United Kingdom), WWVB (USA) - transmitters synchronized to national atomic clocks.
Stratum 1: Our GPS Server
Our Stratum 1 server is built around a Raspberry Pi equipped with a GPS module with PPS output. Here is how this setup works:
The GPS Receiver and the PPS Signal
The GPS module provides two types of information:
- NMEA data: Text sentences containing position, date and time (accuracy ~1 second)
- PPS signal: An electrical pulse precisely at the start of each second (accuracy < 1 microsecond)
Output of the cgps command: 12+ satellites in view, position fixed with accuracy of +/- 8 meters,
time offset of 0.257ms.
The combination of both is essential: NMEA provides the current second (but with a variable delay), while PPS provides the exact instant of the second change. The NTP daemon uses NMEA to "know what time it is" and PPS to "know exactly when the second changes".
ntpd Configuration with GPS
In our setup, the ntpd daemon uses shared memory (SHM) drivers to
communicate with gpsd:
# /etc/ntp.conf - Stratum 1 GPS Configuration
driftfile /var/lib/ntp/ntp.drift
# Statistics for analysis
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
# NMEA source via gpsd (SHM 0) - noselect because less accurate
server 127.127.28.0 minpoll 8 noselect
fudge 127.127.28.0 time1 0.304 time2 0.280 refid NMEA
# PPS source via gpsd (SHM 1) - PRIMARY REFERENCE
server 127.127.28.1 minpoll 1 maxpoll 2 prefer iburst
fudge 127.127.28.1 refid PPS stratum 0
# Stratum 1 validation servers (not public)
# Configuration with several metrological institutes
# for cross-validation of the GPS signal
server [stratum-1-server-A] iburst
server [stratum-1-server-B] iburst
server [stratum-1-server-C] iburst
# ...
# RDEM Stratum 2 servers (cross-validation)
server ntp1.rdem-systems.com iburst
server ntp2.rdem-systems.com iburst
# ... up to ntp10
The NTP Peer Selection Algorithm
NTP does not simply use "the first available source". It implements a sophisticated algorithm to select the best time source among all configured ones.
Selection Metrics
For each source, NTP calculates several metrics:
| Metric | Description | Ideal |
|---|---|---|
| Stratum | Level in the NTP hierarchy | As low as possible |
| Delay | Round-trip time to the server | < 50ms |
| Offset | Difference between the local clock and the server | < 10ms |
| Jitter | Variation of the offset over time | < 5ms |
| Reach | Response history (octal, 377 = 8/8 successes) | 377 |
Interpreting ntpq -c peers
Output of ntpq -c peers: the * character indicates the selected source (here PPS),
+ valid candidates, - rejected outliers.
The characters at the beginning of each line have a specific meaning:
| Symbol | Meaning |
|---|---|
* |
sys.peer - Source currently selected for synchronization |
+ |
candidate - Valid source, candidate for replacement if the primary fails |
- |
outlier - Source rejected by the selection algorithm (too large a deviation) |
# |
selected - Distance too great, but otherwise acceptable |
x |
falseticker - Source considered to be providing incorrect time |
The Intersection Algorithm
NTP uses an intersection algorithm (Marzullo's algorithm) to determine which sources are consistent with each other. The principle is simple: if the majority of sources agree on a time range, the sources that deviate from it are considered "falsetickers" and excluded.
Major Reliable Time Sources Worldwide
For a robust NTP infrastructure, it is essential to know the most reliable time sources. Here are the main worldwide references:
National Metrology Institutes (Stratum 1)
| Organization | Country | Access |
|---|---|---|
| PTB (Physikalisch-Technische Bundesanstalt) | Germany | Restricted access / on request |
| Paris Observatory (LNE-SYRTE) | France | Restricted access / on request |
| NIST (National Institute of Standards) | USA | Restricted access / on request |
| NPL (National Physical Laboratory) | UK | Restricted access / on request |
NTP Services from Major Tech Companies
| Provider | Servers | Specifics |
|---|---|---|
| Google Public NTP | time.google.com |
Leap smearing (smooth leap second handling) |
| Cloudflare Time | time.cloudflare.com |
NTS (Network Time Security) available |
| Apple | time.apple.com |
Used by Apple devices |
| Meta | time.facebook.com |
Leap smearing |
The Leap Second
The leap second is a one-second adjustment applied to UTC time to compensate for the gradual slowdown of the Earth's rotation. Unlike atomic time (TAI), which flows perfectly regularly, UTC must remain synchronized with the Earth's rotation (astronomical time).
For NTP, the leap second is announced via the leap indicator in NTP packets.
Stratum 1 servers connected to atomic clocks receive this information and propagate it
to their clients. The ntpd daemon automatically handles the insertion of the extra second.
The pool.ntp.org Project
The NTP Pool Project is a collaborative initiative that brings together thousands of volunteer NTP servers
worldwide. The addresses 0.pool.ntp.org through 3.pool.ntp.org
(or their regional variants like fr.pool.ntp.org) automatically redirect to
nearby and available servers.
RDEM Systems actively contributes to the French NTP pool with over 10 Stratum 2 servers. You can check our reliability score on our official NTP Pool page, along with the live scoreboard of this specific Stratum 1: ntppool.org/scores/82.65.124.136.
Our Setup in Detail
Hardware Used
- Raspberry Pi 3 Model B Rev 1.2 (1 GB RAM) in a case with heatsink
- PZSMOCN USB GPS Module (MediaTek MTK-3301 chip) with external antenna and PPS output
- Ethernet connection (no WiFi to minimize latency)
- Stable power supply to avoid micro-outages
Software
- Raspberry Pi OS (Debian-based)
- gpsd - GPS management daemon
- ntpd - NTP daemon (reference implementation)
- pps-tools - PPS signal tools
Our Infrastructure Architecture
[GPS Satellites]
|
[PPS Signal + NMEA]
|
[Raspberry Pi - Stratum 1]
ntp-0.hq.rdem-systems.com
|
+-------------+-------------+
| | |
[Stratum 2] [Stratum 2] [Stratum 2]
ntp1.rdem ntp2.rdem ntp3.rdem ...
| | |
+-------------+-------------+
|
[NTP Pool FR]
|
[Your servers]
🔍 You can validate your infrastructure's synchronization with check-ntp.net (real-time diagnostics from a third-party network)
Free NTP Tools
Three independent tools to diagnose your time synchronization: