Friday, February 25, 2011

DTMF issue on Asterisk

IVR and DTMF doesn't work very well if you have VoIP and PSTN connectivity.

IVR to work with VoIP<-->PSTN system perfectly, DTMF coding must be precise which can't be achieved perfectly with VoIP system (no matter if it is CISCO, AVAYA or Asterisk) all the time.

VoIP<-->VoIP is not a problem as DTMF code is passed as RTP payload and they know what to do with it.

VoIP<----RTP Payload------------RTP Payload------>VoIP


But with VoIP<-->PSTN, those DTMF tone has to be converted to RTP payload or RTP payload has to be converted back to DTMF tone, which doesn't happen precisely all the time.
VoIP <----RTP Payload--------------------DTMF------>PSTN

Q: How can I troubleshoot DTMF on asterisk?

Ans: You can go to /etc/asterisk/logger.conf and add dtmf for logging.

#vi /etc/asterisk/logger.conf
[logfiles]
full => verbose,debug,dtmf

Reload logger in asterisk

#asterisk -rv
CLI> logger reload

Perform test calls.

#tail -f /var/log/asterisk/full [ to see the realtime data logging ]

Press Ctrl + C to get out of the real time data monitoring

Q: I am having issues with duplicate DTMF. It appears that my asterisk box is receiving doubled DTMF signals. What could I do to fix it?

Ans: You have to change the setting in /etc/asterisk/chan_dahdi.conf. Add relaxdtmf=yes in that file.

Please ignore trunkgroups setting if that's not applicable in your environment. You simply need is relaxdtmf=yes under [channels] context

#vi /etc/asterisk/chan_dahdi.conf
[trunkgroups]
trunkgroup => 2,24,48

spanmap => 1,2,l
spanmap => 2,2,0

[channels]

usecallerid=yes
callwaiting=yes
usecallingpres=yes
callwaitingcallerid=yes
threewaycalling=yes
callerid=asreceived
relaxdtmf=yes


;This is PSTN Connection (G2)
context=From_Dahdi
switchtype=national
signalling=pri_cpe
group=2
channel => 1-23
channel => 25-47

Q: What kind of DTMF signalling should I prefer?

Ans: Out-of-band technique or RFT2833 is the most appropriate one and it's default on asterisk. You can explicitly specify
dtmfmode=auto [ Use rfc2833 if offered, inband otherwise ]
or
dtmfmode=rfc2833

If you are using SIP channels/trunks, define dtmfmode in sip.conf under [general] context

For more info you can visit www.voip-info.org

Tuesday, February 15, 2011

G711 vs G729 Which one to choose?

G711 is ITU-T standard for audio compression and decompression (i.e codec). It uses pulse code modulation (PCM) technique i.e sampling the audio signal and digitize each sample (voltage) to binary (0's and 1's).

Sender side:
Human Voice/Audio ---> Filter --> 4Khz ----> Nyquist Sampling at 8Khz ----> A/D converter [each sample changed to 8 bit] ----> 64Kb per second

Thus data rate of G711 is 64Kbps

Receiver side:
Digital data is converted back to audio using D/A converter.

It is very simple, less CPU intensive and widely used. However, if bandwidth is expensive, it's not a good option. There are various codecs. Most efficient (bandwidth wise *NOT* CPU wise) one is G729.

Wikipedia: G729 does coding of speech at 8 kbit/s using conjugate-structure algebraic-code-excited linear prediction (CS-ACELP).

G729 uses complex algorithms to synthesize the speakers' voice. It uses vocoder [ tone generator + white noise generator + filter] to shape the sound as the nose, lip, throat, tounge and vocal cavity do. Vocoder itself generates robotic tone which is not acceptable. Thus G729 also uses samples of speakers' voice to adjust the vocoder setting properly and it compares synthetic voice with actual voice to come up with *CODE*. Then that CODE and vocoder settings are sent to the receiver. Receiver generates the sound using the provided CODE and vocoder settings.
Isn't that cool? However, it's CPU intensive.

G711 is free, however G729 requires license ( $10 per channel).

Summary:
  • G711 sends actual sample of speakers' voice, while G729 sends the vocoder settings and calculated CODE required to generate the voice.
  • Data rate: G711 = 64Kbps , G729 = 8Kbps
  • G711 uses high bandwidth but it's not CPU intensive. G729 uses less bandwidth but it's CPU intensive
  • Unlike G711,G729 is not free
  • In VOIP implementation, G711 uses 87Kbps and G729 uses 32 Kbps (with all TCP/IP overhead)

SIP Communication ( SIP Signalling and Media transport)

SIP (Session Initiation Protocol: RFC 3261) Communication involves SIP signaling ( initiate, modify and terminate sessions/calls) and MEDIA transport (using RTP).

In what conditions Asterisk is forced to handle the media stream?
In following conditions, Asterisk involves in media between the phones/UAs.
  • If one of the clients is configured with canreinvite=NO, Asterisk will not issue a re-invite at all and will not redirect the media path.
  • If the clients use different codecs, Asterisk will not issue a re-invite.
  • If the Dial( ) command contains ''t'', ''T", "h", "H", "w", "W" or "L" (with multiple arguments) Asterisk will not issue a re-invite.
If clients support canreinvite=yes and use same codecs, we can set canreinvite=yes in asterisk(sip.conf) as well. With that option, Asterisk will be able to issue re-invite to the clients and redirect the media path so that it doesn't have to handle the media stream any more. However, most of the Asterisk implementation make asterisk to handle the media stream.

Why Asterisk is not SIP Proxy? [ from voip-info.org ]
Asterisk, as a server, is a SIP Registrar, location server and also acts as a useragent endpoint (softphone).

If it is 'controlling' or relaying a call from a SIP phone to another SIP phone, it simply acts as an endpoint UA to the originating call leg and then creates a new call to the receiving phone. Therefore, it stays "in the middle of the call," maintaining state and controlling, and optionally bridging, each remote endpoint. The audio channels (RTP) may go directly from phone to phone or may go through Asterisk's media bridge.

Asterisk can thus be described best as a "back-to-back user agent" (B2BUA), which is also consistent with the use of the term "PBX". Because of this architecture, fairly simple SIP functions, such as REFER (transfer) involve more aspects of the Asterisk core. On the other hand, the architecture provides additional power and flexibility, because each call leg can just as easily be replaced with a different technology channel (ZAP, H323, MGCP, etc) and, thus, Asterisk becomes a powerful media gateway.

SIP Proxy usually doesn't involve in the media stream between the phones, it simply handles SIP signalling. A SIP proxy handles call control on behalf of other user agents (UA) and usually does not maintain state during a call and therefore is never the endpoint of a call.

For more info click here