Log in

No account? Create an account
Fax over voice over IP - Alex Belits
Fax over voice over IP
I have decided to move a fax server from a router box (Pentium MMX 233) to the main server (dual Athlon MP 2600+) that runs mail (Exim and Cyrus) and PBX (Asterisk). A router is really not supposed to have a bunch of users connected to its services, and especially not to store huge numbers of Postscript and TIFF files. Giving a router any access to NFS would be a security disaster, so I had two options -- make it into a terminal server for a remote Hylafax, or remove everything fax-related from it completely, and use a new shiny Sipura^H^H^H^H^H^HLinksys SPA-3102 VoIP adapter (replaced FXO-less Zoom 5801 that is now at my home) as a kinda-modem, with all processing running on a server. After all, they are on the same Ethernet, so it must work, right?

I have installed iaxmodem, so Hylafax can talk to Asterisk, and configured Asterisk to talk to FXO on SPA-3102 over G.711uLaw. Though this setup included some obvious winmodemness (FXO knows nothing about modulation or protocols, G.711uLaw is basically a way to digitize a raw waveform with less bits than usual), I expected the CPU load from processing faxes to exceed the load from DSP-isms, and latency wasn't supposed to be a problem. I have queued a fax to a efax.com number (so it will be emailed back to me), and watched the Hylafax logs. After less than a minute the log recorded a failure -- iaxmodem believed that there was no carrier. I have called the same number from a phone, and found that the carrier was there, so something definitely was wrong.

To test iaxmodem setup with another device, I have decided to send a fax over Voicepulse, something that apparently was done before with intermittent success using a hardware fax modem. In my configuration both G.711 varieties are disabled for Voicepulse connection because I don't want my dumb devices that speak those protocols to get "natively bridged" by Asterisk with Voicepulse, and eat my bandwidth. I have configured separate peers for Voicepulse that allowed only G.711, and routed outgoing fax calls from iaxmodem there. Called the same number, watched the logs. This time carrier was detected, and modems talked, even passed some data, but then got too many errors, and remote end dropped the call. So iaxmodem works over G.711uLaw, I just had some problem with SPA-3102. I have reduced the baud rate in Hylafax config ('Class1RMQueryCmd: "!24,48,72,96"' and 'Class1TMQueryCmd: "!24,48,72,96"') and tried again. Just watching the logs was painful, modem was resending things for half an hour, but in the end hylafax reported success, and few minutes later I have received email with black and white picture of a tiger attached -- the fax passed. All further attempts to adjust the parameters resulted in no improvement, so apparently latency to Voicepulse was messing up the fax (something that should be expected), yet protocols worked properly.

I have returned to SPA-3102, and tried to adjust fax-related parameters. It was in vain, and it didn't even look like the adapter recognized that a fax is being sent -- status screen shows a normal call. Then I have decided to tweak the gain controls. Setting +6dB in both directions suddenly made two modems see each other, and a fax passed, so it looks like the carrier was too quiet for the device. I have tested different values, and ended up with +6dB on receive and +2dB on transmit -- after all, this also applies to local voice calls that now are routed through the same FXO (yay, saving one cent a minute).

So now fax works, though I am not sure if this is a good solution considering that I could do the same thing by just allowing a remote access to the hardware faxmodem on the router. It has an advantage that Asterisk always knows that local phone line is busy when it is sending or receiving a fax, and a disadvantage of lower reliability and higher CPU load. I can make Asterisk aware of the locks on the modem device that Hylafax uses, however that would be a pretty big kludge, so I am not sure yet if I'll keep this configuration. In any case, it works.

Tags: , ,

1 comment or Leave a comment
From: nickhalfasleep Date: July 2nd, 2006 03:57 pm (UTC) (Link)
Nice work. I'm surprised there isn't a linux distro dedicated to being a super PBX easy to setup.

What next? Telegraph-over-IP?
1 comment or Leave a comment