Correcting Echo in Asterisk
Echo on a VoIP connection can be caused by several sources, including the way echo is handled by Asterisk itself. After looking at the basic causes of VoIP echo and making sure that you have eliminated these more likely variables, we have put together some settings (configurations) in Asterisk for troubleshooting and reducing echo.
Steps to reduce echo in Asterisk.
Having a proper audio level on your PSTN interface will reduce the echo that develops from hybrid interfaces on the telco, which can be problematic with VoIP. Echo cancellers can accomplish quite a lot, but starting off with the optimum signal levels (rx and tx gain levels) will significantly help reduce echo that is present. Gain adjustment in Asterisk:
The following instructions require a type 102 milliwat test number for (preferably) your local telco. (Milliwatt test tones are often found at NPA-NXX-0010 or NPA-NXX-9935.)
Start by turning off all echo cancellation in
This prevents these algorithms from interfering with your
adjustments. Set the following:
The echocancelwhenbridged setting is in most cases not necessary and should be "no" when the circuit is TDM.
The adjustment procedure for the rxgain is to dial out to the local test number on every FXO port (line). (This will require you to have set up your dial plan so that your call goes out the appropriate port/line (zaptel zaptata.conf).
- Set both the rxgain and txgain to = 0.0
- Dial the local test number from a phone at which time you should hear a tone.
- On the channel that the call is on open ztmonitor, (ztmonitor 1 -vv) (1 would be the appropriate channel).
- Observing the Rx value and adjust accordingly until you get the value of 14844. This procedure requires you to increase the rxgain or reduce the rxgain depending on the value you see in zapata.conf and saving it and running asterisk -rx "reload". This step will take several adjustments until you are as close as possible to 14844.
- Move to the next FXO port/line and repeat the procedure.
To set the txgain essentially you will need to generate a tone out one channel/port and receive it back (looped back) into the second channel/port. So, this operation requires two lines.
First set up a channel to create a test tone. To generate a
1004KHz tone with Asterisk using the rather non-standard
- exten => s,1,Answer
- exten => s,n,PlayTones(1004/1000)
- exten => s,n,Wait(300)
- To calibrate channel/port 1 have the test tone generated on that channel/port.
- Make channel/port 2 call into channel/port 1 and use ztmonitor to watch the rxgain level on channel/port 2.
- Adjust the tx gain on Channel/port 1 until the rxgain level on channel/port 2 is at or close to 14844, edit zapata.conf and runasterisk -rx �reload�. Repeat this procedure for all of your FXO ports.
Matching impedance in Asterisk.
One primary reason for line echo generation is an
impedance mismatch, which is
actually circuit resistance to AC signals and it changes with
frequency. The first step to reduce echo is to match impedances.
In Asterisk, reducing echo can be accomplished by matching impedances, so they are not unequal.
- Set the country, which can be found in /etc/zaptel.conf loadzone = [your country] and adjust the impedance of the FXO ports to match those of the local PSTN lines.
- Fine-tune matching the impedance by running the �FXO Tune� program. (This can be accomplished by executing the �fxotune� command as root user.)
- A tone will be sent to the telephone line and the application listens to the echo level. It then checks the echo using different parameters and selects the set of parameters that produces the least amount of echo.
For more about Asterisk settings we suggest you go to VoIP Wiki.