[00:02.550 --> 00:11.030] Hey everybody, Gary Kessler here, and welcome to my talk about putting an AIS receiver in Raspberry Pi. [00:11.050 --> 00:16.330] Hope everybody can hear me okay. Sort of strange giving a presentation to a bunch of people from [00:16.330 --> 00:24.330] an office, but off we go. Let me put on my screen here, hang on just a second, [00:33.460 --> 00:38.400] so right now you see me watching you watching me, so we're crossing the beam here. [00:40.820 --> 00:47.300] So let me get to the right page. That's not the right page. Let's go here. [00:48.500 --> 00:53.280] Now you all know that I watch Longmire. So I'm going to talk about setting up an AIS receiver [00:53.280 --> 01:00.080] on a Raspberry Pi, and I'm not going to assume that anybody has a lot of background in any of [01:00.080 --> 01:06.480] this, but obviously through comments and Q&As you'll tell me where I've gone too deep or not [01:06.480 --> 01:16.220] deep enough. But in any case, there are a lot of different ways to build a receiver in any number [01:16.220 --> 01:23.680] of formats. I like the Raspberry Pi because it provides a mechanism where I can take a cheap [01:23.680 --> 01:29.860] machine and have it dedicated to task. To give you an idea of that, just to tell you where it is [01:29.860 --> 01:36.020] we're going, I'm sitting here in my office right now, but over here, if I point this in the right [01:36.020 --> 01:44.640] direction, get rid of that, here's my TV screen showing my current AIS information I'm getting. [01:44.680 --> 01:52.500] Right there, I think if I'm pointing correctly and if I get this in focus, there's my Raspberry Pi. [01:53.220 --> 02:00.720] And now I'm about five miles from the water, so I'm not getting a lot of signal. But back up here [02:00.720 --> 02:07.460] over my shoulder, there's my antenna clipped to my bookcase. And again, connected to the Raspberry [02:07.460 --> 02:13.580] Pi, connected to my TV screen. Now in any case, what I'm going to do, I have a second Raspberry [02:13.580 --> 02:18.100] Pi here, so I'm going to sort of start from there and just give you a little bit of background. [02:18.560 --> 02:24.780] So first of all, I will say I've got a page on my website. If you go to GaryKessler.net, [02:24.780 --> 02:30.200] I egolessly named the domain after myself. If you go to GaryKessler.net, you can get [02:31.860 --> 02:39.480] this webpage. And if you want way more background on AIS, there's a couple of [02:39.480 --> 02:44.840] links that I give you up here. Actually, the Wikipedia page has a lot of good information, [02:44.840 --> 02:48.880] but of course you can go to the Coast Guard NAB Center and get their overview. [02:49.840 --> 02:53.680] International Association of Lighthouse Authorities has a really good overview as well. [02:53.680 --> 02:56.240] But in any case, sort of let me tell you where we're started here. [02:57.520 --> 03:02.940] Now, again, without making too many assumptions about what you all have played with or not played [03:02.940 --> 03:10.020] with, if you haven't seen before, this here's a Raspberry Pi. This one is a little bit old. [03:10.880 --> 03:19.760] This is, as you can see there, if I can focus this. Yeah, there we go. Okay, so this is the [03:19.760 --> 03:25.760] I think they're a couple beyond that now. But in any case, stock standard Raspberry Pi, [03:26.620 --> 03:35.540] a whole bunch of USB ports and Ethernet port as well. Here's where there's an HDMI connection [03:35.540 --> 03:41.960] as well as power. This is the general purpose IO bus back up in here. [03:43.280 --> 03:52.060] And let me go back to being live and personal. Anyway, so that's your stock standard Raspberry [03:52.060 --> 04:01.060] Pi. Now, there are also a number of ways where you can connect an AIS receiver. You can get some [04:01.060 --> 04:09.920] little plug right into the USB port. What I got was this device from Wegman, the Daisy AIS receiver. [04:10.620 --> 04:17.300] If you get a receiver, it is my recommendation, get a two channel receiver. So AIS broadcasts [04:17.300 --> 04:23.820] on two channels, what they call channel A and channel B. I don't see much use if you're going [04:23.820 --> 04:28.360] to be doing research and you're trying to gather data. I don't see much purpose in getting a single [04:28.360 --> 04:38.540] channel AIS receiver. It is true in my experience, most of what I've seen, chips that are broadcasting [04:38.540 --> 04:44.880] on channel B are also broadcasting on channel A. But again, there's probably no really good reason [04:44.880 --> 04:52.060] not to get both channels. In any case, this is, you know, like I said, this is the Daisy hat. [04:52.660 --> 04:57.380] And for those of you who like to look at SuperTree, that's the back part. [04:59.830 --> 05:10.030] So let me go back around here. In any case, so the first part in getting this [05:10.030 --> 05:13.930] together also, when you buy the piece parts, is you're going to have to buy an antenna. You're [05:13.930 --> 05:17.810] probably going to want to buy an antenna. You'll need a marine antenna because that will pick up [05:17.810 --> 05:24.930] the appropriate VHF channels. Read carefully on the antenna connector. I found that they use [05:26.030 --> 05:30.350] a whole different nomenclature. You know, every industry has its own vernacular. [05:30.350 --> 05:36.890] Antenna people have theirs as well. You probably want to get what's shown here [05:36.890 --> 05:44.390] is the stock standard marine antenna connectors. And you're going to need an adapter to go onto the [05:46.310 --> 05:53.570] Daisy hat, which again is what I used. So there's the antenna connector on the Daisy hat. [05:53.570 --> 06:01.950] So what I have here is an adapter. This goes onto the Daisy hat side. This is a stock standard [06:01.950 --> 06:08.550] bayonet connector for here. Here is the antenna connector. This is the part that goes to the [06:08.550 --> 06:19.030] marine antenna. And then here is the bayonet, the female connector. Anyway, so eventually this piece [06:19.030 --> 06:25.150] is going to go onto the Daisy hat. This piece is going to go on to that connector. And this [06:25.150 --> 06:38.700] is going to actually connect to the antenna itself. Oops. Just learning how to use a computer. [06:38.820 --> 06:46.360] Anyway, the operating system for the Daisy hat is going to fit onto a micro SD card. [06:47.820 --> 06:54.800] And, you know, you've all seen micro SD cards. I would get the biggest one that you can, [06:54.800 --> 06:58.280] just because it provides you more of an opportunity if you need to store a whole [06:58.280 --> 07:03.960] bunch of data. Micro SD card probably won't fit in your computer. Luckily, most micro SD [07:03.960 --> 07:10.940] cards these days come with an adapter so that they can plug into stuff. But, you know, basically, [07:11.760 --> 07:17.220] this is like most of my piece parts. I'll put that there so it'll be in the camera range. [07:20.000 --> 07:23.720] So installing Raspbian is something that I'm not going to... [07:25.680 --> 07:30.980] Hang on just a second. I'm getting a message here that I think I need to take a look at. [07:36.750 --> 07:43.510] They're not... you're not seeing the Raspberry Pi. So, do I understand? You're not seeing my camera? [07:43.590 --> 07:54.600] Okay, now, okay, now they are. All right. Anyway, on the Raspberry Pi, I chose to install Raspbian [07:55.120 --> 08:02.240] and then put OpenCPN. And so the rest of what I'm going to talk about is basically about that. [08:02.440 --> 08:08.400] On my page, I mentioned that there is a whole different direction you can go in if you want. [08:08.400 --> 08:15.320] If you go to the website AIS Hub, I've got a link for their RPi AIS, which is AIS Dispatcher [08:15.880 --> 08:21.780] for Raspberry Pi. And what Dispatcher will do, it basically acts as an intermediary [08:21.780 --> 08:26.140] to accept AIS feeds and then pop them out where you want them to go. [08:26.720 --> 08:31.340] That site is a really excellent site and has a lot of really good information as well. [08:31.880 --> 08:37.740] But that's not the direction I'm going to go in right now. What I'm going to talk about is [08:38.500 --> 08:45.500] just, again, stock standard, pretty much vanilla with my Raspberry Pi using the NOOBS operating [08:45.500 --> 08:52.120] system. And again, the operating system is going to go on the microSD card. There are a lot of [08:52.120 --> 08:59.600] places out there that give instructions for how to do this. And the reason I put this page together, [08:59.600 --> 09:05.200] actually, is I don't really have a lot of information here that's really unique to [09:05.200 --> 09:12.620] anything that I made up. But I found I had to go to about a dozen sites to get all the [09:12.620 --> 09:17.680] information together so that I could actually figure out how to do this. So I decided to build [09:17.680 --> 09:22.440] this page because, for me, it provided a roadmap that if I need to do it again in six months, [09:22.440 --> 09:29.640] I've got a place to go. In any case, relatively easy to get NOOBS onto the microSD card. [09:30.460 --> 09:39.400] And then, basically, after you have put the operating system... I'm going to get this off [09:39.400 --> 09:48.380] my card here. So I've got the operating system on my microSD card. And it just goes [09:50.480 --> 09:58.840] into the... oh, there it is. It just goes into the Raspberry Pi. And that is all of your local [09:58.840 --> 10:04.440] storage. That is your disk drive. That's your operating system and your bootable device. [10:04.440 --> 10:09.820] Of course, the joy with the Raspberry Pi is you can have a whole slew of different operating [10:09.820 --> 10:14.880] systems and you change the personality of the Raspberry Pi by what SD card you put in. [10:14.940 --> 10:19.840] One of the reasons I like having a big SD card, like I said, is if I'm doing local storage of [10:19.840 --> 10:29.800] stuff, I can keep it all on the SD card. Clearly, with four USB ports, I could also plug in all the [10:29.800 --> 10:43.120] external storage I want. So once you have gotten the software installed, you're going to plug the [10:43.120 --> 10:49.140] thing in. At this point, you need to have some I-O devices. So you do need to have a keyboard [10:49.140 --> 10:59.500] and a mouse and a monitor of some sort, at least for the initial phases. And so when you start the [10:59.500 --> 11:04.580] system up, you'll get some sort of boot screen and you'll tell it, you know, you want to install [11:04.580 --> 11:12.360] full Raspbian and just let that go. Now, at this point, you have an operating system. You now need [11:12.360 --> 11:18.940] to configure the Raspberry Pi. So I give you a little bit of instruction how to do that. But [11:18.940 --> 11:25.820] what I'm going to do is try to show you a little bit more dynamically and live. So the application [11:25.820 --> 11:32.620] menu is usually up in the upper left. It's the Raspberry Pi icon. And if you go down to [11:32.620 --> 11:38.100] preferences and then Raspberry Pi configuration, here's where you get to configure the things about [11:38.100 --> 11:44.120] your system. So here's where you can put in your password, the name of the computer, and all this [11:44.120 --> 11:49.320] kind of little stuff. One of the most important parts is going to be on the interfaces. If you [11:49.320 --> 11:57.080] want remote access to the Raspberry Pi, and I recommend that you do, be sure to enable SSH and [11:57.080 --> 12:06.880] VNC. SSH is going to use TCP port 22. VNC, I think, uses port 5900. You probably want to have the [12:06.880 --> 12:12.800] serial port enabled either, since you're going to put something onto that serial port. And then [12:12.800 --> 12:18.520] there's some other things you can configure here. One that I do recommend is to set your locale. [12:18.520 --> 12:24.380] If nothing else, be sure you're in the right time zone. And then you might want to do some other [12:24.380 --> 12:28.060] things about, you know, what country you're in, what language, and all those kind of things. [12:28.560 --> 12:37.440] But those are the two biggies. You do need to set the Wi-Fi country. And I must admit, I know you [12:37.440 --> 12:42.800] need to do it, and I haven't explored deeply as to what happens if you configure a different country. [12:43.380 --> 12:46.940] But, well, anyway, I'm going to cancel this, because I didn't really want to accidentally [12:46.940 --> 12:53.780] change anything. So, anyway, so this is all the stuff, like I said, you know, [12:53.780 --> 13:02.720] you can configure on the Raspberry Pi. Now, it turns out, of course, you can use the GUI, [13:02.720 --> 13:07.660] or you can use a command line. And here's some instructions on using the command line. I just do [13:08.880 --> 13:13.860] a sudo, you know, raspi-config, and it'll pop up actually the same screen. [13:14.800 --> 13:22.600] Now, you might want to put your Raspberry Pi onto a Wi-Fi network. And if you have [13:23.960 --> 13:32.460] a Wi-Fi network that it's broadcasting as SSID and doesn't have a password, [13:32.460 --> 13:37.600] and you're not physically connected on the Ethernet port, the Raspberry Pi should pick up [13:37.600 --> 13:43.040] that Wi-Fi network. However, if you want to connect anything else, like a Wi-Fi network [13:43.040 --> 13:52.360] that doesn't broadcast SSID and or requires a password, then there's a file that you need to [13:52.360 --> 14:00.320] edit and put the information in about that, about that network. This is one of the reasons I'm not [14:00.320 --> 14:05.860] going to show you the file that's sitting on my Raspberry Pi, because everything is in plain text, [14:05.860 --> 14:09.100] and I'm not, you know, don't know that I want to show everybody my password right now. [14:09.100 --> 14:16.340] Anyway, so what you need to do is go to this file, the sd underscore supplicant dot com file. [14:16.900 --> 14:24.620] Nano is a nice little GUI editor that comes on the Raspberry Pi. In any case, so what I've done [14:24.620 --> 14:31.700] here is I'm showing you how you could configure two different wireless networks. So, in the first [14:31.700 --> 14:38.300] case, I've got a guest network. There's no password, but in this case, the SSID [14:41.460 --> 14:47.220] is not being broadcast. So, the SSID for the guest network is guest. Anyway, so that's what [14:47.220 --> 14:51.480] that would look like. Then I've got another network called owner. And owner, in this case, [14:51.480 --> 14:58.200] does have a password. The password is secret. And it uses WPA. So, this is what those kind [14:58.200 --> 15:05.380] of commands would look like to, you know, indicate that network. So, let me just go [15:05.380 --> 15:14.420] back here for a second. And I want to get back to my video, actually. Here, let me just click the [15:14.420 --> 15:26.320] video. Oh, just click the video off. Sorry about that. All right. Sorry, we're all still learning [15:26.320 --> 15:39.040] the tools, particularly me. All right. So, I'm going to go back to Firefox here. So, basically, [15:39.040 --> 15:47.740] at this point, you've got your Raspberry Pi now can listen on SSH or VNC. You've got it connected [15:47.740 --> 15:53.540] to the wireless. So, at this point, you can take out your, you know, well, you can keep plugging [15:53.540 --> 15:56.580] into your monitor if you want, but you don't need your keyboard anymore and you don't need your [15:56.580 --> 16:00.840] mouse, because you can now do that remotely if you want. I do have a couple notes about the [16:00.840 --> 16:09.500] screen resolution, because I found that I had to play around a little bit with that. And you can [16:09.500 --> 16:17.140] go into the config.txt file, which is in the boot directory, and there are a number of different [16:17.140 --> 16:24.500] screen sizes you can try. What I found on this was I had to play around a little bit and experiment, [16:24.500 --> 16:32.540] and eventually, I found something that worked. So, now that I got the Raspberry Pi going, [16:32.540 --> 16:40.420] the next thing is installing the daisy hat. Now, again, I'm going to assume that many of you have [16:40.420 --> 16:46.620] played with this kind of stuff before, but there's probably some of you who haven't. So, [16:47.300 --> 16:56.540] on the Raspberry Pi, I've got these two rows of pins back in here, and on the daisy hat, [16:56.540 --> 17:01.220] I've got a socket that goes into it. Let me get that a little bit further down. [17:01.400 --> 17:08.100] And all I can say is, if you've never played around with, you know, putting sockets onto pins, [17:08.100 --> 17:12.820] just do it slowly, carefully, and make sure everything's lined up the first time. [17:12.820 --> 17:18.820] The other thing is, you'll notice, I actually have this in a case. You don't actually need [17:18.820 --> 17:23.740] to have it in a case, but I thought it was better, more better protected that way. [17:24.080 --> 17:31.040] So, I mounted the Raspberry Pi onto the case. You see the standoffs. If you're going to do this, [17:31.040 --> 17:37.800] there's some standoffs for the daisy hat as well. You know, this is the time to put those in. [17:37.800 --> 17:43.240] And then, like I said, it's a matter of, you know, be sure that you've lined up the socket [17:44.060 --> 17:51.900] correctly this way. And actually, it's not, but I can't see it as well as the camera can. [17:51.900 --> 17:57.160] And be sure that you've lined it up correctly, you know, here as well. And once you have everything [17:57.160 --> 18:05.000] lined up, let me try to get this in here. This is the problem with doing anything live, isn't it? [18:05.000 --> 18:13.360] Just be sure that you squeeze evenly on both sides and slowly. And there you go. I mean, [18:13.360 --> 18:19.240] it's like that. And then, of course, you screw it to the standoffs. And then you build the rest [18:19.240 --> 18:28.100] of the case. You can probably guess this is why I took apart one to put back together, [18:28.100 --> 18:31.480] but I'm not using that live because I'm not going to square everything back in together. [18:34.150 --> 18:40.610] Anyway, once you get the Dizzy Hat installed, that's really all you need to do. I gave some [18:40.610 --> 18:47.170] instructions on how to load a program called GPIO that allows you to look at your GPIO pins. [18:47.230 --> 18:53.610] You can do that or not do that, depending upon if you want to track all those things. [18:54.110 --> 18:58.950] I put in the software, but it's absolutely not necessary to do. There's also a program [18:58.950 --> 19:06.010] called Screen, which, again, provides you some useful information about anything on your serial [19:06.010 --> 19:14.010] board on the Raspberry Pi, but it's not essential to the operation of anything related to AIS. [19:14.010 --> 19:20.690] So I'm going to sort of skip over that. And what I want to do is I want to bring you to OpenCPN. [19:20.850 --> 19:27.310] So I'm running OpenCPN on the Raspberry Pi. I'm also running it on my [19:29.090 --> 19:38.730] Mac. And so there's slightly different views here from what I'll show you on the Raspberry Pi. [19:38.730 --> 19:48.910] But the OpenCPN is OpenChart Plotter. OpenCPN runs on just about all software platforms except iOS. [19:50.450 --> 19:56.890] And basically, like with any electronic chart display, you see all the targets out here. [19:56.890 --> 20:02.230] The targets are color-coded, actually, by type of vessel. And with AIS, they're identifying [20:02.230 --> 20:07.410] their type of vessel. Right here, I've got one. I don't really know much about it, [20:07.410 --> 20:14.830] but it apparently is a ship from Norway. It's a Class A vessel, which means we're going to [20:14.830 --> 20:19.430] be getting more information on its position reports. But you'll see here, you know, [20:19.430 --> 20:26.310] you've got its speed, its course, heading, rate of turn. A vessel like this, at this speed, [20:26.310 --> 20:30.990] ought to be broadcasting, well, certainly no more than about 10 seconds before their [20:30.990 --> 20:34.550] transmission. I'm a little bit surprised. They're up to four minutes now. Possibly, [20:34.550 --> 20:41.010] that's due to range. But in any case, I can look at any one of these other vessels. [20:41.230 --> 20:45.950] Baby Cakes, I can know that boat, just because I see it in the harbor all the time. [20:46.230 --> 20:52.290] Right now, it's probably parked. It's a smaller vessel. It's a smaller vessel, by which I mean [20:52.290 --> 21:01.370] it's a yacht. It's a Class B vessel, so it's not required to transmit AIS messages. But in any case, [21:01.370 --> 21:08.070] so OpenCPN, again, being open source and has a nice version for the Raspberry Pi, [21:09.010 --> 21:17.910] you can, you know, download the software at the OpenCPN.org site. They have more documentation [21:17.910 --> 21:26.150] than you can shake a stick at. But again, there's all sorts of information there about [21:26.150 --> 21:32.090] how to install OpenCPN. And again, I tried to put everything sort of in one place that, [21:32.090 --> 21:38.030] you know, steps you through. Most importantly is building yourself a PGP key file on the Raspberry [21:38.030 --> 21:49.290] Pi and how to be sure that you get the key so that you can actually install OpenCPN when you [21:49.290 --> 21:54.910] have, you know, gone through the first process here. So once you've got the key, you know, [21:54.910 --> 22:01.790] here are the steps right here to install OpenCPN. And like most things, you're waiting for a lot [22:01.790 --> 22:08.510] longer than you're actually typing in instructions. But once you get OpenCPN on your computer, [22:09.050 --> 22:15.570] you now have other things you need to play with. So, I'm going to go back to OpenCPN here, [22:15.570 --> 22:23.010] and you're now going to need to configure OpenCPN. Now, one of the things I want to show you, [22:23.010 --> 22:29.250] because I found this to be, and continue to find it to be, one of the, [22:29.250 --> 22:36.850] if anything in OpenCPN is difficult, this is the most difficult step, and that is getting charts. [22:36.990 --> 22:48.190] So, you have to be familiar with charts and how they're organized, at least in the United States. [22:48.190 --> 22:55.090] So, when you want to add a new chart, and you can get charts, as you may know, from the National [22:55.090 --> 23:00.010] Oceanographic and Atmospheric Administration, from NOAA, you can download every chart in the [23:00.010 --> 23:06.110] United States, in a variety of formats. You can download them as a PDF, so that as a person you [23:06.110 --> 23:14.150] can read them, or you can download them in a number of electronic formats, ENC being the most common. [23:15.570 --> 23:22.910] And so, basically what you need to do, if you want to add a chart, is, well, you can go to [23:22.910 --> 23:30.370] Chart Group here, if you want. You can add new groups of charts. The easiest way is to go to [23:30.370 --> 23:37.150] Chart Downloader, and, in this case, you can see that I have four catalogs on my computer right now. [23:37.150 --> 23:43.610] I've got the catalog for California, Florida, Connecticut, and, although it's not all shown here, [23:43.610 --> 23:51.210] for Coast Guard District 1. The reason I downloaded all of District 1's catalog was because I wanted [23:52.210 --> 23:57.190] charts from Vermont, but they don't actually have charts for Vermont. The Vermont charts [23:57.190 --> 24:02.190] are in the District 1 catalog, so that's one of the other things you sort of sometimes need to [24:02.190 --> 24:12.690] fight through. But, so, if you want to add a chart, you just go to Add, and then you get to choose [24:12.690 --> 24:19.270] where do I, from where do I want my charts? I usually want USA and NOAA charts, so I open up that, [24:19.270 --> 24:26.350] and then I can decide, okay, do I want the RNC or the ENC charts? The RNC or the rastrographic, [24:26.350 --> 24:34.510] they're not used very much anymore, or I can get ENC charts. And, now, I can download all the ENCs. [24:34.550 --> 24:40.390] I can look them up by district. I can look them up by state, look it up by region, what have you. [24:40.950 --> 24:45.870] So, if I wanted to look it up by state, for example, well, obviously, here's my states. [24:45.870 --> 24:53.870] So, let's say I wanted to get charts from Illinois. I could go to Illinois, click OK, [24:53.870 --> 25:02.850] and it now has just added the chart, but what it wants me to do is now update. So, the next thing I [25:02.850 --> 25:10.910] need to do is update. So, it gets all of those, and now you'll notice down here it has a list. [25:11.470 --> 25:15.910] Now, those of you that are familiar with charts know that the charts are numbered. [25:16.630 --> 25:23.850] The numbers are only good in OpenCPN as a mechanism to help you find the name of the [25:23.850 --> 25:32.970] chart because you'll notice in the catalog down here everything's by name. So, like I said, [25:32.970 --> 25:37.190] you just need to know the name of the chart. If I wanted to download, let's say, the Chicago [25:37.190 --> 25:43.730] Lakefront chart, I merely click on it, I download selected charts, and now those charts are [25:43.730 --> 25:51.150] available to me in OpenCPN. So, I'm going to say OK, so it's all here, and there's actually, [25:51.150 --> 26:00.640] there really is a reason I'm showing you this. All right, so, if I back out of here [26:01.800 --> 26:05.580] all the way, I'm going to take a look at the United States, [26:06.140 --> 26:10.400] and what you're going to see, well, maybe I'll go in a little closer, what you're going to see here [26:10.980 --> 26:17.500] is a bunch of green boxes. These are all of the places where I have downloaded charts. So, [26:17.500 --> 26:21.940] remember I have the California catalog? Well, all I have from California is some charts up in the [26:21.940 --> 26:27.640] San Francisco Bay Area. Here's Lake Cheyenne Plain, my Vermont charts. I have some charts [26:27.640 --> 26:32.860] from the New London area in Connecticut. The chart we just downloaded in Illinois, [26:33.800 --> 26:37.920] here are some of the Florida charts that I have. This is mostly the Pensacola area, [26:37.920 --> 26:44.620] and the rest of what I have is here where I am in Daytona. So, I have access to every chart [26:44.620 --> 26:49.940] in North America, but of course I haven't downloaded all of them because, you know, [26:49.940 --> 26:55.700] I'm not looking at all of them. And right now, for the feed that I have, I really only care [26:55.700 --> 27:02.260] about this area here, because for me, again in Daytona, this is the Intracoastal Waterway [27:03.720 --> 27:08.500] in my neck of the woods. So, it's going to take a couple seconds while all of this reloads, but [27:09.260 --> 27:12.160] anyway, so hopefully you sort of get the idea here. [27:15.450 --> 27:22.030] Anyway, that is the process that I describe here about downloading charts. [27:24.230 --> 27:30.390] Now, the next thing you need to do is figure out, okay, I'm going to display AIS data. [27:30.390 --> 27:34.170] Where am I getting it from? So, once again, I'm going to go back to here, [27:34.390 --> 27:45.540] and I'm going to go to the connections. And so, there's a variety of ways in which I can get data. [27:46.280 --> 27:54.520] I have myself set up three connections. One of them is that I get data from an antenna that I [27:54.520 --> 27:59.760] have at the university where I teach at Embry-Riddle Aeronautical University. So, I've got [28:01.000 --> 28:09.060] a device there called ssia-ais.eru.edu, and if I connect to that device over the internet on [28:09.060 --> 28:16.040] port 4000, that's where I get a feed. It's, at this point, public. I mean, any of you could point [28:16.040 --> 28:22.660] there as well, if you're interested in what's going on in Daytona. I'm going to move this out [28:22.660 --> 28:29.400] of the way here a little bit. All of these boats that I'm seeing here that's coming from that feed [28:29.400 --> 28:37.260] from Riddle. Now, on this particular computer, I'm not set up on the serial interface because I [28:37.260 --> 28:45.480] don't have an antenna on this computer, but if I switch back over to my... I'll go back to my [28:45.480 --> 28:50.760] Raspberry Pi, you'll notice the interface is slightly different. If I go here and I look at [28:50.760 --> 28:58.840] connections, you can see that I have... I've got a bunch of connections, but the two that are active, [28:58.840 --> 29:04.400] one is coming in, again, from ssia-ais.erau.edu, [29:08.060 --> 29:17.000] and the other, I'm set to the serial port. So, my Raspberry Pi can also be pulling in stuff from [29:17.000 --> 29:26.540] the antenna. So, my office is about, oh, I would say five or six miles from the river and from the [29:26.540 --> 29:32.740] ocean, and since you saw my antenna, it's only about seven feet high, I'm not picking up a lot [29:32.740 --> 29:37.960] of feeds. So, most of it's coming in from the antenna at the university, which is, like I said, [29:37.960 --> 29:46.360] up about 75 feet up. I will tell you one funny story, because when I was first experimenting [29:46.360 --> 29:52.040] with this, I had all this stuff at home, and home is 10 miles from the ocean. So, I'm fooling [29:52.040 --> 29:58.880] around with it one day, and right here, this window here is the NMEA debug window, because I [29:58.880 --> 30:03.340] checked the box. So, you see I'm getting traffic, and you can see where it's all coming from. [30:03.420 --> 30:08.280] So, I'm sitting at home, and I'm not getting any data, but I'm not expecting to, and all of a sudden, [30:08.280 --> 30:15.840] I get a hit. I have an AIS message come in on my serial port, and I go crazy, because I'm very [30:15.840 --> 30:22.380] excited. So, I take the message, and I parse it, and I look at the latitude and longitude, and I [30:23.760 --> 30:31.840] position exactly where the thing is, and it turns out I live about one mile east of I-95, [30:31.840 --> 30:39.480] and the latitude and longitude showed a boat going at approximately, you know, on a heading [30:39.480 --> 30:47.720] of approximately 210 degrees at 65 knots. And I said, there ain't a boat anywhere doing 65 knots [30:47.720 --> 30:54.160] around here. Well, the latitude and longitude put this boat in the southbound lane of I-95. [30:54.420 --> 30:58.960] So, clearly, this boat's sitting on somebody's trailer. They didn't turn off their AIS, [30:58.960 --> 31:04.740] and this guy's zooming down the road, and I got one of its transmissions. I was very excited. [31:05.780 --> 31:12.040] Anyway, I'm going to go back here. So, this is how you set up your connections. [31:12.080 --> 31:18.460] So, you can set up a serial connection, as I show here. If you set up a serial connection, [31:18.460 --> 31:23.980] it's going to automatically be an NEA 0183 protocol. You're going to want to set the [31:23.980 --> 31:29.720] data rate to be 38400, because that's probably what the data rate's going to be over the air. [31:30.540 --> 31:36.160] Or you can set up network connections. And for the network connections, it's going to need an IP [31:36.160 --> 31:42.580] address or a hostname, and it'll need the port on which to read. So, it's getting all of this, [31:42.580 --> 31:48.580] obviously, over the network. And again, you've just seen already, but this is what the debug [31:48.580 --> 31:55.420] window looks like. And let's see. So, this was stuff coming in on a serial port. [31:56.240 --> 32:02.620] This was stuff coming in on a network port. I'm not 100% sure why I decided to hide that IP [32:02.620 --> 32:12.500] address, but I did. Now, it also turns out that if you want to get one of these feeds live, [32:12.500 --> 32:17.540] if you go through OpenCPN, one of your problems is there's no way to take [32:18.380 --> 32:25.260] the information from the debug window and get it in any usable form. One thing you can do [32:25.420 --> 32:32.220] though is go around to a terminal window. I'm going to go around to a terminal window here. [32:32.220 --> 32:44.600] I'll make a new one. And I just do, you know, an NC to ssia-ais.erau.edu, port 4000. [32:47.080 --> 32:52.300] Hopefully, I'll start getting some data. There we go. So, I can get the feed this way. [32:54.200 --> 33:02.460] And this is something I'm actually going to talk about in a later talk when I talk about AIS and [33:02.460 --> 33:11.960] GPS spoofing. But one form of spoofing is a replay attack. So, a replay attack, well, just like the [33:11.960 --> 33:17.100] name sounds. I mean, you replay old data. This is a way of collecting data. So, I've actually [33:17.100 --> 33:23.220] written a program that will do this for you. But you can also do it for yourself. There's a reason [33:23.220 --> 33:28.580] you don't want to collect data in this format and then replay it. And the reason is you don't have [33:28.680 --> 33:36.140] a timestamp. You don't have relative timing. But more on that later. In any case, let me go back [33:36.140 --> 33:40.660] to this. So, like I said, there are a variety of ways where you can get the raw feed if you just [33:40.660 --> 33:48.720] want to see a raw feed. And one of the other things you can do, of course, is you can set up [33:48.720 --> 33:57.760] OpenCPN to display stuff that you are sending it from your computer. So, you can either set up [33:57.760 --> 34:10.640] OpenCPN to read from somebody else's TCP socket, or you can set up OpenCPN and write to OpenCPN. [34:10.660 --> 34:18.000] So, in this case, let's see. When I set up my network connection up here, [34:19.080 --> 34:26.300] you'll notice I was receiving input on this port. I can set up another port that I can then [34:26.300 --> 34:35.020] output on this port. So, what I now need is, if I have a program that will write to port 7777 [34:35.020 --> 34:41.140] on this computer, as I've configured it here, this provides another mechanism where I can show stuff. [34:41.140 --> 34:48.300] So, again, I'll be talking about that later on as well. So, in this case, what I did was I set [34:48.300 --> 34:55.420] something up where my serial port is an input port, network port, port 7777 is an output port, [34:55.420 --> 35:00.320] and this is what the debug window looks like, because it shows that I'm reading on the serial [35:00.320 --> 35:07.480] port and writing to port 7777. Again, there's a variety of ways of, you know, using OpenCPN [35:07.480 --> 35:16.920] for some really, really, you know, clever stuff. Anyway, so I mentioned this program that'll [35:16.920 --> 35:24.160] read for you. So, I have a program called Timestamp Data. It's on my website. It's software that's [35:24.160 --> 35:29.880] available, and we'll be making that available here. But if you run Timestamp Data, here's the [35:29.880 --> 35:40.860] help file. Excuse me. Again, you know, if you specify an IP address and a port number and whether [35:40.860 --> 35:48.820] you want to use TCP or UDP, defaults to TCP, you can now download data for, you know, some period [35:48.820 --> 35:53.560] of time. The program defaults to five minutes, but you could set it, you know, as far up to a week [35:53.560 --> 36:01.920] if you want. And what this will do is this will download the data and it will include a timestamp. [36:01.920 --> 36:08.940] So, what it does is, as it shows here, it creates a program or it creates an output file that looks [36:08.940 --> 36:17.960] like this. It's basically a pipe symbol delimited file. So, here you can see I've got, you know, [36:18.610 --> 36:25.140] the year, day, date, hour, minute, second, and then the Unix Epoch Time format of that. [36:25.520 --> 36:34.060] Now, the reason I'm using the pipe symbol is because if I let people choose their own delimiter, [36:34.060 --> 36:41.040] somebody will end up choosing a delimiter like a comma. Comma is not a unique character in an [36:41.040 --> 36:46.140] AIS message. There are a lot of symbols that you might see, so pipe, I knew, would be at least [36:46.140 --> 36:51.280] unique. If you don't like pipe, you can go into your text file and do a global search in place [36:51.280 --> 36:55.860] for a different delimiter. But just be careful that you don't duplicate something. The other [36:55.860 --> 37:04.080] thing is, by having here the relative timestamp, the message I just brought in, if I turn around [37:04.080 --> 37:11.320] and replay this, I can replay it and I get the same relative timing. So, you know, this really [37:11.320 --> 37:16.920] was not designed for a replay attack. It was designed so that I could gather data and then [37:16.920 --> 37:23.860] replay it in real time and, you know, actually see what was happening. Because I have another program [37:23.860 --> 37:30.580] called Play AIS, where I can replay this file. I can actually speed it up and slow it down, as well. [37:32.780 --> 37:38.420] Anyway, so I've already talked a little bit about sending data to OpenCPN. If you don't [37:38.420 --> 37:45.040] have a timestamp, everything just overwrites itself. And so, if you've got, like, 10 AIS [37:45.040 --> 37:50.840] messages from the same vessel and you replay the file, what you'll see is the last message, [37:50.840 --> 37:57.380] because the first nine got overwritten by all the following ones. Another tool you should know about [37:57.980 --> 38:05.980] for this is, there's a really, really cool NMEA simulator. And it generates NMEA sentences [38:05.980 --> 38:13.400] and, or AIS sentences, and it is really, really a cool program. For good or for bad, [38:13.400 --> 38:21.720] it only runs on Chrome. Can't explain that. This is the only application I actually run Chrome on. [38:22.380 --> 38:29.220] But, as you can see here from the dashboard and the other ways in which you can set this up, [38:29.860 --> 38:35.320] you can pretty much simulate whatever you'd like. You can put yourself in a particular position. [38:35.320 --> 38:39.740] You can get your vessel headed in a certain direction. You can give yourself a rate of [38:39.740 --> 38:44.920] turn. You can do all sorts of cool things. And then what you can do is, you can hook yourself [38:44.920 --> 38:50.580] up to a server and you can actually output the information that the simulator is creating. [38:50.580 --> 39:00.040] So, you could create information such as this. I can set up my simulator. I have it right to [39:00.040 --> 39:07.340] OpenCPN and then I can have it, you know, play on OpenCPN. It's really, really a cool tool. [39:09.560 --> 39:19.220] So, last but not least, how do you interpret this data? For those of you who like to get into code, [39:19.220 --> 39:27.160] Eric Raymond has a AIS protocol decoding page. You can see it's purple. I go there a lot. [39:28.040 --> 39:36.820] And, well, I mean, I may as well go there. He has here, like I said, a lot of information [39:37.600 --> 39:45.380] about the NMEA 0183 format. Not only the format, but what all the messages are, what the contents [39:45.380 --> 39:53.620] are, to a certain degree, how to encode the contents. AIS does not show information in any [39:53.620 --> 40:00.100] clear way that a human can understand. So, for example, you know, we've already seen a couple of [40:00.100 --> 40:06.700] these. This message right here, where I'm sort of moving my mouse, the AIVDM, comma, one, comma, one, [40:06.700 --> 40:12.520] comma, comma, A, comma, you know, all that jazz. There's a special encapsulation method that AIS [40:12.520 --> 40:18.800] messages use. Eric's page talks a little bit about that, how you can get everything into a 6-bit [40:18.800 --> 40:25.340] and armored ASCII and all that kind of stuff. But what you can do is you can take these AIS [40:25.340 --> 40:30.180] messages that you get, and you can go to a place such as the site I've gone to here, [40:30.180 --> 40:35.360] is Meritech Solutions, plop in the AIS message, and it will interpret it for you. [40:36.500 --> 40:41.760] There are a whole bunch of other AIS parsers online, and I've given you some links on my page [40:41.760 --> 40:48.500] here. And I've written a bunch of tools for this, because for some of the research that I wanted to [40:48.500 --> 40:54.960] do, I was trying to create some unique AIS messages. And so, I had to create a parser. [40:54.960 --> 41:03.740] So, I actually have an entire suite of tools, and we'll talk a little bit more with the AIS [41:03.740 --> 41:10.600] spoofing stuff. But if you go to my software page, you can download all of these. But if I take that [41:10.600 --> 41:17.320] same message, or I guess it's not the same message as was above, but some AIS message, [41:17.320 --> 41:24.000] and if all of my stuff is command line, and it's all written in Perl, don't get me started on why. [41:24.880 --> 41:30.920] And, in any case, it'll interpret, you know, the sentence for you. This is, in fact, an AIS [41:32.080 --> 41:39.220] mobile device. It's a VDM, meaning it's a VHF data link message, which is a nice way of saying, [41:39.220 --> 41:44.260] this is a message coming from another boat, as opposed to my message going out. [41:45.060 --> 41:52.320] Here's all the contents of a type one message, which this is. It's a class A big boat position [41:52.320 --> 41:59.720] report. Here's the device identifier. Every device has a unique nine digit identifier. [42:00.220 --> 42:05.900] This gives you all the other information, including longitude and a URL, so that you can [42:05.900 --> 42:15.180] click if you want. And there are a number of places where you can get data. I've already [42:15.180 --> 42:23.520] mentioned the site that is at my university. You can also go to places like AIS hub, and [42:24.600 --> 42:31.860] they also have a whole bunch of information. There are some other places online, if you can [42:31.860 --> 42:37.300] find them, that give you some more localized information. If you find more places you'd [42:37.300 --> 42:43.720] like to share with me, I would be delighted to have you there with me. And the format that we [42:43.720 --> 42:49.720] most commonly see over the air, like I keep saying, NMEA is the National Maritime Electronics [42:49.720 --> 42:59.820] Association, and the 0183 standard, which is about circa 1986, that's still the most commonly [42:59.820 --> 43:08.800] used standard that we see. In about 1999, they came out with NMEA 2000. As we speak, [43:08.800 --> 43:14.720] we're getting prepared to release the OneNet standard. It is very, very difficult to find out [43:14.720 --> 43:20.600] how to do any of the coding on 2000 or OneNet, because it's all highly proprietary. [43:21.820 --> 43:26.860] And everybody who has a copy signs a non-disclosure agreement. But there is a project [43:26.860 --> 43:37.740] called the CanBoat project. The CanBus is used with NMEA 2000. IP version 6 is used as the [43:37.740 --> 43:47.320] transmission for OneNet. NMEA 0183, basically everything runs over a serial bus. So a lot of [43:47.320 --> 43:53.540] the stuff that I'm showing you here with OpenCPN, we're pulling in from over the air. It turns out, [43:53.540 --> 44:01.240] if you can get onto the serial bus, you can get information right off the boat. And there are a [44:01.240 --> 44:06.640] variety of ways... I'm not going to get into that here, but there's a variety of ways of [44:06.640 --> 44:13.680] injecting messages directly on the boat, either through the CanBus, if you're NMEA 2000, [44:13.680 --> 44:22.860] and or through the serial on NMEA 0183. So I'm going to go back here for just [44:23.140 --> 44:32.220] a second. Everybody can see now. I mean, this is basically what I have on the device. [44:33.640 --> 44:39.180] And so, I certainly would like to leave this open to questions, if I have said anything, [44:39.180 --> 44:49.860] for which you have questions. Scrolling back up here to see if I can find the... [44:52.780 --> 44:59.260] AIS text appears closed. So, anyway, does anybody have questions that you want to ask, or [45:00.320 --> 45:24.400] anything like that? I'm detecting silence. Well, I'm going to hang around here for a few minutes. [45:24.460 --> 45:30.820] I've got another talk in about 18 minutes, but I'm going to stay connected until then. So, if [45:30.820 --> 45:39.660] anybody has anything, feel free to ask away. Oh, okay. How close do you have to be to receive [45:39.660 --> 45:45.420] signals is one of the questions I just got. So, I didn't really go into the AIS protocol, [45:45.420 --> 45:50.740] but the AIS protocol is basically designed for ships to talk to each other within about a 10 [45:50.740 --> 45:56.920] to 20 nautical mile range. So, obviously, you're going to get messages further away [45:56.920 --> 46:03.060] if your antenna is higher up. My antenna at my building at work is 75 feet high, [46:03.720 --> 46:14.360] and I have gotten messages from as much as 80 or 90 miles. With a normal ship antenna that might [46:14.360 --> 46:23.240] only be, let's say, at most probably 10 to 15 meters high, they're probably getting, you know, [46:23.240 --> 46:54.840] the 15 to 20 mile range. Okay, let's see. I just got a message asking about the Trend [46:54.840 --> 47:03.520] microlibrary. So, I actually haven't... oops, let's see. I have to get back to my video now. [47:03.760 --> 47:11.920] Ah, never change a working thing. So, at my website, I talk about the AIS Black Toolkit, [47:11.920 --> 47:15.120] and I'll talk a little bit more about that later on. So, [47:15.760 --> 47:21.880] a team of people from Trend Micro, led by a fellow named Marco Balduzzi, has been talking [47:21.880 --> 47:29.620] about AIS issues for a long time. In any case, the AIS Black Toolkit is a Python-based toolkit [47:29.620 --> 47:36.540] where they also wanted to be able to generate any AIS messages that they wanted. And so, [47:37.960 --> 47:43.860] I've used their toolkit a little bit. I've not used the part of their toolkit where they actually [47:43.860 --> 47:50.380] push out messages using software-defined libraries or software-defined radio. [47:51.880 --> 47:57.060] Their messages were basically a demonstration of capability that they could do it, but they [47:57.060 --> 48:03.060] used a lot of defaults that put them like in Italy and stuff like that. So, when I built my tools, [48:03.060 --> 48:08.820] they were a little bit inspired by, you know, what they did. But I tried to build it so that [48:08.820 --> 48:15.360] I used defaults per the standards so that I could create legal messages. But a lot of you [48:15.360 --> 48:22.320] may be familiar with the program HPing3. It allows you to build any TCPIP message you want, no matter [48:22.320 --> 48:29.180] how bogus. So, I was inspired to call my stuff AIS Ping for that reason. I mean, I can build legal [48:29.180 --> 48:35.640] AIS messages. I can also build entirely bogus AIS messages, because AIS won't stop me from doing [48:35.640 --> 48:43.160] it. And that's one of the protocol vulnerabilities. And again, I'll talk more about that later on. [48:43.440 --> 48:50.920] But, in any case, I had success using the AIS block toolkit, but I haven't used the block [48:50.920 --> 48:57.260] toolkit probably in a year, year and a half. I am pleased to say that one of my programs found [48:57.260 --> 49:02.300] its way into the block toolkit, the menu program, but the rest of it's on my site. [49:07.640 --> 49:13.280] Is the CAN project the only NMEA 2000 project? Now, I'm going to have to go look at that one. [49:13.280 --> 49:22.480] Hang on just a second. I'm going to run over to Slack, here. Let's see. Is the CAN project the [49:22.480 --> 49:30.800] only NMEA 2000 project you know of? It is. It's the only, well, by the standard, that's what it runs [49:30.800 --> 49:36.520] over. So, the problem with NMEA 2000, like I said, is it's proprietary. You need to buy the [49:36.520 --> 49:43.340] standard. I have a copy of the standard, with permission, and when they sent it to me for [49:43.340 --> 49:48.720] research purposes, it's actually watermarked with my name in it. They really are trying to [49:48.720 --> 49:54.720] discourage people from, you know, spreading the thing around. And everybody has to sign a [49:54.720 --> 50:00.660] non-disclosure saying that they won't release it. And it's been around for 20 years, and nobody's [50:00.660 --> 50:26.580] released it yet. So, they must be reasonably successful. Got a message. They're waiting for [50:26.580 --> 51:15.400] one more message. Oh, let me try the AIS text. There's maybe a message there. Okay. [51:16.320 --> 51:21.080] Redoubt's making a comment here about DEF CON 2016 open source project release for [51:21.080 --> 51:26.920] the J1939 truck duck. Okay. Good to know. [51:28.460 --> 51:36.620] Redacted by people willing to help port it. Well, where I come from, reverse engineering is a noble [51:36.620 --> 51:59.760] cause. When I was a young person, first in computers, I probably shouldn't age myself [51:59.760 --> 52:06.180] too much. Nothing. First of all, nobody had ever heard of open source. And the two words, [52:06.800 --> 52:13.100] didn't exist. Everything was proprietary. The only way to learn anything was to break the [52:13.100 --> 52:17.580] computer. And once you realize that you broke it, I mean, I was of a mind, once I broke it, [52:17.580 --> 52:23.540] I only had to break it once. Because computer security in the 1970s was when you broke something [52:23.540 --> 52:27.940] and you went to the network people and said, hey, if you do X, Y, and Z, your network will break. [52:27.940 --> 52:33.240] Their answer was, well, don't do that. We would say, oh, okay, we won't. We'll go do something [52:33.240 --> 53:30.960] else. But that's how you learn stuff. Well, I'll tell you what, I have that it is 250 where I am, [53:30.960 --> 53:37.720] so it must be 1150 back on the coast. If there's, like I said, I'm going to hang around for another [53:37.720 --> 53:44.400] 10 minutes or so for my next talk, but I'll, I'm prepared to close it now. You know, [53:44.400 --> 53:49.260] thanks for the questions. Thanks for being here. If you have any questions, if you get to my website, [53:49.980 --> 53:55.580] or any of those that are here, there's tons of ways to get ahold of me. Feel free to do that. [53:55.580 --> 54:01.600] I love talking about this stuff. Happy to help out in any way I can. And in about 10 minutes, [54:01.600 --> 54:06.220] I'll start talking a little bit about GPS spoofing and AIS spoofing and all that kind of stuff.