One-Way Audio and Dropped Calls on SIP Voice AI: NAT, Jitter, Failover and Monitoring
One-Way Audio and Dropped Calls on SIP Voice AI: NAT, Jitter, Failover and Monitoring
The problem
The call connects. The caller says "hello" and your agent never hears it. Or the agent talks and the caller hears nothing. Signaling worked, because the call is up and the SIP ladder looks perfect, but the audio only flows in one direction, or not at all. A day later a different problem shows up: one carrier node goes down and every call fails, even though the carrier had a second node ready.
These are the failures that appear when a voice agent moves from a demo to real phone traffic. Almost none of them are about the AI. They come from how SIP and RTP cross NAT devices and firewalls, how late and lost packets are handled, and how your system finds a working server when one fails. This post goes through each, using the RFCs and the official docs of the tools you would use to debug them. For rejected calls and what each status code means, use the SIP response code chart; this post does not repeat it.
This is part 10 of the Voice AI over SIP series. If a term is new to you, the glossary defines it in plain language and links to the part that covers it.
Why NAT breaks SIP
NAT (network address translation) lets many machines on a private network share one public IP address. The NAT rewrites the source address and port of outgoing packets and keeps a temporary "binding" so replies can find their way back. RFC 6314, the IETF's write-up of NAT traversal practice for SIP, splits the trouble into two parts: signaling and media.
Signaling: responses sent to the wrong port
Over UDP, plain RFC 3261 sends a response back to the IP address the request came from, but to the port written in the top Via header. Behind NAT, that port is the client's private listening port, not the port the NAT opened. RFC 6314's Figure 1 shows exactly this: the response goes to the port in Via and is dropped at the NAT.
RFC 3581 fixes this with the rport parameter. The client adds an empty rport to its Via. The server must fill in the source port it actually saw, add received with the source IP, and send the response there, from the same address and port the request arrived on. The Via header from the RFC's example, as sent by the client and then as recorded by the server (excerpt, other headers omitted):
textVia: SIP/2.0/UDP 10.1.1.1:4540;rport;branch=z9hG4bKkjshdyff
textVia: SIP/2.0/UDP 10.1.1.1:4540;received=192.0.2.1;rport=9988;branch=z9hG4bKkjshdyff
The client sat at private address 10.1.1.1 port 4540. The NAT made it 192.0.2.1 port 9988. In the RFC's example the response goes to 192.0.2.1 port 9988, sent from port 5060, which is the port the NAT is really holding open.
RFC 3581 adds a timing warning that matters for long-ringing calls: most UDP NAT bindings time out after about a minute, so a client waiting on an INVITE should retransmit it about every 20 seconds to keep the binding fresh.
Media: the private address in SDP
The SDP inside the INVITE tells the far side where to send audio, in the c= line and the m= port. If your server is behind NAT and writes its private address there, the carrier sends RTP to an address it cannot reach. RFC 6314 Figure 3 shows both sides sending media to "unknown address". The result is classic one-way or no-way audio, with perfect signaling.
Animation: NAT rewrites the packet header but not the SDP, so RTP is sent to a private address and audio flows one way.
Symmetric RTP
RFC 4961 (a Best Current Practice) defines symmetric RTP: a device that receives a stream on port A also sends that stream from port A. It says symmetric RTP and RTCP are required in two cases: NATs without a SIP-aware application layer gateway, and SBCs or other media relays. It recommends always using symmetric RTP for bidirectional streams and notes there are no known cases where it is harmful.
Symmetric RTP is what lets an SBC or carrier "latch" onto where your packets actually come from, instead of trusting the address in your SDP. If your media server sends from one port and listens on another, that latching fails.
SIP ALG
An ALG (application layer gateway) is a feature in some NAT routers and firewalls that tries to rewrite addresses inside SIP messages for you. RFC 6314 says plainly that ALGs have limitations and that "experience shows they can have an adverse impact on the functionality of SIP", including requiring media and signaling to pass through the same device and not working with encrypted signaling or media. My opinion: when one-way audio appears on a path through a firewall you do not control, find out whether a SIP ALG is active on it before debugging anything else.
ICE, briefly
RFC 6314 lists STUN, TURN and ICE as media traversal tools. ICE (Interactive Connectivity Establishment) has each side gather candidate addresses and test them. It is central to WebRTC. On a server-to-carrier SIP trunk, both sides typically have public addresses or an SBC in between, so I would not reach for ICE unless your carrier documents support for it. That is a judgment call, not a rule from the RFCs.
A one-way audio checklist
| Symptom | Likely cause | Where to look |
|---|---|---|
| Caller hears agent, agent hears nothing | Your c= or port in SDP is private or wrong; firewall blocks inbound RTP range | SDP in your 200 OK or INVITE; firewall rules |
| Agent hears caller, caller hears nothing | You send RTP to the wrong address, or from a port the far side does not expect (not symmetric) | Destination of your outgoing RTP in a capture |
| Both directions silent | Media sent to unreachable addresses on both sides (RFC 6314 Figure 3); SRTP on one side only | Both SDPs; crypto attributes |
| Ringback or greeting missing at the start | Early media expected but not sent, or RTP starts only after ACK | LiveKit's codec doc notes RTP usually starts after ACK, or earlier after a 183 with early media |
| Audio stops at hold or transfer | A re-INVITE set a=sendonly, recvonly or inactive (RFC 3264) | The later SDP exchange |
| Garbled or silent decode | Payload type mismatch, or a dynamic type assumed instead of read from a=rtpmap (see part 4) | m= and a=rtpmap lines vs the RTP payload type field |
| Breaks only through one router | SIP ALG rewriting messages (RFC 6314) | Router or firewall settings |
flowchart TD A[Call is up, audio is missing] --> S[Capture all UDP, open Wireshark VoIP Calls graph] S --> B{Agent hears nothing?} B -->|Yes| C{Your SDP c= or port private?} C -->|Yes| C1[Advertise a public address] C -->|No| C2[Open inbound RTP range in firewall] B -->|No| D{Caller hears nothing?} D -->|Yes| D1[Check where your RTP is sent] D1 --> D2[Send to far SDP address, use symmetric RTP] D -->|No| E{Both directions silent?} E -->|Yes| E1[Check both SDPs and SRTP on both sides] E -->|No| F{Breaks only through one router?} F -->|Yes| F1[Turn off the SIP ALG] F -->|No| G[Stops at hold or transfer: check re-INVITE direction]
Diagram: The one-way audio table as a runbook: start from which direction is silent.
Debugging tools
sngrep: see the SIP ladder in a terminal
sngrep, from Irontec, shows SIP calls as message flows in the terminal, from a live capture or a pcap file. The README's own examples:
bash# From the sngrep README (github.com/irontec/sngrep), not run here sngrep -I file.pcap host 192.168.1.1 and port 5060 sngrep -d eth0 -O save.pcap port 5060 and udp
The first reads a saved capture with a filter. The second captures live on eth0 and saves to a file. Use it first to confirm the INVITE, 200 OK and ACK all happened, and to read the SDP in each. The README also lists optional TLS decryption support (built with OpenSSL or GnuTLS) and an --enable-eep build option for sending and receiving EEP/HEP packets, which ties into the monitoring section below.
tcpdump: capture everything for later
The tcpdump 4.99.2 man page documents the flags you need: -i picks the interface (on Linux, any captures all interfaces but not in promiscuous mode), -w writes raw packets to a file, -s sets the snapshot length (default 262144 bytes), -C rotates files by size in millions of bytes, and -G rotates by time. The filter expression syntax lives in the pcap-filter(7) page.
bash# My example, built only from flags documented in the tcpdump 4.99.2 man page. Not run. # Capture all UDP on all interfaces to a file, rotating every 100 million bytes. tcpdump -i any -w /tmp/sip-rtp.pcap -C 100 udp
Capturing all UDP rather than just port 5060 matters, because RTP runs on whatever ports the SDP negotiated. The man page also notes that reading a saved file does not need special privileges, and it reports packets "dropped by kernel" when tcpdump falls behind.
Wireshark: calls, graphs and playback
The Wireshark wiki's VoIP calls page describes Telephony > VoIP Calls, which finds calls in a capture for SIP, H323, ISUP, MGCP and UNISTIM and gives each a state such as CALL SETUP, RINGING, IN CALL, COMPLETED, REJECTED or CANCELLED. "Prepare Filter" builds a display filter for the selected calls. The Graph view draws the call flow, with an RTP summary arrow that shows the codec.
For one-way audio, my opinion is that the Graph is the fastest check: if RTP appears in one direction and not the other, you have your answer, and the packets themselves tell you which address they were really sent to.
The Player can also replay audio through a fixed-size jitter buffer you choose, and reports packets dropped by that buffer ("Drop by Jitter Buff") and out of sequence. The wiki says that from version 3.2.0 Wireshark can save decoded audio for any codec with 8000 Hz sampling.
Jitter, loss and concealment
Jitter is variation in packet arrival time. RFC 3550 defines the interarrival jitter estimate every RTP receiver reports: for consecutive packets, D is the difference in spacing at the receiver versus the sender, and the running estimate is
textJ(i) = J(i-1) + (|D(i-1,i)| - J(i-1)) / 16
measured in RTP timestamp units. At an 8000 Hz clock, 8 units equal 1 ms (my arithmetic). RTCP receiver reports carry this value along with the fraction of packets lost and the cumulative count lost, so you can monitor quality without capturing the media itself. On Asterisk, GET /channels/{channelId}/rtp_statistics in ARI exposes per-channel RTP stats.
Jitter buffers hold packets briefly so they can be played on time. ITU-T G.114 explains the trade-off: a packet that arrives later than the buffer allows is discarded, and that counts as loss. For planning, assume a buffer adds half its peak delay. G.114's example is a buffer covering 50 ms of variation, adding 25 ms on average. A bigger buffer means fewer late drops but more delay for the agent's turn-taking. Part 5 shows how this fits into the voice agent latency budget.
Loss and concealment. PLC (packet loss concealment) fills gaps with plausible audio. What you get depends on the codec:
- Opus (RFC 7587) has its own PLC and optional in-band FEC (forward error correction).
- G.722 was designed without PLC; the ITU summary says Appendices III and IV add it.
- RFC 3551 points to RED (RFC 2198) for sending redundant audio.
For an AI agent, concealed audio is still guessed audio. Speech recognition sees whatever the decoder invented, so heavy loss can show up as wrong transcripts rather than as audible glitches.
Animation: Packets arrive out of order; the jitter buffer reorders them by sequence number and drops the one that comes too late.
Failover: finding a working server
RFC 3263 describes how SIP uses DNS to find servers, including NAPTR records to choose a transport and SRV records to list servers with priorities and weights. Its example SRV set:
text;; Priority Weight Port Target IN SRV 0 1 5060 server1.example.com IN SRV 0 2 5060 server2.example.com
The part that matters for reliability is section 4.3, which defines failure for SIP: a 503 response, a transport failure, or a transaction timeout with no response at all (RFC 3261 timer B or F firing). On failure, the client should build a new request with a new Via branch, which makes it a new transaction, and send it to the next server in the SRV order. RFC 3263 also recommends giving equal-priority SRV records slightly different weights (its example is 1000 and 1001) so stateless proxies can order them deterministically.
In practice, this means two things for a voice agent. First, point your outbound trunk at the carrier's DNS name if they publish SRV records, rather than at a single IP address. Second, a timeout with no response is a failover trigger, so very long timeouts mean very slow failover. If your carrier gives you two trunks with separate addresses and no SRV, the failover logic is yours to build.
Keepalives: OPTIONS pings
RFC 3261 section 11 defines OPTIONS as a way to query a server's capabilities "without 'ringing' the other party". All user agents must support it, and the response code should be what an INVITE would get, for example 200 if ready or 486 if busy. A transaction timeout with no response suggests the target is unreachable. The RFC's example:
textOPTIONS sip:carol@chicago.com SIP/2.0 Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKhjhs8ass877 Max-Forwards: 70 To: <sip:carol@chicago.com> From: Alice <sip:alice@atlanta.com>;tag=1928301774 Call-ID: a84b4c76e66710 CSeq: 63104 OPTIONS Contact: <sip:alice@pc33.atlanta.com> Accept: application/sdp Content-Length: 0
That makes OPTIONS a natural health check for trunk peers: send one periodically, and mark the peer down when it stops answering. One nuance from RFC 6314: NAT inactivity timers vary from seconds to hours, and it warns that if the timer is short, using SIP signaling as a keepalive adds a lot of traffic and processing. So OPTIONS is a good health check for a carrier peer, but it is not a cheap way to hold NAT bindings open at very short intervals.
Capacity: channels and calls per second
Two numbers describe trunk capacity, and they fail differently:
- Channels are concurrent calls. When you hit the limit, new calls are rejected while existing ones continue.
- CPS (calls per second) is how fast new calls can be set up. Outbound campaigns hit this first, because hundreds of INVITEs can go out in a burst.
Both limits are set by the carrier contract and by your own media servers, and I did not find a standard value to quote. What you can work out from the standards is the media load per call. A G.711 call at the default 20 ms packetization is 50 packets per second in each direction, with 64 kbit/s of audio payload per direction before headers (8000 samples x 8 bits; 1000 ms / 20 ms = 50, my arithmetic). Your SBC or media bridge has to handle that packet rate for every concurrent call. For carrier-specific limits, see SIP trunk providers for voice AI in India compared. Outbound pacing and retries are covered in AMD, DTMF and transfers.
Monitoring: HEP and Homer
Captures are good for one bad call. For every call, you want a capture system running all the time. HEP (also called EEP) is the capture protocol used with SIPCAPTURE's HOMER. Its spec repository describes it as a way to duplicate an IP datagram to a collector by wrapping the original packet and its header details in a new datagram sent over UDP, TCP or SCTP. It is meant for passive copying for central storage and analysis, not for tunneling. The same page lists native HEP support in Kamailio, OpenSIPS, FreeSWITCH, Asterisk and RTP:Engine, and in capture tools including heplify and sngrep. The protocol is at its third version (HEPv3).
heplify, SIPCAPTURE's capture agent, runs as a single binary and can send SIP, correlated RTCP, DNS, Diameter and logs to Homer. It defaults to capturing on interface "any" with a snap length of 8192, and can export Prometheus metrics. Its README's container example passes this command, pointing at a HEP server on port 9060 (excerpt):
yaml# Excerpt from the sipcapture/heplify README Docker example, not run here command: ["-hs", "192.168.1.1:9060", "-m", "SIP", "-dd", "-l", "info", "-S"]
The point of correlated RTCP is that you get each call's jitter and loss figures stored next to its SIP ladder. When someone reports "the agent could not hear me at 3:40 pm", you can find the call by number and time, and see whether the RTCP reports from that call showed loss, rather than guessing.
Where I would start
My opinion, in order: check SDP addresses and ports in a real 200 OK, confirm symmetric RTP and no SIP ALG on the path, capture with tcpdump on all UDP and open it in Wireshark's VoIP Calls graph, then set up OPTIONS health checks and SRV-based failover, and finally put HEP capture in place so the next problem arrives with evidence. For Asterisk RTP port and NAT settings, see the Asterisk reference chart. For a LiveKit-based setup, see LiveKit SIP trunk voice agent setup.
Sources
- RFC 3261: SIP, Session Initiation Protocol
- RFC 3263: Locating SIP Servers
- RFC 3264: An Offer/Answer Model with SDP
- RFC 3550: RTP, A Transport Protocol for Real-Time Applications
- RFC 3551: RTP Profile for Audio and Video Conferences
- RFC 3581: Symmetric Response Routing (rport)
- RFC 4961: Symmetric RTP and RTCP
- RFC 6314: NAT Traversal Practices for Client-Server SIP
- RFC 7587: RTP Payload Format for Opus
- IANA: RTP Parameters registry
- ITU-T G.114 (05/2003): One-way transmission time
- ITU-T G.722 summary (09/2012)
- sngrep README (Irontec)
- tcpdump 4.99.2 man page
- Wireshark wiki: VoIP calls
- SIPCAPTURE: HEP/EEP specification repository
- SIPCAPTURE: heplify capture agent
- Asterisk 20: Channels REST API
- LiveKit: Codecs and negotiation
