Fax & Voip – Part 1/3 – All about codec in Fax transmission

faxmachinemurderCertainly there are huge benefits in adopting VoIP technology (i.e. Asterisk PBX), and certainly there will be many people who will be wise to use Voip PBX trunk instead of traditional phone lines.

But using Voip PBX you may start to notice that faxing just doesn’t seem to work as well as you remember it working on the old analog phone line.

Definitely: faxes work so well in the VoIP PBX/line as the old analogue line/Analog Pbx ?
The answer is: usually no !

Faxes in Voip env do not work as well as you in “old” phone line. FAX was designed for analog networks, and can not travel easly over a digital VoIP network.

The reasons are many: starting from the codec used by VoIP that are designed to compress voice and save bandwidth, and that corrupts the signals used by modems/fax, until the fact that the signal is transformed several times in the path caller-called, and Pbx Voip add more transformation point making more difficult transmit/receive fax.

Remember: it is very important understand that each transformation step introduces some distortion to the signal, imperceptible to the voice but not for the fax: and for faxes it is very important the signal quality !

In this series I’ll try to suggest some tips to increase the fax quality in Voip env.

Att.: In these post I’ll write explicitly about Asterisk PBX, but the same observations are also applicable to other kind of PBX Voip.

How fax works
To begin we have knows some notes about how fax works. Fax involve two device communicating with the purpose of passing on or more images of pages.

The pages are translated in image, and the image is translated in a bits-flow that is transmitted using a phone call: the called device receive this buts-flow and retransform all in images.

To transfer the flow of bits using a phone call, that permit to transfer only voice/audio, the line must be modulated, meaning that all the single bits involved are translated in audio signal that will be decodable by the other end to re-trasform the received waveform in flow of bits, and therefore in images.

More clearly: the bits are translated in “beep and squawks”, and transmitted using audio phone call. The listening device (fax machine) is able to translate this “noise” in bits-flow.

Att.: This is how the old-fashioned and most widespread kind of fax works: more recent fax machine works in different ways (i.e. ISDN Fax device), but they are very rare to find. Here we will discuss only the older types of fax.

Keep out of trouble !
If possibile in your phone system keep a separate old-fashioned analog line to use only with fax device, connected directly to fax device, or use an on-line fax services. The related costs are very low, and help us to keep us out of trouble. In some circumstances this is the last solution to keep the faxes working with reliability.

This is a solution-no solution, I know, but…… it is an option to be evaluated….

Codec
Codec (short for coder-decoder), is the way in which the analog signal of the voice is encoded in bits, and vice versa. There are many types of codecs, each different from the other for quality and bandwidth (byte/sec) utilization.

Some codecs are incompatible with fax signal: i.e. g729 is a really compressed and bandwidth-saver codec, but it is really incompatible with fax transmissions.

In a good Voip system with fax each path must never use this kinds of compressed codecs. If you want use fax in the your system you must use only g711a e g711u: this kind of codes use more byte/sec, but are fully-compatible with fax.

The evaluation related band/codec is very important if the Voip system uses some WAN connections, but it is irrelevant whether the path is inside LAN (I.e g711 codec family use 64 KB/s of bandwidth, really nothing in a 1Gb/s LAN).

Therefor the first step is to verify that all the steps (call legs) involved in the path caller-called are using the correct fax-compatible codec.
i.e. Trunk → Pbx Voip → ATA Analog Gateway connected to fax machine.

Voip-CallLegs

It is preferable use only one kind of codec (g711a or g711u) for all the call legs, to avoid codec translation in the device involved (every codec translation introduce some distortion and delay).

In asterisk you can find the used codec using the next commands.

core show channels

With this command we can get all the channels or legs currently active in the Asterisk PBX.

Usually the legs are two for every call: Trunk → Pbx Voip and Pbx Voip → Analog Gateway connected to fax machine.

Using the next command you can find the used codecs in the single leg.

core show channel <channel id>

Example

> core show channel SIP/sip.messagenet.it-0000021c
…..

NativeFormats: (gsm)

WriteFormat: slin

ReadFormat: ulaw

WriteTranscode: Yes (slin)->(gsm)

ReadTranscode: Yes (gsm)->(slin)->(ulaw)

...

In this example the leg is based on gsm codec (line NativeFormats: (gsm)): really terrible for the faxes !

You can force the codec in asterisk using the next in sip definitions.

Disallow= all
allow=alaw

You can force to use only alaw/G711a codecs in the gateway config too: i.e. in patton smartnode config.

…….
profile voip VOIP
codec 1 g711alaw64k rx-length 20 tx-length 20 no-silence-suppression
dejitter-mode static
dejitter-max-delay 120

Next Series Post: Fax & Voip – Part 2/3