AIS Decoding with an RTL-SDR Blog v3 Dongle

Update July 2021: Run rtl-ais and kplex in a docker container.

At the conclusion of my last AIS blog post, I noted that the AIS receiving station I had set up was not sustainable for the long term. It was using a full hardware radio, and the software was running in a Windows 7 virtual machine on my personal laptop. Since AIS decoding is not super useful only when my laptop is powered on, a new station setup was needed.

One option would be buying a dedicated Raspberry Pi with a dAISy Hat receiver. It's a dual-channel receiver that spits out UART serial NMEA frames to the Raspberry Pi, and costs $70, plus a Pi for $35. But that's a lot of money for something that I don't really get any benefit from.

One Pandemic Positive is that I have a lot of free time on my hands, so I thought about receiving AIS signals using equipment I already own. I have an extra RTL-SDR Blog v3 receiver, and after searching the internets I found the rtl-ais project, which seemed easy enough to try. And I might be able to run it at the same time as my Fox satellite station.

RTL-SDR Blog v3 dongle

Installing and Running rtl-ais Software

Installing the rtl-ais software is easy. On my Ubuntu desktop just git clone the repository, build it, and run it. Since this was on a fresh Ubuntu 20.04 install, I also needed to apt install make, gcc, librtlsdr-dev and rtl-sdr packages. With a single RTL-SDR dongle connected to your computer, run ./rtl-sdr -n to get the NMEA sentences to print to the terminal. A few minutes after installation, I was decoding AIS frames. Super easy!

Screenshot of rtl-ais

As opposed to the earlier AIS decoding program I used, rtl-ais does not demodulate the RF to an intermediate audio stage, such as a physical audio interface or a virtual loopback cable. It goes straight from RF to bits out. No worrying about voltage dividing audio levels or ground loops.

Since this should be running all the time, I use the linux screen program so I wouldn't need to keep a terminal open all the time. The final command I used, which specified which RTL SDR dongle to use and only print statistics every 60 seconds is ./rtl_ais -d 00000003 -h 127.0.0.1 -P 10110 -S 60.

Installing kplex

Using OpenCPN to watch boats bob in the bay near my house is fun, but I really want to send this data to internet services that aggregate AIS data from around the world. My earlier setup sent data only to MarineTraffic.com, but there are several software programs that send each AIS packet to multiple internet companies. And since they are making money from my donated receiver, I didn't want to give one service a priority over another.

Screenshot of OpenCPN

In order to send the AIS reception data to more than one commercial company, I installed kplex, which is a software multiplexer for NMEA data. Given one input stream (from rtl-ais), it can send AIS data to many different providers.

For Ubuntu, installation is a .deb file. The configuration is very simple, and it can either be run from the terminal or as a systemd service. Here's the configuration file I have, located at /etc/kplex.conf for system-wide configuration. I scratched out the port numbers because this is how the different services differentiate the AIS data coming from different stations. The "name" is just something to keep track of which IP/port numbers are for which service.

kplex configuration file

rtl-ais outputs each AIS packet in a UDP packet on localhost port 10110 (which is interestingly an official IANA registered port). Kplex can have as many outputs/destinations as you want, just add another [tcp] or [udp] section in the config file. I also output the raw NMEA frames to a [file], so I can tail -f that file and make sure the packets are still flowing. This file has all the packets received, so it will grow over time.

All of the various ship plotting sites show how many ships your station is receiving, their locations, and various other station statistics. Here's what VesselFinder says about my station.

Screenshot of Vesselfinder

The daily fluctuations is interesting, increasing during business hours as ferries and other support ships travel around the bay. At this point in the pandemic, there are many huge container ships anchored in the bay. Each ship is loaded with (empty?) containers because of the drop off in shipping demand.

Receiving AIS and Satellites

Since the AIS frequencies (~160 MHz) are close to the 2m amateur satellite band (~145 MHz), I designed and built a 1/4 wave ground plane antenna to support both 145 MHz amateur satellites and 160 MHz AIS channels. This allows me to only use one antenna for both services.

Block diagram running two RTL SDRs

This block diagram shows my current station setup. I'm using a Minicircuits ZN2PD2-63-S+ for the RF splitter. While the frequency range of this splitter is specified as 350 MHz to 6 GHz, checking S21 on the network analyzer showed that it works well down around 150 MHz.

links