Course 4 – Writing gnuradio Applications with Python

Summary

At some point, you’re going to want to interface the radio you built in gnuradio-companion (GRC) with code operating outside of GRC. You will also want to build gnuradio flowgraphs without using GRC at all, particularly in headless systems. In this course I’ll show you how to do all of this and more.

Course Result

You’ll know how to write code that inserts data into GRC transmitters and extracts it from GRC receivers. You’ll have the skills to build transmitters and receivers (as well as re-usable heir blocks) completely in Python. Both of these techniques dramatically increase the power of gnuradio, allowing you to solve dramatically more challenging InfoSec problems and build vastly more complex systems.

You’ll also pick up some crucial tips for testing and debugging your Python+gnuradio code. While they may sound less exciting, these tips can save you countless hours of frustration.

Prerequisites

You should be familiar with using gnuradio for building analog and digital radios, both transmitters and receivers, using OOK and FSK. You can acquire these SDR skills by taking my first two classes or by learning them on your own.

Additionally, we will be using Python extensively to interact with gnuradio. I’ll teach you the Python you need to know, but some familiarity with the language will be helpful.

You will not need to bring anything to the class. You will use our laptops and SDR hardware.

Description and Outline

Day 1

  • Overview of gnuradio-based Application Development
  • Connecting GRC Flowgraphs to Application Code
  • Using a File Interface
  • UDP Sources and Sinks
  • ZeroMQ Sources and Sinks
  • Project – Connecting Flowgraphs with ZMQ
  • ZMQ Messaging
  • Polymorphic Types
  • PMT Functions
  • Project – Using PMTs
  • PMT Pairs
  • Project – Building and Dissecting PMT Pairs
  • Serialization
  • Sending ZMQ Messages from Python
  • Project – Send PMT to Flowgraph
  • Receiving ZMQ Messages in Python
  • Project – Receive PMT from Flowgraph
  • Protocol Data Units
  • Extracting Payloads from PDUs in Python
  • Project – Extracting Payloads from Flowgraph
  • Building PDUs in Python
  • Project – Sending Payloads to Flowgraph
  • Project – GFSK Receiver using Python and GRC
  • Python Classes and Objects
  • Project – Object Oriented Python
  • How OOP Cleans Up Our RF Stack
  • Project – Building a Python Class for Flowgraph Communication
  • Using ZMQ for Simulation
  • Project – Creating a Python-driven Transmitter
  • Project – Loopback Simulation
  • Project – Python-driven HW Transmit and Receive

 

Day 2

  • How GRC Generates Python Code from Flowgraphs
  • Quick and Easy Access to GRC Python Code
  • Converting GRC-generated Code to Standalone Applications
  • Gnuradio blocks and connections in Python
  • Managing the Flowgraph Object
  • Project – Simple Flowgraph in Python
  • Dynamic Changes to Flowgraph Parameters
  • Project – Dynamic Variable in Python Flowgraph
  • Recap of Techniques Covered Thus Far
  • Project – Full Radio Stack CLI – Simulated
  • Tips for Building and Debugging Python Flowgraphs
  • Project – Full Radio Stack in HW
  • Frequency Hopping Basics
  • Project – Frequency Hopping Radio Simulation
  • Project – Frequency Hopping Radio in Hardware
  • Calling Simultaneous Flowgraphs From Your Application
  • Project – Building an RF Repeater
  • Custom Block Types
  • Hierarchical Blocks in GRC
  • Project – Building a Tuner Block in GRC
  • Hierarchical Blocks in Python
  • Project – Building a Monolithic OOK Modulator Block in GRC
  • Out-Of-Tree Blocks
  • Block Design Flow
  • Coding the OOT Block
  • Project – Simple OOT Block
  • Coding OOT Message Blocks
  • Message Block Reminders
  • Project – Simple OOT Message Block
  • Recap