The SIP SDP protocol is the combination of SIP, the signaling protocol that establishes, modifies, and terminates calls, and SDP, the session description format carried inside SIP messages that negotiates media parameters like codecs, ports, and transport. Together they let two endpoints agree on how to reach each other and how to exchange audio or video. If you are building or debugging VoIP, understanding how the SDP offer and answer travel inside SIP messages is essential, and platforms like VideoSDK handle this negotiation for you when bridging SIP telephony into WebRTC rooms (VideoSDK telephony docs).
Imagine you are a developer at a contact center company, and your task this sprint is to connect a customer's desk phone on a legacy PBX to your company's browser-based support agent interface. The desk phone speaks traditional telephony. The browser speaks WebRTC. Somewhere in the middle, a call has to be set up, the two sides have to agree on which audio codec to use, which network ports to send media to, and how to traverse whatever firewalls sit in between. That entire handshake, the signaling and the media negotiation, is the job of the SIP SDP protocol.
SIP and SDP are inseparable in practice. SIP is the envelope that carries call control messages between endpoints, and SDP is the payload that describes what the call actually contains. Skip either one and the call either never connects or connects with no media flowing. This guide walks through how they work together, where developers commonly get burned, and how to debug the whole exchange.
What Is the SIP SDP Protocol?
The SIP SDP protocol is defined as the pairing of the Session Initiation Protocol, a text-based signaling protocol specified by the IETF, with the Session Description Protocol, a structured format for describing multimedia sessions. SIP handles the "who, where, and when" of a call: it registers users, locates endpoints, and exchanges requests and responses. SDP handles the "what": which audio and video codecs will be used, which transport protocol carries the media, and which IP address and port each side will send and receive on.
SIP works by exchanging requests and responses between user agents, which are the endpoints (a softphone, a PBX, a media server, or a gateway). Each request, such as an INVITE to start a call or a BYE to end it, triggers a response, such as a 200 OK confirming success. A transaction is one request plus all responses to it, and a dialog is the sustained peer-to-peer relationship between two endpoints for the duration of a call.
SDP works by describing a session as a series of typed lines: a version line, an origin line identifying the session, a session name, timing information, and one or more media lines each describing an audio or video stream. Attribute lines add details like which codec is preferred or which encryption key to use. SDP itself never transports media; it is purely a description that both sides read and agree on.
They are always used together because SIP has no native way to describe media. SIP can tell the far end "I want to talk to you," but only the SDP body inside the SIP message can say "I will send audio, encoded as Opus, to this address and port." Every call setup in a SIP network therefore involves SIP messages whose bodies carry SDP offers and answers.
SIP Overview
SIP is a text-based application-layer protocol modeled loosely on HTTP. A SIP request contains a method (INVITE, ACK, REGISTER, BYE, CANCEL, UPDATE), a request URI identifying the target, headers for routing and identity, and optionally a message body. Responses carry numeric status codes: provisional responses in the 1xx range indicate progress (180 Ringing is the classic example), and final responses in the 2xx through 6xx ranges indicate outcomes, with 200 OK signaling success.
SIP deployments typically route requests through proxy servers, which resolve addresses, apply routing rules, and forward messages, without usually touching the media itself. This separation of signaling from media is the defining architectural trait of SIP, and it is exactly why SDP exists as a separate description: the proxies route the envelope, while the endpoints read the payload and send media directly to each other.
SDP Overview
SDP follows a strict offer/answer model defined in RFC 3264. One side (usually the caller) sends an offer describing the media streams it wants to establish, listing the codecs it supports in order of preference. The other side sends back an answer, selecting from the offered codecs and supplying its own receive address and port. Neither side can invent new codecs in the answer; the answer must choose from what was offered.
An SDP body is built from short text lines, each beginning with a single letter and an equals sign. The media lines are the heart of the description: each one declares a media type (audio or video), a port, a transport protocol (typically RTP over UDP), and a list of supported codec identifiers. Attribute lines then refine each media line with details such as which codec was actually selected, direction of the stream, encryption keys, or ICE network candidates.
How SIP Uses SDP in Call Setup
A SIP call begins when the caller's user agent sends an INVITE request toward the callee, normally routed through one or more SIP proxies. The INVITE carries the first SDP offer in its message body. The offer lists every audio (and optionally video) codec the caller is willing to use, the IP address and port where the caller expects to receive media, and any transport-level details such as encryption or ICE candidates.
As the INVITE traverses the proxies, the proxies read only the SIP headers needed for routing; they generally leave the SDP body untouched. The callee's phone rings, and it sends back provisional responses (180 Ringing) followed by a final 200 OK. The 200 OK carries the SDP answer: the callee's chosen codec, its own IP address and port, and its own transport attributes. The caller then confirms receipt with an ACK, and at that point both sides know exactly where to send media and how to encode it. Real-time audio flows directly between the endpoints, bypassing the proxies entirely.
INVITE Request with SDP Offer
The SDP payload inside the INVITE exists to answer one question before the phone even rings: can these two endpoints actually exchange media? The offer declares the caller's capabilities, meaning the full set of codecs it can encode and decode, the network location where it will listen for incoming media, and any security or NAT-traversal parameters. By putting this in the initial INVITE, the call setup and the media negotiation happen in a single round trip, which keeps post-dial delay low.
200 OK Response with SDP Answer
The SDP answer in the 200 OK finalizes the deal. The callee picks exactly one codec from the offered list, supplies its own receiving IP address and port, and mirrors any required attributes such as encryption keys. Once the caller processes the answer, media can flow immediately. If the callee cannot support any offered codec, it rejects the session with an error response rather than sending an answer, which is why codec lists in offers are usually kept generous.
SDP Offer/Answer Model Details
The offer/answer model is the core of SIP SDP negotiation, and most real-world call failures trace back to a violation of its rules. An offer contains the session-level lines that apply to the whole session, followed by one or more media sections. The version line identifies the SDP format version. The origin line contains a username, a session identifier, a version number, a network type, an address type, and the offering party's address; the session identifier and version number together let the far end detect whether a subsequent message is a new offer or a retransmission. The session name is a human-readable label. The timing line declares when the session is active, and for on-demand calls it is typically set to mean "now, unbounded."
Each media line then opens a media section. It specifies the media type, the port, the transport protocol, and a list of payload format numbers, which are numeric identifiers for codecs. Attribute lines inside the media section map those payload numbers to named codecs (for example, mapping a payload number to Opus or to a specific sampling rate of PCM audio), declare directionality (sendrecv, sendonly, recvonly, or inactive), and carry extras like ICE candidates, DTLS fingerprints for encrypted transports, or telephone-event support for DTMF.
The answer must obey strict constraints: it must contain the same number of media lines as the offer, in the same order, and each answered stream must select a codec from the corresponding offered list. Streams the answerer does not want can be marked inactive or assigned a zero port, which politely declines that stream without breaking the structure. These structural rules matter because SIP proxies and gateways parse SDP bodies to make routing and transcoding decisions, and malformed structure causes silent failures.
Media Descriptions and Attributes
The media line is where codecs, ports, and transport meet. A typical audio media line declares the audio media type, a UDP port where that endpoint expects to receive RTP packets, the RTP/AVP or RTP/SAVP transport profile, and one or more payload numbers. Attribute lines then give each payload number a real meaning, naming the codec and its parameters. For video, the same structure applies, with additional attributes describing resolution, frame rate, and feedback mechanisms for packet loss. The transport declared in the media line determines whether media flows as plain RTP or as SRTP, the encrypted variant, and the attributes carry the keys or fingerprints that make the encryption work.
Modifying a Session
Calls are not static. Putting a call on hold, adding video mid-call, or changing the media path after a network handoff all require renegotiation. SIP supports this through a re-INVITE: a new INVITE sent within an existing dialog, carrying a fresh SDP offer that changes ports, codecs, or direction. The far end responds with a new answer, and media switches accordingly. Holding a call is classically implemented by sending a re-INVITE whose audio stream is marked sendonly or inactive.
The UPDATE method serves a similar purpose but can be sent before the initial call is even answered, which is useful for early media and for updating network information discovered late, such as ICE candidates that only resolve after signaling begins. In WebRTC-style SIP, endpoints also exchange additional connectivity information outside the offer/answer core, sending updated candidate information in follow-up SIP messages as the network probing progresses.
Common SIP SDP Pitfalls and How to Avoid Them
Most SIP SDP failures fall into four buckets: codec mismatches, missing connectivity candidates, wrong ports, and NAT traversal problems. Each produces a distinct symptom, and learning to recognize them from packet captures will save you hours.
A codec mismatch happens when the offer lists codecs the answerer cannot support. The call signaling completes, the phone rings, someone answers, and then there is silence because neither side can encode media the other will accept. The fix is to always offer a broad, standards-common baseline set of codecs alongside your preferred ones, and to log the negotiated codec at call establishment so mismatches are visible immediately.
Missing ICE candidates plague hybrid WebRTC and SIP deployments. WebRTC endpoints gather network candidates asynchronously, and if a SIP gateway forwards an SDP offer before candidate gathering finishes, the far end may receive an offer with no usable network path. The result is a call that connects but never carries media. Ensure your gateway either waits for gathering to complete or supports late candidate updates through additional SIP messages.
Incorrect port numbers usually come from misconfigured network address translation or from a media line advertising a port that a firewall blocks. Symptom: signaling succeeds, one direction of audio works, the other does not. Always verify that advertised ports match what the media gateway actually listens on, and prefer symmetric RTP, where each side sends back to wherever it received media from, to survive NAT rewriting.
Codec Mismatch
Both sides of a SIP SDP negotiation must converge on at least one common codec per media stream. If the offer includes only a modern wideband codec and the answerer only supports narrowband telephony audio, the answerer has nothing legal to select. Include a universally supported fallback codec in every offer, and monitor negotiation results so you catch one-sided configurations before customers do.
ICE and NAT
ICE, the Interactive Connectivity Establishment framework, solves the problem that the address in an SDP media line is often wrong once NAT is involved. Endpoints embed multiple candidate addresses in SDP attributes: the local address, mapped external addresses discovered via STUN, and relay addresses provisioned via TURN. Both sides then probe all candidate pairs and use the first that works. For WebRTC-to-SIP interop, your gateway must translate these candidates into a form the SIP side can act on, or media will fail even though signaling succeeds.
SDP Attribute Errors
Malformed attribute lines are the silent killers. Common mistakes include referencing a payload number in an attribute that was never declared in the media line, duplicating session-level attributes inside a media section where they conflict, and sending direction attributes that contradict each other between offer and answer. Because many parsers are lenient, these errors often do not fail loudly; they produce degraded or one-way media. Validate every SDP body your system generates against the specification before release, not just in the lab but in automated tests.
SIP Call Flow with SDP
The following diagram shows the complete SIP SDP exchange for a basic call routed through a proxy, with the offer and answer highlighted at the moments they appear:

Notice the final step: media never touches the proxy. The proxy's job ends the moment the dialog is confirmed, which is why SIP networks scale well for signaling while media capacity is managed separately.
Security Considerations for SIP SDP
Unsecured SIP SDP is vulnerable on two fronts: the signaling path and the media path. On the signaling side, plain SIP over UDP or TCP can be read, modified, or replayed by anyone on the network path. Transporting SIP over TLS encrypts the entire message, including the SDP body, protecting the negotiated addresses, ports, and keys from eavesdropping and from man-in-the-middle attacks that redirect media to an attacker's recorder.
On the media side, plain RTP has no confidentiality at all; anyone who learns the negotiated port can capture the audio. SRTP encrypts the media stream, and the keys are exchanged inside SDP attributes, either through a key exchange in the signaling or, in WebRTC-style deployments, via a DTLS fingerprint declared in SDP and verified during a DTLS handshake before any media flows. The fingerprint mechanism is important: it binds the encryption identity to the signaling, so an attacker who tries to substitute their own key mid-negotiation produces a fingerprint mismatch and the call fails closed rather than silently downgrading.
For production systems, the baseline posture is SIP over TLS for signaling, SRTP for media, verified key fingerprints, and strict validation of SDP bodies so malformed or injected attributes cannot manipulate the media path. When bridging traditional SIP trunks into modern WebRTC rooms, platforms like VideoSDK handle this secure negotiation end to end, terminating SIP on the telephony side and WebRTC with its native encryption on the room side (VideoSDK SIP integration overview).
Testing and Debugging SIP SDP
The single most valuable debugging skill for SIP SDP work is reading packet captures. Wireshark is the standard tool: it dissects SIP messages into readable form and decodes the SDP body into labeled fields, so you can see the offered codecs, the answered codec, the advertised addresses, and the actual RTP stream addresses side by side. The most common diagnostic is a mismatch between the address in the SDP and the actual source of the RTP packets, which immediately reveals NAT rewriting or a misconfigured gateway.
Most SIP servers and PBXs also offer built-in message tracing, which logs every SIP request and response with full bodies. This is often faster than packet capture for pure signaling questions, such as whether an INVITE carried an offer at all, or whether a re-INVITE was answered correctly. For SDP itself, use a specification-based SDP validator in your test suite to catch structural errors before they reach production, and write automated tests that exercise the full offer/answer cycle, including hold, resume, and codec renegotiation paths.
What to look for in every capture: the offer present in the initial INVITE, the answer present in the final response, the selected codec matching on both sides, the media port actually receiving packets, and the direction attributes matching the observed media flow. If signaling completes and media does not, the answer is almost always in the difference between what SDP promised and what the network delivered.
Best Practices Checklist
- Transport SIP signaling over TLS in every production environment.
- Use SRTP for media and verify key fingerprints during negotiation.
- Offer a broad codec list with a universally supported fallback codec.
- Support ICE with STUN and TURN for NAT traversal, and wait for candidate gathering before finalizing offers.
- Validate every SDP body your system generates against the specification, in automated tests.
- Prefer symmetric RTP so media returns to its actual source address.
- Log the negotiated codec, ports, and direction at call establishment for faster incident diagnosis.
- Exercise renegotiation paths (hold, resume, add video) in testing, not just initial setup.
- Monitor SIP message traces continuously so malformed offers are caught before users report silence.
Definitions Glossary
SIP (Session Initiation Protocol): A text-based signaling protocol that establishes, modifies, and terminates communication sessions, carrying call control messages between endpoints and proxies.
SDP (Session Description Protocol): A structured text format that describes the media of a session, including codecs, ports, transport protocols, and addresses, exchanged inside SIP message bodies.
Offer/Answer Model: The negotiation rules, defined in RFC 3264, where one side proposes media capabilities and the other selects from them, producing the final media configuration.
ICE (Interactive Connectivity Establishment): A framework that embeds multiple candidate network addresses in SDP and probes them in pairs to find a working media path through NAT and firewalls.
SRTP (Secure Real-time Transport Protocol): The encrypted variant of RTP that protects media streams, with keys negotiated through SDP attributes or DTLS fingerprints.
Re-INVITE: A new INVITE request sent within an existing SIP dialog to renegotiate media parameters such as codecs, ports, or stream direction.
Key Takeaways
- SIP handles signaling while SDP describes media, and every SIP call setup depends on the SDP offer and answer traveling inside SIP messages.
- The offer/answer model is strict: the answer must select from offered codecs and mirror the offered media structure, and most call failures trace back to violations of these rules.
- Media flows directly between endpoints after negotiation, bypassing SIP proxies, which is why NAT traversal and correct port advertisement matter so much.
- Security requires both layers: TLS for SIP signaling and SRTP with verified fingerprints for media.
- Packet capture analysis with Wireshark, comparing what SDP promised against what the network delivered, is the fastest path to diagnosing silent call failures.
- For teams bridging SIP telephony into WebRTC applications, VideoSDK's telephony integration handles the SIP SDP negotiation and secure media bridging end to end (VideoSDK telephony introduction).
Conclusion
Mastering the SIP SDP protocol means understanding one handshake from two angles: SIP moves the messages, and SDP makes the deal on media. Once you can read an INVITE's offer, a 200 OK's answer, and a packet capture's actual media flow, the majority of VoIP bugs become mechanical to diagnose. Codec mismatches, missing ICE candidates, and NAT-rewritten addresses stop being mysteries and become checklist items. If you are building modern applications that need to bridge traditional telephony into real-time WebRTC experiences, explore VideoSDK's SIP and telephony integration, which manages the SIP SDP negotiation, secure media bridging, and call routing for you. You can start free at app.videosdk.live/login. What are you building with SIP and SDP? Drop a comment, I'd love to hear what kind of VoIP or telephony integration you are working on.
Free $20 Balance for AI Voice Agents & Video Calls
FAQ
