AIS (Automatic Identification System) Decoding

Ferries departing from and arriving to the port of Gothenburg.
Well, this page is getting really old. Today you can buy AIS receivers at reasonable prices in ”any” shop. When I wrote this page, back in 2003, such receivers had brutal price tags. However, I will keep this page for sentimental reasons.

What is AIS ?

AIS (Automatic Identification System) is a system that continuously transmits a ship’s identification and position to other nearby vessels. All such vessels also receive data from other AIS equipped ships and display their positions and other relevant information on a display on the bridge. In other words, AIS is a navigation aid.

AIS is a global system. It is mandatory on passenger ships and all larger boats from 1st of July 2003. During the years to follow, successively smaller and smaller ships will be required to carry an AIS transponder.

AIS uses two channels (VHF 161.975 and 162.025 MHz) that have been reserved worldwide for this purpose. The modulation type is GMSK (Gaussian Minimum Shift Keying) and the data speed is 9600 bps. It is not easy to distinguish the AIS transmissions from the background noise – they sound the same and the data bursts last only 30 ms. Perhaps the simplest way to tell if you receive anything is to look at your S-meter needle, or adjust the squelch so you can hear it go on and off.

AIS Decoding for the Hobbyist

To add an item to my decoding résumé I decided to spend a few evenings to see if I could catch some position reports from ships in Gothenburg’s harbor. And sure, I caught some …

Most of the time was spent on the Internet, gathering information on GMSK, NRZI and bit stuffing. Too much time was wasted finding the required modem circuit CMX589. Sometimes it is a good idea to look in the least likely place first..! AIS signal from the discriminator The AIS signal is trickier to decode than, for instance, FFSK or Pocsag. Brave souls would use their soundcards to decode AIS, I chose to use a hardware solution with a special modem circuit. This made the programming burden easier, but I had to deal with crystals, ICs and capacitors instead. Decisions, decisions … At least this solution works whatever computer I use, it just needs a serial port. The software doesn’t care if my soundcard is of the ”correct” type, or if I have a soundcard at all.

The more-or-less triangle shaped training sequence in the picture is actually supposed to be a sine wave, or close to one. This creates problems for the modem circuit. The ugly waveform is probably the fault of my radio’s IF filters (I use an AOR AR-3000.) Because of this ill-formed signal I get a lot of data errors. Maybe another radio, with other IF filters, would render a better (or worse) result. That remains to be tried.

AIS, Testing the CMX589

Hardware time! In the bird’s nest in the photo you can see the GMSK circuit (CMX589), an Atmel AVR 2313 and a MAX232 for level converting. This triad converts the VHF data bursts into a nice stream of ones and zeroes to a PC.

AIS Software

This project actually uses software in two places. First, of course, in the PC where the big things happen, but also in a small controller close to the hardware. This is an Atmel AVR 2313 that relieves the PC from finding start/sync and takes care of NRZI decoding and bit unstuffing. Thus the PC is presented with nice, compact packets of data, ready to be decoded according to the AIS protocol.

For the PC software, I recycled code from some of my previous projects – large portions of the code were identical. It took me less than one evening to convert an old Mobitex decoder into a very crude AIS decoder:

First live data!
First live data !
Yes – it worked! Lots of garbage, but two valid MMSI numbers can be seen. 265430000 is Stena Carisma, a passenger catamaran that goes between Sweden and Denmark. And 2655150 is a base station transmitting the UTC time and its own position. Not too bad for one evening’s work.
Somewhat better signal quality.
Slightly improved decoding
Above: After I found a bug (or ”undocumented feature”) in the AVR’s bit unstuffing code, the quality of the decoding was somewhat improved. Far from perfect, but now I can blame the hardware and a poor receiving location.

Human interface
Above: A more human friendly display interface. Looks a bit nicer. At least if you don’t mind reading Swedish :-)

AIS plot
Above is my first attempt of plotting vessels on a map. The decoding program forwards all received positions into a MySQL database, and the plotting program retrieves the latest data for a ship on demand. (The ships are the small red bars that look like matches.)

The ships are reasonably according to scale, but for very small boats (or plots on large scale charts) it will probably be necessary with a certain minimum size for the symbols.

Conclusion

So, it worked and I consider the project a success. I think I was the first guy with AIS hobby decoding in Sweden. Let me know if you are first where you live!

The future involves making a graphical interface and actually plot the ships on a chart or map. Perhaps a web interface would be something? However, first I have some hardware issues to resolve. I need a clean signal from the radio, and that must be the priority before I refine the software.

Update December 2004

Now there is a new program that decodes AIS with the soundcard. It also has lots of other nice features, e.g. plotting ships on charts or satellite images. Highly recommended! Take a look at www.shipplotter.com. Here is a screendump from Shipplotter showing the waters between Sweden and Denmark.

Update September 2005

Here’s a link to my old, simple NMEA/AIVDM sentence decoder. Most AIS receivers seem to report the received messages over the NMEA serial protocol. With this decoder you can test such messages from your receiver.

AIS log dump

Below is a raw log dump from the AIS decoding software. It is here just to fill the space on the bottom of the page.
2003-10-04 22:28:18  (1) 265177000: ns 15, rot 0, 0 kn,  351/ 262, 6403942, 1269413 (3,1 km)
2003-10-04 22:28:20  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:28:31  (5) STENA DANICA (SKFH), T: 60, Dr: 0,0m, GOTEBORG FREDRIKSHAN
2003-10-04 22:28:38  (1) 265177000: ns 15, rot 0, 0 kn,  311/ 262, 6403942, 1269413 (3,1 km)
2003-10-04 22:28:56  (1) 265509390: ns 15, rot 128, 0 kn,  170/ 511, 6404408, 1269558 (3,1 km)
2003-10-04 22:28:57  (1) 265177000: ns 15, rot 0, 0 kn,  239/ 262, 6403942, 1269413 (3,1 km)
2003-10-04 22:29:00  (1) 399647728: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:29:03  (1) 265509390: ns 15, rot 128, 0 kn,  169/ 511, 6404783, 1263054 (9,5 km)
2003-10-04 22:29:18  (1) 265177000: ns 15, rot 0, 0 kn,  273/ 262, 6403941, 1269413 (3,1 km)
2003-10-04 22:29:20  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:29:30  (5) STENA DANICA (SKFH), T: 60, Dr: 0,0m, GOTEBORG FREDRIKSHAN
2003-10-04 22:29:40  (1) 265177000: ns 15, rot 0, 0 kn,  317/ 262, 6403941, 1269413 (3,1 km)
2003-10-04 22:29:41  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:29:51  (1) 265509390: ns 15, rot 128, 0 kn,  168/ 511, 6404404, 1269561 (3,1 km)
2003-10-04 22:29:57  (1) 265177000: ns 15, rot 0, 0 kn,    4/ 262, 6403941, 1269413 (3,1 km)
2003-10-04 22:30:18  (1) 265509390: ns 3, rot 128, 0 kn,  155/ 511, 6404404, 1269562 (3,1 km)
2003-10-04 22:30:20  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:30:35  (3) 621730184: ns 5, rot 0, 0 kn,  314/ 223, 6405388, 1270927 (2,8 km)
2003-10-04 22:30:41  (1) 399647728: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:30:44  (5) PR.CESS OF SCANDINA. (OWEN 2), T: 60, Dr: 6,0m, KRISTIANS1ND ,
2003-10-04 22:31:00  (4) rpt 0, mmsi 2655150, 2003-10-04 20:31:01
2003-10-04 22:31:00  Acc 0, 6402747  1276633  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:31:01  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:31:17  (1) 265177000: ns 15, rot 0, 0 kn,   13/ 262, 6403941, 1269414 (3,1 km)
2003-10-04 22:31:31  (5) STENA DANICA (SKFH), T: 60, Dr: 0,0m, GOTEBORG FREDRIKSHAN
2003-10-04 22:31:37  (1) 265177000: ns 15, rot 0, 0 kn,  326/ 262, 6403941, 1269414 (3,1 km)
2003-10-04 22:31:41  (4) rpt 0, mmsi 2655150, 2003-10-04 20:31:41
2003-10-04 22:31:41  Acc 0, 6402747  1276633  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:31:41  (1) 265509390: ns 15, rot 128, 0 kn,  166/ 511, 6404405, 1269561 (3,1 km)
2003-10-04 22:32:01  (4) rpt 0, mmsi 2655150, 2003-10-04 20:32:01
2003-10-04 22:32:01  Acc 0, 6402747  1276633  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:32:01  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:32:17  (1) 265177000: ns 15, rot 0, 0 kn,  358/ 262, 6403941, 1269414 (3,1 km)
2003-10-04 22:32:21  (1) 265509390: ns 15, rot 128, 0 kn,  166/ 511, 6404405, 1269567 (3,1 km)
2003-10-04 22:32:31  (5) STENA DANICA (SKFH), T: 60, Dr: 0,0m, GOTEBORG FREDRIKSHAN
2003-10-04 22:32:37  (1) 265177000: ns 15, rot 0, 0 kn,   70/ 262, 6403942, 1269414 (3,1 km)
2003-10-04 22:32:57  (1) 265177000: ns 15, rot 0, 0 kn,  333/ 262, 6403942, 1269414 (3,1 km)
2003-10-04 22:33:01  (4) rpt 0, mmsi 2655150, 2003-10-04 20:33:01
2003-10-04 22:33:01  Acc 0, 6402759  1276634  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:33:17  (1) 265509390: ns 15, rot 128, 0 kn,  170/ 511, 6404406, 1269560 (3,1 km)
2003-10-04 22:33:21  (1) 265509390: ns 15, rot 128, 0 kn,  174/ 511, 6404406, 1269560 (3,1 km)
2003-10-04 22:33:40  (1) 265177000: ns 15, rot 0, 0 kn,  323/ 262, 6403941, 1269413 (3,1 km)
2003-10-04 22:33:53  (4) rpt 0, mmsi 922877139, 13481-13-05 18:15:41
2003-10-04 22:33:53  Acc 1, 7710830  -8251207  (9612,9 km)  157,31N   114,95E
2003-10-04 22:33:54  (3) 232732256: ns 5, rot 128, 0 kn,  196/   1, 6404479, 1270247 (2,6 km)
2003-10-04 22:34:00  (1) 265177000: ns 15, rot 0, 0 kn,  147/ 262, 6403940, 1269413 (3,1 km)
2003-10-04 22:34:01  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:34:20  (1) 265509390: ns 15, rot 128, 0 kn,  178/ 511, 6404407, 1269560 (3,1 km)
2003-10-04 22:34:21  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:34:31  (5) STENA DANICA (SKFH), T: 60, Dr: 0,0m, GOTEBORG FREDRIKSHAN
2003-10-04 22:34:41  (1) 265509390: ns 15, rot 128, 0 kn,  169/ 511, 6404407, 1269559 (3,1 km)
2003-10-04 22:35:00  (1) 265177000: ns 15, rot 0, 0 kn,  331/ 262, 6403940, 1269413 (3,1 km)
2003-10-04 22:35:01  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:35:17  (1) 265177000: ns 15, rot 0, 0 kn,  149/ 262, 6403940, 1269413 (3,1 km)
2003-10-04 22:35:20  (4) rpt 0, mmsi 2655150, 2003-10-04 20:35:21
2003-10-04 22:35:20  Acc 0, 6402748  1276632  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:35:21  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:35:28  (1) 265509390: ns 15, rot 128, 0 kn,  165/ 511, 6404408, 1269557 (3,1 km)
2003-10-04 22:35:30  (5) STENA DANICA (SKFH), T: 60, Dr: 0,0m, GOTEBORG FREDRIKSHAN
2003-10-04 22:35:41  (1) 265509390: ns 15, rot 128, 0 kn,  177/ 511, 6404409, 1269557 (3,1 km)
2003-10-04 22:35:57  (1) 265177000: ns 15, rot 0, 0 kn,  161/ 262, 6403940, 1269412 (3,1 km)
2003-10-04 22:36:14  (1) 265509390: ns 15, rot 128, 0 kn,  171/ 511, 6404409, 1269558 (3,1 km)
2003-10-04 22:36:17  (1) 265177000: ns 15, rot 0, 0 kn,  107/ 262, 6403941, 1269412 (3,1 km)
2003-10-04 22:36:20  (4) rpt 0, mmsi 2655150, 2003-10-04 20:36:21
2003-10-04 22:36:20  Acc 0, 6402747  1276633  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:36:21  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:36:22  (1) 388412445: ns 11, rot 0, 1 kn,  352/ 508, 6993631, 1899149 (861,2 km)
2003-10-04 22:36:31  (5) STENA DANICA (SKFH), T: 60, Dr: 0,0m, GOTEBORG FREDRIKSHAV
2003-10-04 22:36:37  (1) 265177000: ns 15, rot 0, 0 kn,   34/ 262, 6403941, 1269412 (3,1 km)
2003-10-04 22:36:41  (1) 388412445: ns 11, rot 0, 1 kn,  338/ 511, 6994387, 1899056 (861,6 km)
2003-10-04 22:36:45  (5) PR.CESS OF SCANDINA. (OWEN 2), T: 60, Dr: 6,0m, KRISTIANSAND  &
2003-10-04 22:37:01  (1) 265177000: ns 15, rot 0, 0 kn,   24/ 262, 6403941, 1269412 (3,1 km)
2003-10-04 22:37:17  (1) 265509390: ns 15, rot 128, 0 kn,  167/ 511, 6404409, 1269558 (3,1 km)
2003-10-04 22:37:20  (4) rpt 0, mmsi 2655150, 2003-10-04 20:37:21
2003-10-04 22:37:20  Acc 0, 6597413  1287513  (195,0 km)   59,44N    12,06E
2003-10-04 22:37:21  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:37:30  (5) STENA DANICA     ! (SKFH), T: 60, Dr: 0,0m, GOTEBORG FREDRIKSHAN
2003-10-04 22:37:58  (1) 265509390: ns 15, rot 128, 0 kn,  171/ 511, 6404409, 1269558 (3,1 km)
2003-10-04 22:38:01  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:38:17  (1) 265509390: ns 15, rot 128, 0 kn,  170/ 511, 6404409, 1269557 (3,1 km)
2003-10-04 22:38:21  (1) 265177000: ns 15, rot 0, 0 kn,  279/ 263, 6403941, 1269412 (3,1 km)
2003-10-04 22:38:21  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:38:22  (1) 388412445: ns 11, rot 0, 1 kn,  343/ 508, 6992874, 1899240 (860,7 km)
2003-10-04 22:38:38  (1) 265177000: ns 15, rot 0, 0 kn,  140/ 263, 6403941, 1269412 (3,1 km)
2003-10-04 22:38:41  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:38:58  (1) 265509390: ns 15, rot 128, 0 kn,  170/ 511, 6404410, 1269558 (3,1 km)
2003-10-04 22:39:06  (1) 265509390: ns 15, rot 128, 0 kn,  167/ 511, 6404411, 1269558 (3,1 km)
2003-10-04 22:39:18  (1) 265177000: ns 15, rot 0, 0 kn,  242/ 263, 6403941, 1269412 (3,1 km)
2003-10-04 22:39:21  (1) 265509390: ns 15, rot 128, 0 kn,  154/ 511, 6404412, 1269558 (3,1 km)
2003-10-04 22:39:31  (5) &(J\C@HB\BBCAQE@AAE (6VLQQA), T: 120, Dr: 0,0m, ^Z(JTZ$OPH$JX RV6PB\
2003-10-04 22:39:37  (1) 265177000: ns 15, rot 0, 0 kn,  193/ 263, 6403941, 1269412 (3,1 km)
2003-10-04 22:39:53  (1) 265509390: ns 15, rot 128, 0 kn,  174/ 511, 6404412, 1269558 (3,1 km)
2003-10-04 22:39:57  (3) 265514500: ns 5, rot 128, 0 kn,  158/ 511, 6405848, 1271890 (2,8 km)
2003-10-04 22:40:01  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:40:18  (1) 265509390: ns 15, rot 128, 0 kn,  140/ 511, 6404412, 1269557 (3,1 km)
2003-10-04 22:40:20  (4) rpt 0, mmsi 2655150, 2003-10-04 20:40:21
2003-10-04 22:40:20  Acc 0, 6402747  1276633  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:40:21  (1) 265509390: ns 15, rot 128, 0 kn,  169/ 511, 6404411, 1269557 (3,1 km)
2003-10-04 22:40:30  (5) STENA DANICA (SKFH), T: 60, Dr: 0,0m, GOTEBORG FREDRIKSHAN
2003-10-04 22:40:40  (4) rpt 0, mmsi 2655150, 2003-10-04 20:40:41
2003-10-04 22:40:40  Acc 0, 6402747  1276633  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:40:41  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:40:57  (1) 265509390: ns 15, rot 128, 4 kn,  296/ 254, 3231965,  543113 (3253,8 km)
2003-10-04 22:41:01  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:41:17  (1) 265177000: ns 15, rot 0, 0 kn,  184/ 263, 6403942, 1269413 (3,1 km)
2003-10-04 22:41:20  (4) rpt 0, mmsi 2655150, 2003-10-04 20:41:21
2003-10-04 22:41:20  Acc 0, 6402747  1276634  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:41:21  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:41:30  (4) rpt 0, mmsi 2655150, 2003-10-04 20:41:31
2003-10-04 22:41:30  Acc 0, 6402747  1276634  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:41:40  (1) 399394728: ns 15, rot 0, 0 kn,  300/ 263, 6403941, 1269412 (3,1 km)
2003-10-04 22:41:41  (1) 265430000: ns 0, rot 0, 0 kn,    0/  77, 6404019, 1270105 (2,5 km)
2003-10-04 22:41:57  (1) 265509390: ns 15, rot 128, 0 kn,  186/ 511, 6404411, 1269561 (3,1 km)
2003-10-04 22:42:00  (4) rpt 0, mmsi 2655150, 2003-10-04 20:42:01
2003-10-04 22:42:00  Acc 0, 6402747  1276635  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:42:02  (1) 265509390: ns 15, rot 128, 0 kn,  136/ 511, 6404410, 1269568 (3,1 km)
2003-10-04 22:42:17  (1) 265177000: ns 15, rot 0, 0 kn,  229/ 263, 6403940, 1269412 (3,1 km)
2003-10-04 22:42:20  (4) rpt 0, mmsi 2655150, 2003-10-04 20:42:21
2003-10-04 22:42:20  Acc 0, 6402747  1276635  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:42:21  (1) 265509390: ns 15, rot 128, 0 kn,  101/ 511, 6404412, 1269564 (3,1 km)
2003-10-04 22:42:30  (3) 578806975: ns 3, rot 140, 65 kn,  200/ 363, 5415439, 3174149 (2142,9 km)
2003-10-04 22:42:30  (4) rpt 0, mmsi 2655150, 2003-10-04 20:42:31
2003-10-04 22:42:30  Acc 0, 6402747  1276635  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:42:31  (5) STENA DANICA (SKFH), T: 60, Dr: 0,0m, GOTEBORG FREDRIKSHAN
2003-10-04 22:42:36  (3) 219077000: ns 5, rot 0, 0 kn,  232/ 223, 6405391, 1270926 (2,8 km)
2003-10-04 22:42:45  (5) PR.CESS OF SCANDINA. (OWEN 2), T: 60, Dr: 6,0m, KRISTIANSAND
2003-10-04 22:43:00  (1) 265177000: ns 15, rot 0, 0 kn,  172/ 263, 6403941, 1269412 (3,1 km)
2003-10-04 22:43:00  (4) rpt 0, mmsi 2655150, 2003-10-04 20:43:01
2003-10-04 22:43:00  Acc 0, 6402749  1276636  ( 4,3 km)   57,69N    12,06E
2003-10-04 22:43:20  (1) 265177000: ns 15, rot 0, 0 kn,  255/ 263, 6403942, 1269412 (3,1 km)

The AIS decoding software is not available for purchase. Nor is it a giveaway, a freeware or a shareware. It was a pure recreational hobby project.