Audio quality problems in Asterisk — one way audio, choppy calls, echo, robotic voices — all have specific root causes you can find in the RTP statistics and debug output. Here's how to diagnose and fix each one systematically.
Asterisk logs RTP statistics at call teardown when rtcpstats=yes is enabled. These stats are your first diagnostic tool:
Key values to check: Fraction lost (0 = no loss, 256 = 100% loss), Packets lost (cumulative), Interarrival jitter (in RTP timestamp units — divide by 8 for ms on G.711). Also check via the CLI during an active call:
One way audio in Asterisk is almost always a NAT or direct_media issue. Check these in order:
With direct_media=yes (default in chan_sip, configurable in PJSIP), Asterisk re-INVITEs to get media flowing directly between endpoints. If one endpoint is behind NAT, direct media will fail. Set direct_media=no to force all media through Asterisk and test.
Enable SIP/PJSIP debug and look at the SDP c= line. If it contains a private RFC 1918 address, NAT is the issue. For PJSIP, set external_media_address on the transport.
Echo in Asterisk calls comes from acoustic feedback at an analog endpoint (handset or speakerphone) being picked up by the microphone. Asterisk includes the OSLEC and SPEEX echo cancellers.
For SIP-to-SIP calls with echo, the most common cause is direct_media=yes with a re-INVITE that changes the media path after the call connects. Disable direct_media as a test.
Choppy audio in Asterisk calls is caused by packet loss or jitter exceeding the jitter buffer. Diagnose with:
Robotic audio specifically (as opposed to occasional clips) often indicates codec transcoding — Asterisk is converting between codecs in the media path. Check the codec negotiation and try to establish a direct codec path without transcoding.
direct_media (called canreinvite in old chan_sip) controls whether Asterisk tries to get out of the media path. When enabled:
Recommendation: Set direct_media=no by default. Enable it selectively only for internal calls between endpoints on the same LAN where NAT is not a factor.
The adaptive jitter buffer automatically adjusts depth based on observed jitter. For most deployments, the defaults work well. Increase jbmaxsize to 200-300ms for high-jitter paths. Don't exceed 300ms or you introduce noticeable conversational latency.
One way audio in Asterisk is almost always NAT or direct_media. First set direct_media=no to force media through Asterisk. If that fixes it, NAT is the cause — configure external_media_address in PJSIP transport or nat=yes in chan_sip with your external IP. Use rtp set debug to see exactly which direction packets are flowing.
Enable rtcpstats=yes in rtp.conf. Asterisk logs RTP statistics at call teardown showing packets lost, jitter, and sequence numbers. During an active call use rtp set debug ip [address] to see live packet flow. Check /var/log/asterisk/full for RTCP report entries.
Choppy audio in Asterisk is caused by RTP packet loss or jitter exceeding the jitter buffer. Check RTCP stats for Packets lost > 0 and Interarrival jitter. Also check server CPU — high CPU causes RTP send scheduling delays that appear as jitter. Robotic audio specifically often indicates codec transcoding.
Paste your Asterisk SIP debug or RTP statistics into SIPSymposium. The analyzer identifies one-way audio causes, codec transcoding paths, and RTP quality issues.