Main Content

Ship Tracking Using AIS Signals

This example shows how to track ships by processing automatic identification system (AIS) signals. You can use previously captured signals or receive signals in real time using an RTL-SDR radio, an ADALM-PLUTO radio or a USRP™ Radio. You can also show the tracked ships on a map using the Mapping Toolbox™.

Required Hardware and Software

By default, this example runs using previously captured signals. Optionally, you can receive signals over-the-air. For this, you also need one of the following:


In marine transportation, vessel traffic services use AIS as a component of the marine traffic monitoring system. AIS performs these functions:

  • Transmit vessel identifier, position, course, and speed.

  • Receive and process specified interrogating calls.

  • Operate continuously while sailing or at anchor.

AIS has these attributes:

  • A transmit frequency in the range 156.025 MHz-162.025 MHz

  • Gaussian frequency shift keying modulation

  • A bit rate of 9600 bits/sec

  • A transmit bandwidth-time product of 0.4

  • A receive bandwidth-time product of 0.5

  • A modulation index of 0.5

AIS transmission packets contain these fields:

  • Training Sequence — 24-bit sequence of alternating zeros and ones (0101...)

  • Start Flag — 8-bit sequence, 01111110

  • Data — The data portion is 168 bits long in the default transmission packet

  • Frame Check Sequence (FCS) — Uses the cyclic redundancy check (CRC) 16-bit polynomial to calculate the checksum

  • End Flag — Identical to the start flag

  • Buffer — 24 bits long to account for bit stuffing (maximum 4 bits), distance delay (14 bits), and synchronization jitter (6 bits)

This figure shows the AIS packet format

Fields in the AIS packet format.

Receiver Structure

This block diagram shows the receiver code structure. The processing has three main parts: signal source, physical layer and data viewer.

Block diagram showing receiver code flow cart.

Signal Source

Specify the signal source as one of these values

  • ''File'' — Uses the comm.BasebandFileReader object to read a file that contains a captured signal.

  • ''RTL-SDR'' — Uses an RTL-SDR radio to receive a live signal.

  • ''ADALM-PLUTO'' — Uses a Pluto radio to receive a live signal.

  • ''USRP'' — Uses a USRP radio to receive a live signal.

The example uses a signal symbol rate of 9600 Hz and 24 samples per symbol.

If you specify ''RTL-SDR'' as the signal source, the example searches your computer for an RTL-SDR radio at the radio address '0' and uses that radio as the signal source.

If you specify ''ADALM-PLUTO'' as the signal source, the example searches your computer for a Pluto radio at the radio address 'usb:0' and uses that radio as the signal source.

If you specify ''USRP'' as the signal source, the example searches your computer for a USRP radio at the radio address you specify and uses that radio as the signal source.

Physical Layer

The physical layer (PHY) processes the baseband samples from the signal source to produce packets that contain the ship position information and raw message bytes. This figure shows the PHY processing components.

Block diagram showing PHY processing components.

  • Packet Search — Search for the strongest burst in the received signal by dividing into multiple windows.

  • DC Offset Removal — Remove DC offset from the detected signal.

  • Frequency Compensation — Estimate and compensate for the carrier frequency offset.

  • Matched Filtering — Perform filtering with a Gaussian pulse generated according to AIS specifications.

  • Synchronization and Demodulation — Perform timing synchronization by correlating the received signal with the known preamble and demodulate to produce bits.

  • AIS Bit Parser — Detect the Start Flag and End Flags, then perform CRC detection. If the CRC is successful, then decodes the ship information.

AIS signal contains 64 specific message types. Ship position information is included in 11 of the message types. In this example, you decode all of the 11 message types that contain ship position information.

This example lists the ship position information including the ship ID, latitude, and longitude, as well as the associated date and time in a table. For decoding additional information from the messages, see [1].

Data Viewer

The data viewer shows the received messages on a graphical user interface (GUI). As data is captured, the application lists information that it decodes from these messages in a table.

Track Ships Using AIS Signals

The default configuration runs for a duration of 10 seconds and uses signal data from a captured data file, and outputs to a text file. To provide input values from the command line, you must change cmdlineInput to 1, then you will be prompted to enter the following information when you run the example:

  1. Reception duration in seconds,

  2. Signal source (Captured data file or RTL-SDR radio or ADALM-PLUTO radio or USRP radio),

  3. Optional output methods (map, text file, or both).

cmdlineInput = 0;
if cmdlineInput
    % Request user input from the command-line for application parameters
    userInput = helperAISUserInput;
% Calculate AIS parameters based on the user input
[aisParam,sigSrc] = helperAISConfig(userInput);

% Create the data viewer object and configure based on user input
viewer = helperAISViewer('LogFileName',userInput.LogFilename, ...

% Launch map based on user input
if userInput.LaunchMap

% Log data based on user input
if userInput.LogData

% Start the viewer and initialize radio time
radioTime = 0;

% Main loop for capturing and decoding the AIS samples
while radioTime < userInput.Duration  
    if aisParam.isSourceRadio       
        if aisParam.isSourceRTLSDRRadio         % For RTL-SDR
            [rcv,~,lost,~] = sigSrc();
            lostFlag = logical(lost);         
        elseif aisParam.isSourcePlutoSDRRadio   % For ADALM-PLUTO
            [rcv,~,lostFlag] = sigSrc();
        elseif aisParam.isSourceUSRPRadio       % For USRP
            [rcv,~,lostFlag] = sigSrc(); 
    else                                        % For baseband file
        rcv = sigSrc();
        lostFlag = uint32(0);

    % Recover the information by decoding AIS samples
    [info, pkt] = helperAISRxPhy(rcv,aisParam);

    % View decoded information on viewer
    update(viewer, info, pkt, lostFlag);

    % Update radio time
    radioTime = radioTime + aisParam.FrameDuration;

% Stop the viewer and release the signal source


If you have the Mapping Toolbox, you can also observe AIS tracking of ships on a map.

Map of Boston Harbor showing AIS tracked ships.

Further Exploration

You can investigate AIS signals using the AISExampleApp. To launch the app, enter AISExampleApp in the MATLAB® Command Window. Use the app interface to select the signal source and change the duration.

You can explore the supporting functions and System objects for details of the physical layer implementation.


[1] Recommendation ITU-R M.1371-5. "Technical characteristics for an automatic identification system using time division multiple access in the VHF maritime mobile frequency band", International Telecommunication Union.