AIS receiver

Ships report their identity, position, speed and heading on two VHF channels near 162 MHz, sharing them by booking time slots. This receiver separates the channels, demodulates each GMSK burst, checks the frame and decodes the report, with every stage shown.

–Vessels decoded
–Reports per minute
–Reports decoded
–UTC

What is modelled. The coastline, port, lanes and ships are made up. Positions sit in open ocean near 44°N 38°W so they can't be mistaken for a real harbour, and MMSIs are random nine-digit numbers. Message formats, HDLC framing, the CRC, bit stuffing, NRZI, GMSK (9600 bit/s, BT 0.4, modulation index 0.5), slot timing, reporting intervals and the SOTDMA, ITDMA and carrier-sense access schemes follow ITU-R M.1371-5. Modelled rather than standard: radio range (plane-earth loss over sea, never below free space, plus a fixed loss per km past the radio horizon), which ships hear each other (a −107 dBm threshold, without demodulating at the ships), transmitter frequency errors, GNSS errors of a few metres, the routes, the rate of turn that counts as changing course (10°/min), and a 60 s wait before a ship slows its reporting. A ship joining or changing rate books all its new slots at once. Anchored and moored Class A ships send message 3 and book one slot ahead with ITDMA. The 8 ramp-up bits carry the same 0101 pattern as the training sequence. There is no base station, no static data (message 5, so no names over the air) and no assigned mode. The demodulator is one reasonable design among many; its settings are in the Receiver panel.

1

Waters

The receiver's antenna stands on a headland. Offshore, a traffic separation scheme carries ships north and south. Others come in to the port in the bay, wait at the anchorage or run the island ferry, and small Class B craft work along the coast and the fishing grounds. Grey triangles are where ships really are; circles are where the receiver has decoded them from their own reports. Past the radio horizon signals fade fast; the dashed rings mark it for a ship's antenna 25 m and 4 m above the sea.

Chart

Zoom with the buttons, ⌘/Ctrl-scroll or a pinch; drag to pan once zoomed; double-click to reset. Click a ship to select it. Zoom in to see the gap between a ship and its last report: the ship keeps moving between reports.

True positionDecoded, Class ADecoded, Class BSelectedTraffic lanes
MMSIClassStatusSpeed (kn)CourseHeadingRange (nm)ReportsLast (s)Level (dBm)Fix errorVessel (truth)
2

The radio band

The receiver samples 96 kHz of spectrum centred on 162.000 MHz as complex baseband, so both AIS channels are in one stream: channel A (161.975 MHz) sits at −25 kHz and channel B (162.025 MHz) at +25 kHz. Each report is one 26.7 ms burst on one channel, and ships alternate channels from one report to the next.

Spectrum

Latest 21 msPeak hold

Waterfall newest at the top, one row per screen update

Channel A on the left of centre, channel B on the right
3

Transmitter: framing, NRZI and GMSK

How a ship turns a 168-bit position report into a burst. The data go out byte by byte, least significant bit first, followed by a 16-bit CRC, the frame check sequence. After any five 1s in a row the transmitter inserts a 0 (bit stuffing), so the data can never imitate the flag 01111110 that opens and closes the frame. A training sequence of alternating bits comes first so the receiver can lock on. Then NRZI: a 0 is sent as a change of level, a 1 as no change. Last, GMSK: the levels are smoothed by a Gaussian filter (BT 0.4) and sent as a frequency of ±2.4 kHz, which turns the carrier's phase by a quarter turn per bit.

Ramp-up and trainingFlagsDataFrame check sequenceStuffed 0Ramp-down and guard time

NRZI level and GMSK frequency

NRZI level (±1)Transmitted frequency

Gaussian frequency pulse one bit, BT 0.4

One bit's contribution to the frequency. It spreads over neighbouring bits, so fast patterns never reach the full ±2.4 kHz.

Baseband I and Q

IQConstant envelope: only the phase carries data. The amplitude ramps up over the first 8 bits and down after the end flag.
4

FM discriminator

For each channel the receiver shifts the channel to 0 Hz, filters it and halves the sample rate to 48 kHz, 5 samples per bit. The FM discriminator then measures how far the phase turns from one sample to the next, which is the instantaneous frequency. The result follows the transmitted ±2.4 kHz plus the ship's carrier error. Over the training sequence the level pattern repeats every 4 bits and its phase comes back to where it started, so any steady turn over those 4 bits is the carrier error. The receiver measures it there and subtracts it for the rest of the frame. Weak signals show clicks: sudden full turns of the phase caused by noise.

Selected burst

Discriminator outputAfter the post-detection filterTransmitted frequency (truth)Measured carrier offset

Channel filter output I, Q and magnitude

5

Clock recovery

Each bit must be sampled in its middle, but the receiver doesn't know exactly where the bits fall: distance, filter delays and the start of the burst all shift them. A digital phase-locked loop counts 5 samples per bit and, at every zero crossing, nudges its count so that crossings fall halfway between sampling instants. The training sequence, with a crossing every 2 bits, pulls it in. The eye diagram overlays two-bit stretches of the signal around each sampling instant: the wider the eye opens, the safer the decisions.

Eye diagram

Signal, offset removedSampling instants

Timing corrections

Where each crossing fell, in bits from mid-bitStart flag
6

Bits, flags and the CRC

A sample above zero is a high level, below zero a low level. NRZI decoding turns "same level as the previous bit" into 1 and "changed" into 0. The receiver hunts for the flag 01111110, collects bits until the next flag, removes every 0 that follows five 1s, and runs the CRC over the data and the received check sequence. A good frame always leaves the same remainder, 0xF0B8.

Decisions

Sampled valueFlagsStuffed 0, removedCheck sequence

CRC check

CRC-16-CCITT as HDLC uses it: generator x¹⁶ + x¹² + x⁵ + 1, register preset to all ones, result inverted, sent least significant bit first.

Last 60 seconds

Error rate against signal level

Eb/N0 is the energy of one bit over the noise power per hertz. The test sends isolated position reports through the same modulator and receiver at set values of Eb/N0, with random carrier phase and timing, and counts bit errors after NRZI decoding and frames that fail. The reference curves are ideal coherent MSK and noncoherent detection of orthogonal FSK. A discriminator on GMSK falls short of both: its two tones are only a quarter-turn apart per bit, not orthogonal, and the Gaussian filter blurs neighbouring bits.

Live traffic share of reports decoded, by Eb/N0

Without overlapOverlapped by another burst

Bit and frame error rate run the test

300 frames at each of 9 levels, with the current receiver settings.
Bit error rateFrame error rateCoherent MSKNoncoherent orthogonal FSK
7

The message

A frame that passes the CRC is split into fields. Position reports (messages 1, 2 and 3 from Class A, 18 from Class B) carry the MMSI, navigational status, rate of turn, speed over ground in tenths of a knot, longitude and latitude in ten-thousandths of a minute, course, heading, the UTC second, and a communication state that tells other ships about the sender's slots. Receivers hand decoded messages on as NMEA !AIVDM sentences: the bits packed six at a time into printable characters, with an XOR checksum.

FieldBitsRawMeaning

8

Sharing the channel: SOTDMA

Each channel is cut into 2250 slots a minute, 26.7 ms each, timed from GNSS. A Class A ship picks its own slots. It keeps a map of the slots other ships have announced, picks at random among the free ones within ±10% of the spacing around each nominal time, and keeps each slot for another 3 to 7 minutes (the slot timeout, counted down in every report) before picking again and announcing the new one. Here, ships at anchor or moored report every 3 minutes with message 3 and book just the next slot (ITDMA). Class B ships listen at the start of a slot and only transmit if it is quiet (carrier sense). Ships too far apart to hear each other can still choose the same slot: the receiver, between them, hears both at once.

Ship

The last minute

Outer ring channel A, inner ring channel B, one tick per slot, clockwise from the top of the minute. The hand is now.

Slots around now

Zoom with the buttons or ⌘/Ctrl-scroll, drag to move along the minute. Top row channel A, bottom row B.

Class A reportClass B reportTwo or more at onceSelected shipIts selection intervalsBooked ahead, outline
#ChannelNominal slotChosen slotTimeoutNext in

Overlaps against traffic run a sweep

Runs 20 to 250 ships for 5 simulated minutes each, once with SOTDMA and once with every ship picking slots at random, counting overlaps at the receiver (the signal isn't generated for this). Then the scenario restarts.
SOTDMARandom slotsRandom-access prediction, 1 − e−GSOTDMA overlaps between ships that can't hear each other
9

Message log

Every frame the receiver decoded, newest first, and the same messages as NMEA sentences, the way a receiver sends them to a chart plotter. Click a row to show it in stages 3 to 7 (while its signal is still in the receiver's capture buffer).

UTCChSlotTypeMMSILatitudeLongitudeSpeedCourseHdgStatus, slotsLevelCRCNMEA

NMEA output