A Deeper Dive Into SIP Packets: Start-Line, Headers, and Message Body

Krishnakumar PG
4 min readMay 15, 2024

--

SIP (Session Initiation Protocol) is a widely-used protocol for initiating, maintaining, and terminating real-time communication sessions such as voice and video calls. To understand how SIP works, it’s essential to have a grasp on the structure of SIP messages. In this article, we’ll break down the key components of a SIP message: Start Line, Headers, and Message Body, and understand how Session Description Protocol (SDP) can be used to add crucial information in SIP sessions.

A SIP message typically consists of three parts: Start line, Header Field, and Message body.

Start Line is the first line of the SIP message, containing the Request-URI, method (INVITE), and SIP version.

Just like you need an address to send a letter, SIP needs an address to send messages. In SIP, these addresses are called Uniform Resource Identifiers (URIs). The Request-URI specifies the address of the user or service being contacted, formed by the combining user’s SIP or SIPS URI and the domain name of the server where the user, and the SIP version.

Header Fields form the backbone of every SIP message, providing the necessary context for successful communication over IP networks. There are six mandatory headers in every SIP message: From, To, Contact, CSeq, Call-ID, and Via.

  • The ‘From’ header identifies the originator of the request, while the ‘To’ header identifies the intended recipient. These headers are essential for identification of parties involved in the session. They don’t play any role in routing of the requests or responses.
  • The ‘Contact’ header provides a direct route to the sender for subsequent requests. It plays a crucial role in tracking the message path. So this is the URI to which responses are sent to.
  • The ‘CSeq’ header contains a sequence number for the Transaction* and the method being used. It helps in identifying and ordering SIP messages within a Dialog*.
  • The ‘Call-ID’ header is a unique identifier for each call. It is crucial for correlating SIP messages that belong to the same call.
  • • The ‘Via’ header traces the route of the request and its response. It helps in understanding the path a SIP message has taken.

Message Body contains the actual data being transmitted in the SIP message. This could be a session description (e.g., SDP), a referral URL, or any other type of data specific to the application using SIP. The Content-Type header defines the message body in a SIP message.

In a voice call, message body carries Session Description Protocol (SDP), that has information about its media and participants.

  • Originator: The ‘o=’ line describes the originating user of that SIP message.
  • Media Description: The ‘m=’ line describes the media type (e.g., audio), port, and protocol (e.g., RTP/AVP) for the session.
  • Connection Information: The ‘c=’ line provides network information, such as the IP address and network type.
  • Attribute Lines: The ‘a=’ lines carry specific media attributes. For voice calls, attributes like ‘rtpmap’ (mapping an RTP payload type number to a codec) and ‘ptime’ (defining the amount of media in milliseconds that can be encapsulated in one packet) are important.

A Dialog represents a peer-to-peer communication relationship between two UAs, consisting a series of SIP messages exchanged back and forth. It typically starts with a SIP INVITE and continues until the session is terminated or times out. Dialogs are typically associated with long-lived sessions, such as voice or video calls.

A Transaction* represents a single request and its corresponding responses. Transactions are short-lived and exist only during the process of a single SIP request and its responses. Each transaction is associated with a specific SIP method, such as INVITE, ACK, BYE, or CANCEL. For example, when an endpoint sends an INVITE request to initiate a call, the transaction associated with that request handles the related responses, such as 2xx for success or 4xx for failure.

Conclusion:

SIP messages are composed of three main parts: Start Line, Headers, and Message Body. Understanding these components is crucial for developing SIP-based applications and troubleshooting issues in real-time communication networks. By breaking down each part of the message, we can gain a deeper appreciation for how SIP works and how it enables seamless communication over IP networks.

--

--