When email was introduced to the general public, people thought it would soon deprecate faxes, but... things didn't quite turn out that way.
One of the frequently asked questions on using asterisk in offices, is how to actually handle faxes in a decent way.
In these tutorials we will try to explain all the possible ways of configuring asterisk for use with faxes.
Before going any further, we to give some background information on regular faxing and faxing over the internet. (FoIP), in a different chapter we will provide more information on the actual possibilities for faxing with asterisk.
Faxes are tradionally used to send documents over the PSTN, from one physical fax machine to another, simplified, this is done by scanning the document on the sending side to a picture format. (.g3) and converting this picture line by line into a series of sounds, which is then converted back into lines of a picture on the receiving side and printed out to paper, the way this is done is described in the ITU T.30 standard.
Sending a fax through a faxmodem works in pretty much the same way, the only difference is that we dont start with a document but with an image file.
With the popularity of the internet, telephone calls are being routed more and more over data links, instead of telephone links, for example over the internet.
Fax signals however were not designed to be transported over data links, with jitter, delays and packetloss and in 20ms packets, leading to unreliable faxes. (not working, stopping in the middle of a page etc.)
Furthermore, most telephone audio calls are sent over the internet in a compressed form. (GSM, g729 etc), these audio codecs are optimized for minimal losses on voice communications, but are lossy codecs, the output is not the same as the input and information is lost. (Some codecs are worse than others, g711 and g726 are better than g729, g723, ilbc etc.).
To be able to send faxes in realtime over the internet, in a reliable way, a new standard callled T.38 was born.
Although T.30 over g711 might work if the jitter and the delay is low (<1ms) such as on a local area network and QoS is implemented on the network, to make sure the voip packets have the highest priority it is still not recommended to do so. If packets are being sent over the public internet, T.30 over a voip codec should never be used, it will rarely work reliably.
2. Different approaches
Let's have a closer look at the different possibilities for integrating faxing possibilities with asterisk:
2.1: Connecting an analog fax machine to asterisk to the PSTN
As mentioned in other tutorials, there are many interface cards that can be used together with Asterisk, in different brands (digium, sangoma, beronet,....) and flavors. (FXO, FXS, PRI, BRI).
If both the PSTN cable going to your telco and the cable connecting asterisk to your fax machine are on the same card, you will most likely be ok as long as the card is functioning properly. (no frame slips, no irq misses, correct gains etc.)
However, as soon as the PSTN cable and the faxmachine cable are NOT connected to the same interface card (For example, the PSTN connection to the PBX is a digital BRI, and the fax machine is analog on an FXS port) , timing issues will most likely occur and faxes WILL have problems, not all the time, but several percent. (Chances of interrupted faxes increase with the number of pages being sent, many fax machines will not retry retransmission of a single page).
Vendors of these interface cards are working on cables to connect the different cards together and pass timing over this external cable, however at the moment of writing to my knowledge none have resolved all issues with faxes yet - but a cable is still better than none at all).
Disclaimer: The asteriskguru team was involved in the development of this commercial application.
2.2: Connecting an analog fax machine to asterisk to a FoIP (Fax over IP provider
If your VOIP provider supports t.38 (Most of them don't yet), you could use the passthrough t.38 support in asterisk 1.4 and higher.
If your voip provider does not support t.38, STOP trying now, you will NOT succeed in having reliable faxing, move on to another voip provider that does support T.38 or sign up with a fax to email service.
2.3: Sending faxes through asterisk to the PSTN network without using physical fax machine
There are again several ways to achieve this,
a) by using a t.38 capable softphone in combination with a t.38 capable Asterisk. (This will require either faxterisk or spandsp).
b) by using some web interface or email gateway which will accept pdf's or tiff's, so that you can email your voip server, which will convert the image and send it over t.30 to your telco.
c) by using a separate fax server (such as hylafax)
d) by using the fax software with chan_capi
2.4: Sending faxes through asterisk to a FoIP provider without using physical fax machine
This can be done in 2 ways:
- by using the passthrough capability in asterisk in combination with a t.38 capable softphone, or
- by using a t.38 capable sendfax application as can be found in the faxterisk or spandsp patches, in this last you will still need some scripts to get the initial tiff or pdf file onto the PBX server, this could be done through ftp, email, web form post etc.