For those of you who don't know who this man is, what are you doing in this room? Seriously, if you have any interest in radio or anything like that, if you don't know who he is, you need to watch this, enjoy it, and then leave and just get on Google, find all the rest of his talks. This man has done everything from printing upside-down pictures of people's faces on the waveform that I was trying to decode through controlling 30-year-old space probes, which I'm not certain, was it launched before or after you were born? Before. The man is quite impressive. He's taken over things in space that were launched before he was born. I really don't know what else to say except for listen to everything he has to say, because I need to sit down and do the same. Thank you muchly for that introduction. Very kind. So thank you for attending and coming out today. My name is Balint Siva. I work at Bastille Networks. We're securing the Internet of Things. And today I'd like to... I'd like to go on this workshop with you to actually go through and show you some tools and tricks and techniques that you can use with open-source software, GNU Radio, and software-defined radio hardware to begin to reverse-engineer signals. So the idea is that you have something out there that you see on your spectrum, something that looks interesting. It might be coming from a terrestrial source. It might be coming from a satellite. And you have no idea what it is. There's no information about it. You can Google around. But what have you got to search for? What keywords? So the idea is that you can apply some pretty common little tricks. I'll show you what they are in GNU Radio. And you can go out, apply them. And once you learn a little bit more about the data, the modulation that you're looking at, then you can go and do some additional research about that on the Internet. So what I'm going to do today for those people that actually have their SDR set up with GNU Radio is I have recorded some signals off the air. And I will... I am actually now rebroadcasting them over the air. Well, let's just say if I'm being recorded, then I would ideally be transmitting them into a dummy load. So if you want to record anything, then you should be really, really close. But let's just say if you wanted to try and see if there was a signal there, I think 622 megahertz looked unoccupied at the moment. Yeah, something like that. So just a moment ago, I was running... So this is... Who's actually heard of or familiar with GNU Radio? Just a show of hands. All right, everyone. So everybody's seen GRC. Does anybody not entirely show what GRC is? The GNU Radio companion is a graphical user interface that sits on top of the GNU Radio runtime. And it's used to actually generate the Python code that invokes GNU Radio. So GNU Radio, all the performance stuff is written in C++ and assembly. And then you've got Python code that can be used to glue everything together at the application level. And then you have this GUI also if you want to attempt to run things there. And what's happened here? Naturally, the curse of the demo has struck me right away. Why didn't that work? Huh. Amazing. What happened there? I haven't been very lucky this week. Whoa. All right, never mind. We'll skip that. I just wanted to show you the radio spectrum. But maybe instead I can run... Communications error. So I'm just going to bring up the radio spectrum now. Ah. I know what's going on. The problem is... And this can happen sometimes when you have multiple SDRs connected to the one computer. You don't know what it's going to pick up. I actually have a B200 and an N210 connected. And I think it was trying to use the N210 and failing because it can't quite support the bandwidth. So let's give that one more go then. Where's my GNU Radio? There we are. There we go. All right. So if we go to 622 mega... Oh, that's sample rate. Probably can't go that high. Let's go to 2010 megahertz sample rate. And if we go to 622 megahertz, then can you see this central portion in the band there? There are these interesting signals there. If we now take it down to 1 megahertz, you can see we've got this spectrum here, right? And as it happens, I have recorded this at some point many years ago now, actually. And if you want to try and receive this signal, it'll be there. So I will try to increase the amplitude so that you can get a good clear capture of it. And this signal, as it turned out, was actually coming down from one of the transponders. On a satellite in geostationary orbit above Australia. I had a friend, and he had a dish pointed up at this particular bird. And the set-top satellite decoder boxes with which you use to watch satellite television has one of those LNB through ports on the back. So the dish has a low noise block down converter, and you get the down converted signal coming out the back of one of these boxes. And I thought, well, hook a USRP up to it, and then actually see what else is coming. And it's actually coming down from the bird. So, if we have a quick look at this presentation here. This one is an old one that I put together. And you can have a look. It's on my website. But this is sort of going to be the basis for what we're going to do today. So, a lot of satellites up there are actually known as bent pipes. So all they do is they receive signals from the ground, and then re-broadcast them back down to the earth. So, in a lot of instances, you might have various VSAT terminals or small transmitters that will transmit up to this satellite in geostationary orbit. It receives a signal like, in fact, transponder, certain satcom transponders on planes. You might think of MH370. It's come back into the light of the news lately. And they're sent back down and usually received at a central location. So, apart from just being a bent pipe on all of these transponders, on a satellite, they also send down telemetry. They send out information about the satellite and the health of the satellite. And they're also accepting commands from the ground station to change various subsystems on board. So, this is the particular satellite that we were looking at at the time. These are the uplink and downlink frequencies. Lots of transponders they use for TV, but some other interesting narrowband things. And if you look up the public manual for the satellite, it actually gives you the spot beam coverage for the continent that it's facing. It also gives you the band plan of the channels on the transponders. And they actually went to the ground station, so you can get pretty pictures of that. And if you go and look at your frequency regulatory authorities database, you can see that it's actually... got a whole bunch of point-to-point links and other frequencies allocated for television, digital television. And what do you know? They went into the ground station itself, so you can see what sort of modems they're using. So, once you actually have a look and zoom in, do a bit of analysis there, you can quickly figure out what style of modem they're using, get the manual, see what kind of tracking receivers and control systems they're using, read those manuals too, so you can do a little bit of background recon regarding the systems that might be in use. Yes, question? I didn't get in there. CNET got in there, and they published the photos publicly online. I mean, I'm sure they probably had to get permission and it was all vetted, but it was by accident that I found it. It was just interesting to see what information could glean from that. And as I did this research, I quickly discovered that there are particular protocols, particular scramblers, particular forward error correction processes that are quite common to satellite links. So, it gave me a good idea on where to start. So, to actually receive things, you need the satellite, a satellite dish, a low-noise block, down converter, because these signals are up at 11, 12 gigahertz, you want to get that down for something that a software-defined radio can actually receive. This is an example. One of them, if you're doing narrowband stuff, you want to get something with high stability so that your signal doesn't move around that much. A lot of the cheap dishes that you can get, that you mount on the side of the home to just receive television, they're very cheap and then don't have a very stable local oscillator later inside. But that's okay because the signals that are coming down for TV are very broadband. And if you have a very broadband signal, then your receiver can actually lock onto that signal and track it as it moves around due to the instability in your oscillator. If you're looking at very narrowband stuff, then that's harder to track if it moves around a lot. So, you need to pay extra for one of these. And then you can do some more googling around. I found that this Optus D1 bird might have had this sort of telemetry transmitter. It says it's using phase modulation, so that's another clue. And this is a picture of the telemetry there. We'll come to that. We'll come to the visualization too. And then, so what we're going to go through is actually decoding one of these interesting narrowband transmissions that I found from the bird. And we'll go through each of these steps to try and get at the raw data. And then eventually, once we get there, we'll talk about phase shift keying and scrambling and forward error correction. And we're basically going to go through this process that I'll demonstrate to you. So, I know that we have two hours blocked out. I've created a very ambitious schedule, and I'm sure we're not going to get through all of it. But if we can, I would have liked to get to a point where we reconstruct some of these flow graphs. Wrong way. So, we're going to try and look at that satellite downlink radar over HF and what that looks like using fast autocorrelation to discover periodic components to signals and then help ID them. So, that applies to the radar as well as to digital radio mondial, which is an OFDM narrowband transmission over HF. And that is used to actually broadcast digital audio around the world over very, very long distances. And then look at actually the beacon, the telemetry beacon coming down from that satellite and how you can create a flow graph to do that. So... We'll get started on that. Any questions so far? All right. All the people that are participating have got their receivers set up. Have you been able to tune to that frequency and you can see signals? Yeah? Okay. All right. So... Let's have a look at what's going on here then. I'm going to cheat a little bit, and I'm just going to replay it from a file. It's the same file that's going out. But I'm just going to replay it from a file here. So... What we'll do is we'll try and do things from first principles. And please, at any stage, if you have questions, then just shout them out, and I'll repeat it from the mic. I must say there's a guy here that's just stepped in the room. I have to point him out because he's an absolute legend. How are you going, Anders? This guy here helped me out big time last year at DEF CON. We were sitting in the Penn & Teller Theater, and there was a huge line. It was really difficult to get in, and we'd camped out, and we finally got a seat. And I got a call from my friend, Austin Epps, who was the lead engineer on the ISE E3 reboot mission, saying that one of the science experiments needed to be rebooted. And, of course, you don't get on the Wi-Fi at a place like this. And I need to SSH in to the computer that we left at the Arecibo Radio Telescope to send commands to the satellite to reboot this thing, to bring the flyby. And we only had a limited amount of time, and we were getting valuable science data from a particular solar science data recorder. And I didn't know what to do. Unfortunately, I had no cell reception, so I couldn't tether to my phone. But I was sitting next to Anders, and we were talking about SDR. And he said, Oh, look, I've got a phone here with tethering capability. I thought, ooh. I sized him up. He seems like a good bloke. I'll trust my judgment. And he was nice enough to let me tether to his phone. So we actually ended up communicating with the space probe flying toward the Earth at 4.2 kilometers a second, first from a laptop tethered over Wi-Fi to his telephone, then from his telephone over the cellular network to the core network, and then out an IP gateway to a laptop in Arecibo through SSH that was then connected to the Red Telescope via software-defined radio sending out at 2 point whatever gigahertz commands up to the boat. So thank you very much for your help there. That really pulled me out of a tight spot. It's generosity like that in the lack of reliable Wi-Fi that really makes it all worth it. So thank you. All right. So that file that I've got playing over the air is actually, I realized, I might actually use this because I need two hands. How do you operate this thing? It's mechanical. It's going to be too hard. All right. I'll just make do. So what we've got is we've got this WAV file. And usually, when you've got a WAV file or a CAPTCHA file, you need to know what sample rate you've recorded it at. And I know that I recorded this one at one mega sample per second. So you can put in a million. I generally like to do a bit of a shortcut. So you can go int 1e6, like that. And that gives you your sample rate. If you're capturing, you can probably sample at one mega sample per second because the original CAPTCHA is like that as well. So in this case, I've got a WAV file. It's a WAV file because I actually like to use HDSDR, which is this app. This is actually running under Wine on my Mac, but you can run it natively under Windows, and you can also run it under Wine on Linux. And with some trickery, you can connect them to all sorts of different software-defined radios too. So there's XIO plug-ins. I wrote one a while back, and it supports USURPS and RTL and FunCubes and UDP streaming to GNU Radio. There are other ones there that are sort of newer for RTL and things like this. But if you were to find that file and play it back... Is it this one? No. This one. So this is the file. This is what it looked like when I was originally recording it, and you can see all these narrowband signals there coming down. I thought, hmm, it would be interesting to try and figure out what these actually are and how the data is encoded and how it's modulated. And if this was coming in live through, say, a USURP, I would click record, and it will record this WAV file. Similarly, you could use other utilities like RxSamples to file, and that would just give you a baseband capture file the same way. But here, because we've got a WAV file, we have INQ. It's a complex recording. So we want to turn that into something complex. So we go float to complex. And we can hook that up easily like this. And because we're also playing back from a file, we're not actually using any hardware in the loop like a USURP or an audio card. We ideally want to use a throttle to make it look like it's a live stream. If you don't use a throttle and a flow graph, the flow graph will run as quickly as it possibly can because there's nothing supplying any back pressure. There's nothing with an external hardware clock to impose a rate across the entire flow graph. So sometimes you want flow graphs to run as quickly as they possibly can because let's say you want to process a bunch of files, in a batch system. There you don't want to be IO bound or anything like that. You just want it to be CPU bound so it runs as fast as you possibly can. Here we want it to run in real time. So we do that. So now you can just grab... Tim, where are you? So Tim O'Shea here, I should point out, is a very integral member, part of the GNU Radio development team. He's going to be speaking later on some interesting stuff. But he's made enormous contributions to GNU Radio. Really, really clever guy, done some amazing stuff. And I've got to apologize, especially to you. I'm still going to use WX today. So GNU Radio supports two different sorts of GUI frameworks for displaying stuff on screen. One's QT. This is the new world order. It's really nice, but I just happen to be old school and I like WX. So I'm going to switch it to WX. Now, you can drop in one of these FFT sinks, hook it up, and just run this. And we'll call it... And there, once again, we have that spectrum that we saw, both in HDSDR and that you guys should see on your laptops. So that means we're correctly now decoding this WAV file. The next step of this is that we want to actually focus in on one of these transmissions. So this is essentially step one. This is known as channel selection. And what you can do then is you can use what's called the frequency translating FIR filter to narrow in on a particular signal of interest. So what I'm going to do is I'm going to leave the main one there, and then I'm going to get this second FFT, hook this up. But we need to figure out how much we're going to decimate by. Because remember, initially we started with a one mega sample per second stream, and we want to narrow that down to a much narrower bandwidth. So I'm going to just completely guess and say we're going to decimate by 20 and end up with a particular sample right there. So if you like to use GNU Radio Companion, then I highly recommend you get in the habit of using variable blocks. Because what variable blocks let you do is put in, these little expressions. And so when you change something somewhere in your flow graph, you only need to change one parameter once, and that'll ripple through the rest of your flow graph if you put these expressions in your variable. So instead of hard coding in numbers all over the place, if you think, oh crap, I've got to change that sample rate, if you have it in one variable and reference that everywhere else, just like in a normal programming language, then it makes it really easy to continue development and update things properly. So in this instance, what I've said is, I want to have a baseband rate of 50 kilohertz, right? So I'm going to go from a one mega sample per second down to 50 kilohertz. And that means that if you calculate your decimation factor, then that's the original sample rate, which is one mega sample per second, divided by 50 kilohertz. So that gives you a decimation factor of 20. And so for the translating FIR filter, you put in a decimation like that. Now the second part of the frequency translating FIR filter is that, sure, you can squish your narrowband stream right down, but you need to filter, because all of the other content in the original capture file will then wrap around inside that. So one very important part of interpolation decimation is filtering. And so what you've got to do is you have to define your filter taps, and that defines essentially how your filter's going to work. What we want to do is we want to use a low pass filter. And Canoe Radio's got this cool filter design tool. I don't know if that works on my Mac, actually. Oh, it does. Right? And I'm not going to use this too much, but what you can do is you can actually use it to design and analyze filters. So here we have one. We're going to bring this up. We said we have a sample rate of 32K. We want the pass band to end at... What's that? 5K. Stop band at 6. And it will actually visualize the roll-off of your filter and the ripple, and you can look at the taps, the phase response, get the filter coefficients, and you can design all sorts of different types of filters here. So they're really, really handy. I'm not actually going to use this now, but just something to keep in mind as you go and use the utilities. That's just in tools, filter design tool. By the way, Tim, if I've missed anything or you can think of anything to add, just shout out. So in this case, I'm going to need some taps. And what I'm going to do is I'm going to... I can't see that. I'm going to use a variable. Right? I'm going to call it taps. And the value here is not just a number. It's actually calling a function. So within GNU Radio, there's a module called the FIR Designer, and that has a function called low pass. So what this is going to do is it's going to generate the taps for a low pass filter given these arguments. Now, you can go and look in the documentation. It's all there, but the first one is the gain. So I'm going to leave it at one. The second one is the incoming sample rate. So we know that's one mega sample per second. So we use that. And then the last one here is the transition bandwidth, which means over what gap you want your start... the end of your start band to go to the beginning of your stop band. So we just pick an arbitrary number there. One kilohertz is fine. And then this third value here is the translation... I just call it the translation bandwidth. So it's actually what the bandwidth of the filter is going to be. And because I have that as a variable there, it means that we can control it when the application's running. And I'll show you what that looks like. So we put that in there. Click OK. And then also, I've got here a slider now, which is called translate bandwidth. And the minimum is zero. The maximum is the base band rate. So it's zero to 50K. And this means that we can actually change the low pass filter while it's running. And the second one here I've got is the translation frequency. And this is the frequency that we're going to shift the original recording to, which is going to be the new base band signal. So let's run that and see what happens. Python quit unexpectedly. Oh, what does it say there? Terminating with unexpected exception of type buffer add reader N0 preload must be greater than zero. What am I? Oh, you know what it is? Um, bandwidth, this should be... Oh, I didn't set the taps. So we have that variable taps, but I never actually used it. That would do it. So I'm going to put taps in here. Now, one cool thing in GNU Radio is that when you enter in variables and expressions here, you can hover your mouse over that particular field, and it will give you a tool tip that will evaluate what's in that field. So you can see the decimation is 20. The taps, it's actually run the code, right? It's run that low pass function, and it's returned those taps. It's not showing you all of them there, but it's just giving you a preview. So now let's run it. Where's my GUI? There we go. Ah, there's one other thing I forgot. This gets me all the time, too. When you just drag GUI blocks in, it's really important that you actually check what your incoming sample rate is. Notice that here, it was valid to have one mega sample per second because it's coming from the original source file. But actually, we've decimated here, so everything after this has a sample rate of... Yeah, and what's the variable name for that? Somebody set it over here? BB underscore rate. Right. So now... No time to charm. So now at the bottom here, we have our original one-meg incoming signal, and you can see that it's from negative 50 to... 500 to positive 500 kilohertz. And here, we've got nothing because our translation frequency is actually zero. So now if we move the slider... It's not going to do anything because I haven't actually added that variable in here either. So now when you change the slider, it's going to change that value. All right. Here we go. So if I move the slider across a little bit, you can see there, there's a particular signal, right? That's one of the narrowband signals, and I can keep moving that, and you get to the next one, and you get to the next one, and you get to the next one as you go through the band. So they're all there. And what this has allowed us to do is now zoom down into one of those, and we can analyze that further. Now there are a couple of other little tricks you can do. The first thing is that here, we know that the variable is called translation frequency. And what we're going to do is we're going to copy that, and in this GUI sync, we're going to set the variable here so that when you click on a particular point in the GUI, that's going to program the frequency. Now in addition, in the... I've modified GNU Radio a little bit, and this is all on my GitHub if you want to download it, but we need to maybe get this stuff merged even though it's WX. But... There are these extra options here. So you've got frequency of interest. So we're going to put this in there as well. And now when we run it... Check this out. See the green line here? You can click, and it will take the slider there and also the translation there. So now wherever I click is going to be where we're actually decimating to. And that's nice. It makes things a little bit more interactive and easy to do. Now the problem is when we close this, every time we run it again, our variables are going to be back to the defaults. And that's okay in certain situations, but in other situations, you want it to be persistent. And there's actually a nice block to do that. So if you look up in your tree, there's the variable config block, and that actually allows you to persist variables between runs. So the way it works is that you give it a configuration file. So I'm going to call this qpsk.txt. You can give it the section that you want to store it in the file, the option. So we're going to call this xlatefreg. I highly recommend for strings as general practice to always wrap them in single quotes. Otherwise they might get interpreted as stuff. And so the idea is that we want to write back the last value that it was set at, so we use this. And we're going to just by convention call this config xlatefreg. And when you run the flow graph, it'll load this variable up with whatever was stored in the file. So then the default value for the slider becomes instead of bvrate, it becomes... Oh, not the bandwidth, sorry. This one. Instead of zero, it becomes what we had in the file. So now when I run it, I can click over here, say on this one, and this is going to be remembering this offset now. So that's good. So the next step is we've identified the signal, and what we want to do now is try and figure out what kind of modulation it actually is using. Now, often on the ground, there are all sorts of modulations in use, but because this is a satellite link, often for satellite links, PSK, phase shift keying, is very popular. It's nice and simple, and one thing that is distinguishing about space links with satellites, unlike the Earth, is that because you're pointing directly up and the beams are coming directly back down, and there are no, for example, buildings in the way, you don't really have to worry about multipath. So these sorts of single-tone modulation schemes work quite well. On the ground, that's not the case. If you think about this sort of thing, it's a sort of urban environment. There are buildings everywhere. There are urban canyons. The signals are going to bounce around off all sorts of different things. You're going to get lots of RF reflections, and they're all going to destructively interfere at your receiver and degrade your signal. That's why in modern modulation schemes, OFDM is pretty much the scheme of choice because it's well designed to be equalized at the receiver so that your receiver can actually take into account that multipath, do some fancy processing, and recover a good signal. Not something you have to worry about for satellite links. So the next step is, we're going to take a wild guess that this might be some sort of phase shift keying. Now, with phase shift keying, you can have BPSK, QPSK, 8PSK. It basically determines the number of points in your constellation. But we don't know what they are, and there's a really easy technique that you can use to figure out what the order of your phase shift keying actually is. And I'll show you what that is. But the first thing is, we need to clean up our user interface a little bit. So I'm going to add a notebook. Can you do, Tim, can you do notebooks or equivalent in QT? What? All right, okay. So I'm just going to give these things some names. First one we're going to call it cap, and the next one we're going to call it BB, and the next one we're going to call it power. And then down here, you can put the notebook. So I'm going to call it MB0, and call the notebook NB. And then this one we're going to put in NB1. And then we're going to use another FFT, and we're going to put that in NB2. Now there's a really neat trick you can do with PSK, which is multiply the signal by itself a certain number of times. So basically you raise each sample to a power, and when you get nice peaks popping up out of your FFT, you've identified the order of the modulation. So you can square it, and if you get peaks, it's BPSK. If you raise it to the power of 4, and you get peaks after an FFT, it's given to you. So it's BPSK. If you do 8, then it's... Right, easy. So if you have GRBAS installed, there's a block there called the power block. And if you don't have that, then you can cheat, and you can basically just do... do this. Right? So you'll end up having the same signal going to each of these ports, if you want to raise it to the power of 4. But we're not going to do that, because we don't want to restart the flow graph. This one, you can actually change it at runtime. So I'm going to add a slider now, so that we can change the power of the exponent. So it's going to be 1 by default. We're going to go from 1 to, say, 8. And then... Why is that complaining? Oh, it's blacklisted. Of course it is. So now we just basically take that off our original signal, put it into an FFT like that, and then run. Now, because we've got the config there, hopefully it remembered our channel selection from last time, which it has. There you go. Baseband is there. And then we go to the power. Now, we've raised it to 1, so we should get exactly the same signal. But if we do it to the power of 2, it's disappeared. Can anybody tell me why it's disappeared off the current chart? Think about the values. I'm taking the samples, and I'm raising them to a power. What kind of... Pardon? Scale. Scale, yeah. Small number gets way smaller than spread. That's right. Small number, we've raised it to a power. It's going to get much smaller. So, luckily, it's still going to be there, so we auto-scale, and it's there, and we average it. You can see that it pretty much has the same sort of shape. We're not seeing any peaks, so it's probably not BPSK. Now, let's raise it to the power of 4. We're not going to check for 3 PSK. So, we're going to go to 4, and turn average off, make it skip along, auto-scale. What do you know? Look at that. We've got some nice peaks there. Now, because our signal here is actually quite narrow band, narrower than the channel we've decimated to, I can drag this slider that's actually changing the low pass filter there, and watch what happens. I can narrow that in to cut out all the noise around our signal of interest, and it's just going to be left with that. So, now if we go to the power, it's also cut it off here. We've got some nice peaks. Now, with PSK, you get these characteristic peaks where you get one large one in the center, and that's really neat because it's almost like it's recreating the carrier that is suppressed normally in phase shift keying. And what's cool about this is that you can actually look carefully, and you see how it's off zero? That's because when I did my channel selection and my frequency translation, I didn't hit the center frequency of this particular signal right on. It's slightly off. So, you can use this as a carrier to track your signal and then mix it exactly back down to base band. So, that's doing some very fine frequency correction. It's a nice little technique. We don't really have to worry about that now because we're going to use a costus loop letter to take care of this. But what's important is that these two peaks on the side of all social networks are going to tone up. So, these three together show you that it's QPSK. And what's also interesting is that although we're slightly off, we can correct for this manually, say, if we have a look here, we're at about, what's that, 800. So, if we get rid of that. Oh, wrong way. Center it up a little bit. And actually, if you look carefully, it's moving around a little bit as well. So, you can test that by turning on peak hold. And if you end up scraping out a bit of peak hold there, it means that actually you've got clock drift. It could be your receiver. It could be the LNB. It could be the satellite. Or it could be the original transmitter on the ground. All these things can contribute to this frequency change. And it's important when you design a receiver to be able to handle this sort of clock drift. And I'll show you how to do that in a minute. But you can see that it's actually drifting quite a bit there. Well, depends upon what you define as quite a bit. But it is drifting. Now, let's just assume that's around about center there at zero. You can mix that down. You've got these peaks out here. Can anybody tell me what would determine how far away these peaks are from DC? Any guesses? Border rate, yeah. So, with PSK, it's really nice because you can actually figure out what the border rate of your signal is. When you don't know anything about our signal, remember, we just saw something interesting. We now know that it's QPSK, and we now know how to actually figure out the rate at which symbols are being transmitted in our stream. So, that's one way, and it works nicely with PSK. I'm going to show you another way that can be used to extract the border rate. And we're going to make a new tab. I think it should work for that, too. I've not actually tried, but I think it should. You know what I mean? It's easy to simulate that in good and great. So, I'm going to make a new tab. I'm going to call it Board. And then what I'm going to do is I'm going to do what is essentially very simple cyclostationary analysis. So, what I'm going to do is I'm going to take the signal and multiply it by a delayed version of itself. So, I'm going to get a delay block. I'm going to set the delay to 1. And then I'm going to get, because we're in the complex domain, you can get the complex conjugate multiply block. Oops, wrong one. Like this. And then hook that up, hook that up to the original stream. And then we're going to take an F50, an FFT of this. But we don't want a complex FFT. We want just an FFT of the magnitude of the output. So, we're going to go complex to magnitude. We're going to discard the phase information from our complex stream. Just look at the bins. Take an FFT. And see what pops up. So, I've got that on the wrong tab there, but I'll correct that in a minute. We bring our low pass filter in again. We've got our nice channelized signal there. But notice here, we're multiplying the signal by one sample delayed version of itself and then taking the FFT of that. You can see the magnitude. And this is the nice effect of actually uncovering the periodicity of the symbols in your original captured stream. And once you take the FFT, you're basically looking at these strong frequency components that'll pop out when you have some sort of periodic timing in your signal. And in this case, you look for the first peak. And you, if we put the mouse cursor there, it's actually at 963333 kilohertz. 9.3. So, 9.6. So, actually, what do you know? What board rate? What common board rate is it? 9600. Board rate. Like the old modems in the old days. So, that's kind of neat. You can get that information out pretty quickly. Now, we can take that a step further. And, and this is where some, a little bit more Gnu Radio trickery comes in. Let's say, we don't just want to be able to put it into an FFT and have to read off a graph and manually look for the first peak. We want Gnu Radio to do all that for us. And you can actually do that with some blocks. And what I want to emphasize is that you can do these sorts of constructions within Gnu Radio, and they're all, as you can see, pretty simple mathematical operations. But I want to emphasize that in this particular setup, we're looking at a streaming continuous flow of this particular channel. In other communication systems, you're going to have bursts of data. And those bursts of data, you might need to analyze as discrete sets of samples instead of in a continuous fashion. So, for that, I recommend that you might consider using something like Boardline. It's getting, growing pretty popular now. I've been using it for years, and Eric Olson, who's the author, keeps adding more features and increasing the FFT process size. And it's even featured on documentaries on TV and things like that. It's getting interesting, making interesting appearances. But it's jam-packed with really lots of advanced tools that make it really an indispensable tool that you can use. And I might also add that in gRBAS, there's a block called the Boardline sink. So, like the QT sink and the WX sink, you can drop one of these blocks in, hook it up to your flow graph. When you run the flow graph, it'll run Boardline and actually feed the samples into it live if you want to do something cool in Boardline. So, if you want to check that out. This here is actually another capture I did off another transponder on that satellite. And what's interesting about this capture is that instead of being those continuous streams like you saw... What are the damn meta keys on the Mac for doing this? Why doesn't it work? Oh no, it's just slow. There you go. That's because... Where is my scroll control? Okay, there we go. So, here you've actually got a bunch of different channels allocated on this transponder, but you have bursts of data coming up from the ground and then being relayed by the satellite. I mean, I'm just theorizing this. I don't know for certain. But what's interesting is that these are all individual bursts, individual packets, and they're in different channels. And you'll also notice that they're of different color intensity. So, obviously, they're different amplitudes. So, you might surmise that actually they're distributed around a wide geographical area. They might be sort of offset pointing. They might have larger distances. So, you get different amounts of attenuation. And so, those packets are coming through and it's some sort of potentially TDMA system, Time Division Multiplexing, for multiple users. And also, you'll note that you have these regular blocks that occur... at the beginning of a packet. So, this is some sort of synchronization signal so that the receiver can lock onto these particular signals that might be coming from different areas because they're all going to have a slightly different frequency offset. So, if you just, in this instance, have a tone, the receiver knows what tone to expect. It can lock to it quickly with a PLL and then have a good chance of decoding the rest of the packet. Now, because they're bursts, having that kind of continuous analysis and it doesn't really work. So, in this case, you'd probably use Boardline, for example. You can select a packet, like so, and then right-click and you can actually go Save Selection As. So, that'll actually allow you to pull that selection out. You can import those raw samples into something like Octiv, which is the open-source equivalent of Matlab, or, like we'll hopefully have time to do a little bit later on, use NumPy and Matplotlib and there are some really nice DSP filtering functions in there. And you can actually then do the same process each step as we've been doing in GNU Radio. So, channel selection, filtering, and then multiplying all the samples by themselves or raising to a power and so on, and then plotting it out and just getting these static graphs. So, I just want to emphasize that you can do all this on a burst basis as well. I won't go through it this time, but just keep that in mind if you want to do analysis like this later on. So, we got up to this stage, but the target is to get, actually, a number appearing on the screen telling us what the baud rate is. How do you go about doing that? So, let's have a quick look at that. I'm going to be a little bit lazy and just copy some of the stuff that I had before. In the interest of time, let's see. Where does this crazy thing start? Right. So, what's happening here is that you'll notice we have our construction here during the cyclostation analysis. You've got the delay, multiply conjugate, complex to mag, and the FFT sink. We did that already. But you'll notice that there's this additional line coming down from the output of magnitude. This is going into the stream-to-vector block. What we want to do is we want to do an FFT. So, remember, when we put this block down, it has an FFT module inside it already that's going to do the FFT, but now we're breaking it out. We're breaking out the raw components. So, we're going to do an FFT manually here that this is already doing. So, when we did that, remember we saw that nice graph with that big peak at 9600. We do the FFT. Because this is accepting vectors, we need to go stream-to-vector and then vector-to-stream. But because we have a FFT of a real floating-point sample stream, you get symmetry. You get a symmetrical spectrum when you do that because it's real and sort of complex. It's just the nature of the transform. So, actually, what we want to do then is we want to throw out half the information because it's just symmetrical duplicate of the first half of it. And to do that, you can use this keep m in n block. So, we had a transform size of 4K, and what we're saying is we want to keep 2,000 of those out of the 4,000. So, we basically throw out the second 2,000 samples. And then once we've got those two, 2,000 samples, which now represent that spectrum that we saw on the GUI before, we go stream-to-vector, turn it back into a vector, get the magnitude because we're just interested in the strength of all those bins. We go back to vector-to-stream. And this is where it gets a little bit interesting because if you... I'll run the flow graph again so you can see. If you look at the FFT, then it's a little bit difficult to see. Maybe you'll be able to tell. But we said find the first highest peak. It looks like this one, right? If you were to search through the magnitudes of all of these bins in this FFT transform, is that going to be the largest peak that it finds? Look over here. You get this very rapid increase toward DC. So actually, there are some very low-frequency components in the signal that are very, very strong, or even up to DC. And so if you were to try and find the bin that has the maximum value in it, you're going to end up finding something down there, which is not what we want. So a little workaround for that. I'm hoping this will sort of get you in the mindset of doing interesting hackery with GNU Radio. The idea is that up to this point, all we've been doing is getting that FFT information. We've been cutting out the second half of the FFT. We've got that bit of information, and we just want to find the bin that has the most energy in it. But we want to ignore those bins down the front near DC, because that's not going to give us the information that we want. We want to look for peaks further out. So what I'm going to do now is I'm going to get this vector source, and I'm going to multiply every 2,000 points, which is one transform, by this vector. So the first 10 elements there are 0, and then the remaining elements, so FFT size 4k divided by 2 is 2k minus 10, are all going to be 1. So effectively you're nulling out the first 10 bins, so you ignore them completely. And then you multiply that by your incoming stream here. You turn that back into a vector, and then you use argmax. And what argmax does is it goes through, and it finds which index into your incoming vector has the highest amplitude. So you're going to go through each of those FFT bins, and you're going to find the one with the highest energy, which is the one that we're interested in. That's going to come out here, maxvec, turn it into a short to float, put it into a number sink, and in the number sink, it would ordinarily just give us the index of the bin, which is kind of useless. We want to know what that is in the board rate in terms of our system. So actually, you need to apply a factor, and that's going to multiply that index by this magic number to give us a board rate. And that's the BB rate, baseband rate, divided by the FFT size. Because if you think about what the transform does, it's normalized ordinarily, but it's 4,000 samples over 50 kilohertz worth of sampling rate. So you basically un-normalize it to get your system rate. And so once you do that, it's just a very basic formula. Once you do that, let's run this. Then, where is it? That's our FFT as you saw before. Then you get your number sink, and it's finding the peak, multiplying it by that factor, and then you get your board rate. Notice that it's not quite 9,600. That's because you have quantization steps now for the bins. If you divide 50k by 2k, you're only going to be going up in steps. But generally speaking, in practice, if you look at these things and it looks very close to a standard kind of number, it's probably going to be that standard kind of number. And that way, you know what the symbol rate is. So that's that step down. The next step is, we want to actually start demodulating this thing. So what we're going to do is we're going to throw in the steps in GNU Radio that you would normally use to decode one of these signals. So what I'm going to do, over here, is put some blocks down. So we know now that the board rate is 9,600. So I'm going to make a variable called board, put in 9,600, because we know that about our system now. And I'm also going to be able to calculate this new variable. I'm going to call it samples per symbol. So that's... What's that? Samples per symbol. Now, who can tell me what this is going to be? How are we going to calculate samples per symbol? If we know the board rate, which is? 9,600, yep. And what's our sample rate at this baseband level now? What's that? Yeah, BBR. And what's that value? 50K, right. So how many samples then do we have per one board? Huh, anyone? Yep. Yep. Okay. Now, we got five. Does anybody see that there's a problem with that number? It got rounded down. Is that a good thing or a bad thing? It's a bad thing, because the timing has to be exact. They don't divide into one another. So this is a common problem with Python. What's the way to get around it? I heard the answer there, but maybe from someone further back as well. Yeah, or you just do one dot times out the front. And now we got 5.20833, right? So this stuff is very important, and these little gotchas can really break your system. So what we're going to do then is we're going to take the signal, again, from our decimated output, and we're going to plug it in to the clock recovery block. Now, in GNU Radio, there's a really nice new block called the PolyPhlase clock synchronizer. I recommend you use that when you're designing a system where you know all the parameters. But in this case, this is an old one, and it works well enough for the purposes of this kind of blind analysis. So I've dropped that in, and it has some parameters there. I'll go through it when I run it just to give you a visual idea of what they do. But basically, this controls how quickly and how tight it will try and lock to a signal. And, you know, in some systems, you want to give it lots of slack. In other systems, you want it to be really tight because you know that it's not going to deviate too much from that. And then the next standard step is that you can add in this costus loop. And what a costus loop does is it accounts for some frequency error in your original signal. So as you saw, remember how we had the peak hold and it was moving back and forth off DC? This thing can then remove that frequency error and remove that frequency offset. And I'll show you visually what that looks like before and after. So what we've got now is the costus loop. This also has some parameters to tell it how quickly to lock to stuff. One of them is the loop bandwidth, and I'll show you that, but we're just missing a slider here. Where's that one here? And what's that? Another little thing you can do is often when you're translating between normalized frequency and the frequency of your app, you often end up using magical constants like pi. You can type in 3.141592 blah blah blah, or you can actually just use math.pi or numpy.pi. But here you can see that it's coming up in red, and that's because there's no math module. So you need to use the import block like so, and then we just go import math. If only it was that simple in real life. Because math is hard. So now with this little construction here, this should, let's see what happens, give us the ability to lock on. So that's actually looking like a dog's breakfast. Pardon? Yeah. So this is not working, and there's a very good reason why it's not working. I haven't quite figured out what that is yet. But really it should look like, here's one I prepared earlier, oh, it keeps appearing on the wrong display. Looks like this. So we knew it was qpsk, so we knew it was order four, and if you actually look in the costus loop, it asks you for the order, and we know that it's four, so we put in four. Done. Clock recovery. Here we came back, ah, that's what it was. Pardon me, I forgot this important step. So some of these blocks can be a little bit finicky. One of them is this clock recovery block, and ideally it always looks for normalized samples. So what that means is in GNU Radio, the idea of a normalized sample is a floating point sample between negative one, and one. That's the idea of normalized. And the clock recovery block is expecting that. This particular block can go into the weeds if your amplitudes are too high or too low. And one way of making sure that your amplitudes are correct is by using an AGC block, automatic gain control. And if you have a look, there are a bunch of different blocks. This one's pretty simple. And you can see here that you've got the rate, so this is how quickly the AGC operates. This is like an arbitrary unit. The reference is the reference level you want to get to. We want to get to one. And the current gain that you start with, and the maximum gain that it can actually apply to your signal. So in that case, it's an arbitrary high number. . Yeah, so there's another AGC block, AGC2, and that has attack and delay values, and that does it a slightly different way. So here, we've got the AGC. Now we're going to connect that up to our original signal. So what I'll do now is I'm going to disconnect this one, and I'm going to show you each step. And sometimes it's nice to do this, but because you've designed part of your flow graph already, you don't want to end up disabling a million blocks, so you can use the null sink. Just drop that down, hook it up, and then it'll run as normal, and then you can hook up your probe essentially to any point. So I've hooked it up to the AGC, this scope, and you'll see this at the bottom of the screen, and hopefully... You see how the scale is... was changing? It was pretty quick. That's actually AGC kicking into effect. So the original signal's pretty low, and then so it amplifies the signal more and more and more at the rate of your gain, and then it... basically gets roughly to your... your... the point that you want. So here, it's not looking particularly pretty. We're immediately after the AGC, right? So we need to do clock recovery, and then we need to apply that frequency offset. So now let's switch to... post-clock recovery... like so. . Now, you'll notice here that this constellation plot looks different from the previous one. How? What's that? There's nothing in the center, and that's good because it means that the clock recovery algorithm has locked onto your incoming signal, and it's sampling at about the right time. And when it samples at the right time, you expect it to be sampling somewhere out where... during the midpoint of your sample where it'll result in some... point that has an amplitude out here, outside of... outside of the origin, which is good. That's what we want. So that's a good signal. But we don't have a clean constellation because if you were to visualize this, the constellation itself is actually rotating. Right? And when you have rotation on this constellation plot, that means that you have some additional frequency component that's part of your clock-recovered signal. So we need to get rid of that additional frequency component to get a nice, stable constellation, and the costus loop will do that for us. So if we get rid of that now, we don't need this anymore. Hook that up. And fingers crossed, this time it'll work. Let's see what we got. What do you know? There we go. Now, the costus loop is now working. It's doing its thing. It's removing that frequency component, and we get these four dots. Now, remember that I've added... copied these sliders across as well. So we've got the gain mu, the costus loop bandwidth, and so on. You can now play with these at runtime to see what effect it has on the constellation. So let's say I want to change the costus loop bandwidth. This is essentially saying how tightly it's going to look at the incoming signal and how much it can deviate by before it'll sort of flip back. So if I really open it up, then you can see how it's sort of losing sync now, and the points aren't as tightly grouped anymore. That's because we've opened it up way too high, and it's sort of going into the weeds and looking beyond where it really should. If you have a stable signal, then generally you can usually put the loop bandwidth down considerably, and that means it'll track very, very tightly to whatever frequency offset is in there. And as you can see, it cleans up the constellation quite well. So now the other ones are the gain mu. I won't go into these too much, but they basically control... You can do a bit of reading how the clock recovery block works and how strictly it adheres to the timing that it's figuring out from the signal. Again, usually you can put these kind of low. If you bring these out, then again, things start to look messy. So we can keep that nice and low as well. So we've got a recovered stream now. We have our recovered symbols. That's really good. We know the timing. We know it's QPSK. At this point, you could actually pull out digital ones and zeros, because you have a constellation, and each of these points are going to map to two bits. So this could be 00, 01, 11, and 10, if it's gray-coded. So if you look on Wikipedia, I think I have a page for that. You can see here, this is a gray-coded QPSK plot. And the gray-coding is important because it means that only one bit is changing between adjacent constellation points. That means if you accidentally get the wrong phase, you only end off wrong by one bit instead of potentially two. So that's important. So if you want to learn a bit more about it, that's a good place to look. Now, the thing is, we've got raw bits now, and we can actually look at that and visualize it, but it's probably not going to give us any information, because it's probably scrambled. Links are usually whitened, so you have some sort of pseudo, noise code put on top of it to distribute the energy through the spectrum. That's pretty standard stuff. And there might be forward error correction on there. Question in the back. Often in these sorts of situations, you've just got to go through the permutations. And actually, so I'm going to show you how to do that in terms of the forward error correction actually right now. So at this point, if we look at our reference design here, we have our costus loop. It's giving us our symbols out, and now we want to actually figure out how to get our raw bits out of there. So... I'll give you a very brief introduction to convolutional codes. So... So there are different classes of forward error correction out there. And one is called convolutional coding. And this has been used a lot. And for space applications, one of the most famous instances that is sort of referenced everywhere and actually turns up here is the NASA Voyager space probe. And the way convolutional code works is that it's essentially a shift register. You have your individual incoming bits going into the shift register. And once every cycle through your register, you have these taps that come off, and you evaluate them, and then you get your bits... It's gone. I was about to sneeze. You get your resulting bits coming out. And you can have different sorts of codes. You can have systematic codes and non-systematic codes. But what this does is given one input bit it'll produce, say, two or three bits output. And those additional bits will give you a special sort of redundancy in your stream. And at the receiver side for convolutional codes, you can use a decoder called a Viterbi decoder using the Viterbi algorithm. And it basically creates... I won't go into the details, but this sort of trellis, depending on what those taps were for your shift register. And as your bits come into your trellis, depending on how your code is designed, it will actually go through and figure out the most likely path through the trellis of your original data bits that resulted in the bits that were sent over the air. And why this is really cool is that if you end up having an incorrect bit somewhere in here, then it will see, oh, it was probably not the most likely path because it was a bad bit. And there's actually another path that you can go through that will give you a higher, what's called a higher metric through your path. And it tries to optimize that. It tries them all in parallel, which is why they're very slow in general purpose PCs. But if you do it on an FPGA, they're blindingly fast because you can compute all the paths in parallel. But it tries to find the most likely path. And then that is actually, they will be the bits that were hopefully transmitted initially over the air. So then you remove those additional redundant bits and you get your original code back. And the length of that path is known as the constraint length. And the constraint length is the length of the shift register. So it all sort of comes together quite nicely. This transmitter side is very simple. The Viterbi algorithm is, it takes a little bit more to get your head around how it works. But it's really cool. Even though it's really cool, it's actually been surpassed now by much more modern codes. There are turbo codes that are used, for example, in LTE and now in satellite links. There are other sorts of classes of code that are much more efficient than this. But this thing, these things are actually on space probes that have flown outside the solar system and are really suitable for these sorts of deep space links as well. So if you do some research, you can see that satellite links tend to use this sort of convolutional code. You can guess that they're probably going to use Voyager because it's standard. Everybody's pretty much implemented it. It's a highly optimal configuration of this convolutional code. And it's actually running that as the decoder. Now the thing is that GNU Radio actually already has a block to do that particular It has all the letters in it. There we go. CCSDS. And this is a space standard. This will do the encoding and decoding of this stream. But it's not as simple as that, unfortunately. If you're going to just start doing error correction stuff in GNU Radio, probably stay away from this one. There's a relatively new module in GNU Radio called grfeq. It's in the tree. And it supports a much wider variety of encoders and it's blindingly fast. It's really, really neat. So you can do that there as well. But I'm going to use this one for a particular reason. The complication here is that we have a PSK signal being transmitted. We have a receiver that is now locked onto it. We've recovered the symbols. And we end up with that constellation. So if I run it again, you'll see what I mean here. There's our constellation. So if you look here at the bottom, you can see our constellation. This is all well and good. And I can say, this is going to be 00, 01, 11, 10. Fine. We can decode, get the bits out. Bob's your uncle. The problem is that our receiver might not be synchronized to our transmitter. So you know how this is all quadrature, we've got our I and our Q. It's quite possible that our transmitter and receiver happen to just have their oscillators come on at a time where the I and Q were actually swapped. Or the whole thing might be rotated. Basically, you have the problem where you don't know how your receiver is aligned with this transmitter that might be on the other side of the world. And what that means is that you can actually end up having this constellation, relative to your transmitter, rotated 90 degrees. Or it might be conjugated, which means that the entire thing is flipped through the complex plane. And you don't know any of this stuff, but you need to account for it. So your receiver has to go through and try all of these different permutations of conjugation, rotation, inversion, shifting bits, because you don't know how the state machine of the decoder on your receiver side is relative to the state of the transmitter. So you need to be able to synchronize to it. And in modern communication systems, often what's done is you know, for example, what the... There's a preamble, right? So there's a fixed code that's documented, that's transmitted by the transmitter. And when it gets to your receiver, then you can try to correlate against that code. You can try correlating against the code as it is in like a zero phase shift, a 90 degree phase shift, a conjugated constellation, a conjugated 90 degree phase shift and constellation. You can precompute these, correlate against them all simultaneously. And as soon as you get a correlation peak on one of them, you know, aha, that's what it is. I'm going to rotate, I'm going to conjugate, I'm going to invert, and then we've logged onto the stream. But in this case, we don't know what the preamble is, right? Because we're coming at this blind. We don't have a clue what it is. But what we can do is we can exploit part of the Viterbi algorithm. And remember how when I showed you that trellis, it tries to draw a path through and determine the metric. So it tries to give a score to all of the paths to see which one was the most likely. And then it picks the most likely one and derives your raw data bits from that. What we're going to do, what you can do, is that you can modify the the the CCSDS decoder. And so I've modified it in this version of Green Radio so that not only does it give you the output bits, but it also gives you the path metric. And the path metric is essentially a score telling you how well the decoder is actually doing. So that if you get, in this case, once you do a bit of fidgeting with the numbers, a path metric of zero, that's actually the best number that you can get. That means that the soft bits that you're getting coming in from your constellation map perfectly through a valid path through your trellis. So that's good. As soon as you get incorrect bits that don't fit nicely with your trellis, so they don't give you a path that's valid for your code, then your metric actually goes up. And that's bad. So if you get a metric that's really noisy and high, it means that you probably haven't locked on and synchronized to your signal. But if you try these different rotations and constellations, and then you wait for the path metric to go back to zero, really close to it, then you probably do have a lock. And so what I've done is I've actually condensed that into this auto fec block here. So it takes in the raw stream coming from the constellation, and then it outputs the byte stream, but internally it's actually applying rotations and conjugations and inversions to your constellation, and trying all the different combinations until the path metric goes to zero. Fundamentally you can break this out. If you were to break it out, then really what you'd get is something like this. So this is more a stripped down version, but the first step is the conjugation, and the next step is the phase rotation, so here you just multiply it by zero, or I'll show you the expression here, actually. Oh, it's not there. But you can multiply it by various numbers that will actually rotate your constellation, and then if you're using this particular convolutional code, you might need to delay by one sample, because you might be misaligned. And then you can do that delay. And each of these blocks are controlled by a state machine that'll conjugate, and then not conjugate, and then rotate phase, conjugate, not conjugate, rotate phase again, conjugate, not conjugate, delay, reset everything, try everything again, and you keep going through this long process until you find the right steps. And that's what that auto effect block actually does. So, restore that, and what I'm gonna do now is I'm gonna run it, and I would like you to page attention, if you can, to the I'll bring the console over so that you can read it properly. I don't know where GRC is running. Which terminal is it? Here we go. Got it. And then magic incantation. Okay. So... I'm gonna run this. I want you to observe what's printed out. So, auto effect starting up here, and you can see here, it's beginning the search. It applied a rotation that didn't work because our bit error rate was still really high. It's the metric coming out of the Viterbi decoder. Applies a rotation, still really high. Applies a rotation and a conjugation and a delay in the Viterbi samples. Still no lock. Applies a rotation. Still no good. Rotation, conjugation, no good. Rotation again. So it basically does all of these permutations, and you can see that it's testing each one of them, waiting for the path metric to come out. It's still too high. And then what do you know? We step through here, we apply the rotation, and we had no conjugation. In this particular instance. And we locked. So our path metric now is really low. And you can actually then see this. I'll run it again, but this time we can actually watch the graph of the path metric, which is just coming out of this port. So this is a graph of the path metric coming out of the Viterbi decoder. So this is 0. We want it to be down at 0. But as you can see, it's sort of in the 4-5,000 range. So this is pretty noisy. It's really high. It's above our magic threshold. It hasn't found anything yet. And as it steps through and rotates and delays and inverts and so on. Look at that. Do you see that? That's now got a lock. And you can see that there are these little humps here. And remember how constellation wasn't particularly clean? You can see here at the bottom, it's not a particularly tight-looking constellation there. Inevitably, you're going to have constellation points that veer off and end up in the wrong quadrant. And that will give you the wrong bits. You'll get bit errors. And so as you go through the Viterbi decoder's path, you'll end up getting some bits that are wrong and it'll figure that out and then output something that's a little bit higher. But this is still low enough so that it'll give you the correct output bits. Question here. So if someone's trying to mess with what was receiving the signal, is it possible to randomize it or make the shifts occur at various points so if you're using a standardized process like this they'll never converge? It's possible. The question was if you were essentially a man in the middle and you wanted to corrupt this link, whether you could get in there and actually insert bad bits. No, not man in the middle. The people who are actually sending the signals, they want to be people other than the intended receiver to be able to convert the message to a locked state if they could mess with the constellations and the preambles so that your system would never have a confidence lock. It's possible. It just depends upon how you do it. In this case, remember we're coming up blind so we have no a priori knowledge about what we're looking for. Usually you wouldn't do it this way. Usually you would look for that known sequence. So this is a bit of a hacky way of doing it. But it kind of works. As you can see here, it's actually running and it's locked and it's doing its thing. And we're now outputting these raw bits coming out of the decoder to a file. So the next step is we've got the raw bits, we need to visualize that file to see whether there's some sort of structure to it. And that will be the next step. So what I'm going to do is I might just run that again. Just so you can get a sense of the final app as we were putting it together. So we've got a constellation plot. We've selected our channel just as a review. We've got our channel there. Let's tighten up the bandwidth. You remember how I used the config variable block? Really, I should be using one for the bandwidth as well so it remembers it whenever I boot it up again instead of having to adjust that manually. We're not using the power. We know what the board rate is here. We've got the peak. We've got the coming out as 96 hundred board. And then our path metric is as you can see, very low there. So I'm just going to let that run for a minute and it's going to go to a file. And then I'm going to run some Python code to actually read the file in and plot it using matplotlib so that we can see if there's any structure and then take the next step in the process. So I'm going to shut that down now and I'm going to switch to the terminal and new tab and be Python and I'm going to open my secret source here If I can find it Okay, so Alright Now, you can do this in all sorts of different ways I have a little program here that I might just where is it I'm just going to show you quickly here so you get a sense of what's going on This is now running under Wine again This is some software that crashes under Mono really quickly I need to put on my GitHub but it's just I wrote it to do some simple manipulations on files so I'm going to import this satellite text file that we made It's basically if you have a look here this is what it looks like It's just the raw bits out of the Turbi decoder Now, we would expect that since it's outputting bits all the time for the first portion it's just going to be corrupt data because it hasn't locked on yet and then eventually we're going to get a locked stream after that So, if we go here, we've imported that file Let's see what it looks like I'm just going to pick an arbitrary width It looks like noise, not very helpful, right? So there's something going on here The first part of it obviously we ignore It's going to be a scrambler because remember as I said in communication systems you want to distribute the energy of your bits over the bandwidth that you're transmitting in You want to whiten the signal and to do that you use some sort of pseudo-random code, some pseudo-noise to spread the energy out and you can use these things called scramblers and I recommend that you read a little bit about them There's another good Wikipedia article on scrambler You're going to have two types of scramblers One is the additive scrambler and the multiplicative scrambler There's an important distinction between the two One is self-synchronizing and the other one is synchronous So one of them you need to look at for like a special preamble and then reset your scrambler so it can follow along The other one doesn't need that, you can just do it Luckily in this case it is the multiplicative one that we're using otherwise we might be a bit out of luck So there's not much going on there Now, if you do a bit of research you can find that a very common scrambler is the IESS308 scrambler So we're going to run that and if you actually look at the source code for this scrambler I've got a Python implementation This is the C sharp implementation It's really quite simple It's just you have some taps coming off some shift registers I think there's a latch in there and then it just calculates what the next bit is So it's really not that complex But the idea is that you give it a bit, it puts it into the shift register and then calculates some tap values and then returns a bit from that Was there a question? Yeah, so GnuReady has scrambling and descrambling blocks I believe the reason why I had to go down this route is because they're generalized ones and this one had some extra flip-flops in the circuitry, like I actually found a reference page that had it mapped down in commentary logic and I don't think you could realize it with the GnuReady one GnuReady is nice because it has both the additive and the multiplicative scrambler Was there another point? So that was on the assumption that the first try was with Voyager So I figured, oh it's probably going to be Voyager, so try that And actually that's a good point I got lucky with Voyager and that CC SDS block is hard-coded to Voyager but actually if you use the new GFX stuff and you look at the so this is the encoded definition using the new paradigm and there's the convolutional code one which is the more generalized one so this one, this convolutional coder is actually set up for the Voyager code, these are the polynomials used to set the taps on the shift ridges for the convolutional but you can configure these any way you like, if you had some other ones that you wanted to try, you would create that kind of state machine and go through and try them as well and then you would go there's another block that you would use with these ones to set it up so as an example what that looks like is like this you go down the bottom here you have this FEC extended decoder and then you have the decoder definition so here I've actually defined again the settings for Voyager, but in this case I've just reversed the taps and then you use this decoder object and you pass in the ID of the definition and then you can set the puncture pattern for punctured codes and then it just does the rest so you could conceivably do something where it tries different decoder definitions if you're trying to iterate through possible combinations and then one other thing to mention here also is that the code that we were looking at is known as the mother code and it uses the half rate code which means that for every bit that you put in it'll generate two bits but there's this cool notion of what's called puncturing the code so if you don't want to have a half rate code let's say you want a three quarter rate code so you give it three bits and it gives you four that way instead of having two for every one which is a lot of information that you're wasting on if your link doesn't support that kind of bandwidth you might opt for a three quarter rate code so if you think about it for every three you get four or you might give it seven and then you get eight and that way you can actually change the code rate which is really nice but it means that when you're running your automatic forward error correction synchronizing you actually have to try all of those different puncturing matrices as well because maybe the transmitter's not using a half rate code maybe it's using a three quarter rate code and so what AutoEffect does is it actually goes through and it tries all of these standard puncturing matrices as well I got lucky in that case because they were using a half rate code but you might be using something else so it's just something to keep in mind there and again there's a good Wikipedia article on that if you have a look here a little bit further down you actually have a good write up on puncturing using the NASA standard k equals seven convolutional code so what this is saying here is the mother code is half rate and you give it a bit and you get two out if you have the two third rate code then you will give it the four bits you don't transmit this one and then you get you basically give it two and then you get these three coming out you might have a three quarter rate code so you have three bits coming in you generate the normal two for one but then you don't send this one you don't send that one and the receiver will know that you're using one of these puncturing codes so every time it gets around through its bitstream to a point where it says this is where it's been punctured it inserts a zero which is like an erasure mark and the convolutional decoder will know when it's looking at the path metric I'm just going to ignore that because it was actually erased and it will still do its thing it's a really nice property I won't go into the details but if you're interested you should definitely read more about it about communications for example in intel sat systems and digital video broadcasting what do you know okay so we were looking at the raw output which is here so now remember we applied that common descrambler so let's see what that looks like we had noise at the beginning because remember we weren't locked to the signal so let's see what we have after that looks like we've got some structure there but still it doesn't look quite right can anybody tell me why exactly right yes so the response was we've got long strings of zeros in some places and long strings of ones in other places and when you see that you know that you're onto something you're almost there but it's quite likely that your original data was also differentially encoded and the idea there is that you don't actually encode the raw data bits you encode the differences between subsequent data bits and that's really good because it means that you do not end up with long strings of ones and zeros in common in communication systems you want as many differences in your data between one and zero as many differences in the clock essentially sorry in the data so that with all those different transitions not particularly in this system but in other ones if they're doing clock recovery the more transitions you have the better your receiver can lock to the signal and recover the clock if you have a long string of zero or a long string of one there's no changing edges there so your receiver has nothing to lock onto because it wants to see the differences in the signal so exactly right so the next step then is to crash the program unbelievable all right what happened there did it not import how weird Okay. Do we still have a valid file? Oh. Oh, you know why? Okay. Not to worry. This has bitten me before. I'm just going to run this again to regenerate the data. The problem is that I'm lazy, simply put. And you'll notice that you can have blocks. I basically got in the terrible habit of writing C++ blocks and not writing GRC XML definitions for them. And instead, I put together this thing called the any block. And what the any block lets you do is just put in arbitrary Python. So this is actually the Python code to generate the print char block from GRBaz. And I'm just supplying arguments there. I don't need to worry about making the XML for it. And then that's really easy. It just works. And you don't have to do the extra effort. The problem is that GRC evaluates all the Python that it can in every single block, both when you boot it up and when you switch back in between flow graphs and change other blocks and stuff. It needs to reevaluate everything. And you notice that this is purple, which means that it's text. But even if, as I said before, even though it's purple and it's text, it will still evaluate it, which means that it will create a temporary instance of this block, which also means that it will create this file. And if there was a file already there, it's just going to reset it and the contents will disappear. That's why it became zero. So that's the problem. And that's me being lazy. So all right, we've probably got enough information now. Let's try that one more time. We've got our data there. Good. Let's run the program one more time. Import. Satellite. Data. Descramble. Differentially decode. View data. Unlocked region. Locked region. And you can see now it looks like legit data. You've got black. This is idle time in the channel. Nothing's being transmitted. And then you have these bursts that show up. And these bursts appear to occur at random points in time. So it's some sort of shared link maybe. Not a shared link, but it's some sort of medium where there's some maybe telemetry system on the ground. It gets some information queued up and then it sends it out as a burst. And if you look carefully, for example, here, you can see that... The bit pattern looks pretty common. So there's a good chance there's some sort of common preamble, common synchronization information in that portion of the file. And actually, we won't do it now. But if you have a look at the steps after that, this should all look pretty familiar now. We selected the channel. We did the... We did the PSK ordering. We did all this stuff. Descrambling, differential decoding, forward error correction, Bayer shift keying, board rate. All this good stuff. Descrambled it. Got our packets there. And then look for the preamble. And then you actually get a packet out like this. And you get the nice since and sin at the top. And then you get start of header and start of text, end of text in these packets that go through. And then you can pull those out and get these packets coming out. And that has BCD and... And then you can pull those out and get these packets coming out. And that has BCD and... And then you can pull those out and get these packets coming out. And that has BCD and... And then you can graph it and you get these pretty lines out. I have no idea what it was in the end because I was only recording for two minutes. I'm sure if you recorded over a long period of time, you could correlate it with human activity somehow and figure out what was going on there. But, yeah, that's kind of the idea. And so, you know, this is a Windows program, but I'll just show you how you can do this nicely in... In Python. So, two hands. And... Where is it? Okay. So we're going to go... I'm not going to look at that screen. So tell me if I stopped something out. Important map plot lib, Python as plot. Good. And then import... I'm sorry. So what we're going to do is we're going to open the file, we're reading, and then we're going to read that line and check that we've got something. And now what we're going to do is we're going to turn the ASCII ones and zeros into bytes of zero and one. What did I do? Oh. Okay. And then... And then we want to find some good value, nine, so we're going to say, what is it, height equals nine, two, six, and S2, S2, one, two, four times height. Right. The reason why we're doing this is we're going to turn it into an image and we want it to have nice dimensions. So we do do that. And then what we do is we want to actually see what it looks like. Okay. Okay. Okay. Okay. So we had, again, all... It's all scrambled, right? Nothing to see there. Now, you can then get the scrambler happening. I did a simple port to Python again. Really, really simple. It's just a class state machine essentially with the shift registers and just call next on it. Okay. So... Did we import that? Yes. And then we create the scrambler. We wanted to tell it to descramble. And then we map that across all of the values again. Takes a second. And then let's see what that looks like. I just... I really like matplotlib because it makes things really easy. Okay. Okay. Okay. Okay. So, now you can see we have that structure again, except the colors aren't particularly nice for it. And then the last step is to do that differential decoding. And so this is a little bit tricky. By the way, if anybody's got any suggestions how to do this better than I'm open to it. But what I'm gonna do here is I'm going to use zip function to create two copies of the array. but they end up in tuples where one array is offset by one sample so you basically get these combinations so I'm going to zip it up and if you have a look at what that looks like it looks like that so it's just basically the pairs now where the second pair is the same stream but delayed by one we need to add an empty one on the end because we'll be off by one for our image and then we're going to do the differential decoding and that's just going to be in that line there so what we're doing there is we're taking the second value in one of these tuples and subtracting it from the first value so it's basically the next sample minus the previous sample mod 2 for the entire stream and then let's see what that looks like and then voila we've got our packets out and then this is nice because now we can actually zoom in and you know see see what these individual headers might look like and you can start playing around with it from there so that's just an example of doing some sort of simple visual analysis in in Python okay so thanks for braving with me we're almost at the end of the session hopefully that's given you an idea of how you can go about doing blind analysis the last two very quick demos I'd like to show you with those HF radar things so this also includes audio I'll just very quickly show you how that works for these sorts of things apart from looking at visually it's also really nice to be able to hear what's going on because that can give you a hint so I'm going to run this and I know I know for a fact that in this particular capture this was on HF so I think it was 17.9 megahertz this here is digital radio mondial it's a 10 kilohertz OFDM carrier that's transmitting digital music and here is going to pop up a chirp a radar chirp that's being sent over the air over long some long distance but this chirps really interesting because it actually changes the chirp rate while they're transmitting so they do a really quick one and they keep slowing it down go slower and slower and slower and with radar as you change the chirp rate it actually changes the resolution with which you can resolve targets but also affects the distance over which you can do it and it's it's basically trade-off in here they're going through the spectrum so they can get high resolution close in and low resolution but further away and what I wanted to show you here was this fast autocorrelation block this was originally written by this very mysterious guy called Frank of radio Roush fame he did some amazing stuff with ADS-B and p25 and and Motorola stuff and CDMA before you and I even knew about software-defined radio and and he is a complete enigma but amazing talent guy I took his code and and sort of spruce it up a bit for the new rotio and what the faster correlation does is it actually looks for periodic structure within your signal so unlike when we were talking about discovering the board right so that's actually the purity see of the symbols themselves this is looking for larger scale priority components to your signal so for example let's say you have on this case a chirp but the more obvious one is GPS and 3G CDMA mobile telephones. If you consider they're both CDMA systems and a receiver has to lock on to the CDMA channel, so it has to look for a particular code in there and part of the code, one of the channels there is the common pilot channel, I think, which contains broadcast information and that is sent out on 3G at 10 millisecond intervals. So, there's going to be some mysterious stuff in your signal. You've got no idea what's going on in there. It's CDMA, it's all coded, it's all, you know, spread and everything. Same for GPS. But you can hook this fast autocorrelation block up to it and you'll get a strong peak at 10 milliseconds because it's finding that there's something repeating in there with a 10 millisecond interval. With GPS, the course acquisition code has a 1 millisecond peak because they have a chip rate of, the chip length is 1023 and their cyclic rate is 1.023 megahertz. So, here we actually have this radar chirp that comes up and so I want to show you what that looks like and what it sounds like as well. So, you can hear the chirps and the rate at which it's chirping, it's basically sweeping a tone across the spectrum, is changing the rate. And it's running through here and again, you look at the first big peak and you can see that every time it changes, the peak moves along because the chirp rate is slowing down. You can hear that. And then again. So, now it's out here. And that's it. So, I'll quickly show you what's going on here and also what I might do actually is to finish up, throw a waterfall in there because it looks pretty here and NB2. And so, before I run that, I just want to show you here, this is essentially, it's really easy to do a fast-order correlation. We have our channel selection here. You do an FFT, you take the magnitude, you do an FFT again, and you take the magnitude of that as well, and that will give you that plot. That's all it is. So that fast-order correlation block, all it does is that, and then you get your plot out. Really simple. It relies on the special theorem. You can read about it more online. I think you pronounced it the Weiner-Kirchner theorem. But it's a really simple and effective way of doing the transform. And again, like before, we have this fancy plotting business so that you get your number sink out, finds the first big peak. And so when you run the thing, you actually have that number sink telling you what the period of the chirp actually is. So if we wait one more time, hopefully we can... Where did I put that waterfall? Ah, snap, I did it again. Hang on, where's the waterfall? Here, right? Yeah. Same old mistake. Right, let's run that. There we go. Very good. Waterfall. Good. Give it a second. So just as a lead-up, in 30 seconds when this is done... Oh. Oh. So, the chirp rate is too fast for this slow waterfall to actually show you, but when we slow down, you can see this peak is moving across, it's doing that thing, and then it's telling you what the period of the chirp is. And then from that, you can calculate what kind of range resolution you can get on your radar signal. But... Yeah, this could be some over-the-horizon radar. Yeah. Yeah. Yeah. So if you look there, you can kind of see this pattern there, this diagonal line, and that's your chirp, that's your tone moving across the frequency band. And you can see these all over the place, all sorts of nation-states doing weird things. So I'll just finish very quickly. That same capture has DRM, Digital Radio Mondial, that same business, and what's interesting about this one is that you can see there's that peak there. That peak corresponds to the unguarded symbol time of an OFDM frame. So if you want to figure out what OFDM timing is used here, same process, same technique, you can read that off. And this, if you invert this, this is the sub-carrier spacing within the OFDM frame. Once you do the cyclostation analysis and use that as your delay, then you run that again with the... So you're running this on the delayed, version of itself, and you get this peak here, and that's telling you the full OFDM symbol length. And with that, you can start to look at the OFDM sub-carriers within your signal. And what we're actually hearing now is this sonified, and you can see we've got that peak again, and it's kind of difficult to hear because we're actually listening to an FFT, but there is actually a tone, a tune in there, a very slight, subtle tone that maps to this strong peak that represents the cyclic nature of the DRM signal. So within DRM, there's probably some synchronization code that gets repeated every so often, making up the frame, and that's why we get that response in the domain because we need to have the receiver synchronized to it. Question? If you haven't seen Contact, it's a really great film, one of my favorites. And then... Promise, last thing, very quickly, back to the satellite thing. Remember how I was telling you that there's telemetry? The satellite will send down telemetry to let you know that it's okay. This is the telemetry here. We've got lots of things modulated onto this carrier. It's actually using phase modulation, we can tell from the research. This now is the channel-selected thing, and you can see how this is slightly off-center. I'm using a PLL here to lock onto that signal, bring it back down to back-center, baseband, and then we can... Can you hear that B thing? That's the satellite saying, oh, I'm here. And that's the telemetry coming down from the satellite. So you can visualize that and try to access and figure out the telemetries. Anyway, thanks for bearing with me. Hope you've learned something, and I'll wrap up there. I've gone over time a little bit, so I'll be outside. Thanks for watching. Please subscribe to my channel.