Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transport: Native KISS+AX.25 support #56

Open
martinhpedersen opened this issue Oct 1, 2019 · 9 comments
Open

transport: Native KISS+AX.25 support #56

martinhpedersen opened this issue Oct 1, 2019 · 9 comments

Comments

@martinhpedersen
Copy link
Member

Several discussions regarding this topic has been started. I'm opening this issue for future discussions regarding:

  • KISS over TCP/UDP/Serial
  • Native AX.25 support (AX.25 on any platform supported by Go)

KISS refers to a protocol to transfer raw bytes (as they should be transmitted on air) to a modem. KISS is usually used to encapsulate AX.25 packets in order to send it to a packet modem (hardware KISS TNC, DireWolf etc).

It merely serves to encapsulate the protocol frames in a way that can successfully pass over a serial link to the TNC.

AX.25 is a data link layer protocol, responsible for establishing link-layer connections, transferring data between nodes, detecting errors and handle re-transmission of lost packets. AX.25 is an ARQ protocol.

In order to support KISS-only TNCs (like DireWolf, TNC-X, Kenwood TH-D74 etc) natively in Go, we will first need a full AX.25 implementation for the link-layer stuff.

KISS should be trivial to implement, but writing a decent AX.25 implementation is a more challenging task.

Some open source implementations exists, but only a few of them have been used and tested extensively.

Non-exhaustive list of implementations with (more or less) open source code:

All of these implementations have their strength and weaknesses which should be identified before considering which could be the basis for an eventual port to Go.

More info on this topic:

Related issues:

@cminyard
Copy link

I realized I commented in a closed issue. So here it is again...

I have just finished implementing an AX25 library in C. It's part of the gensio library at https://github.com/cminyard/gensio and it's portable to Windows, MacOS, and Linux. It has C++ and Python bindings at the moment. I assume Go wouldn't be very hard.

I would really like to avoid having to deal with the Linux kernel AX25 stack. I don't know Go, though. I could learn it if you are interested.

The gensio library can do a lot of other things that might be useful, too.

Obviously it hasn't been around that long, but I'm planning to keep working on it. I have my own uses for it.

@cminyard
Copy link

Just FYI, I have added Go language support to the gensio library.

@cminyard
Copy link

I now have native AX.25 support working in pat. To use this, do the following:

git clone https://github.com/cminyard/wl2k-go.git
cd wl2k-go
git checkout gensio-work
cd ..
git clone https://github.com/cminyard/pat.git
cd pat
git checkout gensio-work
./make.bash libax25
./make.bash gensio
./make.bash

This adds a new connection type named "gax25" that works much like ax25, except it doesn't require the kernel's ax25.
There is a new pat configuration entry for it.

This is based on the gensio library, and the connection below the ax25 layer is specified with a gensio string specifier. The default one is:

kiss,tcp,localhost,8001

which will connect to port 8001 and run kiss on top of that and ax25 on top of that. To connection to a kiss tnc:

kiss,serialdev,/dev/ttyS0,9600n81

Many other transports are available, like UDP, SCTP, unix sockets, ptys, stdio to another program, and connections to remote serial ports with serial port control (RFC2217). It can do encryption and authentication, too. For instance, I've tested by setting up a UDP repeater and run it on a local network without a radio. Handy for testing, especially automated.

I'm hoping this is interesting to the maintainers. It's a lot easier than using the kernel stack. It's going to be rough on the edges at this point, but it does seem to work ok for connecting into the winlink network and for P2P communication.

@cminyard
Copy link

Oh, I forgot, you need a bleeding-edge version of swig, the master branch at https://github.com/swig/swig so you'll need to check that out and install it so it's first in the PATH.

I've found quite a few issues with swig and Go, and there are still a few pending that I have workarounds for.

Also note that gensio works on Windows, so it would be possible to have native AX.25 support on WIndows with this.

@cminyard
Copy link

Well, sorry, the swig people haven't pulled in some patches I sent yet. You will need to get swig from https://github.com/cminyard/swig and use the add-goin-newline, branch. It's a pain, yes. But swig will generate go code that won't compile without those patches.

@xylo04
Copy link
Contributor

xylo04 commented Mar 23, 2022

Still, this is exciting! I can't wait to try it out!

@cminyard
Copy link

I was able to get it to work under Windows. gensio is compiled with mingw64. There were a few little fixes, but nothing big, and it's all checked into the master branch of gensio.

@martinhpedersen
Copy link
Member Author

Very exciting indeed 🙂 👍 Looks like gensio and Go's net package solves much of the same things, by providing a common abstraction over networked I/O. Could be a very good fit 👍

I have some concerns regarding taking in such a large non-Go dependency though. It complicates the build process, especially when it comes to cross compilation to other platforms. That's one of the reasons why a native AX.25 implementation would be such a nice addition to the project. Currently, we can provide everything but AX25 natively. Meaning you can build a full-blown Pat binary for your Android phone as simply as GOOS=android GOARCH=arm64 go build, without the AX.25 support.

But since we're already using cgo to link against libax25 on Linux, I guess we could consider replacing it with this to support even more platforms. The way I ended up implementing support for Linux's AX.25 stack was to use a specific opt-in build tag libax25 in combination with the OS specific build tags. It ensures that both wl2k-go and Pat can be compiled as pure Go programs, making it highly portable. We have also emphasized on not linking against shared libraries, to make the binaries as portable and self-contained as possible. I guess it should be possible to statically link against gensio the same way? 🤔

Another approach could be to wrap gensio in a small app much like libhamlib's rigctld. Then gensio would be like any another modem for Pat 🙂 The benefit of this approach is of course that you could add multiplexing support so multiple apps could share the same AX.25 device.

@cminyard
Copy link

cminyard commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants