Back to Insights
VoIP Engineering

SDP Offer/Answer Explained: How VoIP Endpoints Negotiate Codecs and Media

Telephony Engineering Team
4 min read
SDP Offer/Answer Explained: How VoIP Endpoints Negotiate Codecs and Media

SDP (Session Description Protocol) is the text format SIP uses to describe the media of a call: which codecs each side supports, where to send audio, and in which direction. SIP carries the SDP, and two parties use an offer/answer exchange to agree on a single media configuration.

Reading an SDP Body

v=0
o=- 2890844526 2890844526 IN IP4 203.0.113.10
s=-
c=IN IP4 203.0.113.10
t=0 0
m=audio 16384 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=ptime:20
a=sendrecv
  • c= is the connection address where media should be sent. A wrong or private address here is a leading cause of one-way audio.
  • m=audio 16384 RTP/AVP 0 8 101 means audio on UDP port 16384, offering payload types 0, 8, and 101 in order of preference.
  • a=rtpmap maps each payload type to a codec and clock rate.
  • telephone-event carries DTMF digits in RTP (RFC 2833/4733 style).
  • a=sendrecv, sendonly, recvonly, inactive set the direction, which is how hold works.

The Offer/Answer Model

  1. The caller's INVITE contains an offer listing its codecs in preference order.
  2. The callee picks codecs it also supports and returns an answer with the chosen subset.
  3. Both sides now send RTP to the address and port in the other side's SDP.

The answer can only choose from what was offered. If there is no overlap, the callee responds 488 Not Acceptable Here (see SIP response codes).

Late Offer vs Early Offer

With early offer, the INVITE carries the SDP. With late offer, the INVITE has none and the offer arrives in the 200 OK, with the answer in the ACK. Late offer is legal but trips up equipment that assumes early offer, and it complicates media handling in gateways.

Common Failure Modes

ProblemCause
One-way or no audioPrivate IP in c=, blocked RTP ports, no media relay (see NAT traversal)
488 on call setupNo common codec between the two sides
DTMF not detectedMismatched telephone-event payload type or in-band vs out-of-band handling
Call goes silent on hold or transferRe-INVITE direction or address handled incorrectly
Choppy audioDifferent ptime values or transcoding load (see G.711 vs G.729)

Encryption in SDP

For SRTP, SDP carries key material or fingerprints. WebRTC uses DTLS-SRTP, which is negotiated through SDP fingerprints and ICE candidates. See RTP and SRTP voice encryption.

Practical Advice

  • Offer a short, ordered codec list rather than everything you support
  • Keep ptime consistent end to end where possible
  • Let a media relay such as RTPengine rewrite addresses at the network edge (see open-source SBC with Kamailio and RTPengine)
  • Capture both signaling and media when debugging, since the SDP alone does not prove packets flowed

For the signaling that carries SDP, start with what SIP is and how it works.


Need media handling that just works across carriers and NAT? Our FreeSWITCH development team builds media servers with correct codec negotiation, transcoding, and relay behavior.

Discussion

0

Join the conversation

Sign in with your preferred account to comment, reply, and keep the discussion useful for other engineers.

Takes a few seconds. No separate password required.

C

Controva LLC

Engineering Team

We build digital empires that scale. Specializing in high-performance web architecture, AI automation, and headless commerce.

Work with us

Share this article