DireWolf with ALSA Loopback Devices

As part of poking around with Packet setups, I wanted to be able to easily test things by running two DireWolf instances communicating locally.

Unfortunately while DireWolf can use a UDP socket or stdin for input, it will only output to a sound device.

Fortunately we can fake sound devices, thanks to ALSA’s snd-aloop

(This is all on Debian GNU/Linux; you can probably do something similar on macOS with Loopback / BlackHole; I have no idea about Windows)

Basic setup and testing

  • sudo modprobe snd_aloop to load the aloop driver per https://www.alsa-project.org/wiki/Matrix:Module-aloop

  • aplay -l and arecord -l should show you now have the relevant Loopback devices
    • You may need to install alsa-utils if you don’t have arecord or aplay

    • The devices (I think that’s the right term?) are of the format Loopback,X,Y where Y is the subchannel; audio from 0,Y is output to 1,Y and vice versa

  • gen_packets -o x.wav (packaged with direwolf) will produce you some test packet data in x.wav

  • atest x.wav will check the test data you just generated

Then to actually test transmission:

  • In one session arecord -D plughw:Loopback,1,0 -f cd y.wav to start recording to y.wav

  • In another session then aplay -D plughw:Loopback,0,0 x.wav to play the test data

  • Terminate the arecord once aplay has finished

  • Then verify received data with atest y.wav
    • Sometimes I lose the last packet here - haven’t quite figured out why

    • This probably isn’t entirely correct/optimal in terms of channel and quality etc. but it works Well Enough

DireWolf setup

A basic test setup looks like:

direwolf0.conf
 1 # Input 0,1 Output 1,0
 2 ADEVICE plughw:Loopback,0,1 plughw:Loopback,1,0
 3
 4 # Explicit AGW/KISS ports to not conflict
 5 AGWPORT 5000
 6 KISSPORT 6000
 7
 8 # Send some periodic test data
 9 MYCALL XXXXX-10
10 CBEACON delay=0:10 every=0:10 info=0
direwolf1.conf
 1 # Input 0,0 Output 1,1
 2 ADEVICE plughw:Loopback,0,0 plughw:Loopback,1,1
 3
 4 # Explicit AGW/KISS ports to not conflict
 5 AGWPORT 5001
 6 KISSPORT 6001
 7
 8 # Send some periodic test data
 9 MYCALL XXXXX-11
10 CBEACON delay=0:10 every=0:10 info=1

You can then run these with:

# Session 0
# Run direwolf dumping packets, with text colours off, reporting audio stats every 30s
$ direwolf -dp -t 0 -a 30 -c direwolf0.conf

# Session 1
# Run direwolf dumping packets, with text colours off, reporting audio stats every 30s
$ direwolf -dp -t 0 -a 30 -c direwolf1.conf

And you’ll have two DireWolf instances beaconing at each other through your loopback audio interfaces!