Add T.38 Fax capabilities in Asterisk 13 and Freebx 12

faxunoworkFax in Voip Env….. Joy and pain….

In this post I’ll show how to configure Asterisk 13/FreePbx 12 to use T.38 Fax capabilities to receive fax using SpanDSP (FFA not work in Asterisk 13….).

IMHO when possible is better configure Asterisk Fax system to use T.38 when possible instead alaw or other codec.

To transmit fax you can see my post.
Asterisk Mail2Fax using FFA in poor man style ! (linkografia)

To install and configure SpanDSP you can read my post
Add Fax capabilities in Asterisk >=13 (linkografia)

Configure Gateway Asterisk/Freebx to use T38
1) Setting -> Asterisk Sip Settings -> Chan Sip
2) T38 Pass-Through: Yes
3) Advanced General Settings: add line

t38pt_udptl = yes 

4) Setting -> Fax Configuration
5) Error Correction Mode= ON
6) Minimum transfer rate= 9600
7) Maximum transfer rate= 14400
8) In this step I prefer reboot server and read any log file to check that all works fine.

Configure Gateway
In this post I’ll show how to configure Patton SmartNode and Grandstream HT503 like PSTN/SIP gateway using T.38: I think that using other gateway device involve similar configuration step.

In Patton Smartode Gateway
….
profile voip default
codec 1 g711alaw64k rx-length 20 tx-length 20 no-silence-suppression
codec 2 g711ulaw64k rx-length 20 tx-length 20 no-silence-suppression
dtmf-relay rtp
dejitter-max-delay 100
media detection-timeout 10
fax transmission 1 relay t38-udp
fax transmission 2 bypass g711alaw64k rx-length 10 tx-length 10
fax redundancy low-speed 2 high-speed 1
fax volume -9.0
fax dejitter-max-delay 100
fax bypass-method v150-vbd
modem transmission 1 bypass g711alaw64k rx-length 10 tx-length 10
modem bypass-method v150-vbd
……

In GrandStream HT503
Fxo Port
Fax Mode – Check T.38 (Auto Detect)
Fax Tone Detection Mode – Check Caller or Callee

Now you can receive faxes using T.38: to be sure that you are using T.38 you can check SIP debug or fax sessions.

INVITE sip:[Called Number]@[Asterisk IP Address]:5060 SIP/2.0
Via: SIP/2.0/UDP [Gateway IP Address]:5060;branch=z9hG4bKcb4d0e5f28324194c
Max-Forwards: 70
From: <sip:[Calling Number]@[Gateway IP Address]:5060>;tag=369bc91f97
To: <sip:[Called Number]@[Asterisk IP Address]:5060>
Call-ID: cab68a42f293b4aa
CSeq: 26722 INVITE
Contact: <sip:[Calling Number]@[Gateway IP Address]:5060;transport=udp>
Supported: replaces
User-Agent: Patton SN4970 1E30V 00A0BA09D7E0 R6.5 2014-01-09 H323 RBS SIP M5T SIP Stack/4.2.8.10
Content-Type: application/sdp
Content-Length: 196
v=0
o=MxSIP 0 38220 IN IP4 [Gateway IP Address]
s=SIP Call
c=IN IP4 [Gateway IP Address]
t=0 0
m=audio 5158 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv

pbx*CLI> Capabilities: us - (alaw), peer - audio=(alaw)/video=(nothing)/text=(nothing), combined - (alaw)
pbx*CLI> Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
pbx*CLI> Peer audio RTP is at port [Gateway IP Address]:5158

SIP/2.0 100 Trying
Via: SIP/2.0/UDP [Gateway IP Address]:5060;branch=z9hG4bKcb4d0e5f28324194c;received=[Gateway IP Address]
From: <sip:[Calling Number]@[Gateway IP Address]:5060>;tag=369bc91f97
To: <sip:[Called Number]@[Asterisk IP Address]:5060>
Call-ID: cab68a42f293b4aa
CSeq: 26722 INVITE
Server: FPBX-2.11.0(11.19.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: <sip:[Called Number]@[Asterisk IP Address]:5060>
Content-Length: 0

SIP/2.0 200 OK
Via: SIP/2.0/UDP [Gateway IP Address]:5060;branch=z9hG4bKcb4d0e5f28324194c;received=[Gateway IP Address]
From: <sip:[Calling Number]@[Gateway IP Address]:5060>;tag=369bc91f97
To: <sip:[Called Number]@[Asterisk IP Address]:5060>;tag=as45a2cd19
Call-ID: cab68a42f293b4aa
CSeq: 26722 INVITE
Server: FPBX-2.11.0(11.19.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: <sip:[Called Number]@[Asterisk IP Address]:5060>
Content-Type: application/sdp
Content-Length: 232
v=0
o=root 890014396 890014396 IN IP4 [Asterisk IP Address]
s=Asterisk PBX 11.19.0
c=IN IP4 [Asterisk IP Address]
t=0 0
m=audio 11670 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv

ACK sip:[Called Number]@[Asterisk IP Address]:5060 SIP/2.0
Via: SIP/2.0/UDP [Gateway IP Address]:5060;branch=z9hG4bK266f5b9973ff6ba05
Max-Forwards: 70
From: <sip:[Calling Number]@[Gateway IP Address]:5060>;tag=369bc91f97
To: <sip:[Called Number]@[Asterisk IP Address]:5060>;tag=as45a2cd19
Call-ID: cab68a42f293b4aa
CSeq: 26722 ACK
User-Agent: Patton SN4970 1E30V 00A0BA09D7E0 R6.5 2014-01-09 H323 RBS SIP M5T SIP Stack/4.2.8.10
Content-Length: 0

Reliably Transmitting (no NAT) to [Gateway IP Address]:5060:
INVITE sip:[Calling Number]@[Gateway IP Address]:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP [Asterisk IP Address]:5060;branch=z9hG4bK2bf59381
Max-Forwards: 70
From: <sip:[Called Number]@[Asterisk IP Address]:5060>;tag=as45a2cd19
To: <sip:[Calling Number]@[Gateway IP Address]:5060>;tag=369bc91f97
Contact: <sip:[Called Number]@[Asterisk IP Address]:5060>
Call-ID: cab68a42f293b4aa
CSeq: 102 INVITE
User-Agent: FPBX-2.11.0(11.19.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
X-asterisk-Info: SIP re-invite (External RTP bridge)
Content-Type: application/sdp
Content-Length: 290
v=0
o=root 890014396 890014397 IN IP4 [Asterisk IP Address]
s=Asterisk PBX 11.19.0
c=IN IP4 [Asterisk IP Address]
t=0 0
m=image 4593 udptl t38
c=IN IP4 [Asterisk IP Address]
a=T38FaxVersion:0
a=T38MaxBitRate:14400
a=T38FaxRateManagement:transferredTCF
a=T38FaxMaxDatagram:1400
a=T38FaxUdpEC:t38UDPRedundancy

SIP/2.0 200 OK
Via: SIP/2.0/UDP [Asterisk IP Address]:5060;branch=z9hG4bK2bf59381
From: <sip:[Called Number]@[Asterisk IP Address]:5060>;tag=as45a2cd19
To: <sip:[Calling Number]@[Gateway IP Address]:5060>;tag=369bc91f97
Call-ID: cab68a42f293b4aa
CSeq: 102 INVITE
Contact: <sip:[Calling Number]@[Gateway IP Address]:5060;transport=udp>
Server: Patton SN4970 1E30V 00A0BA09D7E0 R6.5 2014-01-09 H323 RBS SIP M5T SIP Stack/4.2.8.10
Supported: replaces
Content-Type: application/sdp
Content-Length: 234
v=0
o=MxSIP 0 38221 IN IP4 [Gateway IP Address]
s=SIP Call
c=IN IP4 [Gateway IP Address]
t=0 0
m=image 5158 udptl t38
a=T38FaxRateManagement:transferredTCF
a=T38FaxMaxDatagram:1024
a=T38FaxVersion:0
a=T38FaxUdpEC:t38UDPRedundancy
a=sendrecv

pbx*CLI> Got T.38 offer in SDP in dialog cab68a42f293b4aa
pbx*CLI> Capabilities: us - (alaw), peer - audio=(nothing)/video=(nothing)/text=(nothing), combined - (nothing)
pbx*CLI> Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x0 (nothing), combined - 0x0 (nothing)
pbx*CLI> Got T.38 Re-invite without audio. Keeping RTP active during T.38 session.
pbx*CLI> set_destination: Parsing <sip:[Calling Number]@[Gateway IP Address]:5060;transport=udp> for address/port to send to
pbx*CLI> set_destination: set destination to [Gateway IP Address]:5060
Transmitting (no NAT) to [Gateway IP Address]:5060:
ACK sip:[Calling Number]@[Gateway IP Address]:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP [Asterisk IP Address]:5060;branch=z9hG4bK17a678d9
Max-Forwards: 70
From: <sip:[Called Number]@[Asterisk IP Address]:5060>;tag=as45a2cd19
To: <sip:[Calling Number]@[Gateway IP Address]:5060>;tag=369bc91f97
Contact: <sip:[Called Number]@[Asterisk IP Address]:5060>
Call-ID: cab68a42f293b4aa
CSeq: 102 ACK
User-Agent: FPBX-2.11.0(11.19.0)
Content-Length: 0
pbx*CLI> -- Channel 'SIP/1110-000054c7' FAX session '47' started
pbx*CLI> fax show sessions

Current FAX Sessions:

Channel            Tech        FAXID Type Operation State File(s)
SIP/2000-00000006 Spandsp 4   T.38 receive  Active /var/spool/.......

Linkografia
Asterisk Mail2Fax using FFA in poor man style !
Add Fax capabilities in Asterisk >=13