start	end	text
2550	11030	Hey everybody, Gary Kessler here, and welcome to my talk about putting an AIS receiver in Raspberry Pi.
11050	16330	Hope everybody can hear me okay. Sort of strange giving a presentation to a bunch of people from
16330	24330	an office, but off we go. Let me put on my screen here, hang on just a second,
33460	38400	so right now you see me watching you watching me, so we're crossing the beam here.
40820	47300	So let me get to the right page. That's not the right page. Let's go here.
48500	53280	Now you all know that I watch Longmire. So I'm going to talk about setting up an AIS receiver
53280	60080	on a Raspberry Pi, and I'm not going to assume that anybody has a lot of background in any of
60080	66480	this, but obviously through comments and Q&As you'll tell me where I've gone too deep or not
66480	76220	deep enough. But in any case, there are a lot of different ways to build a receiver in any number
76220	83680	of formats. I like the Raspberry Pi because it provides a mechanism where I can take a cheap
83680	89860	machine and have it dedicated to task. To give you an idea of that, just to tell you where it is
89860	96020	we're going, I'm sitting here in my office right now, but over here, if I point this in the right
96020	104640	direction, get rid of that, here's my TV screen showing my current AIS information I'm getting.
104680	112500	Right there, I think if I'm pointing correctly and if I get this in focus, there's my Raspberry Pi.
113220	120720	And now I'm about five miles from the water, so I'm not getting a lot of signal. But back up here
120720	127460	over my shoulder, there's my antenna clipped to my bookcase. And again, connected to the Raspberry
127460	133580	Pi, connected to my TV screen. Now in any case, what I'm going to do, I have a second Raspberry
133580	138100	Pi here, so I'm going to sort of start from there and just give you a little bit of background.
138560	144780	So first of all, I will say I've got a page on my website. If you go to GaryKessler.net,
144780	150200	I egolessly named the domain after myself. If you go to GaryKessler.net, you can get
151860	159480	this webpage. And if you want way more background on AIS, there's a couple of
159480	164840	links that I give you up here. Actually, the Wikipedia page has a lot of good information,
164840	168880	but of course you can go to the Coast Guard NAB Center and get their overview.
169840	173680	International Association of Lighthouse Authorities has a really good overview as well.
173680	176240	But in any case, sort of let me tell you where we're started here.
177520	182940	Now, again, without making too many assumptions about what you all have played with or not played
182940	190020	with, if you haven't seen before, this here's a Raspberry Pi. This one is a little bit old.
190880	199760	This is, as you can see there, if I can focus this. Yeah, there we go. Okay, so this is the
199760	205760	I think they're a couple beyond that now. But in any case, stock standard Raspberry Pi,
206620	215540	a whole bunch of USB ports and Ethernet port as well. Here's where there's an HDMI connection
215540	221960	as well as power. This is the general purpose IO bus back up in here.
223280	232060	And let me go back to being live and personal. Anyway, so that's your stock standard Raspberry
232060	241060	Pi. Now, there are also a number of ways where you can connect an AIS receiver. You can get some
241060	249920	little plug right into the USB port. What I got was this device from Wegman, the Daisy AIS receiver.
250620	257300	If you get a receiver, it is my recommendation, get a two channel receiver. So AIS broadcasts
257300	263820	on two channels, what they call channel A and channel B. I don't see much use if you're going
263820	268360	to be doing research and you're trying to gather data. I don't see much purpose in getting a single
268360	278540	channel AIS receiver. It is true in my experience, most of what I've seen, chips that are broadcasting
278540	284880	on channel B are also broadcasting on channel A. But again, there's probably no really good reason
284880	292060	not to get both channels. In any case, this is, you know, like I said, this is the Daisy hat.
292660	297380	And for those of you who like to look at SuperTree, that's the back part.
299830	310030	So let me go back around here. In any case, so the first part in getting this
310030	313930	together also, when you buy the piece parts, is you're going to have to buy an antenna. You're
313930	317810	probably going to want to buy an antenna. You'll need a marine antenna because that will pick up
317810	324930	the appropriate VHF channels. Read carefully on the antenna connector. I found that they use
326030	330350	a whole different nomenclature. You know, every industry has its own vernacular.
330350	336890	Antenna people have theirs as well. You probably want to get what's shown here
336890	344390	is the stock standard marine antenna connectors. And you're going to need an adapter to go onto the
346310	353570	Daisy hat, which again is what I used. So there's the antenna connector on the Daisy hat.
353570	361950	So what I have here is an adapter. This goes onto the Daisy hat side. This is a stock standard
361950	368550	bayonet connector for here. Here is the antenna connector. This is the part that goes to the
368550	379030	marine antenna. And then here is the bayonet, the female connector. Anyway, so eventually this piece
379030	385150	is going to go onto the Daisy hat. This piece is going to go on to that connector. And this
385150	398700	is going to actually connect to the antenna itself. Oops. Just learning how to use a computer.
398820	406360	Anyway, the operating system for the Daisy hat is going to fit onto a micro SD card.
407820	414800	And, you know, you've all seen micro SD cards. I would get the biggest one that you can,
414800	418280	just because it provides you more of an opportunity if you need to store a whole
418280	423960	bunch of data. Micro SD card probably won't fit in your computer. Luckily, most micro SD
423960	430940	cards these days come with an adapter so that they can plug into stuff. But, you know, basically,
431760	437220	this is like most of my piece parts. I'll put that there so it'll be in the camera range.
440000	443720	So installing Raspbian is something that I'm not going to...
445680	450980	Hang on just a second. I'm getting a message here that I think I need to take a look at.
456750	463510	They're not... you're not seeing the Raspberry Pi. So, do I understand? You're not seeing my camera?
463590	474600	Okay, now, okay, now they are. All right. Anyway, on the Raspberry Pi, I chose to install Raspbian
475120	482240	and then put OpenCPN. And so the rest of what I'm going to talk about is basically about that.
482440	488400	On my page, I mentioned that there is a whole different direction you can go in if you want.
488400	495320	If you go to the website AIS Hub, I've got a link for their RPi AIS, which is AIS Dispatcher
495880	501780	for Raspberry Pi. And what Dispatcher will do, it basically acts as an intermediary
501780	506140	to accept AIS feeds and then pop them out where you want them to go.
506720	511340	That site is a really excellent site and has a lot of really good information as well.
511880	517740	But that's not the direction I'm going to go in right now. What I'm going to talk about is
518500	525500	just, again, stock standard, pretty much vanilla with my Raspberry Pi using the NOOBS operating
525500	532120	system. And again, the operating system is going to go on the microSD card. There are a lot of
532120	539600	places out there that give instructions for how to do this. And the reason I put this page together,
539600	545200	actually, is I don't really have a lot of information here that's really unique to
545200	552620	anything that I made up. But I found I had to go to about a dozen sites to get all the
552620	557680	information together so that I could actually figure out how to do this. So I decided to build
557680	562440	this page because, for me, it provided a roadmap that if I need to do it again in six months,
562440	569640	I've got a place to go. In any case, relatively easy to get NOOBS onto the microSD card.
570460	579400	And then, basically, after you have put the operating system... I'm going to get this off
579400	588380	my card here. So I've got the operating system on my microSD card. And it just goes
590480	598840	into the... oh, there it is. It just goes into the Raspberry Pi. And that is all of your local
598840	604440	storage. That is your disk drive. That's your operating system and your bootable device.
604440	609820	Of course, the joy with the Raspberry Pi is you can have a whole slew of different operating
609820	614880	systems and you change the personality of the Raspberry Pi by what SD card you put in.
614940	619840	One of the reasons I like having a big SD card, like I said, is if I'm doing local storage of
619840	629800	stuff, I can keep it all on the SD card. Clearly, with four USB ports, I could also plug in all the
629800	643120	external storage I want. So once you have gotten the software installed, you're going to plug the
643120	649140	thing in. At this point, you need to have some I-O devices. So you do need to have a keyboard
649140	659500	and a mouse and a monitor of some sort, at least for the initial phases. And so when you start the
659500	664580	system up, you'll get some sort of boot screen and you'll tell it, you know, you want to install
664580	672360	full Raspbian and just let that go. Now, at this point, you have an operating system. You now need
672360	678940	to configure the Raspberry Pi. So I give you a little bit of instruction how to do that. But
678940	685820	what I'm going to do is try to show you a little bit more dynamically and live. So the application
685820	692620	menu is usually up in the upper left. It's the Raspberry Pi icon. And if you go down to
692620	698100	preferences and then Raspberry Pi configuration, here's where you get to configure the things about
698100	704120	your system. So here's where you can put in your password, the name of the computer, and all this
704120	709320	kind of little stuff. One of the most important parts is going to be on the interfaces. If you
709320	717080	want remote access to the Raspberry Pi, and I recommend that you do, be sure to enable SSH and
717080	726880	VNC. SSH is going to use TCP port 22. VNC, I think, uses port 5900. You probably want to have the
726880	732800	serial port enabled either, since you're going to put something onto that serial port. And then
732800	738520	there's some other things you can configure here. One that I do recommend is to set your locale.
738520	744380	If nothing else, be sure you're in the right time zone. And then you might want to do some other
744380	748060	things about, you know, what country you're in, what language, and all those kind of things.
748560	757440	But those are the two biggies. You do need to set the Wi-Fi country. And I must admit, I know you
757440	762800	need to do it, and I haven't explored deeply as to what happens if you configure a different country.
763380	766940	But, well, anyway, I'm going to cancel this, because I didn't really want to accidentally
766940	773780	change anything. So, anyway, so this is all the stuff, like I said, you know,
773780	782720	you can configure on the Raspberry Pi. Now, it turns out, of course, you can use the GUI,
782720	787660	or you can use a command line. And here's some instructions on using the command line. I just do
788880	793860	a sudo, you know, raspi-config, and it'll pop up actually the same screen.
794800	802600	Now, you might want to put your Raspberry Pi onto a Wi-Fi network. And if you have
803960	812460	a Wi-Fi network that it's broadcasting as SSID and doesn't have a password,
812460	817600	and you're not physically connected on the Ethernet port, the Raspberry Pi should pick up
817600	823040	that Wi-Fi network. However, if you want to connect anything else, like a Wi-Fi network
823040	832360	that doesn't broadcast SSID and or requires a password, then there's a file that you need to
832360	840320	edit and put the information in about that, about that network. This is one of the reasons I'm not
840320	845860	going to show you the file that's sitting on my Raspberry Pi, because everything is in plain text,
845860	849100	and I'm not, you know, don't know that I want to show everybody my password right now.
849100	856340	Anyway, so what you need to do is go to this file, the sd underscore supplicant dot com file.
856900	864620	Nano is a nice little GUI editor that comes on the Raspberry Pi. In any case, so what I've done
864620	871700	here is I'm showing you how you could configure two different wireless networks. So, in the first
871700	878300	case, I've got a guest network. There's no password, but in this case, the SSID
881460	887220	is not being broadcast. So, the SSID for the guest network is guest. Anyway, so that's what
887220	891480	that would look like. Then I've got another network called owner. And owner, in this case,
891480	898200	does have a password. The password is secret. And it uses WPA. So, this is what those kind
898200	905380	of commands would look like to, you know, indicate that network. So, let me just go
905380	914420	back here for a second. And I want to get back to my video, actually. Here, let me just click the
914420	926320	video. Oh, just click the video off. Sorry about that. All right. Sorry, we're all still learning
926320	939040	the tools, particularly me. All right. So, I'm going to go back to Firefox here. So, basically,
939040	947740	at this point, you've got your Raspberry Pi now can listen on SSH or VNC. You've got it connected
947740	953540	to the wireless. So, at this point, you can take out your, you know, well, you can keep plugging
953540	956580	into your monitor if you want, but you don't need your keyboard anymore and you don't need your
956580	960840	mouse, because you can now do that remotely if you want. I do have a couple notes about the
960840	969500	screen resolution, because I found that I had to play around a little bit with that. And you can
969500	977140	go into the config.txt file, which is in the boot directory, and there are a number of different
977140	984500	screen sizes you can try. What I found on this was I had to play around a little bit and experiment,
984500	992540	and eventually, I found something that worked. So, now that I got the Raspberry Pi going,
992540	1000420	the next thing is installing the daisy hat. Now, again, I'm going to assume that many of you have
1000420	1006620	played with this kind of stuff before, but there's probably some of you who haven't. So,
1007300	1016540	on the Raspberry Pi, I've got these two rows of pins back in here, and on the daisy hat,
1016540	1021220	I've got a socket that goes into it. Let me get that a little bit further down.
1021400	1028100	And all I can say is, if you've never played around with, you know, putting sockets onto pins,
1028100	1032820	just do it slowly, carefully, and make sure everything's lined up the first time.
1032820	1038820	The other thing is, you'll notice, I actually have this in a case. You don't actually need
1038820	1043740	to have it in a case, but I thought it was better, more better protected that way.
1044080	1051040	So, I mounted the Raspberry Pi onto the case. You see the standoffs. If you're going to do this,
1051040	1057800	there's some standoffs for the daisy hat as well. You know, this is the time to put those in.
1057800	1063240	And then, like I said, it's a matter of, you know, be sure that you've lined up the socket
1064060	1071900	correctly this way. And actually, it's not, but I can't see it as well as the camera can.
1071900	1077160	And be sure that you've lined it up correctly, you know, here as well. And once you have everything
1077160	1085000	lined up, let me try to get this in here. This is the problem with doing anything live, isn't it?
1085000	1093360	Just be sure that you squeeze evenly on both sides and slowly. And there you go. I mean,
1093360	1099240	it's like that. And then, of course, you screw it to the standoffs. And then you build the rest
1099240	1108100	of the case. You can probably guess this is why I took apart one to put back together,
1108100	1111480	but I'm not using that live because I'm not going to square everything back in together.
1114150	1120610	Anyway, once you get the Dizzy Hat installed, that's really all you need to do. I gave some
1120610	1127170	instructions on how to load a program called GPIO that allows you to look at your GPIO pins.
1127230	1133610	You can do that or not do that, depending upon if you want to track all those things.
1134110	1138950	I put in the software, but it's absolutely not necessary to do. There's also a program
1138950	1146010	called Screen, which, again, provides you some useful information about anything on your serial
1146010	1154010	board on the Raspberry Pi, but it's not essential to the operation of anything related to AIS.
1154010	1160690	So I'm going to sort of skip over that. And what I want to do is I want to bring you to OpenCPN.
1160850	1167310	So I'm running OpenCPN on the Raspberry Pi. I'm also running it on my
1169090	1178730	Mac. And so there's slightly different views here from what I'll show you on the Raspberry Pi.
1178730	1188910	But the OpenCPN is OpenChart Plotter. OpenCPN runs on just about all software platforms except iOS.
1190450	1196890	And basically, like with any electronic chart display, you see all the targets out here.
1196890	1202230	The targets are color-coded, actually, by type of vessel. And with AIS, they're identifying
1202230	1207410	their type of vessel. Right here, I've got one. I don't really know much about it,
1207410	1214830	but it apparently is a ship from Norway. It's a Class A vessel, which means we're going to
1214830	1219430	be getting more information on its position reports. But you'll see here, you know,
1219430	1226310	you've got its speed, its course, heading, rate of turn. A vessel like this, at this speed,
1226310	1230990	ought to be broadcasting, well, certainly no more than about 10 seconds before their
1230990	1234550	transmission. I'm a little bit surprised. They're up to four minutes now. Possibly,
1234550	1241010	that's due to range. But in any case, I can look at any one of these other vessels.
1241230	1245950	Baby Cakes, I can know that boat, just because I see it in the harbor all the time.
1246230	1252290	Right now, it's probably parked. It's a smaller vessel. It's a smaller vessel, by which I mean
1252290	1261370	it's a yacht. It's a Class B vessel, so it's not required to transmit AIS messages. But in any case,
1261370	1268070	so OpenCPN, again, being open source and has a nice version for the Raspberry Pi,
1269010	1277910	you can, you know, download the software at the OpenCPN.org site. They have more documentation
1277910	1286150	than you can shake a stick at. But again, there's all sorts of information there about
1286150	1292090	how to install OpenCPN. And again, I tried to put everything sort of in one place that,
1292090	1298030	you know, steps you through. Most importantly is building yourself a PGP key file on the Raspberry
1298030	1309290	Pi and how to be sure that you get the key so that you can actually install OpenCPN when you
1309290	1314910	have, you know, gone through the first process here. So once you've got the key, you know,
1314910	1321790	here are the steps right here to install OpenCPN. And like most things, you're waiting for a lot
1321790	1328510	longer than you're actually typing in instructions. But once you get OpenCPN on your computer,
1329050	1335570	you now have other things you need to play with. So, I'm going to go back to OpenCPN here,
1335570	1343010	and you're now going to need to configure OpenCPN. Now, one of the things I want to show you,
1343010	1349250	because I found this to be, and continue to find it to be, one of the,
1349250	1356850	if anything in OpenCPN is difficult, this is the most difficult step, and that is getting charts.
1356990	1368190	So, you have to be familiar with charts and how they're organized, at least in the United States.
1368190	1375090	So, when you want to add a new chart, and you can get charts, as you may know, from the National
1375090	1380010	Oceanographic and Atmospheric Administration, from NOAA, you can download every chart in the
1380010	1386110	United States, in a variety of formats. You can download them as a PDF, so that as a person you
1386110	1394150	can read them, or you can download them in a number of electronic formats, ENC being the most common.
1395570	1402910	And so, basically what you need to do, if you want to add a chart, is, well, you can go to
1402910	1410370	Chart Group here, if you want. You can add new groups of charts. The easiest way is to go to
1410370	1417150	Chart Downloader, and, in this case, you can see that I have four catalogs on my computer right now.
1417150	1423610	I've got the catalog for California, Florida, Connecticut, and, although it's not all shown here,
1423610	1431210	for Coast Guard District 1. The reason I downloaded all of District 1's catalog was because I wanted
1432210	1437190	charts from Vermont, but they don't actually have charts for Vermont. The Vermont charts
1437190	1442190	are in the District 1 catalog, so that's one of the other things you sort of sometimes need to
1442190	1452690	fight through. But, so, if you want to add a chart, you just go to Add, and then you get to choose
1452690	1459270	where do I, from where do I want my charts? I usually want USA and NOAA charts, so I open up that,
1459270	1466350	and then I can decide, okay, do I want the RNC or the ENC charts? The RNC or the rastrographic,
1466350	1474510	they're not used very much anymore, or I can get ENC charts. And, now, I can download all the ENCs.
1474550	1480390	I can look them up by district. I can look them up by state, look it up by region, what have you.
1480950	1485870	So, if I wanted to look it up by state, for example, well, obviously, here's my states.
1485870	1493870	So, let's say I wanted to get charts from Illinois. I could go to Illinois, click OK,
1493870	1502850	and it now has just added the chart, but what it wants me to do is now update. So, the next thing I
1502850	1510910	need to do is update. So, it gets all of those, and now you'll notice down here it has a list.
1511470	1515910	Now, those of you that are familiar with charts know that the charts are numbered.
1516630	1523850	The numbers are only good in OpenCPN as a mechanism to help you find the name of the
1523850	1532970	chart because you'll notice in the catalog down here everything's by name. So, like I said,
1532970	1537190	you just need to know the name of the chart. If I wanted to download, let's say, the Chicago
1537190	1543730	Lakefront chart, I merely click on it, I download selected charts, and now those charts are
1543730	1551150	available to me in OpenCPN. So, I'm going to say OK, so it's all here, and there's actually,
1551150	1560640	there really is a reason I'm showing you this. All right, so, if I back out of here
1561800	1565580	all the way, I'm going to take a look at the United States,
1566140	1570400	and what you're going to see, well, maybe I'll go in a little closer, what you're going to see here
1570980	1577500	is a bunch of green boxes. These are all of the places where I have downloaded charts. So,
1577500	1581940	remember I have the California catalog? Well, all I have from California is some charts up in the
1581940	1587640	San Francisco Bay Area. Here's Lake Cheyenne Plain, my Vermont charts. I have some charts
1587640	1592860	from the New London area in Connecticut. The chart we just downloaded in Illinois,
1593800	1597920	here are some of the Florida charts that I have. This is mostly the Pensacola area,
1597920	1604620	and the rest of what I have is here where I am in Daytona. So, I have access to every chart
1604620	1609940	in North America, but of course I haven't downloaded all of them because, you know,
1609940	1615700	I'm not looking at all of them. And right now, for the feed that I have, I really only care
1615700	1622260	about this area here, because for me, again in Daytona, this is the Intracoastal Waterway
1623720	1628500	in my neck of the woods. So, it's going to take a couple seconds while all of this reloads, but
1629260	1632160	anyway, so hopefully you sort of get the idea here.
1635450	1642030	Anyway, that is the process that I describe here about downloading charts.
1644230	1650390	Now, the next thing you need to do is figure out, okay, I'm going to display AIS data.
1650390	1654170	Where am I getting it from? So, once again, I'm going to go back to here,
1654390	1665540	and I'm going to go to the connections. And so, there's a variety of ways in which I can get data.
1666280	1674520	I have myself set up three connections. One of them is that I get data from an antenna that I
1674520	1679760	have at the university where I teach at Embry-Riddle Aeronautical University. So, I've got
1681000	1689060	a device there called ssia-ais.eru.edu, and if I connect to that device over the internet on
1689060	1696040	port 4000, that's where I get a feed. It's, at this point, public. I mean, any of you could point
1696040	1702660	there as well, if you're interested in what's going on in Daytona. I'm going to move this out
1702660	1709400	of the way here a little bit. All of these boats that I'm seeing here that's coming from that feed
1709400	1717260	from Riddle. Now, on this particular computer, I'm not set up on the serial interface because I
1717260	1725480	don't have an antenna on this computer, but if I switch back over to my... I'll go back to my
1725480	1730760	Raspberry Pi, you'll notice the interface is slightly different. If I go here and I look at
1730760	1738840	connections, you can see that I have... I've got a bunch of connections, but the two that are active,
1738840	1744400	one is coming in, again, from ssia-ais.erau.edu,
1748060	1757000	and the other, I'm set to the serial port. So, my Raspberry Pi can also be pulling in stuff from
1757000	1766540	the antenna. So, my office is about, oh, I would say five or six miles from the river and from the
1766540	1772740	ocean, and since you saw my antenna, it's only about seven feet high, I'm not picking up a lot
1772740	1777960	of feeds. So, most of it's coming in from the antenna at the university, which is, like I said,
1777960	1786360	up about 75 feet up. I will tell you one funny story, because when I was first experimenting
1786360	1792040	with this, I had all this stuff at home, and home is 10 miles from the ocean. So, I'm fooling
1792040	1798880	around with it one day, and right here, this window here is the NMEA debug window, because I
1798880	1803340	checked the box. So, you see I'm getting traffic, and you can see where it's all coming from.
1803420	1808280	So, I'm sitting at home, and I'm not getting any data, but I'm not expecting to, and all of a sudden,
1808280	1815840	I get a hit. I have an AIS message come in on my serial port, and I go crazy, because I'm very
1815840	1822380	excited. So, I take the message, and I parse it, and I look at the latitude and longitude, and I
1823760	1831840	position exactly where the thing is, and it turns out I live about one mile east of I-95,
1831840	1839480	and the latitude and longitude showed a boat going at approximately, you know, on a heading
1839480	1847720	of approximately 210 degrees at 65 knots. And I said, there ain't a boat anywhere doing 65 knots
1847720	1854160	around here. Well, the latitude and longitude put this boat in the southbound lane of I-95.
1854420	1858960	So, clearly, this boat's sitting on somebody's trailer. They didn't turn off their AIS,
1858960	1864740	and this guy's zooming down the road, and I got one of its transmissions. I was very excited.
1865780	1872040	Anyway, I'm going to go back here. So, this is how you set up your connections.
1872080	1878460	So, you can set up a serial connection, as I show here. If you set up a serial connection,
1878460	1883980	it's going to automatically be an NEA 0183 protocol. You're going to want to set the
1883980	1889720	data rate to be 38400, because that's probably what the data rate's going to be over the air.
1890540	1896160	Or you can set up network connections. And for the network connections, it's going to need an IP
1896160	1902580	address or a hostname, and it'll need the port on which to read. So, it's getting all of this,
1902580	1908580	obviously, over the network. And again, you've just seen already, but this is what the debug
1908580	1915420	window looks like. And let's see. So, this was stuff coming in on a serial port.
1916240	1922620	This was stuff coming in on a network port. I'm not 100% sure why I decided to hide that IP
1922620	1932500	address, but I did. Now, it also turns out that if you want to get one of these feeds live,
1932500	1937540	if you go through OpenCPN, one of your problems is there's no way to take
1938380	1945260	the information from the debug window and get it in any usable form. One thing you can do
1945420	1952220	though is go around to a terminal window. I'm going to go around to a terminal window here.
1952220	1964600	I'll make a new one. And I just do, you know, an NC to ssia-ais.erau.edu, port 4000.
1967080	1972300	Hopefully, I'll start getting some data. There we go. So, I can get the feed this way.
1974200	1982460	And this is something I'm actually going to talk about in a later talk when I talk about AIS and
1982460	1991960	GPS spoofing. But one form of spoofing is a replay attack. So, a replay attack, well, just like the
1991960	1997100	name sounds. I mean, you replay old data. This is a way of collecting data. So, I've actually
1997100	2003220	written a program that will do this for you. But you can also do it for yourself. There's a reason
2003220	2008580	you don't want to collect data in this format and then replay it. And the reason is you don't have
2008680	2016140	a timestamp. You don't have relative timing. But more on that later. In any case, let me go back
2016140	2020660	to this. So, like I said, there are a variety of ways where you can get the raw feed if you just
2020660	2028720	want to see a raw feed. And one of the other things you can do, of course, is you can set up
2028720	2037760	OpenCPN to display stuff that you are sending it from your computer. So, you can either set up
2037760	2050640	OpenCPN to read from somebody else's TCP socket, or you can set up OpenCPN and write to OpenCPN.
2050660	2058000	So, in this case, let's see. When I set up my network connection up here,
2059080	2066300	you'll notice I was receiving input on this port. I can set up another port that I can then
2066300	2075020	output on this port. So, what I now need is, if I have a program that will write to port 7777
2075020	2081140	on this computer, as I've configured it here, this provides another mechanism where I can show stuff.
2081140	2088300	So, again, I'll be talking about that later on as well. So, in this case, what I did was I set
2088300	2095420	something up where my serial port is an input port, network port, port 7777 is an output port,
2095420	2100320	and this is what the debug window looks like, because it shows that I'm reading on the serial
2100320	2107480	port and writing to port 7777. Again, there's a variety of ways of, you know, using OpenCPN
2107480	2116920	for some really, really, you know, clever stuff. Anyway, so I mentioned this program that'll
2116920	2124160	read for you. So, I have a program called Timestamp Data. It's on my website. It's software that's
2124160	2129880	available, and we'll be making that available here. But if you run Timestamp Data, here's the
2129880	2140860	help file. Excuse me. Again, you know, if you specify an IP address and a port number and whether
2140860	2148820	you want to use TCP or UDP, defaults to TCP, you can now download data for, you know, some period
2148820	2153560	of time. The program defaults to five minutes, but you could set it, you know, as far up to a week
2153560	2161920	if you want. And what this will do is this will download the data and it will include a timestamp.
2161920	2168940	So, what it does is, as it shows here, it creates a program or it creates an output file that looks
2168940	2177960	like this. It's basically a pipe symbol delimited file. So, here you can see I've got, you know,
2178610	2185140	the year, day, date, hour, minute, second, and then the Unix Epoch Time format of that.
2185520	2194060	Now, the reason I'm using the pipe symbol is because if I let people choose their own delimiter,
2194060	2201040	somebody will end up choosing a delimiter like a comma. Comma is not a unique character in an
2201040	2206140	AIS message. There are a lot of symbols that you might see, so pipe, I knew, would be at least
2206140	2211280	unique. If you don't like pipe, you can go into your text file and do a global search in place
2211280	2215860	for a different delimiter. But just be careful that you don't duplicate something. The other
2215860	2224080	thing is, by having here the relative timestamp, the message I just brought in, if I turn around
2224080	2231320	and replay this, I can replay it and I get the same relative timing. So, you know, this really
2231320	2236920	was not designed for a replay attack. It was designed so that I could gather data and then
2236920	2243860	replay it in real time and, you know, actually see what was happening. Because I have another program
2243860	2250580	called Play AIS, where I can replay this file. I can actually speed it up and slow it down, as well.
2252780	2258420	Anyway, so I've already talked a little bit about sending data to OpenCPN. If you don't
2258420	2265040	have a timestamp, everything just overwrites itself. And so, if you've got, like, 10 AIS
2265040	2270840	messages from the same vessel and you replay the file, what you'll see is the last message,
2270840	2277380	because the first nine got overwritten by all the following ones. Another tool you should know about
2277980	2285980	for this is, there's a really, really cool NMEA simulator. And it generates NMEA sentences
2285980	2293400	and, or AIS sentences, and it is really, really a cool program. For good or for bad,
2293400	2301720	it only runs on Chrome. Can't explain that. This is the only application I actually run Chrome on.
2302380	2309220	But, as you can see here from the dashboard and the other ways in which you can set this up,
2309860	2315320	you can pretty much simulate whatever you'd like. You can put yourself in a particular position.
2315320	2319740	You can get your vessel headed in a certain direction. You can give yourself a rate of
2319740	2324920	turn. You can do all sorts of cool things. And then what you can do is, you can hook yourself
2324920	2330580	up to a server and you can actually output the information that the simulator is creating.
2330580	2340040	So, you could create information such as this. I can set up my simulator. I have it right to
2340040	2347340	OpenCPN and then I can have it, you know, play on OpenCPN. It's really, really a cool tool.
2349560	2359220	So, last but not least, how do you interpret this data? For those of you who like to get into code,
2359220	2367160	Eric Raymond has a AIS protocol decoding page. You can see it's purple. I go there a lot.
2368040	2376820	And, well, I mean, I may as well go there. He has here, like I said, a lot of information
2377600	2385380	about the NMEA 0183 format. Not only the format, but what all the messages are, what the contents
2385380	2393620	are, to a certain degree, how to encode the contents. AIS does not show information in any
2393620	2400100	clear way that a human can understand. So, for example, you know, we've already seen a couple of
2400100	2406700	these. This message right here, where I'm sort of moving my mouse, the AIVDM, comma, one, comma, one,
2406700	2412520	comma, comma, A, comma, you know, all that jazz. There's a special encapsulation method that AIS
2412520	2418800	messages use. Eric's page talks a little bit about that, how you can get everything into a 6-bit
2418800	2425340	and armored ASCII and all that kind of stuff. But what you can do is you can take these AIS
2425340	2430180	messages that you get, and you can go to a place such as the site I've gone to here,
2430180	2435360	is Meritech Solutions, plop in the AIS message, and it will interpret it for you.
2436500	2441760	There are a whole bunch of other AIS parsers online, and I've given you some links on my page
2441760	2448500	here. And I've written a bunch of tools for this, because for some of the research that I wanted to
2448500	2454960	do, I was trying to create some unique AIS messages. And so, I had to create a parser.
2454960	2463740	So, I actually have an entire suite of tools, and we'll talk a little bit more with the AIS
2463740	2470600	spoofing stuff. But if you go to my software page, you can download all of these. But if I take that
2470600	2477320	same message, or I guess it's not the same message as was above, but some AIS message,
2477320	2484000	and if all of my stuff is command line, and it's all written in Perl, don't get me started on why.
2484880	2490920	And, in any case, it'll interpret, you know, the sentence for you. This is, in fact, an AIS
2492080	2499220	mobile device. It's a VDM, meaning it's a VHF data link message, which is a nice way of saying,
2499220	2504260	this is a message coming from another boat, as opposed to my message going out.
2505060	2512320	Here's all the contents of a type one message, which this is. It's a class A big boat position
2512320	2519720	report. Here's the device identifier. Every device has a unique nine digit identifier.
2520220	2525900	This gives you all the other information, including longitude and a URL, so that you can
2525900	2535180	click if you want. And there are a number of places where you can get data. I've already
2535180	2543520	mentioned the site that is at my university. You can also go to places like AIS hub, and
2544600	2551860	they also have a whole bunch of information. There are some other places online, if you can
2551860	2557300	find them, that give you some more localized information. If you find more places you'd
2557300	2563720	like to share with me, I would be delighted to have you there with me. And the format that we
2563720	2569720	most commonly see over the air, like I keep saying, NMEA is the National Maritime Electronics
2569720	2579820	Association, and the 0183 standard, which is about circa 1986, that's still the most commonly
2579820	2588800	used standard that we see. In about 1999, they came out with NMEA 2000. As we speak,
2588800	2594720	we're getting prepared to release the OneNet standard. It is very, very difficult to find out
2594720	2600600	how to do any of the coding on 2000 or OneNet, because it's all highly proprietary.
2601820	2606860	And everybody who has a copy signs a non-disclosure agreement. But there is a project
2606860	2617740	called the CanBoat project. The CanBus is used with NMEA 2000. IP version 6 is used as the
2617740	2627320	transmission for OneNet. NMEA 0183, basically everything runs over a serial bus. So a lot of
2627320	2633540	the stuff that I'm showing you here with OpenCPN, we're pulling in from over the air. It turns out,
2633540	2641240	if you can get onto the serial bus, you can get information right off the boat. And there are a
2641240	2646640	variety of ways... I'm not going to get into that here, but there's a variety of ways of
2646640	2653680	injecting messages directly on the boat, either through the CanBus, if you're NMEA 2000,
2653680	2662860	and or through the serial on NMEA 0183. So I'm going to go back here for just
2663140	2672220	a second. Everybody can see now. I mean, this is basically what I have on the device.
2673640	2679180	And so, I certainly would like to leave this open to questions, if I have said anything,
2679180	2689860	for which you have questions. Scrolling back up here to see if I can find the...
2692780	2699260	AIS text appears closed. So, anyway, does anybody have questions that you want to ask, or
2700320	2724400	anything like that? I'm detecting silence. Well, I'm going to hang around here for a few minutes.
2724460	2730820	I've got another talk in about 18 minutes, but I'm going to stay connected until then. So, if
2730820	2739660	anybody has anything, feel free to ask away. Oh, okay. How close do you have to be to receive
2739660	2745420	signals is one of the questions I just got. So, I didn't really go into the AIS protocol,
2745420	2750740	but the AIS protocol is basically designed for ships to talk to each other within about a 10
2750740	2756920	to 20 nautical mile range. So, obviously, you're going to get messages further away
2756920	2763060	if your antenna is higher up. My antenna at my building at work is 75 feet high,
2763720	2774360	and I have gotten messages from as much as 80 or 90 miles. With a normal ship antenna that might
2774360	2783240	only be, let's say, at most probably 10 to 15 meters high, they're probably getting, you know,
2783240	2814840	the 15 to 20 mile range. Okay, let's see. I just got a message asking about the Trend
2814840	2823520	microlibrary. So, I actually haven't... oops, let's see. I have to get back to my video now.
2823760	2831920	Ah, never change a working thing. So, at my website, I talk about the AIS Black Toolkit,
2831920	2835120	and I'll talk a little bit more about that later on. So,
2835760	2841880	a team of people from Trend Micro, led by a fellow named Marco Balduzzi, has been talking
2841880	2849620	about AIS issues for a long time. In any case, the AIS Black Toolkit is a Python-based toolkit
2849620	2856540	where they also wanted to be able to generate any AIS messages that they wanted. And so,
2857960	2863860	I've used their toolkit a little bit. I've not used the part of their toolkit where they actually
2863860	2870380	push out messages using software-defined libraries or software-defined radio.
2871880	2877060	Their messages were basically a demonstration of capability that they could do it, but they
2877060	2883060	used a lot of defaults that put them like in Italy and stuff like that. So, when I built my tools,
2883060	2888820	they were a little bit inspired by, you know, what they did. But I tried to build it so that
2888820	2895360	I used defaults per the standards so that I could create legal messages. But a lot of you
2895360	2902320	may be familiar with the program HPing3. It allows you to build any TCPIP message you want, no matter
2902320	2909180	how bogus. So, I was inspired to call my stuff AIS Ping for that reason. I mean, I can build legal
2909180	2915640	AIS messages. I can also build entirely bogus AIS messages, because AIS won't stop me from doing
2915640	2923160	it. And that's one of the protocol vulnerabilities. And again, I'll talk more about that later on.
2923440	2930920	But, in any case, I had success using the AIS block toolkit, but I haven't used the block
2930920	2937260	toolkit probably in a year, year and a half. I am pleased to say that one of my programs found
2937260	2942300	its way into the block toolkit, the menu program, but the rest of it's on my site.
2947640	2953280	Is the CAN project the only NMEA 2000 project? Now, I'm going to have to go look at that one.
2953280	2962480	Hang on just a second. I'm going to run over to Slack, here. Let's see. Is the CAN project the
2962480	2970800	only NMEA 2000 project you know of? It is. It's the only, well, by the standard, that's what it runs
2970800	2976520	over. So, the problem with NMEA 2000, like I said, is it's proprietary. You need to buy the
2976520	2983340	standard. I have a copy of the standard, with permission, and when they sent it to me for
2983340	2988720	research purposes, it's actually watermarked with my name in it. They really are trying to
2988720	2994720	discourage people from, you know, spreading the thing around. And everybody has to sign a
2994720	3000660	non-disclosure saying that they won't release it. And it's been around for 20 years, and nobody's
3000660	3026580	released it yet. So, they must be reasonably successful. Got a message. They're waiting for
3026580	3075400	one more message. Oh, let me try the AIS text. There's maybe a message there. Okay.
3076320	3081080	Redoubt's making a comment here about DEF CON 2016 open source project release for
3081080	3086920	the J1939 truck duck. Okay. Good to know.
3088460	3096620	Redacted by people willing to help port it. Well, where I come from, reverse engineering is a noble
3096620	3119760	cause. When I was a young person, first in computers, I probably shouldn't age myself
3119760	3126180	too much. Nothing. First of all, nobody had ever heard of open source. And the two words,
3126800	3133100	didn't exist. Everything was proprietary. The only way to learn anything was to break the
3133100	3137580	computer. And once you realize that you broke it, I mean, I was of a mind, once I broke it,
3137580	3143540	I only had to break it once. Because computer security in the 1970s was when you broke something
3143540	3147940	and you went to the network people and said, hey, if you do X, Y, and Z, your network will break.
3147940	3153240	Their answer was, well, don't do that. We would say, oh, okay, we won't. We'll go do something
3153240	3210960	else. But that's how you learn stuff. Well, I'll tell you what, I have that it is 250 where I am,
3210960	3217720	so it must be 1150 back on the coast. If there's, like I said, I'm going to hang around for another
3217720	3224400	10 minutes or so for my next talk, but I'll, I'm prepared to close it now. You know,
3224400	3229260	thanks for the questions. Thanks for being here. If you have any questions, if you get to my website,
3229980	3235580	or any of those that are here, there's tons of ways to get ahold of me. Feel free to do that.
3235580	3241600	I love talking about this stuff. Happy to help out in any way I can. And in about 10 minutes,
3241600	3246220	I'll start talking a little bit about GPS spoofing and AIS spoofing and all that kind of stuff.
