login | register
Sat 17 of May, 2008 [07:15 UTC]

voip-info.org

Search with Google
Search this site with Google. Results may not include recent changes.
 
Google Ads
Shoutbox
  • Juan Ortega, Thu 15 of May, 2008 [10:33 UTC]: Hi everybody, I'm Juan, an ITCom student, and I need to know what basic elements I need to create a VoIP network. Can anybody helpme, please?,Thank you very much
  • gineta, Wed 14 of May, 2008 [03:58 UTC]: any here not fine the configuration of firewall juniper -screem for VOIP asterisk????
  • Anoop Prabhakaran, Tue 13 of May, 2008 [12:16 UTC]: I am developing Asterisk IVR, Whenever i make a internation call to the IVR system, the DTMF is not getting detected properly, this happens only for the first time, second call onwards system works fine. why this is happening
  • joe, Mon 12 of May, 2008 [04:27 UTC]: Is there an opensource browser based softphone, or a system like Busta where everything is not manages through their website?
  • Nick Barnes, Fri 09 of May, 2008 [11:36 UTC]: Christopher - yesterday I tried an Asterisk install on a CentOS 5.1 box with stock GUI and it all worked fine. Sorry I can't help.
  • aero, Fri 09 of May, 2008 [08:20 UTC]: can someone help me out on this, i tried to play some sound files on my asterisk box and this is the error message i got. WARNING[4429]: format_wav.c:169 check_header: Unexpected freqency 22050 May 8 11:17:39 WARNING[4433]: codec_gsm.c:194 gsmtolin_fra
  • Christopher Faust, Thu 08 of May, 2008 [14:15 UTC]: I beleive that I may have to change something in the xserver configuration. Please advise
  • Christopher Faust, Thu 08 of May, 2008 [14:14 UTC]: Everything was perfect. In the bios I have increased the memory allocated Still receive input not supported on my display.
  • Christopher Faust, Thu 08 of May, 2008 [14:13 UTC]: This would not be my main box. I am doing some testing to see if I can install zaptel and asterisk 1.4 on a full centos 5.1 box with development software Its bizzare, because before I went through the asterisk and zaptel installation everything was perfe
  • Nick Barnes, Thu 08 of May, 2008 [13:44 UTC]: Christopher - I can't see any way in which an Asterisk installation would muck your GUI, but remember that it is advised not to use a GUI on an Asterisk box anyway.
Server Stats
  • Execution time: 0.55s
  • Memory usage: 2.24MB
  • Database queries: 38
  • GZIP: Disabled
  • Server load: 0.98

Asterisk echo cancellation

Echo cancellation in Asterisk


Before you proceed down this path, make sure you have read the notes in Causes of Echo on tracing, and attempting to eliminate, the source of any echo. It should be possible to eliminate any residual echo with the zaptel echo canceller, but it won't be able to cope with line faults; and in any case, you'll get better results if you do all you can to eliminate echo at source.

How does echo cancellation work?

Almost all (if not all) echo cancelling algorithms operate by generating multiple copies of the received signal, each delayed by some small time increment In digital terms, this is the equivalent of a shift register and each delayed signal appears at its own unique "tap". The number of taps determines the size of the echo delay that can be cancelled. These delayed copies are then scaled (or weighted) and subtracted from the original received signal. The trick is scaling the the delayed signals to exactly the extent needed to remove the echo and nothing else. The methods used in determining the tap weights (scaling factors) is what distinguishes one algorithm from another.

Don't trust your ears...

The echo canceller must "train" itself by computing the weights when it first sees a signal at the input. The training time depends upon the algorithm used and the number of taps. For optimal training, the number of taps should be as small as possible, while still adequately cancelling the echo. For the typical scenario being experienced by most of us, the signal delay should be relatively short. Don't let your ears be the guide here! The echo you hear has a lot of additional delay added between the location of the echo canceller and your phone. The real delay you are interested in is the delay from the echo canceller, out through the Digium card, through the network to the source of the echo (see Causes of Echo), and back again, to the echo canceller. This delay is relatively short, probably less than 20-30 ms. Simplistically, you'd need a "tail circuit" (the distance between your echo canceller and the source of the echo) of over 2500 miles to acheive an echo path of 30ms (though the digium card and driver probably add a few ms of latency in each direction, so that may be an exaggeration).

Each tap represents 1 sample, so at 8kHz (which is what all of Asterisk's echo cancellers assume), each tap represents 0.125ms. Asterisk's default of 128taps will therefore handle echo paths of up to 16ms, and is therefore probably good for most things.

The take home, however, is that you may get better performance with fewer taps because the training time is shorter and the canceller will adapt faster. Conversely, if you're having problems with echo on long-distance phone calls, you may need to up this to 256 taps.

Beware that Asterisk only lets you set 32, 64, 128 or 256 taps (this is because the algorithms assume the number of taps will be a power of two). Attempting to use a different number of taps will cause Asterisk to fall back to 128 taps without warning.

Algorithmic echo cancellers will never give performance equal to that obtained by balancing the hybrid. This is due to several reasons, not the least of which is that the expansion/compaction must be undone before cancellation, introducing noise and decreasing accuracy of cancellation, and that the delay characteristics and amplitude characteristics of the echo are never as well defined as they are at the point of origin of the echo (the hybrid). This is really too bad, since we don't get to do anything about the hybrid imbalance.

You should also note that you'll only be able to successfully cancel echo if your echo canceller is on the same side of any VoIP links as the source of the echo - the latency introduced by a VoIP system will be too great for any normal echo canceller to cope with.

Also (and this may be obvious!) your echo canceller needs to be pointing in the right direction! Asterisk's echo cancellers will cancel echo arriving from the PSTN via a digium card, before sending the signal up to Asterisk itself. It will not cancel echo arriving over a VoIP channel (which should have been dealt with at the other end, for the reason noted above).

Gain configuration


Before an echo canceller can work, you need to make sure that the levels of the signals it receives are about right. See Asterisk zapata gain adjustment for how to do this.

Terminology


  • Near-end signal - the received signal, to which we need to apply echo cancellation. Note that, (somewhat confusingly) in the context of an Asterisk setup, this will typically be physically further away than the far-end signal - however, in terms of signal latency, the near-end signal (coming from the PSTN) is "closer" than the far-end signal (coming via a VoIP link).

  • Reference signal - the signal we're about to transmit over the PSTN - that is to say, the far-end signal.

  • Tail circuit - the potential distance between the echo canceller and the source of any echo.

  • Doubletalk - the problem the echocanceller encounters when someone at the near end (them) is talking at the same time as the speaker at the far end (you).

Echo cancellation in Asterisk


The first thing to check if you experience echo cancellation with analogue (eg TDM400) cards is that the PSTN loadzone is set correctly. For instance if running in (default) FCC mode, and you are connected to a UK PSTN line, then you *will* observe harsh echo. You will need to change to using UK mode (see TDM400P) in this instance.

The zaptel drivers provide five echo cancellers (seven in zaptel 1.2)--you can configure which is used in zconfig.h. Unfortunately, there's not much documentation available on how to choose between them, or even how to configure them. I'm going to collect the information I've managed to glean on them on the pages below - however, I'm really not an expert in this field, and it really would be nice if the original authors gave some better documentation ;). Proper selection of an echo canceller is dependent upon knowing the algorithm. You need to know what the training performance, tail length, weighting mechanism, etc. If they were identified, at least one could consult the literature for information about the conditions for which the algorithm is ideal: is it best for room echo associated with speaker phones, is it best for cancelling echo from hybrid imbalance, etc.


zaptel 1.0.x offers only the first five of the algorithms listed above. The default echo canceller used by later versions of 1.0.x (eg, 1.0.9.2) is mark2. The default echo canceller used by zaptel 1.2 (up to 1.2.5, at least) is kb1. None of these algorithms has changed since zaptel version 1.2.1(?) 2005-11-30.

fxotune


The FXO module typically has quite a few tunable parameters that affect the electronical characteristics of the device. When tuned right, the device will generate less echo. Those parameters also tend to be quite country-dependent, and hence the first approximation would be to set opermode. See below.

This will work with basically all analog FXO cards (with recent drivers), except the X100P, whose hardware does not have such tuning (anybody tried it with Sangoma A200 cards?)

Basically fxotune pretunes the FXO Module on a TDM400 to deal with the line quality reducing convergence and decreasing the ammount of echo generated in the first place. Hence the echo canceller will have much less echo to cancel later on.

See the Asterisk fxotune page for more info :)

Fax-tone detection


The zaptel drivers provide code which listens for a fax tone (a 2100Hz monotone), and automatically disable the echo cancellers if such a tone is heard in either direction.

This functionality can't be switched off at runtime (though it can be disabled at compile time by setting NO_ECHOCAN_DISABLE)

Stephen R. Besch, November 2003
Updates (with apologies) — Richard van der Hoff, July 2005

See Also


Asterisk | Tips & Tricks | FAQ
Created by oej, Last modification by Rhino Equipment EMEA on Tue 07 of Aug, 2007 [14:56 UTC]

Comments Filter

Echo shown as Off

by Tim King on Friday 27 of April, 2007 [15:29:33 UTC]
Echo cancellation is only shown if the channel is in use.

Echo cancellation: Currently off

by Marco Passarinho Dias on Monday 23 of April, 2007 [11:16:18 UTC]
Despite having the zapata.conf file with echocancel= true and echotraining= true, when I debug the channel in Asterisk CLI "zap show channel 4" it always says "Echo Cancellation: 128 taps, currently OFF". The last line in zapata.conf file of each channel is the definition of the channel...What could be the reason for the echo canceler not to be working? Any help would be much appreciated...

my zapata.conf file (channel 4):

echotraining = yes
callprogress = off
busydetect = yes
signalling = fxs_ks
echocancel = yes
context = incoming
echocancelwhenbridged = yes
channel = 4


Echo Problem PSTN ISDN/DIGIUM/ASTERISK

by jimmmm2 on Monday 25 of April, 2005 [20:40:03 UTC]
We are having a problem that whenever some customers use an analog line to dial into our asterisk box, we occasionally get echo.

Because we are using Speech Recognition we need to eliminate the echo at the digium side.

We are currently looking into the mec3.h program.

1) Does anyone have experience with this and how to remove these types of echo at all times.

ie


a)Double talk
b)Complex echo
c)Residual Error Suppression
d)Length of the filter

2) If it does, can you give us information on how to use it to cancel echo when an Analog line dials into our ISDN?

ie Please can you tell us how to compile the mec3.h program for the Digium trunk?

3) or Do you know of a better echo canceller that we should use to get rid of the echo's described above?



Edit

Re: Be sure to try echo cancellation on both FXO and FXS lines

by Anonymous on Wednesday 12 of January, 2005 [00:51:50 UTC]
could you provide you zapata.conf file to illustrat how you did this?

thnx

echotraining=800

by meowmeow64 on Thursday 26 of August, 2004 [19:53:40 UTC]
rc2 version of asterisk echo training eliminated echo dramatically in my adtran TA750+T100p+TDM400p(4fxo) setup.
setting echotraining=800 in zapata.conf and echocancel=128(default)

(:biggrin:)

Be sure to try echo cancellation on both FXO and FXS lines

by allanon on Thursday 05 of February, 2004 [22:32:40 UTC]
We had a problem with echo on inside lines (extensions), and tried putting echo cancellation on just the inside lines. It did nothing. Our customers couldn't hear any echo, so we didn't immediately try putting echo cancellation on the outside lines.
Once we put echo cancellation on the outside lines, the echo on the inside lines completely went away!

Please update this page with new information, just login and click on the "Edit" or "Add Comment" button above. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

Sponsored by:

Terms of Service Privacy Policy
© 2003-2008 VOIP-Info.org LLC

Powered by bitweaver