Experimenting with Analog modem calls over OCTOI

So I’ve been messing with AMR modems for a while. This topic isn’t really about them but rather about the “infrastructure” I’m trying to get running so I can actually test and use them. I mention them here just so that you can keep them in mind as another potential variable/source of issues …

What I was trying here is to get basically a few FXS ports that are uplinked to the OCTOI community network. Here’s the setup :

Hardware wise :

  • Raspberry Pi 5 with a PCIe breakout and connected to that a PCIe->PCI bridge
  • A Digium TDM410 PCI card with 4 FXS modules
  • An icE1usb connected to the RPi5 via USB
    • It’s properly connected to a GPS signal
    • The first port is connected to a loopback plug, the second port is not used
  • Two AMR modems connected to a test computer
    • Interface to the computer is through osmo-amr module I’m working on
    • Software wise, I run a modified slmodemd that’s been adapted to interface with my hardware

The connection to the OCTOI network is not typical. Instead, the E1OIP link doesn’t go to the icE1usb but instead to an internal trunkdev virtual device. However to get any kind of stability, you need a good clock source and this is what the icE1usb is for and also why it has a loopback plug because you need the link to be up to be a valid clock source.

On the software side, I’m running DAHDI (obviously) driver stack, osmo-e1d for the OCTOI uplink and GPSDO status and yate for the call routing.

Let’s review the configuration.

modprobe wctdm24xxp companding=alaw
modprobe icE1usb
modprobe dahdi-trunkdev

Modules are loaded as above and in this order so the span order is the same everytime. By default for analog cards the wctdm24xxp driver (for the TDM410 card) uses ulaw but because on E1 we use alaw I force it to use alaw as well to avoid the conversion and the potential signal degradation that goes with it.

Next step is to create the trunkdev. I also change access rights so I can run a bunch of that stuff as a normal user. And then finally load the DADHI configuration.

dahdi-tools/trunkdev/dahdi_trunkdev create octoi

chgrp users /dev/dahdi/* -R
chmod g+rw /dev/dahdi/* -R

dahdi-tools/dahdi_cfg -c dahdi-tools/system.conf

And speaking of that system.conf, here’s what I’m using :

# Span 1: TDM410P
fxoks=1-4
alaw=1-4

# Span 2: icE1usb port 0
span=2,1,0,ccs,hdb3,crc4
bchan=5-35

# Span 3: icE1usb port 1
# unused

# Span 4: trunkdev
span=4,0,0,ccs,hdb3,crc4
bchan=67-81,83-97
dchan=82

# Global data
loadzone    = be
defaultzone = be

Mostly standard stuff, just making sure to set the FXS as alaw here as well and then configuring the icE1usb as the clock master. And configuring the trunkdev with the proper dchan for the uplink to OCTOI.

Next step is then to start osmo-e1d which will handle the OCTOI uplink to our virtual span trunkdev.

osmo-e1d -c osmo-e1d.cfg

And associated osmo-e1d.cfg :

octoi-client YOUR_OCTOI_ENDPOINT_IP 10013
 local-bind 0.0.0.0 3333
 account YOUR_OCTOI_USERNAME
  mode dahdi-trunkdev
  dahdi-trunkdev name octoi
  dahdi-trunkdev line-number 0
  prefill-frame-count 200
e1d
 interface 0 dahdi-trunkdev
  trunkdev-name octoi
  line 0
   mode e1oip
 interface 1 icE1usb
  usb-serial YOUR_ICE1USB_SERIAL_HERE

And then finally start yate :

yate

Its configuration is in multiple files. I’ll try to remember all I had to add :

In zapcard.conf:

[card-fxs]
type=FXS
span=WCTDM/0
voicechans=1-4
format=alaw

[octoi]
type=E1
span=trunkdev/octoi/0
dtmfdetect=disable

In ysigchan.conf:

[octoi]
type=isdn-pri-cpe
sig=octoi
voice=octoi
switchtype=euro-isdn-e1
channelsync=0

In analog.conf:

[chan-fxs]
type=FXS
spans=card-fxs

And then finally the dialplan in regexroute.conf :

[contexts]
; Analog (FXS) incoming
${address}^chan-fxs/\(.*\)$=from_analog_ctx;called=off-hook
; OCTOI incoming
${address}^octoi/\(.*\)$=from_octoi_ctx

[from_analog_ctx]
; Direct FXS lines 
^100\(.\)$=analog/chan-fxs/\1
; To OCTOI
^0\(........\)$=sig/\1;trunk=octoi
; as long as we are in overlap (variable set by php script), bail out 
${overlapped}yes=goto overlapped
; Off-Hook from FXS
^off-hook$=external/nodata/overlapped.php;accept_call=true;tonedetect_in=yes

[from_octoi_ctx]
^2460100\(.\)$=analog/chan-fxs/\1 

[default]

[overlapped]
; avoid enum routing as long as the dialled number is incomplete
.*=;error=incomplete;enumroute=false

Ok, that’s it for the setup description. I will write about the results in a following post …

2 Likes

Ok, so results with this are not great.

Calling directly from FXS to FXS ( all local ), I can connect pretty reliably but the speed isn’t great. I’m getting between 7.2k and 14.4k (and the latter was only once) with most attempts ending up at 9.6k.

It’s not terrible, but given it should be pretty much an ideal analog line quality, I expected more.

I tried calling from FXS to FXS but routing through OCTOI. So I’m sending the call to the OCTOI remote yate and then I get it back and send to another FXS port. I could never get this to work … NO CARRIER everytime.

During those attempts I monitoed the E1OIP link quality and it was perfect, no lost packets, no underflow, no re-order. I even dumped the actual packets with tcpdump, extracted the B channel data and compared that the data is the same in what I send in one call vs what I get back in the other and it’s perfectly fine.

I also tried calling various services on OCTOI. I think in the end it was always the port master 3 because it’s a bit tricky to find modem services from other people that are actual online.

In anycase, attempts on 12343333 ( C3BBS through PM3 ) mostly fails. I think in 50+ attempts I got maybe 3 successful connections.

So this is where I stand ATM and I’m not sure what to try next. Ideally I would try with a real “hardware modem” (to eliminate one of the variable) but I don’t have any of those ATM.

When dumping the OCTOI link and comparing audio, I did notice that the volume level was maybe a bit low. I tried playing with the various gain/attenuation settings on the FXS card and also on my AMR modems but it was inconclusive, either it was the same results, or worse than the defaults.

I still should check the levels on the actual PCM interface of my AMR modem to see where those stands.

I also want to try with nothing in between the modems, just a “line simulator” ( basically a 20 mA current loop ) and see how well that works (if at all)

One possible issue I see is the FXS card clock. I’m not actually sure if this ends up locked to the 8 kHz tick from DADHI. It has a 8.192 MHz oscillator on there but I couldn’t tell for sure if this was voltage controlled or not. Maybe I could try to check if its frequency is well aligned or not.

If any one else has any ideas how to improve things, I’m all ears. Also if anyone has other results using analog modems with different setups, I’d like to hear about that too.

1 Like

This seems worthwhile.
In the past I’ve used a logic analyser (one of those Salaea thingies) to capture such an interface and then converted the .csv dump to a .wav file to analyse with Audacity. That worked very well and helped me troubleshoot.

Another very possible problem. Some of the DADHI PCIe cards needed external clock connections (actual wiring between the cards) for synchronization.

You could hack up DAHDI to toggle a GPIO on each clock pulse and then look at both clocks with a scope/logic analyser and compare them maybe?

Ah! That has never worked very stabily for me either. I was able to get 33600 sync once and it kinda worked but then died after a couple of seconds.
I’m not sure why it wasn’t reliable, I’ve triple checked the audio samples going in and out of the binary and they were absolutely spotless.
I’m guessing the codebase was not designed for 9600Hz 16bit signed lin operation and something with the way it was compiled/converted over for AMR use broke it internally, but I really have no idea.

Thanks for all your efforts and report here.

I will see what I can do about setting up a hardware modem attached to my Auerswald COMmander2 at my home, connected to OCTOI and give you remote access to a shell so you can use that modem. I had that on the TODO list for quite some time, actually even a ELSA MicroLink ISDN TA with built-in analog modem so one can test both ISDN and analog from there, exactly like we had it at 39C3.

1 Like

So upon checking the 8.192 MHz clock on the FXS card is definitely not locked. I measured it with a frequency counter locked to GPS and it’s about 46 ppm too slow ( 8.191954 MHz ).

As a sanity check of the measurement method, I checked the 30.72 MHz from the icE1usb and this reads withing 0.5 Hz of nominal ( so within 0.02 ppm )

I don’t have an immediate way to create a 8.192 MHz signal to feed to that board but that’s definitely something to try in the future.

Regarding slmodemd, did you use it with any AMR modem ?
I’m running it at 9600 Hz because that’s what it seemed to want, but technically I can run the AMR modem at a bunch of other rates …

I know that at 39C3 where I first tried it, I managed to connect at a pretty high speed, AFAIR > 30k or so and it ran fine for a whole session ( not sure of the length, maybe 10 min or so of playing with the BBS ).

I am using a slightly different setup than at 39C3, since I now made a “all-in-one” host board rather than the mix of dev board wired together by flying wire I was using at 39C3, so it’s not impossible I screwed up something and maybe the power is very dirty or something …

I had used it on a ThinkPad T41 with the builtin modem and with 2 different audio libraries I also converted a 8000Hz a-law call into the 9600Hz 16bit slin audio (but that might’ve also been broken)

Yeah, but the slmodem blob only has the required lookup-tables for 9600 internally. the code has provisions for 8000Hz, etc. but sadly they aren’t compiled in.

yeah OK :slight_smile:
sounds like a job for some janky Si5351 for a quick test and then a better solution later :joy:

So I tried to connect two of my osmo-amr contraptions running slmodem directly to each other using a simple current loop.

The hardware setup is just the two RJ11 in series along with a 270 ohm resistor and a power supply, here set around 18V to produce a 20 mA current when both phones are off-hook.

And it worked pretty well !

This is the connection report of one of the two modem :

Modulation: V34
Protocol: LAPM
Compression: V42bis
TxRate: 31200 
CONNECT 33600

It was a bit asymmetric with one side being slightly slower but it’s pretty much the max that an analog line can support.

I tested the stability by doing a Zmodem transfer of a 2 Mb file and it sustained an average of 2640 bytes/s which is not fantastic, a bit lower than I’d expect for 31200 but not terrible either.

At least I think this confirms the AMR modem hw, the osmo-amr interface and the slmodem can establish and sustain a connection at a decent rate.

I’m sure there are some bugs or improvements that could be made with them, but they should still allow more than the 9.6k and NO CARRIER I’ve been getting.

1 Like

Tried a bit more, this time using the “intercom” function of my ISDN TA that has two analog port and you can dial one from the other.

Pretty much the same results as through the direct FXS connection. Maybe a tiny bit better 12k ~ 14k4 . One thing that helped was actually to set the interface chip line settings to “US” . Probably because I suspect that’s what the TA emulates ( given its locally generated dial tone is a US one ).

That also gave me the opportunity to check the ring detection which seems to work. I haven’t plumed it into slmodem but it does generate the USB DLM notification messages on the interrupt endpoint.

1 Like