packet
Setup IP Networking via Packet Radio with DireWolf and IL2P

Setup IP Networking via Packet Radio with DireWolf and IL2P

This guide will get you a working TCP/IP network connection over the 2m or 70cm band over just about any radio. This guide will get you a working direwolf installation, a program called tncattach installed, and a network interface connected via IL2P (Improved Layer 2 Protocol). Tncattach is a modern way of creating am IP interface for KISS TNC’s. IL2P is an improvement on the AX.25 protocol to add error correction without the overhead that FX.25 has. Direwolf is a software TNC, eliminating the need for extra hardware.

Prerequisites

Creating a User

Otherwise, follow long to create a user we will use for the rest of the guide.

Swap to the root user if you haven’t already:

#On Debian/Ubuntu
su -l
#On Raspi
sudo su

As root enter the following commands (replace “yourusername” with your chosen username):

apt-get update
apt-get upgrade
apt install sudo
adduser yourusername
sudo usermod -aG pulse-access yourusername
sudo usermod -aG audio yourusername
sudo usermod -aG plugdev yourusername
sudo usermod -aG dialout yourusername
sudo usermod -aG sudo yourusername

Go ahead and reboot the server or relog/ssh into your terminal session as your new user before proceeding.

sudo reboot

Everything from now on will be ran in the context of the new user you just created.

Install Direwolf

This is a quick down and dirty on getting a basic installation of direwolf up and running. It will assume you are using the digirig. For a full guide, with details and all supported sound card interfaces, see this guide (The Ultimate guide to DireWolf)

Issue the following commands to install the latest version of direwolf as a standard user:

sudo apt-get update
sudo apt-get install git
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install make
sudo apt-get install cmake
sudo apt-get install libasound2-dev
sudo apt-get install libudev-dev
sudo apt-get install libavahi-client-dev
sudo apt-get install alsa-utils
cd ~
git clone https://www.github.com/wb2osz/direwolf
cd direwolf
git checkout dev
mkdir build && cd build
cmake ..
make -j4
sudo make install
make install-conf
cd ~

Sound Card Interface

Grab your soundcard device numbers by issuing the following command:

arecord -l

You will see a list of cards, locate the one that has your sound card interface (such as “usb” if using the digirig). Note down the card number, as well as the device number. Most likely 0/0 or 1/0. You will need these numbers for the next part.

Now issue the following command to setup volume levels, and disable AGC:

alsamixer

Press “F6” and use your arrow keys to select your radios sound card interface. Set the speaker volume to 50. If the Microphone seciton has “MM” arrow key to it, and press “M” on your keyboard to unmute it, and set the microphone volume to 10. If a”AGC” bar is present, arrow key to it and Press “M” to mute it. Press escape to close the window, and enter the following command the save the settings:

sudo alsactl store

Serial PTT Setup

We will also need to know the serial port path for PTT. These devices are located in /dev/. If using a usb PTT interface, your PTT serial path will be in the format “/dev/ttyUSBX” .

You can see a list of devices with the following command:

ls -l /dev

Setup the Direwolf Config File for IL2P and Networking

We will now create a new direwolf configuration file. You will need to replace the numbers after “ADEVICE plughw:” with the card and device number found above in the Sound Card Interface section. You will need to replace the serial path after “PTT” with your own. “RTS” used after the path here is for the digirig. This can be RTS or DTR depending on your interface.

Enter the following command to create a new config file:

nano ~/direwolf-network.conf

In the file, paste the following configuration, adjusting the PTT serial path, and ADEVICE card numbers as needed from the results we found previously:

ADEVICE plughw:1,0
CHANNEL 0
IL2PTX 1
MODEM 1200
PTT /dev/ttyUSB0 RTS
AGWPORT 9998
KISSPORT 8001
RETRY 3
FRACK 3
MAXFRAME 7
EMAXFRAME 63
PACLEN 512
DWAIT 0
TXDELAY 20
TXTAIL 10

Press Ctrl+X to Save.

Install tncattach:

sudo apt install git
sudo apt install build-essential
git clone https://github.com/markqvist/tncattach.git
cd tncattach
make
sudo make install

Starting and Testing the Network

We will now need 3 terminal windows to start and test everything. After this, we will move it all to services so that it’s all started on boot automatically.

On Terminal 1, Start Dire Wolf (replacing “youruser” with your own):

direwolf -d kn -c /home/youruser/direwolf-network.conf

On Terminal 2, Start TNC Attach.

Use the following command if you want a Point to Point network (2 IP’s) with no Ethernet overhead:
( The “KN4MKBTNCATTACH” portion of the below needs to contain your own callsign, and must be at least 15 char long) It is used as ID.

sudo tncattach --kisstcp --tcphost=127.0.0.1 --tcpport=8001 -s 'KN4MKBTNCATTACH' -t 600 -m 508 --noipv6 --noup -v

If you instead want to have a network where more than 2 people can communicate, you will need to use the following command instead of the above to add Ethernet frames into the mix (The MTU is adjusted here to leave room for 22 bytes of overhead from the Ethernet frames comapred to the direwolf PACLEN):

sudo tncattach --kisstcp --tcphost=127.0.0.1 --tcpport=8001 -s 'KN4MKBTNCATTACH' -t 600 --ethernet --mtu 490 --noipv6 --ipv4 44.0.0.1/24

In the above command, we give ourselves the IP “44.0.0.1”, and will be able to communicate with anyone on that network via packet.

On Terminal 3, Create the Network Tunnel (Only If using the Point to Point command above):
In the below example, 44.0.0.1 will become your own IP in the radio network, while 44.0.0.2 would be the destination IP. On the other server, connected to a different radio, these IP addresses would be reversed.

sudo ifconfig tnc0 44.0.0.1 pointopoint 44.0.0.2

Testing the network:

If everything goes error free above, you should now be able to ping a distant end, in the example case “44.0.0.2”. You can use the following command to send a single ping:

ping -c 1 44.0.0.2

If all goes well, you should see a reply back. If not, check the direwolf window to make sure the packets are being decoded properly.

Setup Start on Boot

We will now setup the entire network stack to come up when your server is booted.

Install Screen:

sudo apt install screen

Setup Direwolf auto start:

sudo nano /etc/systemd/system/direwolf.service

Paste the following, changing “yourusername” in the three separate areas with your own:

[Unit]
Description=Direwolf
After=network.target

[Service]
Type=forking
ExecStart=screen -S direwolf -dm bash -c "direwolf -d kn -c /home/youruser/direwolf-network.conf; exec sh"
Restart=always
User=kn4mkb
Group=kn4mkb

[Install]
WantedBy=default.target

Press Ctrl+x to Save.

Enable the Service:

sudo systemctl enable direwolf

Setup tncattach to auto start:

sudo nano /etc/systemd/system/tncattach.service

Paste the following, take care to replace the portion in quotes (“”) with your intended tncattach command (the one you used above):

[Unit]
Description=tncattach
After=network.target

[Service]
Type=forking
ExecStartPre=/bin/sleep 30
ExecStart=screen -S tncattach -dm bash -c "sudo tncattach --kisstcp --tcphost=127.0.0.1 --tcpport=8001 -s 'KN4MKBTNCATTACH' -t 600 -m 508 --noipv6 --noup -v; exec sh"
Restart=always
User=root
Group=root

[Install]
WantedBy=default.target

Enable the Service:

sudo systemctl enable tncattach

Auto start the Point to Point Tunnel

This is only needed if your are configuring a point to point tunnel for the tncattach command instead of a /24 network.

sudo nano /etc/systemd/system/tunnel.service

Paste the following:
Take care to replace the IP addresses below with the ones you intend to use with yourself and your packet partner.

[Unit]
Description=tunnel
After=network.target

[Service]
Type=forking
ExecStartPre=/bin/sleep 40
ExecStart=screen -S tunnel -dm bash -c "sudo ifconfig tnc0 44.0.0.1 pointopoint 44.0.0.2; exec sh"
Restart=always
User=root
Group=root

[Install]
WantedBy=default.target

Enable the service:

 sudo systemctl enable tunnel

Restart the Server

sudo reboot

Auto Start Results Verification

Once the server is back up, give it a solid 60 seconds to bring the services up. Afterwards, you can issue the following commands to “check in” on the services by attaching to their console sessions. Take care to use sudo for the tncattach, and tunnel screen commands.

screen -r direwolf
sudo screen -r tncattach
sudo screen -r tunnel

To detach from the screen press Ctrl + A on your keyboard, followed by the “D” key. If all is well, you will be able to ping the distant radio/server.

EXTRA: Optimizing the Network

This is just a few notes on achieving lower latency, and higher throughput in your packet network.

Reducing Latency

The first element to take a look at are the TXDELAY and TXTAIL parameters within the direwolf configuration file. Start these out higher to give plenty of room for your transmitter to “balance” out before sending data, as well as give the transmitter time to finish sending before disabling the PTT. These values are calculated by multiplying the value by 10, and the result is the delay in milliseconds. The above configuration of TXDELAY 20 and TXTAIL 10 will result in a 200ms delay prior to data, and a 100ms delay before stopping the transmission. Slowly turn these values down one at a time, and verify the other end can still decode your packet until your station is no longer understood. Then add a bit back onto it to create a small buffer. This will result in the lowest latency your radio can handle. I’ve found my RT95 will work finer with a TXDELAY 10 and a TXTAIL 0, despite warnings form dire wolf.

Increase Speed

Using a larger PACLEN value in the configuration file, combined with an increase in the MTU supplied to the tnc attach command can allow larger packet sizes. This can result in overall less overhead of the network by sending more data with each frame header. As a general rule, have your PACLEN within direwolf be 4 bytes more than the MTU supplied to tncattach to allow for the IP frame header in point to point networks. If using ethernet frames as well (such as a /24 network) have your PACLEN be at least 20 more than the MTU supplied to tncattach. The draw back to larger packet sizes will be the likelihood of a packet not being decoded due to interference screwing up too many bits in the packet. As such, a more reliable link will allow larger packet sizes.

You can also increase the modem speed within dire wolf from the 1200 supplied in the above example configuration. Keep in mind, this is somewhat limited to your digital sound card interface, and radio. Radios that supply a dedicated data jack often support up to 9600 baud. I’ve found that most radios will be happy with a value of 2400. But this rule has exceptions. Both modems in the network will need the same speed setting. As such, my config usually has “MODEM 2400” as the speed setting as this does well with my RT95.

Consider Subscribing!

Signup for our once a month newsletter!

We don’t spam! Read our privacy policy for more info.

1 thought on “Setup IP Networking via Packet Radio with DireWolf and IL2P

Leave a Reply

Your email address will not be published. Required fields are marked *