Skip to content

Your First Decode — A Fixture Flight

Outcome: readsb running, two aircraft on its table, and a checked proof — not an impression — that what it decoded is what was sent. This is the chapter the whole guide hangs on, and every step of it ran in the lab.

Why a fixture first

A new station has two halves that can fail independently: the radio half (antenna, dongle, gain) and the decoding half. With a real antenna you cannot tell which half is misbehaving, because you have no ground truth — the sky does not publish what your decoder should have seen. A fixture fixes that: a known input, generated by you, against which the decoder's output can be compared exactly. If the decoder passes the fixture, it is proven; later trouble belongs to the radio, and you will know it.

The fixture: real packets, invented aircraft

adsb-lab/make_fixture.py builds genuine DF17 packets in pure Python: the real CRC polynomial, the real CPR position encoding, the real type codes from chapter 3. Nothing is mocked — if any of that arithmetic were wrong, readsb would reject the packets, as it rejects damaged ones from real aircraft.

The aircraft, however, are invented, deliberately and completely:

  • abc123, callsign FICT1 — flies a two-leg track over 24 five-second steps: north-east at 400 knots climbing to 10,200 ft, then turns east at 399 knots, level.
  • def456, callsign TEST2 — sits at one spot at 0 ft, broadcasting positions, sending no velocity.

The intended track is printed by the script itself (adsb-lab/transcripts/t02-track.txt). The packets are wrapped in Beast framing — the binary stream format receivers use to talk to each other — and served on a loopback TCP port:

python3 make_fixture.py serve 18112

The decoder, as a network client

readsb then connects to the fixture, exactly as it would connect to a second receiver across the house:

./readsb --net --net-only \
  --net-connector 127.0.0.1,18112,beast_in \
  --write-json <dir> --write-json-every 1 \
  --lat 33.0 --lon -97.0 \
  --no-interactive --stats-every 10

Flag by flag: --net enables the networking; --net-connector says "connect out to this address and consume its Beast input"; --write-json is where the state files go, refreshed every second; --lat/--lon give the receiver's own position for local CPR decoding and for the distance and direction fields; --no-interactive trades the live screen for a readable log; --stats-every prints the score every ten seconds. The log's first lines confirm the marriage:

readsb version: 3.16.20 wiedehopf git: v3.16.20-17-g90ece6f
Using lat: 33.000000, lon: -97.000000 (location accuracy: exact)
Beast TCP input: Connection established: 127.0.0.1 port 18112

Watching it think

With no --quiet, readsb narrates every packet. The identification arrives first, and decodes completely:

DF: 17 AA:ABC123 CA:5 ME:101890D4C60820
 Extended Squitter Aircraft identification and category (2)
  ICAO Address:  ABC123 (adsb_icao)
  Ident:         FICT1

Then the teaching moment of chapter 3, in the wild: the first position frame, even, alone —

CPR decoding:  none

— and its odd partner a blink later, yielding the global position (32.999997, −96.999973 for a sent 33.000000, −97.000000 — a couple of hundred-thousandths of a degree of CPR grid quantisation). The first velocity frame decodes to Ground track 45.0, Groundspeed 400.2 kt, Geom rate 512 ft/min, exactly the components the fixture encoded.

The score, and the proof

The run lasted 69 seconds. The final statistics:

369 Mode S messages received
    0 with bad message format or invalid CRC
  369 accepted with correct CRC
291 airborne position messages received
289 global CPR attempts with valid positions
2 unique aircraft tracks

Zero CRC rejections means the generated packets were well-formed to the last bit. The 289 successful pairs out of 291 position messages means the CPR arithmetic round-tripped.

Finally, the comparison that turns "looks right" into "is right". adsb-lab/check_decode.py reads the aircraft.json readsb wrote at the end of the run (kept as adsb-lab/aircraft-final.json) and the fixture's intended final state, and compares field by field:

PASS  altitude 10200 == 10200
PASS  lat 33.071501 ~ 33.071481
PASS  lon -96.785291 ~ -96.785282
PASS  ground speed 399.0 ~ 399.0
PASS  track 94.02 ~ 94.0
...
ALL CHECKS PASSED (13/13)

The full transcript is adsb-lab/transcripts/t05-compare.txt. Note the two honest blemishes, kept rather than cleaned: the moving aircraft's decoded position differs from the sent one by about 0.00002° (that is the CPR grid's cell size, not an error), and the parked TEST2 showed a calc_track of 303° in an early snapshot — a heading "calculated" from the tiny position jitter between CPR frames of a stationary sender. A decoder infers; inference on noise produces confident nonsense, and chapter 15 collects the moral.

You now own a proven decoder and a fixture you can re-run after any change. The rest of the guide connects it to the sky.