Ais Decoder by Neal Arundale

Decodes All 27 AIS message types
  and 50 Binary Messages


Main Features
Introduction
The decoder will decode all the NMEA content of all 27 AIS mesage types. The NMEA messages must be in !AIVDM or !AIVDO format.
The decoder has been tested on an XP PC, and believe it should work on all Windows PC's after 98. Other users report it works on Vista, Win 7, Win 7-64 and Linux (Wine).
The maximum speed messages will be decoded depends of the information you are requesting and how the NMEA sentences are being received.
I would be very interested in any comments, suggestions or bugs. If you find any bugs, please email me the nmea.log file which is located in Documents and Settings\User\Application Data\Arundale\Ais Decoder\. This holds all nmea messages received since the decoder was last started (or the log was last read), so, to prevent the message triggering the error being overwritten, please rename it before you restart the decoder. I have intentionally not included any "blanket" error traps so that any bugs are not silently ignored, so it is very likely any bugs will crash the program.
 



Quick Start
Download and install AisDecoder as described above.
This window will be displayed.

Click on Options and configure AisDecoder to receive UDP or Serial/USB Data.

Serial or USB Input
If your receiver output is USB, you probably already have installed a virual COM port driver so you will need to use this virtual com port as the input to AisDecoder.

UDP Data
By default, the decoder expects NMEA AIS data on a dedicated UDP port 29421 (on the local PC), so you may need to convert the output from your receiver into UDP packets. IP address 127.0.0.1 is always the local machine.

If you are running ShipPlotter, it has a UDP output option.

You can also use Ais Dispatcher , which will convert tcp, udp or serial input into UDP.
If using Ais Server Lite see these additional instructions Interfacing with SiiTech Ais Server Lite
.
If your receiver outputs serial data to a serial-to-network adaptor (such as a Digi One) and the adaptor supports udp multicasting, you can forward udp packets to the local network ip address and port of your pc.

Start Decoding
Close the Options window (Click on the X)
On the Control/Stats Window ensure you have ticked the configured External Source (UDP or Serial) you are receiving data from.


Click the Start Control Botton

These two windows will be displayed

This window will display the incoming NMEA data (with a time stamp appended)
This window will display a decoded summary of the incoming NMEA AIS data 

Now left click anywhere on one line of the Summary window
This window will display the detailed decode of the AIS message clicked


For details of all 27 AIS message types click here
For details of AIS Binary messages click here

To Display the Ships on Google Earth

Install Google Earth


In the Control/Stats window click the Options button
This Options window will be displayed



In the Options window click the Open New button


Browse to the directory shown on the bottom of the Control window, select the Settings folder, Open the file GoogleEarth.ini

This Options window below will be displayed
 
Close the Options window (Click on the X)

After one minute all vessels data received since you started the decoder will be available to view in Google Earth and the GIS button on the Control/Stats window will be available.



If you have Google Earth installed, on the Control/Stats window click the GIS button
Any ships, from which you have received data, will be displayed on Google Earth.


To view the current map using Google Earth Click here

You can also use Google Maps (you may have to sign up for this), and you will have to construct a template file.


For more information on receiving AIS see Rene's excellent site at http://www.discriminator.nl/ais/index.html and Marine Traffic's FAQ
For details of all 27 AIS message types click here
For details of AIS Binary messages click here

Detailed Instructions

Schematic Description
The incoming NMEA sentences are decoded. The filter passes the AIS message types you have selected. If scheduled output is required, these messages are held in the scheduler buffer until the scheduled time.
If specific AIS fields are required the value of the field is tagged.
If the value of the tag requires filtering, by having a valid range set, the range is validated, by the tag filter.
The Formatter replaces the tag in the tag template file, with the tag value.
The fully formatted and decoded sentence is output to a file, by UDP and/or displayed.


Display Windows
There are two main windows which allow you to alter the behaviour of the decoder
Control/Stats Window

  • Start commences decoding NMEA sentences
  • Pause continues receiving sentences but holds them in a buffer until pressed again, when processing will recommence. This enables you to pause scrolling screens without loosing incoming messages.
  • Stop stops all processing
  • Options displays the Options window
  • Update wll be enabled if there is a new update available for download
  • Help displays this file

  • UDP decodes input from the UDP input port set on the Options window
  • Serial decodes input from the Serial Com port set on the Options window
  • External selects the External Source(s) ticked above.
  • Log file decodes input from a previously saved NMEA log file. You will be prompted to browse for the file after you press Start.
  • Template will decode input from a log file containing one of each type of AIS message

  • The Nmea Input window displays the NMEA sentences before decoding
  • The Summary window will display the Decoded message summary before input filtering, after input filtering or on being output from the scheduler.
  • The Detail window will display all messages as they are being received or after filtering. By clicking on a message in the summary display, the detail of the selected message only will be displayed. This will stop any display of message detail if previously selected.
  • Pressing the GIS button, will display the current Tagged Output file using the application associated with the file extension. For example if a KML file Google Earth will be used if KML is set as the default program to run using explorer. If the current output file was an HTML file, the current default browser will be used to render the HTML file. The button is only enabled after a new Tagged file has been created after the Start button has been pressed. It is also disabled temporarily during creation of a new file by the Scheduler. 

  • Received is the number of NMEA sentences entering the decoder. As each part of a multi-part AIS message consists of a separate AIS message, each part is counted separately.
  • Waiting are the number of messages being held in the receive buffer awaiting decoding.
  • Processed are the number of incoming NMEA sentences which have been decoded.
  • Filtered are the number of NMEA sentences that have been accepted by the input filter
  • Scheduled are the number of sentences currently being held in the Scheduler buffer, these will be output when the next scheduled time interval is reached.
  • Last Output are the number of different MMSI's that were last output by the Scheduler.
  • Named Vessels are the current number of MMSI's thet have a vessel name associated with them that will be used to put a name to a MMSI, if required, on outputting the MMSI.

Options Window

All settings can be saved in an initialisation file. This includes the settings on the Control/Stats window.
  • Open New - will allow you to browse for an existing initialisation file, which contains any previously saved settings. I have included three files.
    • default.ini - The basic setting to receive, decode and display messages
    • GoogleEarth.ini - Output a KML file suitable for Google Earth
    • UdpTagsRange.ini - Range filtering with UDP output
  • Save - saves the current settings to the Current setting file
  • Save As - saves the current settings to a new file


  • Check for updates - will check my website on start-up, to see if a later version of AisDecoder has been placed on the WebServer. This may not have a later version number if the changes are minor.
  • Reject Shore Stations will reject any MMSI's starting with 00
  • UDP Input - the input port that will be used for UDP input
  • Serial Input (just added) - Sets the serial port and speed. For AIS the speed will normally be 38,400 and for GPS NMEA normally 4,800
  • Log File Source determines whether Received, Processed or Filtered NMEA sentences are written to the log file (nmea.log).
  • Format determines whether the logged NMEA sentences have a time stamp appended to the sentence. All incoming sentences have a time stamp (obtained from the PC's clock) appended, as the scheduler needs to know when the sentence was received.  If NMEA only is selected, this time stamp is removed prior to being written out to the log file.
  • Log File Rollover - Messages are appended to the log file (nmea.log) as they are received. This is NOT reset each time you start the decoder, so the file can get very large. If you wish you can have the logfile "Roll Over" to a new file at midnight every day. If you select Log File Rollover, the logfile will be named nmea_yyyymmdd.log, where yyyymmdd is the current Year, Month, and Day.



For a NMEA sentence to pass through the filter, it has to reach the end of a number of checks. A message failing at one level will fail completely. Each level is indented (to the right) from the previous level. When you tick one level, if there are any more levels, you will be presented with another set of tick boxes. If you do not tick any boxes on any one level, the whole of the level will be removed, in which case all messages ticked on the previous level will be accepted. You do not have to tick sub items - they are assumed to be ticked.
The complete Accept Filter tree is displayed on the Control/Stats window, with all redundant options removed.

  • Minutes are how often the Scheduler will output messages. This output is triggered be the arrival of a new message into the Scheduler's buffer and NOT by the PC's clock.
  • The Scheduler outputs AIS messages in MMSI order. If messages are duplicated, only the last received message is output. The Time to Live is the time the messages remain in the Scheduler's buffer before removal. If you are using the output of the decoder to display live vessel position data, the Time To Live will be the time the vessel will remain on the GIS display, after the last message from the vessel was received, before being removed from the GIS display.
  • MMSI change
    • If ticked the latest Tag values will be output whenever the MMSI changes.
    •  If unticked the Tags/CSV will be output after each message rather than on change of MMSI. This is to allow, when reading a log file, to output the history of one vessel.
  • The file name is the Tag Template file currently being used to create a Tagged Output File.

You will need to Tag some AIS message fields if you wish to
  • Create a Tagged Output File - the Tags in the Template File will be replaced by the value associated with the Tag
  • Create a CSV Output File - The Tag values will be output as a CSV file
  • Create a NMEA Output File requiring Output Range Filtering - the NMEA message will be Output Filtered by the Range allowed by the Tag
AIS messages consist of a number of fields, it is the value of these fields which AisDecoder is decoding. All these fields and/or values are displayed in the Detail window. If you left click on any of these fields, you will be asked to create a Tag.
See below


If you click OK you will see the Tag in both the Output Field and the Output Tags list. By default he Tag name has _2 appended signifying it has the value in the second column of the Detail window. If you wished to have the descriptive name "Latitude" output and clicked the first column, the default Tag would be lat_1, Likewise if you wished the formatted Latitude "53° 36.9981' N" to be output and clicked the third column, the default Tag would be lat_3.
The same default Tag name can be generated by differing AIS message types, only you know whether this is the required behaviour. For example Latitude is not necessarily the position of a vessel, it could be defining an area (see AIS message type 22).
It is more likely you will wish to have the latest value of Latitude to be Output when the vessels position is available from more than one message type (see AIS message types 1,2,3).
In this case you will need to set a Field Tag for all three message types (1,2 and 3), in each case give the Tag the same name say "lat". In this case there will be three separate entries in the Fields an Tags table, but only the one in the Tags and Range table. You can alter the Tag name before (but not after) you click OK in the Input Field box above.

To delete a Field Tag, click on the Tag in the Fields and Tags list.
You cannot edit the tag, you must delete and re-create the Tag.

All differing Tags you have created in the Field and Tags list, will be put in the Output Tags and Range list.

You can delete an Output Tag and all Fields with the same Tag, by clicking on the Tag name in the Output Tags and Range list.
You can set a valid output range for any Tag.
Click on the Min or Max cell for the Tag for which you wish to filter the range.
Enter the Minimum, Maximum or both for the Tag.
If Range Filtering is selected as an Output Option, only those MMSI's passing the range check will be output.
If any range is blank, the range check will pass.
You can insert the minimum or maximum Range value into a Tagged Output File, see the notes below on Tag Template Files.

All Tags will be listed in the Output Tags and Range list. This shows a list of those you will most probably want to output for GIS. Note for all vessels the coresponding Field Tag list will contain approx 50 Tagged Fields.

If using tagged output, Synchronise ensures the decoder will process all messages containing output tags and not process redundant messages not containing tags.
There are two Output "Channels". One outputs to a file, and the other to an IP address using UDP. The options for both are the same.
  • File/UDP Output - if ticked turns on the output
  • FTP - if ticked sends Output File to FTP server (Website)
  • Display Output - Displays the Output. You can display the output, without actually outputting and data.
  • NMEA - NMEA sentences are output.
    • Time Stamp - if ticked the NMEA will be time stamped
  • CSV - All Tag values will be output in CSV format. The default delimiter is a Comma. If the delimiter character is found within the value of a tag, the tag value will be quoted (within " "). GIS filtering is applied to CSV output as well as Tagged output.
  • Tagged - Tags in the Tag Tamplate file are replaced with the Tag value before output.
    • GIS Filtering - The MMSI will only be output if both a Latitude and a Longitude have a value for the current MMSI.
    • A Special Tag <IconHeading> is created
  • Scheduled - The data will be output in batches according to the Schedule
  • Range Filtered - The value or all Tags must be within the value set in the Output Tags and Range list for the MMSI to be output.


These are the settings to access your FTP server, normally to upload an Output file to your Webserver.
  • URL is the domain to access your FTP (web) server, example my.server.com
  • USER is your login User Name
  • PASS is your password to login to the FTP (web) server
  • DIR is the directory below your root directory, where you wish the output file to be placed, example /uploads/ais Note this will probably be case sensitive (it depends on the Webserver).


If NMEA output the default name will be output.nmea
If CSV output the default name will be output.csv
IF Tagged output the default name will be the same as the Tag Template File

For UDP output, you should set your own IP and Port number.


Range Filtered NMEA Output
Output Range Filtered Scheduled
Output
No No As received
No Yes In MMSI order
Yes No Output Range is checked when MMSI changes. Either all or no sentences with the same MMSI are output
Yes Yes In MMSI Order, Output Range is checked when MMSI changes. Either all or no sentences with the same MMSI are output
Extracting Tag values and Range filtering must be done by MMSI because you may select tags or ranges which span two different AIS message types. For example, you may choose to output a vessel's position (AIS message type 1,2 or 3) and at the same time the vessel's length (AIS message type 5). The position is on one message type and the length on another. As it is very unlikely both messages will arrive together, neither message will be output if both position AND length are required for output.
The primary reason the Scheduler exists is to resolve this problem. The Scheduler retains the most recent message, of each message type, for the "Time to Live", outputting them in batches of the same MMSI.
The Vessel name is an exception as it is held separately; the vessel name list is re-started each time the Decoder is started.
If you require the vessel name on every CSV or Tagged output (and you probably will), you must tag the vessel name that is displayed next to the Vessel Name in bold, immediately before AIS Message Type on every Detail AIS message type you select for other field tags.
Do not Tag the second Vessel Name (not in bold) on the static data message (AIS message type 5), unless you only want the vessel name outputting when AIS message type 5 is output.

Directories/Folders and Files

Files

Logs
Output
Settings
Templates

In addition if you RIGHT click on the detail display, a CSV copy of the complete window will be placed on the PC's clipboard, enabling you to save the details to Excel, Word or any other program you wish.

Tag Template File
Any tags you have defined will be replaced with the value of the tag when the MMSI is output to the Tagged Output File. For example if in the Tag Template file you have added a tag <lat>, <lat> will be replaced with the value for the MMSI so if the latitude was 53.1234, <lat> would be replaced with 53.1234.

The Maximum and Minimum Range values may be inserted into the Tagged Output File by using the tag name with _min or _max appended. For example if the minimum latitude range for the <lat> tag was 53.0, <lat_min> would be replaced with 53.0.

A Special Tag <IconHeading> is created, if GIS has been ticked on output, which will contain the ships Heading (HDG) if it is available, otherwise it will contain the vessels Course Over Ground (COG), this is because some vessels do not output heading and it enables the Icon on GIS displays to be oriented to the COG rather than the Heading (HDG). This conforms to IALA Guidelines on Presentation.
 
All tags are case sensitive.

NMEA Sentence Processing
Limited processing of $GPZDA and $GPGGA messages has been added to allow GPS time stamping.
The default tags are the type of NMEA sentence (eg $GPZDA).
Note if trying to output tag values (including CSV), the Tag Value is only output when the MMSI changes, as GPS sentences will not have a MMSI, you will not get any output until an AIS sentence with an MMSI is output, unless the MMSI change option is unticked.
As with all tagged output, the decoder will only output the latest Tag value, if more than one message with the same Tag has been received, since the previous Tag was output.
If you require to see all messages, you should use NMEA output.

Binary Messages

The International Binary Messages are still evolving, all the common ones I believe I have decoded.  St Lawrence Seaway, Inland Waterways and most ITU/IMO will be decoded by the program. To see which, click here.

Many binary messages are subject to local interpretation. Potentially there are many thousands of different binary messages possible. I have decoded many of the more common ones, where I can find the requisite information. If you have details of any of the DAC/FI messages types where I do not display at least some of the information, I would be pleased to receive more details.
For further details of binary message decoding click here


Command line switches
To automatically start decoding on startup add ' start' at the end of the command line
For example:
"C:\Program Files\Arundale\Ais Decoder\AisDecoder_v3.exe" start
Note there is a space between exe" and start.
To start the decoder without any windows (so you can use it as a server) add start/nowindow

CSV Output
It is not practical to output each individual field of each type of AIS message separately to a spreadsheet. I decode over 1500 separately defined fields so you would require 1500 columns! The decoder will output any fields you require to be output to a csv file. To do this you need to "tag" the fields you require outputting individually for each AIS message type you are interested in.
Right click on the field you are interested in on the detail window and set the outputs to File and Display in the Options window.
This field will be output in the first "column" of the csv file.
For example if you wish to output the MMSI from AIS Message type 1
  1. On the Control/Stats Window
    click Options
  2. On the Options Window
    In the Accept Input Filter box
    Tick AIS Message 1    
    Click OK 
  3. On the Control/Stats Window
    Ensure the Display - Summary - Input Filtered button is selected
    Click Start
    After a message has been displayed in the Summary Window
  4. On the Summary Window
    Click any message line

    The Detail Display for this AIS message will be displayed
  5. On the Detail Window
    Click the Cell containing the MMSI number (this will be in the second column).
    The Input Field Window will be displayed
  6. On the Input Field Window
    Note you can rename the default field names to combine or split them on output)
    Click OK
  7. Repeat from step 5 to set up additional fields
  8. Repeat from step 2 for additional message types
This all sounds very complicated, but if you try it, it should be fairly obvious

 Glossary
ITU
International Telecommunication Union
Allocates the radio spectrum and sets standards
IALA
International Association of Lighthouse Authorities Standards for navigation and pilotage
AIS
Automatic Identification of Ships

UAIS
Universal AIS
Extended AIS - principally binary mesages (USA)
NMEA
National Marine Electronics Association
Standands for communication between wired electonic ship devices
RAIM
Receiver Autonomous Integrity Monitoring
AIS Receiver monitors electronic position fixing device
DSC
Digital Selective Calling
Selectively call one (or many) station from another station
TDMA
SOTDMA
ITDMA
CSTDMA
RATDMA
FATDMA
Time Division Multiple Access
Self Organising TDMA
Incremental
TDMA
Carrier Sense TDMA
Random Access TDMA
Fixed Access TDMA
It allows for large numbers of transmitters to share one single narrow band radio channel, by synchronizing their data transmission to an exact timing standard (GPS)
There are a number of different methods used to allocate and synchronise "slots".
A Slot is a time slice used by the transmitter and receiver of the data.
GNSS
Global Navigation Satellte System
Any type of GPS
MMSI
Maritime Mobile Service Identifier Unique number to identify a ship or coast radio station
EPFD
Electronic Position Fixing Device

DTE
Data Terminal Equipment
Ais tx/rx & associated equipment
SAR
Search and Rescue

SART
Search and Rescue Transponder
Automatic Emergency Beacon
CRC
Cyclic Redundancy Check
Checks integrity of Nmea messages
MID
Maritime Identification Digits
The part of the MMSI identifying the home Country or base area. For an up to list see here
tx/rx
Transmitter/Receiver

IAI
International Application Identifier
Binary Message header consisting of the DAC and the FI
DAC
Designated Area Code
Geographic area for the binary application (1=international, normally the MID)
FI
Function Identifier
Type of binary message
IEC
International Electrotechnical Commission Electrical Standards, in particular for AIS inter-equipment NMEA formatted messages
ENI

European Vessel Identification Number
Unique European inland waterways vessel identification number (similar to MMSI)
EMMA
European Multiservice Meteorological Awareness system
Standards for weather warnings & symbols
GIS Geographic Information System
Any system for plotting data on a map - eg Google MAps, Google Earth