Skip to content
SIP Mastery

Part 5 · Media / Module 15

SDP and offer/answer

How two phones agree on media — the SDP body line by line, the m= line, static and dynamic payload types, rtpmap and fmtp, direction attributes and hold, telephone-event for DTMF, and the offer/answer rules of RFC 3264, from the early and late offer to re-INVITE, PRACK, and UPDATE.

IntermediateAdvancedNOC coreDEV core

After this module, you can

  • Read an SDP body and say what each line means, at the session level and in each media section.
  • Explain static and dynamic payload types, and what rtpmap and fmtp add.
  • Build the answer to an offer: the same m= lines in the same order, port 0 to reject, and codecs from the offer.
  • Predict which codec each side sends, and with which payload type number.
  • Put a call on hold and resume it with direction attributes, and say why the o= version must go up.
  • Say where the offer and the answer go: INVITE and 200 OK, 200 OK and ACK, reliable 183 and PRACK, UPDATE.
On this page13 sections
  1. 15.1What SDP does: it describes media, it does not carry it
  2. 15.2Each line: v=, o=, s=, c=, t=, m=, a=, b=
  3. 15.3The m= line: media, port, profile, payload types
  4. 15.4Payload types: static and dynamic; rtpmap and fmtp
  5. 15.5Direction: sendrecv, sendonly, recvonly, inactive; hold and resume
  6. 15.6Other attributes: ptime, maxptime, rtcp, rtcp-mux, mid, group:BUNDLE
  7. 15.7DTMF with telephone-event
  8. 15.8Offer/answer rules
  9. 15.9Where the offer goes: early offer or late offer
  10. 15.10New offers: increment the o= version
  11. 15.11SDP in 183, with PRACK or UPDATE
  12. Common mistakes
  13. Summary

15.1 What SDP does: it describes media, it does not carry it

SIP sets up the call. It does not say where the audio goes, or how it is coded. That is the job of the body: a short text in the Session Description Protocol, SDPSDP. The body format that describes media sessions.. The audio itself travels in RTPRTP. The protocol that carries audio and video. packets, directly between the phones (Module 16).

Protocol Job Example
SIP Sets up, changes, and ends the call INVITE, 200 OK, BYE
SDP Describes the media: address, port, codecs, direction c=IN IP4 192.0.2.10, m=audio 49170 RTP/AVP 0
RTP Carries the media 50 packets per second, 160 bytes of audio each

SDP is a body in a SIP message, with Content-Type: application/sdp. One side sends an offeroffer. The SDP that one side sends first, listing the media it wants and the codecs it can use.: “send my audio here, with one of these codecs”. The other side sends an answeranswer. The SDP sent back for an offer. It accepts or rejects each stream and picks codecs from the offer.: “agreed, and send mine here, with these”. Each side says where it wants to receive:

RFC 3264 §5.1 · Unicast Streams
“For recvonly and sendrecv streams, the port number and address in the offer indicate where the offerer would like to receive the media stream.”
Read the section ↗

Here is Alice’s offer. Each line is one letter, =, and a value:

v=0
o=alice 2890844526 2890844526 IN IP4 192.0.2.10
s=-
c=IN IP4 192.0.2.10
t=0 0
m=audio 49170 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

It says: “I am alice on 192.0.2.10. Send my audio to 192.0.2.10, port 49170, as RTP. I can use PCMU, PCMA, or keypad events, and I prefer PCMU.”

15.2 Each line: v=, o=, s=, c=, t=, m=, a=, b=

An SDP body has a session level, then zero or more media sections. Each media descriptionmedia description. One stream in SDP. It starts with an m= line that gives the media type, port, transport, and formats. starts with an m= line. A c= or a= line at the session level applies to every stream that does not have its own.

RFC 8866 §5 · SDP Specification
“An SDP description consists of a session-level section followed by zero or more media descriptions.”
Read the section ↗
Line Name Example Meaning
v= Version v=0 Always 0
o= Origin o=alice 2890844526 2890844527 IN IP4 192.0.2.10 Who created the SDP: username, session ID, version, address
s= Session name s=- Not used by SIP. It must not be empty, so it is -
c= Connection c=IN IP4 192.0.2.10 The address that receives the media
t= Timing t=0 0 No fixed start or end: SIP starts and ends the session
m= Media m=audio 49170 RTP/AVP 0 8 One stream: type, port, transport, formats
a= Attribute a=rtpmap:0 PCMU/8000, a=sendonly Everything else
b= Bandwidth b=AS:64 The bandwidth the receiver wants, in kbit/s

The order is fixed, and a receiver may reject an SDP with lines out of order or with a type letter it does not know:

RFC 8866 §5 · SDP Specification
“Some lines in each description are required and some are optional, but when present, they must appear in exactly the order given here.”
Read the section ↗
RFC 8866 §5 · SDP Specification
“The set of type letters is deliberately small and not intended to be extensible -- an SDP parser MUST completely ignore or reject any session description that contains a type letter that it does not understand.”
Read the section ↗

c= can be at the session level, in each media section, or both. One of the two is required:

RFC 8866 §5.7 · Connection Information ("c=")
“A session description MUST contain either at least one "c=" line in each media description or a single "c=" line at the session level.”
Read the section ↗

The o= line names the session and its version. The username, session ID, and address stay the same for the whole call. The version goes up by one each time this side changes its SDP (15.10).

RFC 8866 §5.2 · Origin ("o=")
“In general, the "o=" line serves as a globally unique identifier for this version of the session description, and the subfields excepting the version, taken together identify the session irrespective of any modifications.”
Read the section ↗

Paste any SDP into the linter, or pick an example. Select a line to see what it means and which rule it follows:

SDP linter · RFC 8866, RFC 3264

What does each line say, and what is wrong?

  • SDP
  • ⚠Problem

Valid SDP1 stream

Select a line to see the rule behind it.

15.3 The m= line: media, port, profile, payload types

m=audio 49170 RTP/AVP 0 8 101
  │     │     │       └── formats: payload types, most preferred first
  │     │     └── transport and profile
  │     └── port: where this side receives RTP
  └── media type
Field Values Notes
Media audio, video, text, application, image image is T.38 fax
Port 1 to 65535, or 0 Port 0: the stream is rejected or removed. RTCP goes to port + 1, unless a=rtcp or a=rtcp-mux says otherwise
Transport RTP/AVP Plain RTP
RTP/SAVP SRTP: encrypted RTP (Module 18)
RTP/SAVPF, UDP/TLS/RTP/SAVPF SRTP with feedback; DTLS-SRTP (WebRTC, Module 26)
Formats 0 8 101 RTP payload type numbers, in order of preference
RFC 8866 §5.14 · Media Descriptions ("m=")
“When a list of payload type numbers is given, this implies that all of these payload formats MAY be used in the session, and these payload formats are listed in order of preference, with the first format listed being preferred.”
Read the section ↗

The order matters. The answerer should pick the first format in the offer that it can use, and the offerer sends the first format in the answer.

15.4 Payload types: static and dynamic; rtpmap and fmtp

Each RTP packet carries a 7-bit payload typepayload type. The number in each RTP packet that says which codec the packet uses. 0 to 95 are static; 96 to 127 are dynamic. number: which codec is in this packet. Some numbers have a fixed meaning in the RTP audio/video profile (RFC 3551). Those are static payload types:

Payload type Codec Clock rate Notes
0 PCMU 8000 G.711 μ-law, 64 kbit/s. North America and Japan
8 PCMA 8000 G.711 A-law, 64 kbit/s. Most other countries
9 G722 8000 Wideband, 64 kbit/s. Its clock rate is 8000 although it samples at 16 kHz
18 G729 8000 8 kbit/s. Often with a=fmtp:18 annexb=no
13 CN 8000 Comfort noise
96–127 Dynamic Any Their meaning comes only from a=rtpmap in the SDP
RFC 3551 §4.5.2 · G722
“Even though the actual sampling rate for G.722 audio is 16,000 Hz, the RTP clock rate for the G722 payload format is 8,000 Hz because that value was erroneously assigned in RFC 1890 and must remain unchanged for backward compatibility.”
Read the section ↗

Newer codecs have no static number. Opus, AMR-WB, EVS, H.264, and telephone-event always use a dynamic number, and a=rtpmap says what it means in this SDP:

RFC 3551 §3 · Registering Additional Encodings
“This profile reserves payload type numbers in the range 96-127 exclusively for dynamic assignment.”
Read the section ↗
a=rtpmap:<payload type> <encoding>/<clock rate>[/<channels>]
a=rtpmap:111 opus/48000/2         Opus. Always 48000/2, whatever the real rate
a=rtpmap:101 telephone-event/8000 DTMF events (15.7)
a=rtpmap:96 H264/90000            Video always uses a 90 kHz clock
RFC 8866 §6.6 · rtpmap
“This attribute maps from an RTP payload type number (as used in an "m=" line) to an encoding name denoting the payload format to be used.”
Read the section ↗

A dynamic number with no a=rtpmap means nothing: the receiver cannot decode it. Static numbers do not need a=rtpmap, but most phones send it anyway, and an answer should:

RFC 3264 §6.1 · Unicast Streams
“Even if the same payload type number is used, the answer MUST contain rtpmap attributes to define the payload type mappings for dynamic payload types, and SHOULD contain mappings for static payload types.”
Read the section ↗

a=fmtp carries settings for one format. SDP does not read them; only the codec does:

a=fmtp:111 minptime=10;useinbandfec=1                         Opus: 10 ms packets at least, forward error correction
a=fmtp:18 annexb=no                                           G.729 without silence suppression
a=fmtp:96 profile-level-id=42e01f;packetization-mode=1        H.264 profile and level
a=fmtp:101 0-16                                               telephone-event: the events this side can receive
RFC 8866 §6.15 · fmtp (Format Parameters)
“This attribute allows parameters that are specific to a particular format to be conveyed in a way that SDP does not have to understand them.”
Read the section ↗

15.5 Direction: sendrecv, sendonly, recvonly, inactive; hold and resume

Each stream has a direction, from the point of view of the side that writes the SDP. Without a direction attribute, it is sendrecv.

Offer This side… The answer must be Typical use
a=sendrecv (or none) Sends and receives Any of the four A normal call
a=sendonly Sends, wants nothing back recvonly or inactive Hold, with music on hold
a=recvonly Receives, sends nothing sendonly or inactive Answer to a hold; a listen-only device
a=inactive Neither inactive Hold with no music; both sides on hold
RFC 3264 §6.1 · Unicast Streams
“If a stream is offered as sendonly, the corresponding stream MUST be marked as recvonly or inactive in the answer. If a media stream is listed as recvonly in the offer, the answer MUST be marked as sendonly or inactive in the answer.”
Read the section ↗

holdhold. Stopping the media from the other side with a new offer, usually a=sendonly or a=inactive. is a new offer. Alice’s phone sends a re-INVITE (or an UPDATE) with a=sendonly, and Bob’s phone answers a=recvonly. Bob’s audio stops; Alice’s phone may send music on hold. To resume, Alice offers a=sendrecv again.

RFC 3264 §8.4 · Putting a Unicast Media Stream on Hold
“If the stream to be placed on hold was previously a sendrecv media stream, it is placed on hold by marking it as sendonly. If the stream to be placed on hold was previously a recvonly media stream, it is placed on hold by marking it inactive.”
Read the section ↗

Call flow · hold and resume

Hold and resume with re-INVITE

  • SIP
  • RTP media
Alice192.0.2.10Bob203.0.113.2001INVITE (offer)02200 OK (answer)03ACK04RTP audio05INVITE (hold)06200 OK (recvonly)07ACK08RTP music on hold09INVITE (resume)10200 OK (sendrecv)11ACK12RTP audio
01/12

Alice calls Bob. Her offer is sendrecv, version 2890844526.

All steps as text
  1. Alice → Bob: INVITE (offer). Alice calls Bob. Her offer is sendrecv, version 2890844526.
  2. Bob → Alice: 200 OK (answer). Bob answers, sendrecv too.
  3. Alice → Bob: ACK. The call is up.
  4. Alice → Bob: RTP audio. Audio flows both ways.
  5. Alice → Bob: INVITE (hold). Alice presses Hold. Her re-INVITE offers a=sendonly, with the next o= version: 2890844527.
  6. Bob → Alice: 200 OK (recvonly). Bob must answer recvonly or inactive. His SDP changed, so his version goes up too.
  7. Alice → Bob: ACK. The re-INVITE is complete. The dialog has not changed; only the media has.
  8. Alice → Bob: RTP music on hold. Bob's phone stops sending. Alice's phone may send music on hold.
  9. Alice → Bob: INVITE (resume). Alice presses Resume. She offers sendrecv again, version 2890844528.
  10. Bob → Alice: 200 OK (sendrecv). Bob answers sendrecv, with his next version.
  11. Alice → Bob: ACK. The call is back to normal.
  12. Alice → Bob: RTP audio. Audio flows both ways again.

Each side holds by itself. If Bob holds too while Alice holds him, the only answer Alice can give to Bob’s sendonly is inactive: no media either way. When Alice resumes, Bob is still holding, so Bob answers sendonly. Each side leaves hold with its own offer. Try it:

Hold player · RFC 3264 §8.4

Press Hold on either phone

  • re-INVITE
  • SDP
  • RTP
Alice
Bob
Alicea=sendrecvversion …526not holdingBoba=sendrecvversion …564not holdingAlice's voiceBob's voice

The call is up: sendrecv both ways. Press Hold on Alice's phone.

    RFC 6337 §5.3 · Hold and Resume of Media
    “If it had not previously initiated "hold", then it should offer "a=sendrecv" attribute, even if it had previously been forced to answer something else. Without this behavior it is possible to get "stuck on hold" in some cases, especially when a 3pcc is involved.”
    Read the section ↗

    Old phones put a call on hold with c=IN IP4 0.0.0.0. RFC 3264 replaced this with the direction attributes, but a receiver must still understand it:

    RFC 3264 §8.4 · Putting a Unicast Media Stream on Hold
    “Its usage for putting a call on hold is no longer recommended, since it doesn't allow for RTCP to be used with held streams, doesn't work with IPv6, and breaks with connection oriented media.”
    Read the section ↗

    RTCP still flows on a held stream. A phone that sees no RTP but still gets RTCP knows the other side is alive (Module 17).

    15.6 Other attributes: ptime, maxptime, rtcp, rtcp-mux, mid, group:BUNDLE

    Attribute Example Meaning
    ptime a=ptime:20 This side wants to receive 20 ms of audio in each packet. 20 ms is the usual value
    maxptime a=maxptime:40 At most 40 ms of audio in one packet
    rtcp a=rtcp:53020 Send RTCP to this port, not to the RTP port + 1. NAT often makes it needed
    rtcp-mux a=rtcp-mux RTP and RTCP share one port. Used only if both sides include it
    mid a=mid:audio A name for the stream, used by groups such as BUNDLE
    group:BUNDLE a=group:BUNDLE audio video Several streams share one address and port. WebRTC uses it (Module 26)
    RFC 8866 §6.4 · ptime (Packet Time)
    “This gives the length of time in milliseconds represented by the media in a packet.”
    Read the section ↗
    RFC 5761 §5.1.1 · SDP Signalling
    “If the answer does not contain an "a=rtcp-mux" attribute, the offerer MUST NOT multiplex RTP and RTCP packets on a single port.”
    Read the section ↗
    RFC 9143 §5 · SDP Grouping Framework BUNDLE Extension
    “Within a BUNDLE group, each "m=" section uses a BUNDLE transport for sending and receiving bundled media. Each endpoint uses a single address:port combination for sending and receiving the bundled media.”
    Read the section ↗

    Each side may ask for a different ptime: each one says how the other side should send to it. So ptime is not negotiated; it is a request.

    15.7 DTMF with telephone-event

    When a caller presses 1 for sales, the IVR must get the digit. Low-rate codecs such as G.729 cannot carry keypad tones well enough for a machine to recognise them, so DTMFDTMF. The tones of the telephone keypad. In VoIP they usually travel as RTP telephone-event packets (RFC 4733). usually travels as separate RTP packets: telephone-event (RFC 4733).

    RFC 4733 §1.2 · Overview
    “Separate RTP payload formats for telephony tone signals are desirable since low-rate voice codecs cannot be guaranteed to reproduce these tone signals accurately enough for automatic recognition.”
    Read the section ↗
    m=audio 49170 RTP/AVP 0 8 101
    a=rtpmap:101 telephone-event/8000
    a=fmtp:101 0-16
    • The number is dynamic: 101 is common, but 96, 100, and others are also used.
    • The clock rate usually follows the voice codec: telephone-event/8000 with G.711, telephone-event/48000 with Opus.
    • a=fmtp:101 0-16 lists the events this side can receive: 0–9, * (10), # (11), A–D (12–15), and flash (16).
    RFC 4733 §2.5.1.1 · Negotiation of Payloads
    “For backward compatibility, if no "events" parameter is received, the sender SHOULD assume support for the DTMF events 0-15 but for no other events.”
    Read the section ↗

    If the answer has no telephone-event, there are two other ways: the tones inside the audio (works only with G.711), or SIP INFO messages. Module 16 compares the three.

    15.8 Offer/answer rules

    RFC 3264 defines how an answer is built from an offer. The rules are strict, because the two sides match streams by position:

    Rule Why
    The answer has exactly the same number of m= lines, in the same order, with the same media types Streams are matched by position, not by name
    To reject a stream, set its port to 0. Never remove the m= line Removing it moves every stream after it
    An accepted stream has at least one codec from the offer Otherwise the offerer cannot send anything the answerer understands
    No codec in common: reject the stream with port 0 No codec in common for any stream: reject the call with 488
    Keep the payload type numbers of the offer (SHOULD) Each side still sends with the number the other side wrote
    Keep the order of the offer (RECOMMENDED) Then both sides send the same codec
    The answer has its own o= line, c=, and ports It describes where the answerer receives
    RFC 3264 §6 · Generating the Answer
    “The answer MUST contain exactly the same number of "m=" lines as the offer. This allows for streams to be matched up based on their order.”
    Read the section ↗
    RFC 3264 §6 · Generating the Answer
    “To reject an offered stream, the port number in the corresponding stream in the answer MUST be set to zero.”
    Read the section ↗
    RFC 3264 §6.1 · Unicast Streams
    “For streams marked as sendrecv in the answer, the "m=" line MUST contain at least one codec the answerer is willing to both send and receive, from amongst those listed in the offer.”
    Read the section ↗

    Who sends which codec? The offerer sends the first codec in the answer. The answerer sends the most preferred codec of the offer that is also in its answer, with the number from the offer:

    RFC 3264 §7 · Offerer Processing of the Answer
    “It MUST send using a media format listed in the answer, and it SHOULD use the first media format listed in the answer when it does send.”
    Read the section ↗
    RFC 3264 §6.1 · Unicast Streams
    “The answerer MUST send using a media format in the offer that is also listed in the answer, and SHOULD send using the most preferred media format in the offer that is also listed in the answer. In the case of RTP, it MUST use the payload type numbers from the offer, even if they differ from those in the answer.”
    Read the section ↗

    Build an offer, change what Bob’s phone can do, and see the answer. Try Bob’s order and Own payload numbers: both are allowed, and both surprise people.

    Offer/answer negotiator · RFC 3264

    What do Alice and Bob agree on?

    • SDP
    • RTP
    • Rejected

    Alice's offer most preferred first

    Bob's phone what it can do

    Offer · INVITE from Alice

    v=0
    o=alice 2890844526 2890844526 IN IP4 192.0.2.10
    s=-
    c=IN IP4 192.0.2.10
    t=0 0
    m=audio 49170 RTP/AVP 111 9 0 8 101
    a=rtpmap:111 opus/48000/2
    a=fmtp:111 minptime=10;useinbandfec=1
    a=rtpmap:9 G722/8000
    a=rtpmap:0 PCMU/8000
    a=rtpmap:8 PCMA/8000
    a=rtpmap:101 telephone-event/8000
    a=fmtp:101 0-16
    a=ptime:20
    

    Answer · 200 OK from Bob

    v=0
    o=bob 2808844564 2808844564 IN IP4 203.0.113.20
    s=-
    c=IN IP4 203.0.113.20
    t=0 0
    m=audio 3456 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
    

    Audioaccepted · sendrecv → sendrecv

    AliceBobPCMU, payload type 0
    BobAlicePCMU, payload type 0

    Keypad digits: telephone-event (RFC 4733).

    • 2 codecs in common: PCMU, PCMA. Alice sends the first one in the answer.

      “It MUST send using a media format listed in the answer, and it SHOULD use the first media format listed in the answer when it does send.” RFC 3264 §7 ↗

    • Bob sends the most preferred codec of the offer that is also in his answer: PCMU.

      “The answerer MUST send using a media format in the offer that is also listed in the answer, and SHOULD send using the most preferred media format in the offer that is also listed in the answer. In the case of RTP, it MUST use the payload type numbers from the offer, even if they differ from those in the answer.” RFC 3264 §6.1 ↗

    15.9 Where the offer goes: early offer or late offer

    SIP puts the offer and the answer in fixed places. With only RFC 3261, there are two patterns:

    Pattern Offer in Answer in Who uses it
    Early offer INVITE 200 OK (and the same SDP in 18x, if any) Most phones and trunks
    Late offer (delayed offer) 200 OK ACK Some PBXs, gateways, and B2BUAs; 3pcc (Module 22)
    Early offer, reliable 1xx INVITE Reliable 183 (100rel) Early media; mobile networks (15.11)
    Late offer, reliable 1xx Reliable 183 PRACK Rare
    In a dialog re-INVITE or UPDATE Its 2xx Hold, codec changes, new streams
    RFC 3261 §13.2.1 · Creating the Initial INVITE
    “Concretely, the above rules specify two exchanges for UAs compliant to this specification alone - the offer is in the INVITE, and the answer in the 2xx (and possibly in a 1xx as well, with the same value), or the offer is in the 2xx, and the answer is in the ACK.”
    Read the section ↗

    Call flow · early offer

    Early offer: the SDP offer in the INVITE

    • SIP
    • RTP media
    Alice192.0.2.10Bob203.0.113.2001INVITE (offer)02180 Ringing03200 OK (answer)04ACK05RTP audio (PCMU)
    01/05

    The offer lists four formats, most preferred first: PCMU, PCMA, G.722, and telephone-event.

    All steps as text
    1. Alice → Bob: INVITE (offer). The offer lists four formats, most preferred first: PCMU, PCMA, G.722, and telephone-event.
    2. Bob → Alice: 180 Ringing. Bob's phone rings. A 180 may carry the answer, but it does not have to.
    3. Bob → Alice: 200 OK (answer). Bob's phone has no G.722, so the answer drops it. The order of the offer stays.
    4. Alice → Bob: ACK. The ACK completes the INVITE. With an early offer, it carries no SDP.
    5. Alice → Bob: RTP audio (PCMU). Both phones send PCMU, the first codec in the answer, to the address and port in the other SDP.

    With a late offerlate offer. The INVITE has no SDP. The offer is in the 200 OK (or a reliable 1xx), and the answer is in the ACK (or PRACK)., the caller sends no SDP, and the callee must offer in the 200 OK. The caller cannot refuse the offer at that point: it must answer in the ACK, then hang up if it does not like the result.

    Call flow · late offer

    Late offer: the SDP offer in the 200 OK

    • SIP
    • RTP media
    Alice192.0.2.10Bob203.0.113.2001INVITE (no SDP)02180 Ringing03200 OK (offer)04ACK (answer)05RTP audio (PCMU)
    01/05

    The INVITE has no body. Gateways and B2BUAs do this when they do not know the media yet.

    All steps as text
    1. Alice → Bob: INVITE (no SDP). The INVITE has no body. Gateways and B2BUAs do this when they do not know the media yet.
    2. Bob → Alice: 180 Ringing. Bob's phone rings. No SDP yet.
    3. Bob → Alice: 200 OK (offer). Bob answers the call. Because the INVITE had no offer, Bob's 200 OK must carry one.
    4. Alice → Bob: ACK (answer). The ACK carries the answer: PCMU and telephone-event. Alice cannot reject the call here; she can only answer, then send BYE.
    5. Alice → Bob: RTP audio (PCMU). Media starts after the ACK. Bob could not send any before he knew where to send it.
    RFC 3261 §13.2.2.4 · 2xx Responses
    “If the 2xx contains an offer (based on the rules above), the ACK MUST carry an answer in its body. If the offer in the 2xx response is not acceptable, the UAC core MUST generate a valid answer in the ACK and then send a BYE immediately.”
    Read the section ↗

    Only one offer can be waiting at a time in a dialog. If both sides send a re-INVITE with an offer at the same time, that is glare: both get 491 Request Pending and try again after a random time (Module 9).

    RFC 6337 §2.2 · Offer/Answer Exchange Pairs in SIP Messages
    “There may be ONLY ONE offer/answer negotiation in progress for a single dialog at any point in time.”
    Read the section ↗

    15.10 New offers: increment the o= version

    Any new SDP from a side — a hold, a resume, a new codec list, a new address — keeps the same username, session ID, and address in o=, and increases the version by exactly one:

    RFC 3264 §8 · Modifying the Session
    “When issuing an offer that modifies the session, the "o=" line of the new SDP MUST be identical to that in the previous SDP, except that the version in the origin field MUST increment by one from the previous SDP.”
    Read the section ↗

    If the version does not change, the receiver may assume the SDP has not changed, and skip it:

    RFC 3264 §8 · Modifying the Session
    “If the version in the origin line does not increment, the SDP MUST be identical to the SDP with that version number. The answerer MUST be prepared to receive an offer that contains SDP with a version that has not changed; this is effectively a no-op.”
    Read the section ↗

    A re-INVITE that only refreshes the session (session timers, Module 9) repeats the same SDP with the same version. That is correct: nothing changed.

    Two more rules hold for the whole session:

    RFC 3264 §8 · Modifying the Session
    “Deleted media streams from a previous SDP MUST NOT be removed in a new SDP; however, attributes for these streams need not be present.”
    Read the section ↗
    RFC 3264 §8.3.2 · Changing the Set of Media Formats
    “However, in the case of RTP, the mapping from a particular dynamic payload type number to a particular codec within that media stream MUST NOT change for the duration of a session.”
    Read the section ↗

    If an offer is rejected (for example with 488 or 491), nothing changes: the session goes back to the state before that offer.

    RFC 3264 §4 · Protocol Operation
    “The offer/answer exchange is atomic; if the answer is rejected, the session reverts to the state prior to the offer (which may be absence of a session).”
    Read the section ↗

    15.11 SDP in 183, with PRACK or UPDATE

    A 183 Session Progress often carries SDP, so that the caller hears a ringback tone or an announcement from the far network: early mediaearly media. Audio sent before the call is answered, such as a ringback tone or an announcement from the far network.. A normal 1xx is not reliable: it can be lost, and it is never retransmitted. With 100rel (RFC 3262), the 183 is sent reliably, the caller acknowledges it with PRACK, and the SDP in it is the real answer:

    RFC 3262 §5 · The Offer/Answer Model and PRACK
    “If the INVITE contained an offer, the UAS MAY generate an answer in a reliable provisional response (assuming these are supported by the UAC).”
    Read the section ↗
    RFC 3262 §5 · The Offer/Answer Model and PRACK
    “Once an answer has been sent or received, the UA SHOULD establish the session based on the parameters of the offer and answer, even if the original INVITE itself has not been responded to.”
    Read the section ↗

    After the answer in a reliable 1xx, either side can send a new offer before the call is answered, with UPDATE (RFC 3311). A re-INVITE cannot be sent until the first INVITE has its final response.

    RFC 3311 §3 · Overview of Operation
    “Once a dialog is established, either early or confirmed, the caller can generate an UPDATE method that contains an SDP offer [3] for the purposes of updating the session. The response to the UPDATE method contains the answer.”
    Read the section ↗

    Call flow · 183, PRACK, and UPDATE

    SDP in a 183, then PRACK and UPDATE

    • SIP
    • RTP media
    Alice192.0.2.10Bob203.0.113.2001INVITE (offer)02183 Session Progress (answer)03PRACK04200 OK (PRACK)05RTP early media06UPDATE (new offer)07200 OK (answer)08200 OK (INVITE)09ACK10RTP audio (PCMU)
    01/10

    The offer lists PCMU, PCMA, and telephone-event. Supported: 100rel says Alice can acknowledge provisional responses.

    All steps as text
    1. Alice → Bob: INVITE (offer). The offer lists PCMU, PCMA, and telephone-event. Supported: 100rel says Alice can acknowledge provisional responses.
    2. Bob → Alice: 183 Session Progress (answer). The 183 carries the answer and Require: 100rel, so Alice must acknowledge it. Early media can start now.
    3. Alice → Bob: PRACK. Alice acknowledges the 183. RAck names its RSeq and the INVITE CSeq.
    4. Bob → Alice: 200 OK (PRACK). Bob confirms the PRACK. The session exists, although nobody has answered yet.
    5. Bob → Alice: RTP early media. Bob's network plays a ringback tone or an announcement. It flows to Alice only.
    6. Alice → Bob: UPDATE (new offer). The answer kept two codecs. Alice offers PCMU alone, and the o= version goes up by one.
    7. Bob → Alice: 200 OK (answer). Bob answers with PCMU alone. His o= version goes up too, because his SDP changed.
    8. Bob → Alice: 200 OK (INVITE). Bob answers the call. The 200 OK has no SDP: the offer and answer are already done.
    9. Alice → Bob: ACK. The ACK completes the INVITE.
    10. Alice → Bob: RTP audio (PCMU). Both sides now send PCMU.

    The 200 OK to the INVITE then has no SDP, or repeats the same answer. The caller uses the first answer it received:

    RFC 3261 §13.2.1 · Creating the Initial INVITE
    “The UAC MUST treat the first session description it receives as the answer, and MUST ignore any session descriptions in subsequent responses to the initial INVITE.”
    Read the section ↗

    Many networks still send SDP in an unreliable 183, without 100rel, and repeat the same SDP in the 200 OK. It usually works, but if the 183 is lost, the caller has no early media, and if the 200 OK has different SDP, phones disagree about which one counts.

    Common mistakes

    A private IP address in c=

    Alice’s phone is behind a home NAT router. It writes its own address in the SDP: c=IN IP4 192.168.1.20. The NAT router changes the IP header of the packet, but not the text of the SDP. Bob’s phone sends its audio to 192.168.1.20, which does not exist on the Internet. Alice’s audio reaches Bob, but Bob’s never reaches Alice: one-way audio. The SIP signaling works perfectly, so the call looks fine in every log.

    Broken

    Broken: a private address in c=

    • SIP
    • RTP media
    • ⚠Problem
    Alice192.168.1.20NAT router198.51.100.7Bob203.0.113.2001INVITE (offer)02INVITE (offer)03200 OK (answer)04200 OK (answer)05ACK06ACK07RTP Alice to Bob08✕RTP to 192.168.1.20⚠
    01/08

    Alice's phone puts its own address in c=: 192.168.1.20. It is a private address.

    All steps as text
    1. Alice → NAT router: INVITE (offer). Alice's phone puts its own address in c=: 192.168.1.20. It is a private address.
    2. NAT router → Bob: INVITE (offer). The NAT router changes the IP header, not the SDP. Bob receives c=IN IP4 192.168.1.20.
    3. Bob → NAT router: 200 OK (answer). Bob answers. His SDP has his public address, 203.0.113.20.
    4. NAT router → Alice: 200 OK (answer). The NAT router sends the 200 OK back to Alice through the NAT mapping.
    5. Alice → NAT router: ACK. Alice confirms the call.
    6. NAT router → Bob: ACK. Signaling works: the call is up.
    7. Alice → Bob: RTP Alice to Bob. Alice sends RTP to 203.0.113.20:3456. It crosses the NAT router and arrives.
    8. Bob → Alice: RTP to 192.168.1.20. Bob sends RTP to 192.168.1.20. That address is private, so the packets never arrive. Problem: One-way audio: Bob hears Alice, but Alice hears nothing.
    RFC 6314 §3 · Problem Statement
    “The problem arises when a client advertises its address to receive media and it exists in a private network that is not accessible from outside the NAT.”
    Read the section ↗

    Remember: the address in c= and the port in m= must be reachable from the other side. A phone learns its public address with STUN; an SBC can replace the SDP address with its own and relay the media; ICE tries several addresses (Module 20). The address in o= does not matter. Fixing the Contact but not the SDP gives a call that connects with no audio.

    The o= version is not incremented in a new offer

    Alice’s phone puts Bob on hold. Its re-INVITE has a=sendonly, but the o= version is the same as in the first offer. Bob’s phone sees an unchanged version, treats the offer as the SDP it already has, and answers sendrecv as before. Alice thinks the call is on hold; Bob’s phone keeps sending audio.

    Broken

    Broken: the hold offer keeps the old version

    • SIP
    • RTP media
    • ⚠Problem
    Alice192.0.2.10Bob203.0.113.2001INVITE (offer)02200 OK (answer)03ACK04RTP audio05INVITE (hold)06200 OK (sendrecv)07ACK08RTP audio⚠
    01/08

    Alice calls Bob. Her offer is sendrecv, version 2890844526.

    All steps as text
    1. Alice → Bob: INVITE (offer). Alice calls Bob. Her offer is sendrecv, version 2890844526.
    2. Bob → Alice: 200 OK (answer). Bob answers, sendrecv too.
    3. Alice → Bob: ACK. The call is up.
    4. Alice → Bob: RTP audio. Audio flows both ways.
    5. Alice → Bob: INVITE (hold). Alice offers a=sendonly, but the o= version is still 2890844526.
    6. Bob → Alice: 200 OK (sendrecv). Bob's phone sees the same version and treats the offer as the SDP it already has. It answers sendrecv, as before.
    7. Alice → Bob: ACK. Alice thinks the call is on hold. Bob does not.
    8. Alice → Bob: RTP audio. Bob still sends audio, and Alice may still hear him. Problem: The hold did nothing: the SDP changed, but its version did not.

    Remember: every SDP that differs from the last one this side sent needs the next version, plus one. Repeat the same version only with exactly the same SDP. Turn on Forget to increment o= version in the hold player above and press Hold.

    The answer has a different number or order of m= lines

    Alice’s video phone offers audio and video. Bob’s phone has no camera, so it answers with only the audio m= line. Alice matches streams by position: she cannot tell whether the one m= line answers her audio or her video. Most phones reject such an answer and end the call. The same happens when an answer puts video first and audio second.

    Broken

    Broken: the answer removes the video m= line

    • SIP
    • ⚠Problem
    Alice192.0.2.10Bob203.0.113.2001INVITE (audio, video)02200 OK (audio only)03ACK04BYE⚠05200 OK
    01/05

    Alice's video phone offers two streams: audio, then video.

    All steps as text
    1. Alice → Bob: INVITE (audio, video). Alice's video phone offers two streams: audio, then video.
    2. Bob → Alice: 200 OK (audio only). Bob's phone has no camera, so it removes the video m= line from the answer.
    3. Alice → Bob: ACK. Alice must ACK the 200 OK, but the answer does not match her offer.
    4. Alice → Bob: BYE. Alice's phone cannot match the streams, so it ends the call. Problem: The call fails, although both phones can do audio.
    5. Bob → Alice: 200 OK. The call ends after a second.
    RFC 3261 §13.2.2.4 · 2xx Responses
    “If, after acknowledging any 2xx response to an INVITE, the UAC does not want to continue with that dialog, then the UAC MUST terminate the dialog by sending a BYE request as described in Section 15.”
    Read the section ↗

    Remember: one m= line in the answer for each m= line in the offer, in the same order. Reject a stream with m=video 0 RTP/AVP 96: port 0 and one format. A new offer never removes an m= line either; it sets the port to 0, and may reuse that slot later.

    Assuming a dynamic payload type is the same on both sides

    Alice offers Opus as 111. Bob’s phone answers with its own number for Opus, 96. Both are correct. But a gateway that assumes “Opus is 111” sends Opus to Bob as 111, a number Bob’s phone did not define, and Bob hears nothing. Or a capture filter that looks for payload type 111 misses half the call.

    Offer (Alice):   m=audio 49170 RTP/AVP 111 101      a=rtpmap:111 opus/48000/2
    Answer (Bob):    m=audio 3456 RTP/AVP 96 100        a=rtpmap:96 opus/48000/2
    Alice → Bob:     RTP payload type 96     the number from the answer
    Bob → Alice:     RTP payload type 111    the number from the offer
    RFC 3264 §5.1 · Unicast Streams
    “However, for sendonly and sendrecv streams, the answer might indicate different payload type numbers for the same codecs, in which case, the offerer MUST send with the payload type numbers from the answer.”
    Read the section ↗

    Remember: a dynamic number means something only in the SDP that defines it. Each side sends with the number the other side wrote. Read the a=rtpmap lines of the received SDP; never hard-code 101 for DTMF or 111 for Opus. Try Different payload numbers in the negotiator above.

    No telephone-event, so DTMF fails

    The caller presses 1 for sales, and nothing happens. The offer had telephone-event, but the answer did not: the far side cannot receive RTP events, so the digits are dropped. Or the offer had none, the codec is G.729, and the tones inside the audio are too damaged for the IVR to recognise.

    m=audio 49170 RTP/AVP 18 101          G.729 and telephone-event: digits as RTP events
    a=rtpmap:18 G729/8000
    a=rtpmap:101 telephone-event/8000
    a=fmtp:101 0-16
    
    m=audio 49170 RTP/AVP 18              no telephone-event: digits only inside G.729 audio

    Remember: offer and accept telephone-event on every audio stream, usually with the clock rate of the voice codec. If a far side does not support it, agree on one other method — G.711 with in-band tones, or SIP INFO — and configure it on both sides (Module 16). Try No DTMF in the negotiator above.

    Summary

    • SDP describes the media: the address and port where each side receives, the codecs, and the direction. RTP carries the media.
    • An SDP body is a session level, then one media section per m= line. The lines have a fixed order. c= is at the session level or in every stream.
    • m=audio 49170 RTP/AVP 0 8 101 lists payload types in order of preference. 0–95 are static; 96–127 are dynamic and mean something only with their a=rtpmap. a=fmtp adds codec settings.
    • Directions: sendrecv, sendonly, recvonly, inactive. Hold is a new offer with sendonly (or inactive); each side holds and resumes by itself.
    • DTMF travels as telephone-event RTP packets, if both sides list it.
    • The answer has the same m= lines in the same order; it rejects a stream with port 0 and keeps at least one codec from the offer. Each side sends with the payload numbers the other side wrote.
    • Early offer: INVITE and 200 OK. Late offer: 200 OK and ACK. A reliable 183 can carry the answer, acknowledged with PRACK; UPDATE changes the session before the call is answered.
    • Every changed SDP has the next o= version. Same version means same SDP.