Show HN: Building a GPS receiver
An in-depth project on building a GPS receiver with an RTL-SDR stick sparks wide interest in how GPS actually works, from spread-spectrum signal processing and satellite ephemeris data to modern tricks for fast time-to-first-fix. Commenters compare software-defined approaches with older hardware-based receivers, share resources on GNSS theory and history, and highlight how clever the original 1970s GPS radio design remains, including its power efficiency and backward compatibility. The thread also touches on related topics such as selective availability, assisted GPS on phones, jamming and spoofing attacks, export controls on high-performance receivers, and the (semi-)codeless use of encrypted military signals.
Overall reception & learning style
- Thread is highly positive about the project and write-up.
- Many appreciate the “live learning adventure” style, including showing search terms, mistakes, and gaps in understanding.
- Several readers say it helped them finally understand GPS signal processing end-to-end.
“From scratch” and hardware choices
- Some initially expect “from scratch” to include custom RF hardware; others argue that starting from an SDR that only samples RF is still legitimately “from scratch” for GPS.
- Discussion notes that older GPS receivers implemented much of this in dedicated hardware; here it’s done in software.
- Modern production chips often mimic SDR-style architectures but with hardware accelerators for power efficiency.
- One correction: there now exist commercial “direct RF sampling” devices fast enough to sample GPS carriers directly.
Time-to-first-fix, almanac, and processing
- Older receivers needed 12.5+ minutes to pull down the full almanac at low data rates.
- Modern devices speed acquisition by:
- Brute-forcing PRN codes, Doppler offsets, and code phases in parallel.
- Using network assistance to fetch almanac/ephemeris (“A-GNSS”).
- There is debate over what “brute force” means: some see it as simply “try all plausible codes/frequencies,” which is feasible with modern compute.
- Clarified that ephemerides repeat on ~30-second cycles and are sufficient for a basic fix without full almanac.
Pre-2000 GPS accuracy and automotive navigation
- One side claims selective availability (SA) made GPS “definitely useless” for road navigation.
- Others counter with concrete examples of pre-2000 in-car systems and differential GPS that were “usable but clunky,” arguing SA was only one of several limitations (maps, UI, computation).
- Consensus: by today’s standards they were poor; whether they were “useless” depends on expectations.
Jamming vs spoofing
- Distinction emphasized:
- Jamming = drowning out real signals with noise.
- Spoofing = transmitting fake but valid-looking signals.
- Wide-area spoofing is considered feasible with a single terrestrial transmitter; this can make many receivers report essentially the same false location.
- Reported real-world incidents (e.g., ships and phones showing as being at airports) are interpreted as likely terrestrial spoofing, not satellites transmitting fake data.
- Modern receivers try to mitigate by ignoring too-strong signals and using multiple constellations and sensors (Wi‑Fi, cellular, inertial, etc.), but attacks remain a cat-and-mouse game.
P(Y) code and higher-precision signals
- Discussion notes:
- The P code sequence itself is specified publicly;
- It is XORed with a cryptographic W-code to produce the encrypted P(Y) signal.
- Older civilian techniques (“semi-codeless” tracking) inferred enough about P(Y) to use L2 for ionospheric correction, improving accuracy.
- Today, public dual-frequency signals reduce the need for these workarounds.
Export controls and “munition” status
- Historically, GPS receivers that worked above certain speed/altitude thresholds were controlled under ITAR as munitions; it’s unclear from the thread how current rules apply.
- Similar export-control concerns led one SDR vendor to remove open-source passive radar software; legal uncertainty around combining hardware and radar software is highlighted.
Implementation details and tooling
- A user attempting to run the provided code on Windows encounters a syntax error; others note it requires Python 3.11 for the starred-expression syntax used.
- Multiple external learning resources are recommended: in-depth GPS theory sites, an online GNSS course, test apps (e.g., Android GNSS diagnostic tools), and documentary/books on GPS history.