[Xastir] dual port TNC
Tom Russo
russo at bogodyn.org
Wed Jun 17 00:41:40 EDT 2009
On Tue, Jun 16, 2009 at 11:58:11AM -0600, we recorded a bogon-computron collision of the <russo at bogodyn.org> flavor, containing:
> On Tue, Jun 16, 2009 at 11:15:13AM -0600, we recorded a bogon-computron collision of the <russo at bogodyn.org> flavor, containing:
> [TNC sharing]
> >
> > I have been trying to figure out ways to do this without ldsped, and they
> > all seem to revolve around "kissnetd" and remserial.
> >
> > The thing that's missing is a simple program that can tie together two
> > ax.25 network ports. Digi_ned's web page describes a way of doing it with
> > digi_ned, but since I don't really want to do any digipeating that seems the
> > wrong approach.
> >
> > Here's what I've thought might do the trick if that one piece were available:
> >
> >
> >
> >
> > +--- ax25bridge---+ 2 3 4
> > | | pty pty pty
> > ax25p1 ax25p2 | | |
> > | | | | |
> > KISS TNC PTY1 | | |
> > | | | |
> > +--kissnetd--+---+---+
> >
> > That is, there's an AX.25 kernel interface to a real tnc, bridged simply
> > to a second ax.25 interface that talks KISS on a PTY. kissnetd creates
> > a fake network of PTYs that all talk KISS to one-another. The ptys can be
> > attached to applications, or to remserial. Obviously, the PTYs are really
> > pairs of devices, I'm just showing them as one for simplicity of the figure.
> [...]
> >
> > It's that simple bridge that doesn't seem to exist.
> [...]
>
> Someone here just mentioned socat in this thread. I've never used it, but
> it appears that it could possibly be exactly the tool for the job:
>
> socat INTERFACE:ax25p1 INTERFACE:ax25p2
>
> Has anyone used socat to connect interfaces directly this way? If it works
> then perhaps the little ugly ascii graphic above can be implemented trivially
> with existing tools (socat, kissnetd, remserial, and ax.25 kernel networking).
Cha-CHING! W00T!!!1! and all that sort of silliness.
Got it working with only socat and ax.25 kernel networking in the toolbox. I
am currently running my Xastir station on FreeBSD attached to a KISS TNC on my
SheevaPlug. Xastir is also running in a VNC server on the Sheeva, talking to
the same TNC through an AX.25 kernel port. So far it works like a charm.
Here's what I did:
- Built a custom 2.6.30 kernel on the Sheeva to add several modules, including
USB Serial support (so the serial adapter would be recognized), and of course
enabling AX25 networking). The sheeva ships with a 2.6.22 kernel with
almost no modules. Building a custom kernel is almost a required first
step.
- apt-get install libax25-dev ax25-apps ax25-tools
- download and build socat 1.7.1.1 from source
> cat /etc/ax25/axports
aprs KM5VY-5 19200 256 7 144.39 APRS (1200 bps)
fake KM5VY-6 19200 256 7 to be attached to ptys
> /usr/sbin/kissattach /dev/ttyUSB0 aprs 44.24.250.250
> /usr/sbin/kissparms -p aprs -t 500 -s 200 -r 32 -l 100 -f n
> /sbin/route add -net 444.0.0.0 netmask 255.0.0.0 dev ax0
These steps enable the ax.25 interface ax0, known as "aprs" to Xastir.
I'm really not sure why I need to add the route, but that's there in all
the ax.25 instructions I've seen so far. Since I have no need to do
TCP/IP on these network interfaces, I don't know that this is necessary.
Would be delighted to find out it isn't.
> (a "modprobe mkiss" would be necessary here, but I built mkiss into my
custom kernel without it being a module)
> /usr/sbin/kissnetd /dev/ptyp1 /dev/ptyp2 &
This sets up two pseudo ttys talking KISS to each other. Add more ptys to
taste if you're gonna share the port with more than one program or machine.
> /usr/sbin/kissattach /dev/ttyp1 fake 44.24.250.251
> /usr/sbin/kissparms -p fake -t 500 -s 200 -r 32 -l 100 -f n
This enables ax.25 interface ax1, known as fake, and attaches it to one of
the two PTYs on the virtual kiss network created by kissnetd.
> socat INTERFACE:ax0 INTERFACE:ax1
This ties the two ax.25 interfaces together. Unfortunately, this requires
version 1.7.0 of socat (or later), and the version in the Ubuntu repositories
is 1.6.0 even on Jaunty 9.04 --- so I had to build socat from source.
1.6.0 does not provide the capability of connecting raw network interfaces
like this.
By doing this, all the traffic on the real TNC is now showing up on the
PTYs connected through "fake" and kissnetd.
Now there's a pty, /dev/ptyp2 that is sitting there talking KISS with nobody
attached to it. All traffic received by the TNC is being fed from ax0 to
ax1, which then talks to the fake KISS tnc on /dev/ttyp1, which traffic is
relayed through kissnetd to the fake serial port on /dev/ptyp2. Tne last step
is on my FreeBSD machine:
BSD> socat PTY,link=$HOME/.xastir/dev/faketnc0,raw,echo=0,waitslave EXEC:'"ssh sheevaplug socat - /dev/ttyp2,nonblock,raw,echo=0"'
This ties a PTY on the BSD machine through an SSH tunnel to the shevaplug's
/dev/ttyp2, and creates a symlink to the new PTY called "faketnc0" in the
'dev' directory of my .xastir directory. For all intents and purposes, there's
a serial KISS TNC connected to that PTY. Create a KISS TNC interface in Xastir
and give it "/users/russo/.xastir/dev/faketnc0" as the device name, and
badabing badabang, badaboom, that Xastir is sharing the TNC on the other
machine. Socat will create the link upon activating the interface in Xastir,
which in this case causes ssh to prompt for a password (this is why I haven't
backgrounded the socat instance here).
In theory one could have used remserial here instead --- but it turns out that
remserial doesn't build on FreeBSD. Socat does.
This is, of course, a cheesy workaround that I'll only use until ldsped is
released in source code. It is not dynamically extensible --- the number of
shares of the TNC is fixed when you run kissnetd. I set it up here with
only two ptys, one for the fake TNC connection through ax1, and the other to
be used by xastir remotely. Add more ptys to that line and you can share 'em
all over the place. ldsped will be a better choice, though, because it will not
require so many pieces. It simply binds to all ax.25 interfaces and provides
an AGWPE-compatible daemon to connect to.
Will add this to the wiki some other time, after I've had a little experience
with how well it works and how stable it is.
Thanks, Jason, for mentioning socat. I had never heard of it before, and
it's like the Swiss Army knife of network tools! Unfortunately, all this does
you no good at all since AX.25 kernel networking is a linux-only deal. It
did me no good at all before getting the SheevaPlug, either --- I have no
linux machine at home other than my cracktop, and I'm not willing to leave
that at home as a permanent server. If the Sheeva turns out to be a stable
platform, I now have a TNC server!
Next step: get javAPRSSvr working on it... I'd really like to stop using
Xastir as the IGate software.
Real next step: script this thing so I can reproduce it without having to
reread this email or a wiki page every time I need to start the thing up.
--
Tom Russo KM5VY SAR502 DM64ux http://www.swcp.com/~russo/
Tijeras, NM QRPL#1592 K2#398 SOC#236 http://kevan.org/brain.cgi?DDTNM
In some cultures what I do would be considered normal.
-- Ineffective daily affirmation
More information about the Xastir
mailing list