[Asterisk-Users] Will Echo problems EVER be solved, I'm scared

Rich Adamson radamson at routers.com
Thu Aug 25 12:25:51 MST 2005


> On Thursday 25 August 2005 08:00, Rich Adamson wrote:
> > If you mean placing a transmission test set at the customer's demarc (at
> > the customer's site), the -2 to -3 db is still incorrect for "analog"
> > pstn circuits. That level _will be_ the 0db generator tone minus the cable
> > loss from the CO to the customer's demarc. That cable loss is 100%
> > predictable if you know the length and gauge of the copper wires between
> > the central office and the customer's site. (That "is" exactly how the
> > engineering spec is set for the less technical telephone installers
> > to measure after installing a new pstn facility to a customer site.)
> 
> Ok...
> 
> > The echo cancellation problem with the x100p and TDM cards are very
> > much related to the narrow operating range that the existing echo
> > cancellation software can operate within.  In the above 8 db loss
> > example (assuming there is an actual 8 db of copper loss between the
> > CO and the customer's site), the _correct_ rxgain and txgain settings
> > would be to provide approximately +6 dbm of gain within asterisk/zaptel.
> > Those gain settings would fall within the stated -2 to -3 db TLP range.
> > However, that 6db of gain (in both directions) will fall outside the
> > operating range of the existing echo canceller, therefore smaller
> > gain values are almost always required in asterisk. It doesn't make
> > any difference whether the transmission level is measured with
> > ztmonitor or a $10k transmission test set. Neither will make it work
> > right.
> 
> Now I'm confused.
> 
> In the first quoted paragraph you seem to be saying that I should tune the 
> rxgain in order to achieve a perceived 0dBm by Asterisk.  (14844 in 
> ztmonitor.)  But then in the paragraph quoted above you're saying that a 
> reading of 7422 (-3dBm if ztmonitor's output is linear-reading) to 14844 is 
> acceptable.
> 
> I'm reading it as "if it takes an rxgain of +8 to get a 0dBm level in 
> ztmonitor, you should tune rxgain to provide 6dBm of gain in order to fall 
> within the -2dB to -3dB range."  
> 
> Am I misreading?
> 
> I was under the impression that the echo canceller worked with whatever came 
> out of the zaptel driver *after* the rxgain was applied and *before* the 
> txgain was applied.  This would mean that your rxgain setting to achieve -2dB 
> to -3dB TPM would certainly fall within what the echo canceller was designed 
> to expect on its input, and that the echo canceller assumes that it's output 
> is at 0dBm, so whatever it sent out would be "corrected" to 0dBm by the 
> transmit amp stage of the zaptel driver.
> 
> > of reflected energy (latency), etc. The companies that engineer dedicated
> > echo cancellers can throw processing power at the problem or use
> > dedicated chips (DSP's) to do that function. Not likely asterisk's
> > canceller will ever be equivalent to dedicated hardware cancellers.
> > (And, why does the new digium T1 card have it on board?)
> 
> You just described why; it's an enormously complex problem that takes lots of 
> CPU time.  By putting it in hardware before the PCI bus access you eliminate 
> a lot of the variables that doing it on the host CPU introduce.
> 
> > One other point that may not be obvious from previous echo postings.
> > Those asterisk users that are physically located a greater distance
> > from the CO _always_ have greater echo issues. Those that are relatively
> > close don't have as big an issue. That _is_ due to the small operating
> > range of asterisk's echo canceller. And, that is _one_ of the reasons
> > why one implementor's settings don't work at another implementor's
> > location. (Not to mention differences in motherboards, etc, etc.)
> 
> Agreed.

Let's see if I can clearify all of the above a little.

Two different examples....

#1: audio signal from an internal asterisk source (eg, sip phone) passing 
to an outbound analog pstn facility. It _is_ normal practice to set both
rxgain and txgain to the exact same value in non-asterisk telephony terms, 
and that value is typically about 2db less then the loss that you're 
trying to overcome. The closer you try to set those gains to "no loss" 
(eg, 8db of gain to compensate for 8db of cable loss), the higher the 
probability of creating an unwanted audio feedback loop that _could_ 
create a hawl, echo, or other unwanted sounds. Its common practice to 
set the gains to 2-3db below that level.

Using an audio tone for this example, a 0db tone would be amplified by
the 6db gain (txgain) to hit the rj11 jack of the pstn interface. As the
signal passes through the cable pair to the CO, the cable loss reduces
the audio to -2db at the CO (effectively at the TPL). However, as that
audio passes through the TDM card to the rj11 (and pstn copper), some
level of energy is always reflected back to the receive side of the TDM
card.  The larger the outbound signal, generally the larger the inbound
energy. (Some of that is the result of an imperfect hybrid on the TDM
card, some from mismatched impedance (there is always some at different
frequencies), some from the CO, and maybe even some from a distant 
hybrid. Don't care whether its called far-end or near-end; its energy 
coming back at ya that needs to be cancelled out or subtracted from the 
inbound signal. Effectively, the echo canceller is only applied to that
inbound energy, substracting out what was witnessed as outgoing audio.)

If you experiment with asymentric gain settings, you should find that
cranking the rxgain up and the txgain down is very different from the
opposite. (I happen to be happy with rxgain=5 and txgain=0 when I'm
7db from the CO with no echo. But, the party I'm talking to will have
a more difficult time of hearing me.)

#2: 1: audio signal from a pstn source passing into the TDM card and
heading towards a sip phone (as an example). Using the same 8db cable
loss example, the inbound audio arrives at the TDM card at -8db assuming
the pstn speaker actually hit the CO at 0db. The rxgain=6 inceases the
audio to hit the sip phone at basically -2db. Since there is no hybrid
involved (other then the sip phone internals), there is no echo cancellation
required. So, setting the rxgain to any reasonable value has little or
no effect on the asterisk ehco cancellation functions. (I don't have
a clue whether asterisk's rxgain value is applied before or after the echo
canceller gets the audio.)

Now combine the two in a full duplex facility. The echo canceller _must_
keep track of audio sent outbound, and find the equivalent of that audio
(and its harmonics) on the inbound side at a much lower level. Once the
canceller finds a match (which is not trevial by any stretch), identifying
the _magnitude_ of data to substract from the inbound audio must be fairly
accurate. (Since I've not written echo cancelling software, I'm sure there
is slightly more to it then this simple example, and I'm sure Steve Underwood
would back that statement up.)

Asterisk's echo canceller attempts to preload the canceller by sending a
short duration burst/pulse at the start of a call (echotraining=800).
Since the circuit is relatively quiet (at 800 milliseconds into the call),
the reflected energy is relatively clean and easy to quantify. But, the
call has not yet been completed to the far end, so the preload is only
compensating for any energy reflected from the TDM hybrid, the pstn
copper, and the CO. (There might be another switch or so involved, but
the called party link would not have been set up nor would the called
party have answered. Therefore any energy reflected from that stuff isn't
considered in the preload.)

The canceller is suppose to also stay in circuit and sample the human 
audio as it passes out to the pstn, and further adjust the cancellation 
as time progresses. That's the piece that supposedly does not have a very
wide operating range considering high vs low pitch voices, high vs low
loudness, harmonics, etc.

So, the txgain setting turns out to be the most critical adjustment,
and its a trade off between reasonable transmission levels and echo.
In the majority of cases that I've worked with, txgain can never be
set to anything close to the analog cable loss (minus 2db) unless you
are very close to the CO.





More information about the asterisk-users mailing list