Actions

Notes on Soundmodem: Difference between revisions

From HacDC Wiki

No edit summary
No edit summary
Line 2: Line 2:
[http://www.baycom.org/~tom/ham/soundmodem/ Soundmodem] emulates a hardware modulator/demodulator in software, vis a vis a daemon running in userspace.
[http://www.baycom.org/~tom/ham/soundmodem/ Soundmodem] emulates a hardware modulator/demodulator in software, vis a vis a daemon running in userspace.


v0.15 is the latest, I recommend using that.  v0.14 requires libxml, which I don't think anybody makes available anymore.  libxml2 is used for storing the config file in /etc/ax25.
v0.18 is the latest, I recommend using that.  It now only depends on two things, audiofile and gtk2.


Soundmodem will either turn your soundcard into a KISS radiomodem or an AX.25 network interface.  We're going to be working with the AX.25 side of the house.
Soundmodem will either turn your soundcard into a KISS radiomodem or an AX.25 network interface.  We're going to be using it to create AX.25 network interfaces (/sm[0-9]*/).


= Installation =
= Installation =
Line 10: Line 10:
== From Source: Ubuntu Karmic and Lucid ==
== From Source: Ubuntu Karmic and Lucid ==
<pre>
<pre>
wget http://www.baycom.org/~tom/ham/soundmodem/soundmodem-0.15.tar.gz
wget http://www.baycom.org/~tom/ham/soundmodem/soundmodem-0.18.tar.gz
sudo apt-get install libasound2-dev libxml2-dev libgtk2.0-dev libaudiofile-dev
sudo apt-get install libasound2-dev libxml2-dev libgtk2.0-dev libaudiofile-dev


tar xvzf soundmodem-0.15.tar.gz
tar xvzf soundmodem-0.18.tar.gz
cd soundmodem-0.15
cd soundmodem-0.18
./configure && sudo make install
./configure && sudo make install
sudo mkdir /etc/ax25  ## or else it won't be able to save your configurations
sudo mkdir /etc/ax25  ## or else it won't be able to save your configurations
</pre>  
</pre>  


Configure it by running (as root) /usr/local/bin/soundmodemconfig.  It will open a window on your desktop with nothing in it.  Click File, New, Configuration.  Give your configuration a name (I used 'default').
Configure it by running (as root) /usr/local/bin/soundmodemconfig.  It will open a window on your desktop with nothing in it.  Click File, New, Configuration.  Give your configuration a name (I used 'sm0').


== Apt-Get: Ubuntu Lucid and Up ==
== Apt-Get: Ubuntu Lucid and Up ==
Line 34: Line 34:
==On Fedora==
==On Fedora==
???
???
==Arch Linux==
<pre>
sudo packer -S soundmodem ax25-apps ax25-tools
</pre>


= Configuration =
= Configuration =
== IO Tab ==
== IO Tab ==
On the I/O tab, choose your sound driver (out of soundcard, file, simulation, and alsa, I picked alsa).  You'll have to play around with the value of the ALSA Audio Driver field to get one that works.  On Windbringer, I used plughw:0,0.  Check half duplex for now.  Leave the Capture Channel field set to 'mono'.  I don't know what to set the PTT Driver field to yet, so I left it on 'none'.
On the I/O tab, choose your sound driver (out of soundcard, file, simulation, and alsa, I picked alsa).  You'll have to play around with the value of the ALSA Audio Driver field to get one that works.  On Windbringer, I used plughw:0,0.  Check half duplex for now.  Leave the Capture Channel field set to 'mono'.  I don't know what to set the PTT Driver field to yet, so I left it set to 'none'.  My radios do VOX so I've been experimenting with that.


It's possible that we'll have to develop some sort of [http://www.baycom.org/~tom/pcf/ptt_circ/ptt.html serial or USB push-to-talk interface] for the comm system, or use full duplex with two radios, using one to transmit and one to receive.  We could rig up PTT circuits with microcontrollers, build a known circuit (like the serial port or VOX one from the above link), or evade the problem entirely.
Haxwithaxe, Dan, and Mirage are working on PTT circuits for our radios.  It hasn't been an easy process because the Baofengs seem to kick out just enough EMI to make the circuits act weird as-is.  We have a few [https://drwho.virtadpt.net/archive/2013/05/31/project-byzantium-milestone-three-in-progress partial solutions] at this time.


== Channel Access Tab ==
== Channel Access Tab ==
Line 48: Line 53:


=== Modulator Tab ===
=== Modulator Tab ===
The possible values for the Mode selector are Off, fsk, afsk, pam, psk, and newqpsk.  I picked afsk because [http://www.xastir.org/wiki/HowTo:SoundModem the Xastir wiki told me so]I left the values for Bits, Frequency 0, and Frequency 1 set to 1200, but we can play with that later.  Leave Differential Encoding checked.
The possible values for the Mode selector are Off, fsk, afsk, pam, psk, and newqpsk.  I picked fsk because it grants the highest effective bit rate (9600 bps)The values for Frequency 0 (1200), Frequency 1 (2200), and Filter (df9ic/g3ruh) were left set to defaults.  Leave Differential Encoding checked.


=== Demodulator Tab ===
=== Demodulator Tab ===
On the Demodulator tab (which governs decoding audio signals into bits) the options are much the same, save that the Mode selector has an extra option (p3d)Leave everything else the same for now.
On the Demodulator tab (which governs decoding audio signals into bits) the options are much the same because they match the modulation scheme by defaultThis is what we want.


=== Packet IO Tab ===
=== Packet IO Tab ===
On the Packet IO tab, the network/non-serial side of soundmodem is configured.  Pick an IP address, netmask, and broadcast addres for a network interface (hint: stick with RFC 1918 for now).  There are two options in the Mode selector, KISS and MKISS.  I went with the default (MKISS).
On the Packet IO tab, the network/non-serial side of soundmodem is configured.  Pick an IP address, netmask, and broadcast addres for a regular network interface.  There are two options in the Mode selector, KISS and MKISS.  I went with the default (MKISS).  The network settings we used are:
* IP address: 44.x.y.z (pick something)
* Netmask: 255.0.0.0
* Broadcast: 44.255.255.255
 
We're using the [https://en.wikipedia.org/wiki/AMPRNet AMPRnet] IP block which was set aside for amateur radio use.  We should probably use the private subnet of that, 44.128/16 because it's akin to the RFC-1918 subnets and is used for experimentation in this area.


= Theory =
= Theory =
When running the soundmodem utility ('''soundmodem /etc/ax25/default.conf &'''), the daemon configures the sound card to send and receive bitstreams encoded as audio through the jacks in the soundcard.  On the network side of the house, it allocates a virtual network interface (sm0) which has a callsign associated with it (relevant for ham radio, not so much for other applications) as well as an IP address, network mask, and broadcast address.  The idea is that whatever packets are sent through that network interface will be transparently converted into sound and transmitted using whatever device is connected to the headphone and microphone jacks of the computer.  Conversely, any data received by the broadcast device (ham radio, laser, etc) is demodulated into bits, encapsulated into network frames, and made available to the OS.
When running the soundmodem utility ('''soundmodem /etc/ax25/soundmodem.conf &'''), the daemon configures the sound card to send and receive bitstreams encoded as audio through the jacks in the soundcard.  It allocates a virtual network interface (sm0) which has a callsign associated with it which serves as the MAC address (relevant for ham radio, not so much for other applications) as well as an IP address, network mask, and broadcast address.  The idea is that whatever packets are sent through that network interface will be transparently converted into sound and transmitted using whatever device is connected to the headphone and microphone jacks of the computer.  Conversely, any data received by the broadcast device (ham radio, laser, etc) is demodulated into bits, encapsulated into network frames, and made available to the OS.


In theory, it's just like a point-to-point IP link, only instead of ethernet you're using a nebulously defined network technologyYou should then be able to do with this network interface what you could do with any other: send and receive traffic, route packets, use IPtables to filter traffic, et cetera.
In theory, it's just like a regular network connection, with all of the dynamics you'd expect from IPv4.  This means that we can do things like IP multicasting over these links.  We discovered, through analyzing the code for a utility called [http://www.w1hkj.com/EasyPacket.html easypacket] that the Linux kernel treats AX.25 interfaces as real network interfaces, so much so that it sets up some iptables rules to prevent arbitrary traffic from being routed over them because there isn't much bandwidthWe'll have to add that to our rules.  We tried setting up IPv6 addressing on some AX.25 interfaces and weren't able to.


= Diagnostics, Testing, and Configuration =
= Diagnostics, Testing, and Configuration =
Here's where you debug your configuration.  It's going to take some flipping back and forth between tabs to get right the first time.
Here's where you debug your configuration.  It's going to take some flipping back and forth between tabs to get right the first time.


You really should run soundmodemconfig from a terminal, because if you got something wrong (like the audio device) it'll be printed to stderr.  It doesn't show up in a window.
soundmodemconfig now pops open windows with error output.


The Diagnostics menu only appears when you have a channel (Channel 0) highlighted.
The Diagnostics menu only appears when you have a channel (Channel 0) highlighted.

Revision as of 18:25, 2 June 2013

Soundmodem emulates a hardware modulator/demodulator in software, vis a vis a daemon running in userspace.

v0.18 is the latest, I recommend using that. It now only depends on two things, audiofile and gtk2.

Soundmodem will either turn your soundcard into a KISS radiomodem or an AX.25 network interface. We're going to be using it to create AX.25 network interfaces (/sm[0-9]*/).

Installation

From Source: Ubuntu Karmic and Lucid

wget http://www.baycom.org/~tom/ham/soundmodem/soundmodem-0.18.tar.gz
sudo apt-get install libasound2-dev libxml2-dev libgtk2.0-dev libaudiofile-dev

tar xvzf soundmodem-0.18.tar.gz
cd soundmodem-0.18
./configure && sudo make install
sudo mkdir /etc/ax25  ## or else it won't be able to save your configurations

Configure it by running (as root) /usr/local/bin/soundmodemconfig. It will open a window on your desktop with nothing in it. Click File, New, Configuration. Give your configuration a name (I used 'sm0').

Apt-Get: Ubuntu Lucid and Up

Gets you version 0.13 on Lucid, and 0.15 on Maverick and Natty

As root do the following

apt-get install soundmodem
mkdir /etc/ax25
soundmodemconfig /etc/ax25/soundmodem.conf #see below for configs
soundmodem /etc/ax25/soundmodem.conf -R -M >/dev/null 2>/dev/null& #this makes an awful noise when it works

On Fedora

???

Arch Linux

sudo packer -S soundmodem ax25-apps ax25-tools

Configuration

IO Tab

On the I/O tab, choose your sound driver (out of soundcard, file, simulation, and alsa, I picked alsa). You'll have to play around with the value of the ALSA Audio Driver field to get one that works. On Windbringer, I used plughw:0,0. Check half duplex for now. Leave the Capture Channel field set to 'mono'. I don't know what to set the PTT Driver field to yet, so I left it set to 'none'. My radios do VOX so I've been experimenting with that.

Haxwithaxe, Dan, and Mirage are working on PTT circuits for our radios. It hasn't been an easy process because the Baofengs seem to kick out just enough EMI to make the circuits act weird as-is. We have a few partial solutions at this time.

Channel Access Tab

Don't change the settings on the Channel Access tab.

Channel 0

Right below the name of your configuration in the tree you will see a new entry, Channel 0. If you select it you'll be presented with three new tabs on the right.

Modulator Tab

The possible values for the Mode selector are Off, fsk, afsk, pam, psk, and newqpsk. I picked fsk because it grants the highest effective bit rate (9600 bps). The values for Frequency 0 (1200), Frequency 1 (2200), and Filter (df9ic/g3ruh) were left set to defaults. Leave Differential Encoding checked.

Demodulator Tab

On the Demodulator tab (which governs decoding audio signals into bits) the options are much the same because they match the modulation scheme by default. This is what we want.

Packet IO Tab

On the Packet IO tab, the network/non-serial side of soundmodem is configured. Pick an IP address, netmask, and broadcast addres for a regular network interface. There are two options in the Mode selector, KISS and MKISS. I went with the default (MKISS). The network settings we used are:

  • IP address: 44.x.y.z (pick something)
  • Netmask: 255.0.0.0
  • Broadcast: 44.255.255.255

We're using the AMPRnet IP block which was set aside for amateur radio use. We should probably use the private subnet of that, 44.128/16 because it's akin to the RFC-1918 subnets and is used for experimentation in this area.

Theory

When running the soundmodem utility (soundmodem /etc/ax25/soundmodem.conf &), the daemon configures the sound card to send and receive bitstreams encoded as audio through the jacks in the soundcard. It allocates a virtual network interface (sm0) which has a callsign associated with it which serves as the MAC address (relevant for ham radio, not so much for other applications) as well as an IP address, network mask, and broadcast address. The idea is that whatever packets are sent through that network interface will be transparently converted into sound and transmitted using whatever device is connected to the headphone and microphone jacks of the computer. Conversely, any data received by the broadcast device (ham radio, laser, etc) is demodulated into bits, encapsulated into network frames, and made available to the OS.

In theory, it's just like a regular network connection, with all of the dynamics you'd expect from IPv4. This means that we can do things like IP multicasting over these links. We discovered, through analyzing the code for a utility called easypacket that the Linux kernel treats AX.25 interfaces as real network interfaces, so much so that it sets up some iptables rules to prevent arbitrary traffic from being routed over them because there isn't much bandwidth. We'll have to add that to our rules. We tried setting up IPv6 addressing on some AX.25 interfaces and weren't able to.

Diagnostics, Testing, and Configuration

Here's where you debug your configuration. It's going to take some flipping back and forth between tabs to get right the first time.

soundmodemconfig now pops open windows with error output.

The Diagnostics menu only appears when you have a channel (Channel 0) highlighted.

The first option is Scope, for oscilloscope. To get a test signal, click the PTT button (make sure your speakers are turned down!)

The second option is Spectrum, for spectrum analyzer of the signal being send to the sound card. To get a test signal, click the PTT button (again, make sure your speakers are turned down!)

The third option, Modem, dumps the raw bitstreams that your soundcard-emulating-a-modem is sending and receiving. Seeing strings of bits (even when disconnected) means that you have probably configured soundmodem correctly.

I do not know what the AO40-P3D option does. (It's an amateur satellite protocol thingy. We don't need it?)

To save your config file, use the File, Quit option. It'll save it automagically to /etc/ax25/soundmodem.conf.

So, how is this supposed to work, anyway?

Assume that you have a laptop running Linux (or Windows if you dare) and soundmodem. Assume that soundmodem is configured correctly. Assume that you have a transceiver - a black box that has a pair of audio jacks (speaker and microphone) on the back, can receive signals, and can broadcast signals.

Further assume that there is a third jack on the black box which plugs into the USB port of a computer. Whenever a signal is sent to that jack, the black box stops receiving and transmits whatever signal it gets through its microphone jack. Alternatively two radios one transmitting only and one receiving only (possibly on different channels) such that there is no need for drivers or a switching mechanism.

You'd connect the speaker jack on the black box into the microphone jack on your laptop. You would then connect the headphone jack of your laptop into the microphone jack of the black box. Then plug the push-to-talk USB jack of the black box into a USB port on your laptop.

Whenever a packet (say an ICMP4 echo request) is transmitted to the IP address of device sm0 on your laptop, it is converted by the soundmodem daemon into modulated sound which goes out through the headphone jack to the black box. The push-to-talk circuit engages and the black box stops receiving and goes into transmit mode. The black box receives that modulated static and broadcasts it. When the broadcast is done the PTT disengages and the black box goes back into receive mode. Conversely, whenever the black box picks up a signal it converts it into modulated static, which then goes out through its speaker jack into the microphone jack of your laptop. After the signal hits the mic jack, the soundmodem daemon demodulates the static into bits, packages them into an IP packet, and drops it into the networking subsystem of the kernel.

By using soundmodem we'll be setting up a virtual AX.25 network interface that, insofar as we're concerned, acts just like an ethernet interface. We can use ifconfig, route, and ip to configure it, IPtables to filter traffic, and /proc/net/ipv4/* to tweak it (and set up packet forwarding).

Other resources