SDP Examples: SIP and WebRTC Offer and Answer, Annotated
Session Description Protocol (SDP) is the plain-text body inside a SIP INVITE, or inside a WebRTC createOffer(), that tells the other side which media you want to send, where to send it, and how. If you are new to the format itself, Siperb’s primer on what SDP is covers the fields. This guide is the next step: real SDP examples, annotated line by line, so you can read the SDP in your own logs and see why a call did or did not set up.
Each of the SDP examples below is a trimmed, representative capture of the kind you will see in sngrep, the Asterisk PJSIP logger or chrome://webrtc-internals. Addresses, keys and fingerprints have been changed.
Reading SDP examples: offer and answer in five rules
SDP itself, now defined in RFC 8866, only describes a session. The negotiation comes from the offer/answer model in RFC 3264. As a result, five of its rules explain most of what goes wrong in the SDP examples that follow:
- One offer, one answer. One side proposes; the other replies with what it accepts, chosen from what was offered.
- Same number of media lines, same order. The answer “MUST contain exactly the same number of ‘m=’ lines as the offer” (section 6). In other words, streams are matched by position, not by name.
- Rejecting a stream means port 0. To decline an offered stream, the answer keeps its
m=line and sets the port to zero. Removing the line instead, however, breaks rule 2. - Codecs come from the offer. The answer lists the codecs it accepts from the offered set. If nothing overlaps, there is no call: on SIP that is usually a 488 Not Acceptable Here.
- Keep the offer’s payload type numbers. For dynamic codecs (96 to 127), the answerer SHOULD use the same number the offer used (section 6.1). However, it is a SHOULD, not a MUST, which is why mismatched numbers still turn up in the field.
Example 1: a desk phone calls Asterisk (plain SIP, G.711)
First, the simplest real-world offer: a SIP desk phone sending an INVITE over UDP.
v=0
o=1001 3816 3816 IN IP4 192.168.1.50
s=Talk
c=IN IP4 192.168.1.50
t=0 0
m=audio 16384 RTP/AVP 0 8 9 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
Reading the desk phone’s offer, line by line
v=0is the SDP version. In practice, it has always been 0.o=is the origin: user, session ID, session version, network type, address type and address. The session version (the second 3816) must go up by one each time this side sends a changed SDP in the same call. A re-INVITE that changes the media without changing the version is a common cause of the far end ignoring the change.s=is the session name. Because SIP ignores it, a dash or any text is fine.c=is where to send media: here the phone’s own LAN address. If you see a private address here on a call that crosses the internet, you have found your one-way-audio problem.- Next,
t=0 0means the session is not time-bounded, which is always the case for calls. m=audio 16384 RTP/AVP 0 8 9 101means: one audio stream, receiving RTP on port 16384, plain RTP profile, and these payload types in order of preference.0,8and9are static payload types defined in RFC 3551: PCMU (G.711 µ-law), PCMA (G.711 A-law) and G.722. Strictly speaking, thertpmaplines are optional for static types, but most phones send them anyway.a=rtpmap:9 G722/8000looks wrong but is correct. G.722 samples at 16 kHz, yet its RTP clock rate is 8000, a historical mistake RFC 3551 keeps for compatibility (section 4.5.2). Consequently, software that “fixes” it to 16000 breaks G.722 calls.101 telephone-event/8000withfmtp:101 0-16is DTMF as RTP events (RFC 4733): digits 0 to 9,*,#, A to D, and flash.- Likewise,
a=ptime:20asks for 20 ms of audio per packet. a=sendrecvmeans two-way audio. It is also the default when no direction is given.
Asterisk’s answer to the desk phone
Next, Asterisk’s answer, with allow=alaw,ulaw on the endpoint:
v=0
o=- 1001 3 IN IP4 203.0.113.10
s=Asterisk
c=IN IP4 203.0.113.10
t=0 0
m=audio 14582 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:140
a=sendrecv
In this answer, G.722 has gone because the endpoint does not allow it. Also, one media line answers one media line (rule 2). In addition, the codecs are a subset of the offer (rule 4). Finally, payload 101 keeps its number (rule 5). Therefore the call will use PCMU, the first codec both sides share. Note, however, that Asterisk’s own allow order can override the offer’s preference order, depending on the endpoint’s codec_prefs_* settings.
Example 2: a browser’s WebRTC offer
By contrast, the same call from a browser softphone looks very different. For example, this is a trimmed audio-only offer from Chrome:
v=0
o=- 4611731400430051336 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=extmap-allow-mixed
a=msid-semantic: WMS
m=audio 9 UDP/TLS/RTP/SAVPF 111 63 9 0 8 13 110 126
c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:pwLG
a=ice-pwd:5TXuaOWk10pu2NQzjeL87lFS
a=ice-options:trickle
a=fingerprint:sha-256 B0:48:A2:87:9E:8E:D2:79:3C:6E:04:FB:23:CC:71:B6:04:AE:10:FB:B5:E1:30:B7:A7:90:08:09:5C:21:32:1D
a=setup:actpass
a=mid:0
a=sendrecv
a=msid:- 7c1d1a1e-5b7f-4c1e-9d0e-2f6c1c9b8a44
a=rtcp-mux
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=fmtp:111 minptime=10;useinbandfec=1
a=rtpmap:63 red/48000/2
a=fmtp:63 111/111
a=rtpmap:9 G722/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:13 CN/8000
a=rtpmap:110 telephone-event/48000
a=rtpmap:126 telephone-event/8000
a=ssrc:1234567890 cname:Xy7Kq2mVb9Lp4nRt
What the browser offer tells the PBX
Compared with the desk phone, these are the lines that matter for SIP interop:
m=audio 9andc=IN IP4 0.0.0.0. Here, port 9 is the “discard” port and 0.0.0.0 is a placeholder. At this point, the browser has not chosen an address yet. The real addresses arrive as ICE candidates, either asa=candidate:lines in the SDP or separately (“trickle”). A PBX that takes thec=line literally and sends media to 0.0.0.0:9 will never get audio.UDP/TLS/RTP/SAVPFis the WebRTC profile: RTP, encrypted (S), with feedback (F), keyed over DTLS. As a result, a PBX endpoint offering or expecting plainRTP/AVPwill not match it, and the usual result is a 488.a=ice-ufrag,a=ice-pwd,a=ice-options:trickleare the ICE credentials (RFC 8839). Both sides must have ICE enabled, and the candidates they exchange come from STUN and TURN servers. Also, “trickle” means candidates may arrive after the SDP.
Security, bundling and codecs in the browser offer
a=fingerprintanda=setup:actpassset up DTLS-SRTP. Specifically, the fingerprint is a hash of the certificate the browser will present. RFC 8842 requires the offerer to sendactpass(either side may start the handshake). The answerer picksactiveorpassive; if it picksactive, it must send the first DTLS message. For this reason, a fingerprint that does not match the certificate is a silent call killer: signalling succeeds and the media never starts.a=group:BUNDLE 0anda=mid:0let every stream share one transport (RFC 9143). With only one audio line this is trivial; however, with audio and video it is the main source of interop trouble with older gateways.a=rtcp-muxsends RTCP on the RTP port (RFC 5761). Moreover, browsers require it.opus/48000/2is always written this way, even for mono speech: RFC 7587 fixes the clock rate at 48000 and the channel count at 2 in the SDP. In addition,useinbandfec=1turns on Opus’s built-in loss recovery.red/48000/2withfmtp:63 111/111is redundant audio: each packet carries the previous Opus frame as well. Meanwhile, a PBX that does not understand RED should simply not pick it.- Two telephone-event lines, one at 48000 and one at 8000. That is because DTMF events must use the same clock rate as the audio codec chosen. So if the call settles on Opus, the 48000 version is the right one; on G.711, the 8000 version. A PBX that answers Opus with an 8000 Hz telephone-event is a classic cause of “DTMF does not work from the browser”.
Browsers build all of this according to JSEP, now RFC 9429, which replaced RFC 8829 in April 2024 after BUNDLE behaviour was found to be inconsistent.
Example 3: Asterisk answers the browser
For Asterisk to answer Example 2, the PJSIP endpoint needs webrtc=yes. Since Asterisk 15 that one option enables rtcp_mux, use_avpf, ice_support and media_use_received_transport, sets media_encryption=dtls, dtls_verify=fingerprint and dtls_setup=actpass, and, if no dtls_cert_file is set, auto-generates a certificate (dtls_auto_generate_cert, since 15.2). With that in place, the answer looks like this:
v=0
o=- 2032465931 2 IN IP4 203.0.113.10
s=Asterisk
c=IN IP4 203.0.113.10
t=0 0
a=group:BUNDLE 0
a=msid-semantic: WMS
m=audio 18342 UDP/TLS/RTP/SAVPF 111 0 126
a=connection:new
a=setup:active
a=fingerprint:SHA-256 5E:9A:11:C4:73:0B:2D:88:F1:44:9C:6A:3E:BD:07:12:A9:5F:60:CE:28:91:D3:4B:7E:02:6C:F5:1A:B8:93:4D
a=ice-ufrag:4a1b2c3d
a=ice-pwd:6e7f8a9b0c1d2e3f4a5b6c7d
a=candidate:Ha0a000a 1 UDP 2130706431 203.0.113.10 18342 typ host
a=rtpmap:111 opus/48000/2
a=fmtp:111 useinbandfec=1
a=rtpmap:0 PCMU/8000
a=rtpmap:126 telephone-event/8000
a=fmtp:126 0-16
a=ptime:20
a=maxptime:120
a=rtcp-mux
a=mid:0
a=sendrecv
Checking the answer against the rules
Next, check it against the five rules:
- One
m=line answers onem=line, with the same profile,UDP/TLS/RTP/SAVPF. - Codecs are a subset of the offer and keep their numbers: 111 for Opus, 0 for PCMU, 126 for telephone-event.
a=setup:active: Asterisk will start the DTLS handshake. Meanwhile, the browser, having offeredactpass, waits for it.- Asterisk sends its own
a=candidate:line with its public address. So if Asterisk is behind NAT and that address is private, setexternal_media_addresson the transport, or ICE will offer the browser an address it cannot reach. a=mid:0matches the offer, anda=group:BUNDLE 0confirms bundling.
Finally, one thing to notice: Asterisk chose telephone-event/8000 alongside Opus. Browsers tolerate this in practice, but if DTMF is unreliable from a browser phone, the telephone-event clock rate in the answer is the first line to check.
Example 4: putting a call on hold
Hold is a re-INVITE with a new SDP: same media, new direction, and the session version in o= raised by one. RFC 3264 section 8.4 says a held sendrecv stream becomes sendonly:
o=1001 3816 3817 IN IP4 192.168.1.50
...
m=audio 16384 RTP/AVP 0 101
...
a=sendonly
In response, the far end answers recvonly and usually starts music on hold. Similarly, taking the call off hold is another re-INVITE with sendrecv and the version raised again.
Even so, you will still meet the older method, c=IN IP4 0.0.0.0, from some phones. RFC 3264 says it is “no longer recommended” for hold, but every agent “MUST be capable of receiving” it. If a PBX misreads it, the symptom is a call that goes silent and never comes back.
What SDP examples show about failed calls
| What you see in the SDP | What happens | Usual fix |
|---|---|---|
| No codec in common between offer and answer | 488 Not Acceptable Here | Allow a shared codec on the endpoint; see the 488 guide |
Offer is UDP/TLS/RTP/SAVPF, endpoint expects RTP/AVP |
488, or call drops after answer | Enable webrtc=yes (Asterisk) or the equivalent WebRTC profile |
| Fingerprint does not match the certificate | Call connects, no audio, DTLS errors in the log | Check dtls_cert_file, or let Asterisk auto-generate |
Private address in c= or in the only candidate |
One-way or no audio across NAT | external_media_address, rtp_symmetric, a TURN server for browsers; see the one-way audio field guide |
Answer has fewer m= lines than the offer |
Call rejected or media mapped to the wrong stream | Reject unwanted streams with port 0; never delete the line |
o= version not raised on a re-INVITE |
Change ignored, e.g. hold never takes effect | Fix the sending device; most current firmware handles this |
| telephone-event clock rate differs from the audio codec | DTMF not detected | Match the event rate to the codec (48000 for Opus) |
Capturing your own SDP examples
- Asterisk:
pjsip set logger onat the CLI prints every SIP message with its SDP. - Any SIP server:
sngrepshows the call flow; select the INVITE and the 200 OK to compare offer and answer side by side. The SIP 403 guide walks through a capture step by step. - Chrome:
chrome://webrtc-internalsshows the local and remote description of every peer connection. Firefox:about:webrtc. - In code:
pc.localDescription.sdpandpc.remoteDescription.sdpin the browser console.
Then compare your offer and answer with the SDP examples above, rule by rule, in order. In practice, almost every SDP failure breaks one of them.
Frequently asked questions about SDP examples
What is an SDP offer and answer?
The offer is the SDP one side sends to propose media: streams, codecs, addresses and security. The answer, in turn, is the reply listing what the other side accepts from that offer. For instance, in SIP the offer is usually in the INVITE and the answer in the 200 OK. The rules are defined in RFC 3264.
Why does a WebRTC SDP show port 9 and 0.0.0.0?
In short, they are placeholders. A browser sends its real addresses as ICE candidates, either inside the SDP as a=candidate: lines or separately as they are gathered. The m= port and c= address are not used for media.
Why does Opus show as 48000/2 when the call is mono?
RFC 7587 requires the Opus rtpmap to always read opus/48000/2, whatever the actual sampling rate or channel count. Instead, the real stereo and bandwidth settings go in the a=fmtp line.
What causes a 488 Not Acceptable Here?
In almost every case, it is an SDP mismatch: no codec in common, or a media profile the other side does not support, such as a WebRTC offer reaching an endpoint without WebRTC enabled. For every other code, see the SIP response codes lookup.
Where can I find more SDP examples?
The quickest source is your own system: turn on pjsip set logger on or open chrome://webrtc-internals during a test call. For the formal definitions, RFC 4317 collects official SDP offer/answer examples, and RFC 9429 shows the SDP that browsers generate.