Related Topics:
 • Thru-Modem
 


 Using a Soundmodem on Packet Radio


How to configure a soundmodem for JNOS or the AX25 Utilities


Typical Sound Card as
found in many machines today
D

id you know that you can use your sound card as an audio modem for packet radio, similiar to a TNC or even a Baycom modem ? It is called a soundmodem. What makes all this possible is the audio frequency synthesis emanating from your sound card's wave generator! Most machines come with this great piece of hardware already on-board; and no doubt, you have played music through your sound card, or played sound-tracked games with it, without ever considering to what other uses it might be put!

Well, here is a great application just waiting to happen! If you are a Ham, and have an interest in packet and would like to explore this "medium" without spending alot of money just to see if you like it, here is a way to use the equipment you probably already own, or have had running at one time. You'll need a vhf radio, a little patience and persistence, and a few electronic parts. (You might even want to try experimenting with 9600 Baud, which a fairly fast machine, and properly "tweaked" FM radio, should be able to handle.)

You'll also need to have the soundmodem module compiled on your system. To find out how to do this, please see "Making the Soundmodem Module" companion page. (And be sure to read the extensive documentation that comes with the soundmodem distribution, or found at "Thomas Sailer"'s website via Google.)

Note : This article is meant for operators who are already running a JNOS or AX25 Utilities System. The approach here is the "long way 'round." There is a much quicker install/configuration called the "user space" or "user mode" found on Thomas Sailer's website. If you are looking for a quick setup and test, download the "user" package(s) found there. If you want to compile and apply the sound modules on a more system "integrated" basis, then read on ... :)

We have two (2) options. We can set up the drivers for the AX25 Utilities, or we can set them up for JNOS, or any NOS system running on Linux. If you want to use JNOS as the application software for a soundmodem device, you could obtain the complete AX25 Utilities package, although, you may not need to do this. At the very least, you need a copy of net2kiss and sethdlc, which are both usually included in an AX25 Utilities distribution. (You may be able to obtain these two pieces of code independently in a separate "soundmodem" distribution. From Google, try the search key "Thomas Sailer" who is the software engineer and designer who put together this super soundmodem package. You will certainly be able to find a suitable, down-loadable distribution via FTP for your machine.)

Preliminary to either set up, JNOS or the AX25 package applications, the soundmodem device drivers must be loaded into the kernel, either at compile time, or by using the insmod command to load them as modules. I prefer to load them as modules. At a minimum you will need these modules:

  • bsd_comp.o
  • hdlcdrv.o
  • soundmodem.o

NOTE: You may need more modules depending on what you want to do, your network requirements, and the software release. (The soundmodem module is called soundmodem.o, responsible for the sm[0-3] interfaces.)



Loading the Modules and Configuring the Interfaces

If you don't have the sm devices already compiled into the kernel, then you may load them in the order shown using this general command syntax:

  • insmod [ -f ] <path>/<modules>

where path is /lib/modules/<ur_os_version>, for example:

  1. insmod [ -f ] <path>/bsd_comp.o
  2. insmod [ -f ] <path>/hdlcdrv.o
  3. insmod [ -f ] <path>/soundmodem.o

Your "ur_os_version" can be obtained from the command:

  • uname -r
An example command line from my system:
  • insmod -f /lib/modules/2.0.30/net/hdlcdrv.o
You should initially load these manually from the console to verify that each step has worked. Later on, you may build a script that will automate these installs. The "-f" indicates a force and will attempt a load whether the module version and the OS version match. (It may "complain" that the module does not match, and it may not work correctly if at all, so the "-f" switch is only marginally useful and thus is optional.)

After you have issued these commands, you should see their listing in the modules table. The command lsmod should display:

The Installed Modules Table

Module:        #pages:  Used by:
soundmodem         2            1
hdlcdrv            2    [soundmodem]    4
bsd_comp           1            0
dummy              1            1
ne                 2            1
8390               2    [ne]    0
ppp                5    [bsd_comp]      0
slip               2            1
slhc               2    [ppp slip]      1
                      

This indicates that the modules are now "a part" of the kernel and are ready to be configured. Note that the soundmodem driver uses the hdlcdrv driver. Also, note the short length of this table which was excerpted from the ka1fsb.ampr.org machine, a very "light" router.

As further confirmation, you should also see these devices appearing in the /proc/net directory in file dev. So before the insmod command, these network interfaces will not be listed in this table and after the module insertion, they will be listed. And one more point, if you had these interfaces compiled into the kernel, they would already be in the file dev.

The Listing of Interfaces Available in the Kernel (/proc/net/dev)

Inter-|   Receive                  |  Transmit
 face |packets errs drop fifo frame|packets errs drop fifo colls carrier
    lo:     18    0    0    0    0       18    0    0    0     0    0
   nr0:      0    0    0    0    0        0    0    0    0     0    0
   nr1:      0    0    0    0    0        0    0    0    0     0    0
   nr2:      0    0    0    0    0        0    0    0    0     0    0
   nr3:      0    0    0    0    0        0    0    0    0     0    0
  eth0:   1392    0    0    0    0     1300    0    0    0     0    0
dummy0: No statistics available.
   sl0:    852    0    0    0    0      573    0    0    0     0    0
  bpq0:      0    0    0    0    0        0    0    0    0     0    0
   sm0:      0    0    0    0    0        0    0    0    0     0    0
   sm1:      0    0    0    0    0        0    0    0    0     0    0
   sm2:      0    0    0    0    0        0    0    0    0     0    0
   sm3:      0    0    0    0    0        0    0    0    0     0    0

Notice the four (4) interfaces sm[0-3] now resident in this kernel table. The detail information is nearly the same as returned by the ifconfig command. (This table can sometimes be useful when troubleshooting a device.)

OK, we now have "offical" network devices in place ready to be configured and activated. The configuration utility is called sethdlc and it performs the final required attaches for the network interfaces sm[0-3]. It links the interface/device or port to the sound card at the specified address on an irq, using a selected "mode." (The mode might have more commonly been sbc:afsk1200 with an address of 220 and irq of 5. But many years ago, I configured my sound card to emulate a Windows Sound System (wss) and that is why I used the configuration below.) Here are example commands:

  1. sethdlc -p -i sm0 mode wss:afsk1200 io 0x530 irq 7 dma 0

If you were to do an ifconfig on sm0 at this point, you should see a new line added to the interface information display, the "Interrupt" and "Base address" line. This proves that the device is potentially tied to the sound card via the soundmodem drivers. (As you can see, this table also contains extensive network parameters which will be explained below... )

Network Interface Parameters Table

sm0       Link encap:AMPR AX.25  HWaddr KA1FSB-8
          inet addr:44.56.26.10  Bcast:44.56.26.255  Mask:255.255.255.0
          UP BROADCAST RUNNING  MTU:256  Metric:1
          RX packets:692 errors:0 dropped:0 overruns:0
          TX packets:448 errors:0 dropped:0 overruns:0
          Interrupt:7 Base address:0x530

We now need to set some operational parameters for the radio. Again, we use the sethdlc utility featuring the "-a" switch:

  • sethdlc -i sm0 -a txd 250 txtail 20 slot 100 ppersist 128 half
This is where you can specify your customary values similiar to what you might use on a regular TNC. Be sure to specify "half" for half duplex. (It is capable of full, but it doesn't make sense given the nature of packet radio transmissions.)

OK, we are almost done! One final required step is to make sure the interface is up. By up, I mean activated, appearing on the "big" list as a result of the ifconfig command. You can do all the above steps, but if it isn't up, it won't work! Here is the last essential command, including an optional mtu parameter for packet size:

  • ifconfig sm0 mtu 256 up
Now, you have a fully configured network interface. It is ready to be used by either the AX25 Utilities or JNOS. However, you still may wish to further modify this interface by using the ifconfig command to optionally add an IP number, a netmask, or a broadcast address.
  • ifconfig sm0 44.xx.xx.xx netmask 255.255.255.0
  • ifconfig sm0 broadcast 44.xx.xx.255
You would fill in the "xx" values based on your network. And you might want to add routes to the routing table as well...

EXTRAS: If you are in a troubleshooting frame of mind, here are some handy commands that could help in diagnosing faults:

  1. sethdlc -i sm0 -p
  2. sethdlc -i sm0 -a
The first shows the mode and driver values for the port/device/interface, sm0. The second shows the communication parameters for the radio.


How To Setup for AX25

If you want to use your new interface as a port in the AX25 Utilities, you are 90% of the way to your objective. All you have to do is to make sure this port is defined in the axports file and configured in the ax25d.conf file. (For a more complete discussion, see the sections on the AX25 Utilities. )

Sample Data Values for Axports and Ax25d.conf Files

sm0 entry in the axports file:
     sm0 KA1FSB-8 1200 256 1 145.070 Mhz "Wellesley, MA" 1200 bps Radio AFSK Modem
sm0 entry in the ax25d.conf file:
     # FSB-BBS on sm0
     [KA1FSB-8 via sm0]
     NOCALL * * * * * * L
     default 1 10 3 300 10 5 -       root    /usr/sbin/node node %d %s

Then you either will have to re-start the ax25d daemon or give it the "-HUP" signal and it will re-read the ax25d.conf file and pick up your newly added port. Here is what the signal command looks like:

  • kill -HUP <pid_of_ax25d>
where the "pid_of_ax25d" is found by listing the process table using ps ax. And to log this activity, you will have to start the mheardd daemon again by a kill and a re-start; it can't be "hupped."

To verify that the port is active and "listening," use the netstat command with the "--ax25" switch:
  • netstat --ax25
You should see the port listed in this table as an active AX.25 socket.

The Active AX.25 Sockets Table

Activate AX.25 sockets
Dest       Source     Device  State        Vr/Vs  Send-Q  Recv-Q
*          KA1FSB-8   sm0     LISTENING    00/00  1228    0

And you should be able to call out on this port as well:
  • call -r sm0 <callsign>
where "callsign" is a well known station that always comes back to your requests for a connection. (test, test, test... )


How To Setup for JNOS

Setting up the internal "links" for JNOS is not too troublesome, in fact, it is relatively straightforward. Recall, though, that at a bare minimum, you need to obtain the newest net2kiss code, or the kiss part of the AX25 Utilities, or the whole package. This code forms a "bridge" between the soundmodem driver and the JNOS application. (The code may be available along with the soundmodem drivers, separate from the AX25 package.)

As an interesting and peculiar aside, you may use both JNOS and the AX25 Utilities at the same time and with the same SSID, "sharing" the same hardware device, although I don't recommend this for normal use! They can both call out, but the result on receive is unpredictable! Sometimes, one or the other receives, and sometimes they both receive together. To solve this, you may kill the ax25d server if you don't need it, and still be able to call out using the AX25 package! Now all receives for the "shared" SSID go to JNOS. (Of course, if you are using different SSID's for the AX25 package than you are using in JNOS, there will be no problem.)

NOTE : By way of clarification, you do not need the AX25 Utilities package, nor do you need to configure the axports or ax25d.conf files, to use the soundmodem drivers for JNOS! All you need to use are net2kiss and sethdlc. The sethdlc "talks" to the hdlcdrv driver module which you installed earlier, and the net2kiss set ups a bridge or link between the driver and the JNOS application via a pseudo-tty.



Once you have an active and configured sm0 interface, you need to choose a pseudo-terminal , such as ptyqa. You may choose any one that you like. Make sure it is not in use anywhere on the system. A quick look at the PID table (ps ax) is a good place to begin. This will create the internal communication link between the network interface, sm0 and the JNOS application, i.e., JNOS's network interface, whatever you decide to call it. (I labelled mine sm0 as well.)

The "glue" that makes this work is a program named net2kiss. It links the system interface with JNOS's interface by means of a pseudo-terminal. Here is the command:

  • net2kiss -i sm0 /dev/ptyqa &
This program also encapsulates the data packets in a kiss format, hence, its name. (JNOS needs to see it coming across as kiss.) It then "un-kisses" the packet and extracts the original data.

On the JNOS side, you need to set up an attach statement to "grab" the other side of the "pipe." You also need to label the JNOS interface. Here are the sequence of commands that are run from your autoexec.nos:

Configuration Statements for Attaching the sm0 Device in the Autoexec.nos File

attach asy ttyqa - ax25 sm0 1024 256 1200
asyconfig sm0 txq 5
asyconfig sm0 rxq 5
ifc sm0 description " VHF port on 145.070 SOUND  MDM 1200 baud 
ifc sm0 broadcast 44.56.26.255
ifc sm0 netmask 0xffffff00
ifc sm0 ax25 bctext "JNOS/Linux 1.11f TCP/IP 44.56.26.11 14.105<>145.070, [Wellesley, MA]"

The pseudo-terminal ttyqa is the slave side of the "pipe" and hooks into the ptyqa side. As you can see, I have named my JNOS interface sm0. Once inside JNOS, you can label it anything you like. You may then go on to further configure this device in JNOS just as you would for any TNC.


A Script for Setting Up the Soundmodem

Here is a script that I use on my desktop machine. It loads the necessary drivers if they are not already there as modules, and then sets parameters for the soundmodem driver via the sound card. This script just manages the setup for the network interface, sm0. It does not apply the device to any application, so you may want to encorporate portions of this script into your own startup or runtime config routines...

Script: do_smd
#!/bin/sh
# do_smd
# 12-20-04: Revised for Desktop machine
# 12-27-04
# KA1FSB/kbn
#
# -----------------------------------------------------------------
# Set up the sound card as a modem for packet radio: 
# Can be used by JNOS or the AX25 Utilities. (JNOS requires
# an additional net2kiss configuration.)
#
# NOTE: The sound card can only do one thing at a time, so either
# it is used for the cdrom as music, or it is used for the
# soundmodem! Not both! Note that you can insert, then remove it, 
# to initialize the sound environment, but is that always necessary?
#
# NOTE: We are just configuring the device sm0 here... (You will need
# to continue on config'ing it as you would any AX25 device, such
# as ax0.)
#
# -----------------------------------------------------------------

#----- Inits...
LINUX_VER=""
MOD_PATH=""

#----- Begin at screen top
clear

#----- Sound initializations, this may be optional...
#----- Test to see if required on your system
#insmod sound
#sleep 1
#rmmod sound

#----- Set some system vars here...
LINUX_VER=`uname -r`
MOD_PATH=/lib/modules/${LINUX_VER}/net

#----- Must insert these mods first...
echo "=>     Inserting modules for soundmodem operation..."

#----- Usually already there... but just in case it isn't
insmod $MOD_PATH/bsd_comp.o
if [ "$?" = "0" ]
then
        echo "bsd_comp loaded..."
fi

insmod $MOD_PATH/hdlcdrv.o
if [ "$?" = "0" ]
then
        echo "hdlcdrv loaded..."
fi

insmod $MOD_PATH/soundmodem.o
if [ "$?" = "0" ]
then
        echo "soundmodem loaded..."
fi

echo "=>     Finished module insertion!"
sleep 1
echo "=>     Attaching the sm0 device..."

#----- "Attach" the device sm0 to the sound card
#----- The alternate below is often the default on the card...
#----- Alternate: sethdlc -i sm0 -p mode "sbc:afsk1200" io 0x220 irq 5 dma 1

ifconfig sm0 down

sethdlc -p -i sm0 mode wss:afsk1200 io 0x530 irq 7 dma 0

if [ "$?" = "0" ]
then

#----- Set up the packet radio params, or could re-do in do_kissparms... 
        sethdlc -a -i sm0 txd 250 txtail 20 slot 100 ppersist 128 half

        sleep 1

#----- NOTE: Use command sethdlc -a -i sm0 to verify registered data...

#----- Turn on the interface...
#----- Alternate for TCP/IP work: ifconfig sm0 promisc mtu 216 up
#----- Verify with: ifconfig sm0
        echo "=>     Configuring the device for TCP/IP"
        ifconfig sm0 44.56.26.10 hw ax25 ka1fsb-8 broadcast 44.255.255.255 mtu 216 up

#----- Set your callsign on this device
#----- Must have this: axports table entry not enough, evidently!
#----- Maybe redundant to above...
        axparms -setcall sm0 ka1fsb-8

#----- NOTES: Use the smmixer to adjust the soundcard... 
#      This is ***just*** an example... set radio vol to about 4-5 o'clock
#      This is the "line" input on the sound card. i=input, o=output
#      Alternate: smmixer -i sm0 s=aux1 i=3 o=0

#----- Mic input version... This may have better pickup on RX
        echo "=>     Adjusting the Mic gain..."
        smmixer -i sm0 s=mic i=10 o=0

else
        echo "Could not inititialize the sm0 device!"
fi

#----- Just set up the sound card here as a AX25 device, sm0...
#----- You could now configure routes, etc and set up ax25
#----- as usual... use: netstat --ax25 to verify in sockets table

#----- End of do_smd

Here is the screen capture for the output of this script. Notice that the "new parameters" conform to the specs that we asked for. So, the "attach" worked OK! Also the mic gain has been set to 9dB, which is close to the 10 we asked for. (I adjust my soundmodem's output via the sound card's mechanical volume control.)

Output from the script do_smd

=>     Inserting modules for soundmodem operation...
hdlcdrv loaded...
soundmodem loaded...
=>     Finished module insertion!
=>     Attaching the sm0 device...
sethdlc: Version 0.5; (C) 1996-1997 by Thomas Sailer HB9JNX/AE4WA
driver name: soundmodem
current parameters: mode <unspec>:<unspec>,<unspec> io 0x0 irq 0 dma 255 dma2 
 4294967295 serio 0x0 pario 0x0 midiio 0x0
new parameters:     mode wss:afsk1200 io 0x530 irq 7 dma 0 dma2 
 4294967295 serio 0x0 pario 0x0 midiio 0x0
sethdlc: Version 0.5; (C) 1996-1997 by Thomas Sailer HB9JNX/AE4WA
current parameters: TX delay 200ms, TX tail 20ms, slottime 100ms, 
 p-persistence  40/256, Half duplex
new parameters:     TX delay 250ms, TX tail 20ms, slottime 100ms, 
 p-persistence  128/256, Half duplex
=>     Configuring the device for TCP/IP
=>     Adjusting the Mic gain...
smmixer: Version 0.2; (C) 1996-1997 by Thomas Sailer HB9JNX/AE4WA
Left input:  Source: Mic  Gain:   9dB
Right input: Source: Mic  Gain:   9dB
Left output:  Gain:   0dB
Right output: Gain:   0dB

Notice that there is a "call and response" pattern to this output. The code shows what is currently in place, and then shows the effect of the request with the new data replacing the "unspecifed" parameters.

You might also see some "minor complaints" generated by sethdlc, such as, no CPUID and irq 7 not being available. But, these are not serious issues. Irq 7 actually is free on my system; it may not be exactly what the sound card was set to, but it is "programmable" from sethdlc! It accepted these values; and it does work!

To further show the depth of the attach, here is the dump from the /proc/ioports file:

File: /proc/ioports  
ka1fsb:/proc# cat ioports
0000-001f : dma1
0020-003f : pic1
0040-005f : timer
0060-006f : keyboard
0080-009f : dma page reg
00a0-00bf : pic2
00c0-00df : dma2
00f0-00ff : npu
0170-0177 : ide1
01f0-01f7 : ide0
0240-025f : NE2000
02e8-02ef : serial(set)
02f8-02ff : serial(set)
0376-0376 : ide1
0378-037f : lp
03c0-03df : vga+
03e8-03ef : serial(set)
03f0-03f5 : floppy
03f6-03f6 : ide0
03f7-03f7 : floppy DIR
03f8-03ff : serial(set)
0530-0537 : wss

Notice the port at address 0530. It is wss as requested...

And here is a sample of the /proc/interrupts file:

File: /proc/interrupts  
ka1fsb:/proc# cat int*
 0:    2079174   timer
 1:       4287   keyboard
 2:          0   cascade
 3:        122 + serial
 7:      44681 + wss
10:          6 + serial
12:       5272   NE2000
13:          1   math error
14:         39 + ide0
15:      33864 + ide1

If you observe the number to the left of the wss label, you will notice that it steadily increments, just as its "close relative" baycom does. If another dump of the file shows increasing numbers, then you know it is up and running OK! And if you "peek" into the /proc/dma file, you will see a "0" also as requested via sethdlc.

All this "evidence" should convince you that you have a viable sm0 network device, or port on AX25, running and are ready to start moving packets!

Conclusions...

In summary, using your sound card as a soundmodem can be an inexpensive way to "test the waters" in packet radio and even experiment with higher over-the-air speeds. Building the module does require a little patience and care; but once made, it is quite straighforward to work with, being similiar to the bc[0-3] baycom devices, which, in fact, Thomas Sailer created as well. So, not only can you listen to your favorite music through your sound card, but you can get your packet radio station on the air with it too! (Just not at the same time... :)



(Courtesy KBNorton Computer Services)