WEBVTT

00:04.920 --> 00:06.740
All right, it's 1.30.

00:08.580 --> 00:10.760
Thanks for coming to my talk about Mesh-tastic.

00:10.760 --> 00:12.240
We're going to go really low level.

00:12.480 --> 00:21.780
You can see on the screen right now we have chirps being captured on one side, on the right, and chat messages and node infos coming out on the left here.

00:21.780 --> 00:25.760
So I'll explain how I got to this state, how we got this working, or how I got this working.

00:26.420 --> 00:27.860
Let's stop this for a moment.

00:32.340 --> 00:35.360
All right, so just real quickly first, what is Mesh-tastic?

00:35.360 --> 00:39.380
Probably most of you who are here probably know this, so I'm going to go a bit faster these first few slides.

00:39.460 --> 00:43.460
But if you don't know, it's an off-grid, multi-mile, low-power Mesh network.

00:43.560 --> 00:47.140
Low power and it's very resilient to noise.

00:47.160 --> 00:49.900
You can send messages below the noise floor.

00:50.580 --> 00:52.480
It doesn't rely on any infrastructure.

00:52.600 --> 00:57.860
Basically, you would install an app on your phone, relay over to a little device, like such a device.

00:57.860 --> 01:06.140
I have a tiny one here, fits in your pocket or your backpack, and then that sends the message out a couple of miles using this technology called LoRa.

01:06.160 --> 01:10.240
It's able to transmit fairly far at very low power.

01:10.360 --> 01:18.880
And then with this Mesh-tastic app layer on top, that retransmits the message a couple of times, a couple of hops, to get your message pretty far.

01:20.080 --> 01:22.420
It's open source and has a lot of community momentum.

01:22.420 --> 01:25.160
That's what I like about it, and I think a lot of people like about it.

01:26.700 --> 01:29.880
Just to give a taste, this is the Android app.

01:29.880 --> 01:30.440
It's what it looks like.

01:30.440 --> 01:31.540
Just a chat app.

01:31.580 --> 01:35.800
It has a bunch of other features I'm not that interested in, but it can do a lot of stuff.

01:39.600 --> 01:43.460
The next slide will be about what you probably need to know for this to make sense.

01:43.980 --> 01:49.040
Then I'll go deep in this technology LoRa, this technology underlying Mesh-tastic.

01:50.120 --> 01:52.660
How it's modulated, how it's encoded, how to decode it.

01:52.660 --> 01:57.720
And then I'm going to go deep in how Mesh-tastic, the layer on top, is encoded and decoded.

01:57.860 --> 02:00.180
I'm going to be using, I'm going to be demoing a lot.

02:00.420 --> 02:05.520
Different software, GQRX and Spectrum to zoom in really far, GQRX to capture.

02:05.520 --> 02:08.260
GNU Radio to do some more actual decoding.

02:08.660 --> 02:13.980
Wireshark because it's useful to look at individual bytes and see what byte means what in what packet.

02:14.400 --> 02:16.820
And Python to glue it all together.

02:18.340 --> 02:23.420
So Prereqs, this is not like an intro talk to RF and software-defined radio.

02:24.200 --> 02:26.240
I'm not really going to go over the basics of GNU Radio.

02:26.240 --> 02:28.740
You probably need to know a little bit of GNU Radio for it to make sense.

02:29.680 --> 02:35.340
That said, you'll still get the gist of most of it, I'd say, even if you don't.

02:35.820 --> 02:38.700
Packet formats, it should probably not be your first time seeing Wireshark.

02:38.700 --> 02:40.500
That wouldn't make much sense either.

02:41.100 --> 02:48.760
Protobufs, Google's very efficient format for serializing structured data into bytes in a binary format.

02:49.260 --> 02:51.100
So that's pretty much all we need to know about that.

02:51.100 --> 02:53.080
It's a serialization format.

02:54.320 --> 03:05.860
Hardware I'm going to be using, I'm going to be using one of these T1000s, but there are a lot of other Meshtastic devices or LoRa devices that can run Meshtastic firmware.

03:06.380 --> 03:08.600
I like this one because it fits in your pocket.

03:10.880 --> 03:15.940
Eric yesterday was giving a really good talk about that, so you can see the recording for that if you want to see all the different types of devices that exist.

03:15.940 --> 03:17.100
He has all of them, I think.

03:18.660 --> 03:24.600
I'm going to be using the HackRF, Software Defined Radio Receiver or Transceiver.

03:25.200 --> 03:27.900
You could probably use a really cheap RTL-SDR as well.

03:27.900 --> 03:30.440
I didn't get time to try, actually, but I think you could.

03:30.440 --> 03:33.980
What I'm doing here doesn't really require such a fancy SDR, actually.

03:34.180 --> 03:38.740
And then I'm going to be, because I'm going to be transmitting a little bit at the end, I didn't get time to transmit through the HackRF.

03:38.740 --> 03:41.840
It is probably possible, but it would take a lot more effort.

03:41.840 --> 03:46.640
So I'm just transmitting through a really simple Arduino with a LoRa chip built in.

03:46.680 --> 03:51.680
I'll show you that at the end, but you can get these on Amazon for real cheap as well.

03:53.120 --> 03:54.480
So what is LoRa?

03:54.480 --> 03:58.780
So LoRa is a radio modulation and encoding system.

03:58.800 --> 04:03.320
It's a closed source technology by this company called Semtech.

04:03.320 --> 04:06.020
And the primary use is for LoRaWAN.

04:06.340 --> 04:16.980
So LoRaWAN is like a commercial, or rather, I guess you could call it a commercial system, where it's more like a traditional cell system.

04:16.980 --> 04:20.380
You'd have base stations that are connected to the internet then.

04:20.380 --> 04:27.500
So your LoRa devices reach base stations, and then that relays the thing onto the internet.

04:27.660 --> 04:46.300
So IoT device manufacturers, for example, that's I think the primary use case, can use this as an alternative to LTE or other cell technologies to have a low power, like low bandwidth, low power, really cheap way of connecting IoT devices through these base stations out to the internet.

04:46.300 --> 05:01.060
So manufacturers, all they have to do is use some LoRaWAN API on their server side, on the internet side, to receive packets or send packets, and then some SDK to put on their IoT devices to communicate to the internet through LoRa.

05:01.060 --> 05:03.080
So it's just kind of a hop to the internet.

05:03.700 --> 05:05.560
That's what LoRaWAN is.

05:06.000 --> 05:07.680
That's not what Meshtastic does, though.

05:07.680 --> 05:21.100
Meshtastic just uses the physical layer, not LoRaWAN, just LoRa, which is just the physical layer, and they use it to peer-to-peer messages between nodes and relay them on in this mesh fashion.

05:22.760 --> 05:25.520
So real quick recap of common modulations.

05:25.520 --> 05:34.160
Like I said, it's not like a beginner's R, but just to recap, AM modulation, so you might have some, let's say, 900 MHz signal.

05:34.540 --> 05:43.040
You might make it stronger, weaker, stronger, weaker in some wave, a 400 Hz wave, for example, if you're modulating an audible tone.

05:43.040 --> 05:44.640
So that would be amplitude modulation.

05:44.860 --> 05:50.260
You might turn it on and off, on and off, if you're modulating, if you're trying to encode a digital signal in this fashion.

05:50.360 --> 05:52.160
So amplitude shift keying.

05:52.960 --> 06:00.480
You might make the frequency higher, lower, like 400 times per second if you were modulating a tone.

06:00.680 --> 06:12.120
If you were modulating something digital with frequency shifting, you might make the frequency higher for some time, lower for some time, higher for some time, to encode ones and zeros.

06:12.280 --> 06:13.440
So that's a quick recap.

06:13.960 --> 06:18.320
So LoRa uses a really different modulation, which is very clever.

06:19.380 --> 06:20.740
I've seen different names for it.

06:20.740 --> 06:23.020
Chirp Spread Spectrum is one name.

06:23.520 --> 06:25.820
Frequency Shift Chirp Modulation is another name.

06:25.820 --> 06:28.020
I thought that was a pretty well-descriptive name.

06:28.260 --> 06:41.440
So the first way you can think of it is there's some frequencies, like in frequency shift modulation, but they're moving from some frequency and then gradually up, and then down to that frequency and up.

06:41.440 --> 06:42.840
So it's these chirps, like up, up, up.

06:42.840 --> 06:45.400
We'll see it in a different format later.

06:45.800 --> 06:51.220
The illustration here is in what we call a time domain, right?

06:51.220 --> 06:52.960
This is what the wave would look like.

06:52.960 --> 06:56.260
Wave gets shorter and shorter and shorter, higher and higher frequency.

06:56.340 --> 06:59.620
We can also look at it in the FFT plot style.

06:59.620 --> 07:00.600
We'll do that later.

07:01.080 --> 07:07.620
But chirps, so tones rising, rising, rising, and then I'll show you how you can encode data in that.

07:08.280 --> 07:09.380
And why is this good?

07:09.380 --> 07:15.460
Because with frequency shift keying, you're sending on one frequency for a bit and then another on a bit.

07:15.460 --> 07:17.980
But while you're on this one frequency, you might get a lot of noise.

07:17.980 --> 07:19.880
You might get buried in the noise.

07:20.160 --> 07:24.420
The signal would easily drown out in other types of modulation.

07:24.420 --> 07:28.000
This type of modulation is very resilient to drowning out.

07:28.140 --> 07:35.860
It can work below the noise floor, which is still hard for me to comprehend, but I'll tell you later of a video where the guy explains it really well.

07:36.400 --> 07:37.520
I'll leave it at that.

07:38.580 --> 07:40.480
All right, so let's do some demoing.

07:40.480 --> 07:41.600
Let's capture a chirp.

07:44.880 --> 07:46.560
So I'm using the HackRF.

07:48.900 --> 07:58.580
I'm going to use the software called GQRX, which is a software-defined radio, kind of just like an explorer, a viewer, and recorder.

07:58.580 --> 07:59.340
And that's what I'm going to be doing.

07:59.340 --> 08:00.340
I'm going to be recording.

08:00.580 --> 08:05.000
So what we already see here is 917 megahertz, a bunch of stuff going on.

08:05.000 --> 08:13.080
Now, that's the DEF CON configuration that most people here are probably running, like LORAC or Meshtastic configuration.

08:13.160 --> 08:14.140
It's called...

08:14.140 --> 08:17.000
there's some different modem settings you can have in Meshtastic.

08:17.000 --> 08:18.940
You can have different frequencies and so on.

08:19.520 --> 08:29.260
Meshtastic has some presets, and the preset that the DEF CON Meshtastic configuration recommends is running around 917 megahertz.

08:29.260 --> 08:31.840
So that's why we're seeing a bunch of stuff going on up there.

08:32.240 --> 08:34.380
The preset is called short turbo.

08:34.380 --> 08:37.260
Because it's turbo, it's really hard to view.

08:37.260 --> 08:45.280
So I'm going to transmit on the medium slow preset, which is what we use in the Bay Area mostly.

08:46.900 --> 08:48.580
It's just popular there.

08:48.760 --> 08:52.080
So that... well, you know, different presets are more resilient to different things.

08:52.080 --> 08:58.100
Some have longer range, but take more time so you don't have as high bandwidth.

08:58.160 --> 09:07.160
I guess the DEF CON, the folks who came up with the configuration for DEF CON decided we need the short ones because it doesn't take up much time on air, so there's so many messages going around.

09:07.160 --> 09:10.960
We want there to be enough room for all messages to not step on each other.

09:13.140 --> 09:15.980
All right, so I'm on my phone getting up now in the Meshtastic app.

09:15.980 --> 09:18.440
I'm just going to send one message here.

09:18.460 --> 09:20.120
Okay, we saw my message here.

09:20.120 --> 09:24.600
I'm sending on medium slow, so that's a different frequency, like around 915 megahertz.

09:24.600 --> 09:26.580
And it got retransmitted because nobody acted.

09:26.580 --> 09:28.040
Let me move them a little bit away.

09:28.320 --> 09:30.540
These are the transmitters.

09:30.540 --> 09:33.480
I'll just move them away from the antenna so it doesn't blast so loud.

09:35.660 --> 09:37.600
And this time I'm going to record.

09:40.180 --> 09:43.360
So I'm going to try to time it because the recordings are really big.

09:43.360 --> 09:48.760
It's like we're looking at 8 megahertz of bandwidth here, and it's like 100 megabytes a second or something.

09:48.760 --> 09:54.000
So I'm just going to record for just a second when I press send.

09:56.320 --> 09:57.740
Okay, I got it.

09:58.100 --> 10:01.660
So I'm stopping the program.

10:01.660 --> 10:02.540
I got this down here.

10:02.540 --> 10:03.260
I pressed record.

10:03.260 --> 10:04.280
I got this file.

10:04.420 --> 10:07.140
We're going to look at that now in a tool called InSpectrum.

10:07.140 --> 10:08.620
I'm going to launch that.

10:13.620 --> 10:17.380
So the reason I like this tool is you can zoom in really well.

10:27.160 --> 10:28.280
Here we go.

10:28.300 --> 10:30.880
So I had offset.

10:30.960 --> 10:34.120
I didn't center it around the tuned frequency.

10:34.120 --> 10:37.580
There's some limitations of the HackerRF, so I offset it by 1 megahertz.

10:37.580 --> 10:41.560
That's why we're seeing it centered around 1 megahertz here.

10:41.840 --> 10:48.500
And if you notice, this is, when I saw this, oh, now I understand why the Mishtastic logo is these kind of waves up and down.

10:48.700 --> 10:51.500
That's what the modulation looks like when you visualize it.

10:55.470 --> 10:58.550
So let's see what next I want to show here.

10:59.110 --> 11:04.550
Yeah, I think what I'll show now is this tool, InSpectrum, you can choose, you can enable a grid.

11:04.750 --> 11:05.810
Let's do that.

11:06.190 --> 11:15.570
Just to kind of help you analyze what's going on, let's set it at, I just want a grid with four lines, and I'll try to align that.

11:15.570 --> 11:17.450
Okay, that's pretty well aligned almost.

11:17.790 --> 11:18.170
There we go.

11:18.170 --> 11:19.930
Align that at these up chirps.

11:20.770 --> 11:23.450
So each up chirp, each chirp here is a symbol.

11:24.030 --> 11:27.010
And let's move a little around.

11:27.170 --> 11:29.750
At the beginning, there's some, I'll come back to actually how the structure is.

11:29.750 --> 11:31.650
There's some up chirps, there's some down chirps.

11:31.650 --> 11:36.470
But now we got, like, from the up chirps in the beginning, we could see the width of each symbol.

11:36.890 --> 11:39.890
So now I have my grid, like, set up right for that width.

11:40.750 --> 11:43.650
And then there's two and a quarter down chirps.

11:43.650 --> 11:45.090
I'll tell more about that later.

11:45.190 --> 11:46.830
And then there's a bunch of up chirps.

11:46.830 --> 11:49.250
Let's actually, let's go here.

11:49.250 --> 11:50.450
It's more interesting.

11:50.530 --> 11:51.210
Yeah, okay.

11:51.210 --> 11:58.630
So the intuition here is when you've aligned this right, you can see where these up chirps start and then wrap around.

11:59.030 --> 11:59.910
This is a good one.

11:59.910 --> 12:05.530
It starts kind of in the middle, goes to the top, and then wraps around, goes up there, goes up to where it started.

12:06.850 --> 12:11.230
So this starting position, the intuition here is the starting position is the symbol.

12:11.290 --> 12:14.230
So we're trying to send numbers here, right, at the end of the day.

12:14.430 --> 12:22.170
So maybe the number we were sending, if bottom is, let's say, 100, top is, sorry, bottom is zero, top is 100, then maybe this is the number 80.

12:22.270 --> 12:23.950
This is maybe, I don't know, 79.

12:23.970 --> 12:26.190
And this might be the number 40 or 30.

12:26.190 --> 12:29.690
And this might be number 20, and so forth.

12:29.690 --> 12:34.330
So that's how the encoding works intuitively, like at a high level.

12:38.180 --> 12:43.800
All right, so we had these, we saw many just up chirps in the beginning.

12:43.800 --> 12:54.140
Those are the preamble, and those are used by the radios to synchronize, to figure out what's this beginning, like how, not so much how wide they are, that's pre-configured, but more where does each one start.

12:54.140 --> 12:59.660
And then after that, it knows kind of how to align its grid like I was doing manually.

12:59.920 --> 13:11.200
There's a sync word, there's like a specific thing, a specific symbol that's encoded at the beginning of the transmission for radios to know was this part of the application they're using.

13:11.200 --> 13:20.020
So like Meshtastic uses symbol, like one byte symbol, 2B, to indicate that this transmission was a Meshtastic transmission.

13:20.160 --> 13:27.140
Then there are these two and a quarter down chirps to show that the preamble has ended and now the actual payload is coming.

13:27.260 --> 13:31.980
So everything after that are symbols that are the actual Meshtastic data.

13:33.260 --> 13:35.240
So let me go back here and look.

13:35.940 --> 13:46.500
So we saw all these up chirps, the preamble, and actually the last two of them are a little bit off, it's hard to see, but this is supposed to encode the symbol 2B, I believe.

13:46.500 --> 14:00.740
Though there is some open issue right now with some of these chips, some of the firmers are doing something slightly wrong about the sync word, so it could also be that they're all just zeros here, but it's like 000 and then supposed to be 2B in these last couple of chirps,

14:00.740 --> 14:07.820
and then two and a quarter down chirps, and then from here, after the quarter down chirp, our actual payload begins.

14:11.120 --> 14:13.400
All right, so let's see, how are we on time?

14:13.780 --> 14:33.280
Okay, so a useful property of chirps is that you can get them to almost be like frequency shift keying, if you have your up chirp and you multiply it, like complex multiply it by a down chirp, you kind of translate the up chirp down, that flattens it,

14:33.280 --> 14:38.480
so it becomes like, if you have this symbol, an up chirp, this down chirp, you get a flat line.

14:38.640 --> 14:52.520
So if you have this discontinued, like this broken one, up chirp here, then you know the first bit will get pulled down to here, and the second bit would get pulled up to here, so you would get a straight line, like frequency shift keying.

14:52.520 --> 15:12.480
So that makes it easy, in the end you just, like in your radio receiver, in your decoder, you just multiply all of these, all the up chirps, or the received chirps, with the opposite chirp, and that gives you just like a single frequency, so you can just do a Fourier transform on that to figure out where,

15:12.480 --> 15:16.780
like which was the dominant frequency in this time span, in this chirp.

15:16.780 --> 15:33.720
Here's a little animation then showing how we could be sweeping over different symbols we're sending, and then when you combine that with a down chirp, we would get this, we've de-chirped it and turned it into just a straight line, and it's basically then normal frequency shift keying encoding from there,

15:33.720 --> 15:35.900
somewhat, there's more to it.

15:37.680 --> 15:54.040
Oh, and a clever thing about the preamble, I thought this was really interesting at least, like how does the radio synchronize, how does it know, like, are we at the right place now, like have we positioned ourselves at the beginning of the chirp, or are we kind of offset?

15:54.200 --> 15:55.420
So how does it do that?

15:55.420 --> 16:04.920
Well, turns out, you can just put the grid anywhere, the radio can just assume some random synchronization, let's say it assumed here, right in the middle, right?

16:05.040 --> 16:19.020
So it would still be getting the same symbol, if this is 0, this is 100, then it would be getting 50, 50, 50, 50, so the radio just sees, when I got the same symbol many times in a row, 50, 50, 50, 50, then I know I'm in a preamble, and the symbol was 50,

16:19.020 --> 16:21.640
then I know I need to move it this much back.

16:22.900 --> 16:24.500
That's how it synchronizes, right?

16:24.500 --> 16:37.440
So it's actually, I can imagine how they've implemented the syncing in that fashion, by looking for repeated symbols, getting that symbol that was repeated, and then translating the synchronization window back to the right position.

16:40.200 --> 16:54.060
This talk is really good, it goes really deep, and he does experiments in MATLAB showing why and how LoRa works below the noise floor, and highly recommended for the demodulation part, he goes really deep.

16:54.120 --> 16:55.980
Visual Electric, it's on YouTube.

16:57.200 --> 17:04.900
You can, oh, I should mention my slides here are on my GitHub, so you can go and click the links from there.

17:05.840 --> 17:09.420
Okay, encoding, so I think I've got to move a bit faster now.

17:09.420 --> 17:13.680
So we've talked about modulation so far, right?

17:13.680 --> 17:16.600
We're getting from radio signals into some kind of numbers.

17:16.600 --> 17:18.320
So what happens with these numbers?

17:18.320 --> 17:21.080
Well, let's talk first about what would happen when we're sending, right?

17:21.080 --> 17:25.420
So first, it adds a cyclic redundancy check, it adds some error detection, right?

17:25.420 --> 17:31.340
A hash, just a couple of bytes at the end, just to see, like, did the end result turn out right?

17:31.440 --> 17:51.660
It does what's called whitening, so that's, like, it just combines with a known sequence of not random, but pseudo random numbers, so every radio would get the same sequence, but the sequence, like, doesn't have any repeated long run of zeros, so that ensures that there will be nothing like the preamble anywhere in the payload,

17:51.660 --> 17:55.400
because then we wouldn't be able to, you know, then the preamble isn't that unique, right?

17:55.400 --> 18:00.080
So the payload could never contain this repeated sequence of zeros.

18:00.300 --> 18:11.980
Then it does some forward error correction, it adds some extra bits that it could use to fix if there are errors, like, it can, yeah, do error correction, I'll leave it at that.

18:11.980 --> 18:28.520
It does interleaving, so it spreads bits from your individual bytes over different symbols, because then that way, if one symbol was slightly misread, then maybe we haven't lost a whole chunk of bytes at least, so that way we can better recover later.

18:28.920 --> 18:35.180
So, like, maybe the forward error correction will help us recover if just, like, one of the symbols were a bit off.

18:35.180 --> 18:37.840
And then gray coding, so that reduces the impact of errors.

18:37.840 --> 18:47.560
Gray coding is kind of like binary encoding, but numbers that are close to each other have fewer, have not very many bytes apart, sorry, bits apart.

18:47.660 --> 18:50.600
This is because, like, you might misread the signal slightly.

18:50.600 --> 18:56.000
If it was with binary, there'd be a big difference between the number 63 and 64.

18:56.000 --> 18:57.340
Like, there's a lot of bits that are different, right?

18:57.340 --> 19:01.240
So if you misread it slightly, you'd be completely off, like, your bits would be completely off.

19:01.240 --> 19:06.600
With gray coding, you might still be able to recover with the other techniques with the forward error correction it's on.

19:06.840 --> 19:09.420
All right, so let's move to GNU Radio to see this.

19:11.880 --> 19:26.920
So I'll do a real quick walkthrough of my GNU Radio flow graph here, receiving the signal from my hackerf, moving the signal down to baseband, down to zero, filter it, because the following blocks expect it to be around zero.

19:27.880 --> 19:41.860
And then frame synchronization, so that's what I was talking about, like, looking for the repeated sequence and then moving, and then it's like, what comes out of this flow graph is, like, only when it's found, when we're past the preamble and the down chirps,

19:41.860 --> 19:45.360
then it starts flowing out this flow graph.

19:45.540 --> 19:55.120
And this and all these blocks were a guy called Joachim Taperl, he made the open source, these blocks that are pretty decent.

19:55.120 --> 20:00.900
I tried myself, it was a lot of work, so I ended up using his blocks for the decoding and demodulation.

20:02.920 --> 20:16.660
So demodulation, gray mapping, interleaving, all those I just talked about, so the signal flows through all these blocks, de-whitening, that was the de-scrambling to avoid the long run of zeros, checks the CRC, then does some parsing.

20:16.660 --> 20:24.840
This is some code I made, just some pretty basic Python code I'll show you in a minute that does the mishtastic decoding.

20:24.840 --> 20:25.860
So it gets bytes.

20:25.860 --> 20:26.940
At this point, we're at bytes.

20:26.940 --> 20:28.080
Actually, we're at messages.

20:29.360 --> 20:34.500
So chunks of bytes come into the Python code, and then we can decode that.

20:34.500 --> 20:35.500
I'll show you that in a minute.

20:35.500 --> 20:40.320
Um, yeah, I'll just, let me just run this real quick.

20:42.560 --> 20:46.280
Oh, the device is busy because I still have GQRX open.

20:46.280 --> 20:47.380
Let's close that.

20:51.170 --> 20:53.810
So that was what I was showing in the beginning before I started.

20:53.810 --> 20:55.850
I'll just open the console window I launched this from.

20:55.850 --> 20:57.890
So right now I've set it, let me stop it again.

20:58.270 --> 21:00.950
I've set it to print out the symbols, that's what we see up here.

21:00.950 --> 21:10.270
The demodulation got the symbols, in this case, the mishtastic configuration for Defcon uses a spread factor of seven.

21:10.370 --> 21:19.230
So that means, like, that's, like, how many numbers could there possibly be between the bottom and the top of the chirp, right?

21:19.230 --> 21:21.310
So two to the power of seven in this case.

21:21.310 --> 21:29.050
So that's, oh, that should have been, instead of two to the power of seven, not two to the power of seven, it's just that two to the power of seven is 128.

21:29.050 --> 21:31.790
So we'll get symbols between zero and 128.

21:31.790 --> 21:35.250
So that block that's printing out the symbols gives us that.

21:35.250 --> 21:37.510
It gives us numbers between zero and 128.

21:38.290 --> 21:39.470
127, rather.

21:39.470 --> 21:40.670
Zero and 127.

21:41.170 --> 21:41.950
All right.

21:41.970 --> 21:46.490
So that's some basic walkthrough of the GNU Radio flow graph.

21:46.570 --> 22:00.030
And then I'd highly recommend this talk by a fellow called Matt Knight, who's here in the audience I know, who I think was the first person to reverse engineer the LoRa decoding, all of the gray coding and the scrambling stuff I was talking about earlier.

22:00.030 --> 22:02.210
That stuff, you can't really read it anywhere.

22:02.210 --> 22:03.810
You have to do a lot of experimentation.

22:04.010 --> 22:12.030
And this talk walks through very well how they arrived, and I think they were the first to reverse engineer, how they arrived at the perimeters that are actually used here.

22:12.030 --> 22:13.710
So highly recommend that talk.

22:15.130 --> 22:17.630
So there are different modem settings, like I mentioned.

22:18.290 --> 22:20.490
So this is like in the Mystastic source code.

22:20.490 --> 22:29.050
You can go there and you can look up modem setting different presets for what modem settings you want your LoRa radio configured at.

22:29.690 --> 22:30.770
This is one example.

22:30.770 --> 22:34.330
Like I said, this is popular in the Bay Area Mystastic network.

22:36.150 --> 22:41.170
So we've talked all about demodulation, all about LoRa, and we have some bytes now.

22:41.170 --> 22:43.910
Now we're at the application layer, Mystastic.

22:43.910 --> 22:55.330
So the bytes of a Mystastic packet consist of first a 16-byte header, where it is like a destination, sender.

22:55.330 --> 22:57.190
There's like, channel does this belong to?

22:57.190 --> 22:58.770
That's kind of a funky way to do that.

22:58.770 --> 22:59.990
I won't go deeper there.

22:59.990 --> 23:01.950
And then there's a payload, which is encrypted.

23:02.970 --> 23:11.210
And yeah, you can click here to see the protobuf definition for this top-level encrypted chunk of payload.

23:11.490 --> 23:14.990
But I think it's more interesting to let's look in Wireshark.

23:14.990 --> 23:16.550
So I'll start this again.

23:17.670 --> 23:23.430
And what I've done is I've rewritten, I've written a small, oops, let's close this.

23:25.550 --> 23:27.090
Open Wireshark.

23:27.630 --> 23:35.570
My new radio flow graph ended up, oh I should say that, it ended up with just dumping the bytes out on UDP.

23:35.650 --> 23:45.990
So then I've written a small, I've set up here Wireshark to listen on UDP, and written a small Lua disector.

23:45.990 --> 23:53.050
In Wireshark it's really easy to make your own extensions for how to decode a packet, how to dissect a packet.

23:53.230 --> 23:55.610
So I've made one for Meshtastic.

23:55.990 --> 23:56.970
So we can click on it.

23:57.350 --> 24:00.730
Here's an interesting, here's a text message that was the most interesting, I think.

24:01.770 --> 24:03.550
We can look at here.

24:03.710 --> 24:05.710
This is what Wireshark really shines at.

24:05.930 --> 24:12.730
You can click on different bytes of your package and it'll tell you, it'll highlight what was that.

24:13.730 --> 24:15.550
You can click the other way as well in the tree here.

24:15.550 --> 24:16.750
This is the destination.

24:16.750 --> 24:22.030
There's the sender, there's a packet ID, there's some flags about how many hops can we take.

24:22.350 --> 24:27.310
We don't want it to circle around forever so it decreases the hops every time it relays a packet on.

24:29.370 --> 24:30.710
Channel hash and so on.

24:30.810 --> 24:36.130
These first are the 16 bytes of header that are plain text.

24:36.130 --> 24:38.530
And then comes the payload which is encrypted.

24:38.730 --> 24:44.550
I've done the decryption over in my Python code that was in the new radio flow graph because that was too difficult to do in Lua.

24:44.550 --> 24:49.090
So it's already decrypted by the time it reaches my setup here, my Wireshark setup.

24:49.570 --> 24:54.410
So payload says that the message type, what they call a port number, is a text message.

24:54.470 --> 24:58.470
Actual payload is a text message, someone sent Weep.

24:59.550 --> 25:12.730
Node info, most of the things that go there aren't just node info, like nodes transmitting their name, short name, long name, which hardware model it is, the public key if you want to send them an encrypted direct message.

25:14.030 --> 25:18.770
So yeah, that's the basics of the packet.

25:18.770 --> 25:22.310
Okay, so we're getting close to time so I'm going to go a bit quick now.

25:22.530 --> 25:26.450
The last bit, I'll skip past this.

25:26.450 --> 25:30.450
Encryption, yeah, it's a normal AES-256 encryption, the keys are pre-shared.

25:31.430 --> 25:33.610
Transmission you might be interested in.

25:33.790 --> 25:41.910
So could be done by an SDR, much easier just to do with an Arduino that already has a LoRa radio built in, so that's what I did.

25:42.150 --> 25:49.810
Like I showed you before how the bytes are not that complicated and the keys are already pre-shared, so why not?

25:49.950 --> 25:53.490
Why not transmit like not using their firmware, just writing your own.

25:53.490 --> 25:54.810
So that's what I did here.

25:56.490 --> 25:59.570
Actually, real quick, just show the code.

26:00.150 --> 26:02.410
Here's my little sender.

26:03.750 --> 26:13.190
Set a few constants here, like what I want my address to be, what the destination should be, broadcast in this case, channel name, scroll down a bit.

26:13.190 --> 26:15.550
Here's the real interesting part, build a packet.

26:15.550 --> 26:31.930
So it's first using protobuf here to build a packet, get some bytes, data plane, packet ID is random in this case, encrypt the packet, get a packet, like append this header which consisted of these bytes here.

26:31.930 --> 26:43.010
There's like the three 32-bit integers, destination, sender, packet ID, followed by four one-byte fields, the flags, the channel number, and a few other fields.

26:43.010 --> 26:44.150
Then you get your packet.

26:45.070 --> 26:52.770
I wrote a little Arduino program that just receives these simple commands where you just write your data in hex and then it sends it out.

26:52.790 --> 27:02.150
So if any of you have your MISTASIC device open right now, I'm going to send a message, I'm going to send a few sweet potatoes.

27:02.150 --> 27:14.730
I'm writing sweet potatoes because that's kind of sweet, it's kind of nasty what I'm doing here because I'm skipping the whole protocol of MISTASIC, I'm not adhering to what you should normally be doing as a sender on this.

27:14.730 --> 27:21.070
You should normally have carrier sense, multiple access, collision avoidance, like you shouldn't be transmitting on top of somebody else.

27:21.070 --> 27:28.510
We're not doing any of that right here, we're just bypassing all of that, not following the protocol of, you know, relaying on messages that were supposed to be relayed on.

27:28.510 --> 27:30.130
Did any of you get the message?

27:33.250 --> 27:33.790
Not?

27:33.790 --> 27:35.010
Oh, okay, let me see.

27:35.190 --> 27:36.490
Did I comment that out?

27:36.510 --> 27:37.790
Oh, I put it on the wrong channel.

27:37.790 --> 27:38.770
Let's set it on the

27:43.210 --> 27:46.490
DefConnet channel.

27:50.020 --> 27:50.680
You got it?

27:50.680 --> 27:51.440
Okay, great.

27:56.880 --> 27:58.440
Almost done, yeah, almost done.

28:02.280 --> 28:03.780
So you could do things like this.

28:03.780 --> 28:06.440
I haven't done this before because it's kind of nasty to do.

28:06.440 --> 28:06.940
You see what I'm doing?

28:06.940 --> 28:09.780
I put a loop around the send, a little sleep.

28:10.520 --> 28:12.340
This is nothing really preventing us from doing that.

28:12.340 --> 28:13.700
This is our airwaves.

28:13.700 --> 28:16.500
This is unlicensed spectrum.

28:16.820 --> 28:18.960
So are you getting a bunch of messages?

28:21.300 --> 28:22.240
This one so far?

28:22.240 --> 28:24.600
Okay, maybe the receiver app filters out of it.

28:24.600 --> 28:26.460
I hadn't tried this kind of spamming before.

28:27.000 --> 28:27.820
I'll stop it again.

28:27.820 --> 28:28.740
You get the idea.

28:30.320 --> 28:31.000
Yeah.

28:31.860 --> 28:32.680
That's it.

28:32.880 --> 28:36.400
We're past time, so there has to be one question, I think, at most.

28:37.120 --> 28:37.920
Thank you.

