Inside a SIP Packet: Decoding SDP
Have you ever wondered how your phone or a video conferencing software knows how to establish a call and exchange media like audio and video? This magic lies in the protocol called Session Initiation Protocol (SIP). Within a SIP message, there’s a crucial component called the Session Description Protocol (SDP). Today, let’s crack open a SIP packet and decode the secrets of SDP!
Think of SIP as the invitation manager for your communication session. It sets up the call, negotiates terms, and manages its lifecycle. But SIP itself doesn’t handle the media content — that’s where SDP comes in. SDP acts as a menu card, describing the media types (audio, video) available, the codecs used for encoding them, the ports on which this media exchange will happen, etc. It is defined in RFC 4566.
SDP is typically carried in the message body of INVITE, 200 OK, and ACK messages during the session establishment phase. It is also used in re-INVITE and UPDATE messages for modifying sessions. The SDP payload in SIP packets provides the necessary parameters for media negotiation between endpoints.
Structure of an SDP Message
An SDP message is composed of several lines, each starting with a single character (a field name) followed by an equals sign and a value. The following are the key fields in an SDP message:
- v= (protocol version): Indicates the version of the SDP. Currently, the version is always 0.
- o= (originator and session identifier): Provides information about the creator of the session, including a username, session ID, session version, network type, address type, and the address.
- s= (session name): A human-readable name of the session.
- i= (session information): Optional field providing additional information about the session.
- c= (connection information): This line describes the connection information, including the network type (e.g., IN for internet) and the address where media will be sent and received.
- m= (media description): This, my friends, is the heart of SDP! This line defines a media stream. It specifies the media type (e.g., audio, video), the transport protocol (typically RTP/AVP for real-time media), and the port number used for this media stream. Imagine this line saying, “I have audio available on port 5004!”
- a= (session attribute): These provide additional information about the media. For example, a=rtpmap maps RTP payload types to codec names and their clock rates. Other attributes like a=sendrecv, a=recvonly, or a=sendonly, a-inactive, describes the direction of the media stream.
- t= (time the session is active): Specifies the start and stop times for the session.
Now let’s look at some of the key attribute values:
- a=rtpmap: This attribute maps a payload type number (used for identifying media streams) to a codec and its parameters (like clock rate, bitrate).
- a=fmtp: This attribute provides format-specific parameters for codecs, allowing for additional configuration beyond what’s specified in the rtpmap attribute.
- a=crypto: This attribute acts as the security instructions within the SDP menu card. It specifies the encryption details for securing the media stream using the Secure Real-time Transport Protocol (SRTP).
- a=ptime: This attribute defines the packetization time, which is like the portion size for audio data. It specifies the duration (in milliseconds) of audio contained in each RTP packet.
- a=rtcp: This attribute points to the port number used for the Real-time Transport Control Protocol (RTCP). RTCP acts as quality control, providing feedback on how well the media stream is being delivered.
In a nutshell SDP plays a vital role in SIP-based communications by providing the necessary details for media negotiation. Understanding how to decode and interpret SDP messages is essential for SIP engineers and anyone involved in VoIP technology. By familiarizing yourself with the structure and common attributes of SDP, you can ensure more robust and compatible SIP communications.
Want to delve deeper? Explore RFC 3261: https://datatracker.ietf.org/doc/rfc3261/ for the official SDP specification.
Happy sipping SIP!