Applied Digital Signal Processing


This is a notes post and may not be as easy to follow as a de facto blog post.

Intro

Radio waves are literally everywhere always passing through us. FM/AM radio, HAM radio, WiFi, Bluetooh, car keys, garage door openers, and so much more all use radio waves to transmit information across space. Radio waves help comprise the EM spectrum, so they travel at the speed of light.

Signal Basics

Being light, a radio wave is an analog signal which means we can model it using a sine wave. With this being said, the wave's attributes include its frequency, amplitude, and phase, the most important of which when modeling the wave in simple terms are its frequency and amplitude. We often communicate information by changing the signal's frequency or amplitude over time, called frequency modulation and amplitude modulation, respectively. I'm not certain why, but FM is more popular than AM in nearly all radio communication.

Getting Hands Dirty

We can use a Software Defined Radio (SDR) dongle and attach an antenna to it in order to receive lots of radio signals. SDRs receive raw radio signals on a wide range of frequencies (often high kHZ to low GHz). The cool thing about them is that you use software to interpret the raw radio signals, which means you can do all the signal processing entirely using software. You can use GNU Software like GNU Radio or other open source software like the  rtl-sdr and its more approachable Python wrapper, pyrtlsdr. I found GQRX  to be the easiest thing to get started using for beginners with a new SDR. It was easy to download and install, and you can immediately plug in your SDR dongle and start tuning it to nearby radio stations to listen to music.

The vast majority of SDRs simply receive radio signals, but more expensive ones like the HackRF can also transmit! There's even a little hack to get your Raspberry Pi to transmit on some lower frequencies and serve as a cheap radio station. It's very approachable since the Pi is cheap, but do NOT transmit before consulting the laws in jurisdiction.

FM Demod

As previously stated, FM is more common than AM, so knowing how to demodulate FM signals is probably more desirable than doing so for AM signals. Davy Wybiral's spirit-box project has a very clear example of FM demodulation to playable sound using pyrtlsdr. Another good page for demodulation using Python is this post by Fraida Fund.

Decoding Digital Signals

Protocols like WiFi and GSM encode purely digital information using FM, so decode the binary information from the signals we need to convert raw radio signal to FM and then FM to binary. The signal to FM is can be done using tools from the previous section, but FM to binary (often via square waves) can be done by demodulating Frequency Shift Keyed  waves and then converting the resulting square waves into bits. Knowing a bit about Phase-Locked Loops (PLLs) may help in understanding FSK.

Broader Signal Processing

Cool places to learn more about Digital Signal Processing include Audio and Digital Signal Processing (DSP) in Python,  Digital Signal Processing Stack Exchange, and Cal's EE123 Course.

Security

Information security related to radio signals is pretty low level. Radio is layer 1 and layer 2 of the OSI and Internet networking models. This means that attacks on protocols on those two layers are possible using radio waves, which includes WiFi, Bluetooth, and GSM/CDMA cell signal attacks. Replay attacks are also common against devices like garage door openers and car keys.

You can do cool things like sniff WiFi traffic on insecure (read: WEP) networks and get a feed of all phones nearby and their IDs and carrier as if you were a cell tower, like a passive version of the  IMSI Catchers that law enforcement and militaries use. This is a good post to follow for that.