AX.25 and Direwolf under Linux

Last updated: 2019-09-07 12:15

I initially was interested in getting Winlink working, so I could send and receive email from anywhere in the world, even thousands of miles from a phone tower, or Internet connection.

As the name suggests, it's heavily focussed around Windows. I don't have any Windows computers in my house, and I don't want to use Wine, so that looked like a dead-end.

So I changed my approach a little. I wondered if it was possible to get an IP connection over an HF radio link. And that's what AX.25 is. I remember seeing AX.25 stuff in the kernel options when compiling my own kernels many years ago.

The good thing about the OSI networking model is that you can replace any layer, and the other layers don't care.

Indeed - people have used pigeons as their physical layer before.

So, as the other layers won't notice the difference, all your existing software will work as normal.

Just really really slowly. 300bps is incredibly slow. If you thought a 56k modem was slow, you ain't seen nothing yet. Still - a slow connection is better than no connection.

One other thing - encryption is banned in amateur radio, so don't use HTTPS, or SSH, or anything else like that over the link.

To get two Linux computers talking over AX.25 and Direwolf

Perform the following steps on both computers. Remember to use a different IP address (in the same subnet!) on each computer.

Also, make sure you use different callsigns

This assumes that you are 1.1.1.1 and the other station is 1.1.1.2. One of you will need to reverse the IP addresses in these instructions for this to work.

Install the necessary stuff

sudo apt-get install ax25-tools direwolf

Configure /etc/ax25/axports

Add the following to /etc/ax25/axports

YOURCALLSIGN YOURCALLSIGN 0 255 7 HF

Configure Direwolf

Save the following config. Adjust ADEVICE, MYCALL, and the PTT lines

ADEVICE plughw:1,0 ACHANNELS 1 CHANNEL 0 MYCALL YOURCALLSIGN MODEM 300 1600:1800 7@30 /4 PTT RIG 237 /dev/ttyUSB0 AGWPORT 8000 KISSPORT 8001

Pick a frequency

Pick a clear frequency on a band that is open between both stations. Try and keep to the narrowband parts of the bandplan.

Start Direwolf

In terminal one, run

/path/to/direwolf -t 0 -p -B 300 -c /path/to/direwolf-ax25.conf

It should show something like this:

Dire Wolf version 1.5 Includes optional support for: hamlib Reading config file /path/to/direwolf-ax25.conf Audio device for both receive and transmit: plughw:2,0 (channel 0) Channel 0: 300 baud, AFSK 1600 & 1800 Hz, D, 44100 sample rate / 3. 0.0: D 1510 & 1710 0.1: D 1540 & 1740 0.2: D 1570 & 1770 0.3: D 1600 & 1800 0.4: D 1630 & 1830 0.5: D 1660 & 1860 0.6: D 1690 & 1890 Ready to accept AGW client application 0 on port 8000 ... Ready to accept KISS TCP client application 0 on port 8001 ... Virtual KISS TNC is available on /dev/pts/1 Created symlink /tmp/kisstnc -> /dev/pts/1

If you have any problems, build it from source.

Set up the networking

In terminal two, run:

sudo modprobe -v ax25 # The pts device has to match the one output by direwolf in the previous step sudo kissattach /dev/pts/1 YOURCALLSIGN sudo kissparms -p YOURCALLSIGN -t 300 -l 30 -s 20 -r 80 -f n sudo ifconfig ax0 1.1.1.1/30 sudo arp -H ax25 -s 1.1.1.2 OTHERCALLSIGN

Allow packets to and from your machine

# The following commands will allow anything in and out of ax0. sudo iptables -I INPUT -i ax0 -j ACCEPT sudo iptables -I FORWARD -i ax0 -j ACCEPT sudo iptables -I FORWARD -o ax0 -j ACCEPT sudo iptables -I OUTPUT -o ax0 -j ACCEPT sudo iptables -L -n -v

Try the network

Ping is the easiest way to try it. The following command sends 2 pings with 1 byte of payload, and some long timeouts

ping -s 1 -i 20 -W 20 -c 2 1.1.1.2

When you hit enter, your radio should transmit, and the other end should reply

PING 1.1.1.2 (1.1.1.2) 1(29) bytes of data. 9 bytes from 1.1.1.2: icmp_seq=1 ttl=64 9 bytes from 1.1.1.2: icmp_seq=2 ttl=64 --- 1.1.1.2 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 37ms

I'm not quite sure where the 37ms comes from. Each ping took about 7 seconds to send and receive a reply.

As a further test, you can try telneting to the other machine on a tcp port that is open. Maybe 22, 25, 80, etc

telnet 1.1.1.2 22

If that works, you should eventually see the SSH banner.

$ telnet 1.1.1.2 22 Trying 1.1.1.2... Connected to 1.1.1.2. Escape character is '^]'. SSH-2.0-OpenSSH_7.4p1 Raspbian-10+deb9u6 BOO! Protocol mismatch. Connection closed by foreign host.

Remember - encryption is not allowed on amateur radio (for good reason), so don't SSH to it, or visit any HTTPS websites.

Troubleshooting

Use tshark to see what packets are going in and out of the ax0 interface:

tshark -npi ax0

Other things to check are ifconfig ax0, route -n | grep ax0, arp -H ax25

Error handling

AX.25 seems to use a 16-bit CRC, and if there is a single error in the packet, the checksum is invalid, and the packet is discarded. On a noisy HF circuit, this could make it very inefficient, retrying each packet, over and over, until it gets through perfectly.

It appears that AX.25 doesn't employ any forward error correction. The fact that FX.25 exists seems to imply that there isn't any. (I can't find any reference to FX.25 in my Linux distro though, so I'm assuming it's not supported).

Problems

I had a problem with a version of Direwolf, so I downloaded and compiled my own version from https://github.com/wb2osz/direwolf, which was pretty painless

IP addresses

Yes, I'm aware that 1.1.1.1 has been assigned. Yes, I'm aware I won't be able to reach the "real" 1.1.1.1 while I'm playing with this. Yes, I'm aware of RFC1918. Yes, I'm aware of AMPRNet. No, it *really* doesn't matter for a closed network between two nodes.