Skip to main content

9. - SIP Header

A sip message looks like an HTTP message

here is an example of a SIP header.

 

INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.0.10:5060;branch=z9hG4bK776asdhds
Max-Forwards: 70
To: <sip:[email protected]>
From: "John" <sip:[email protected]>;tag=4234235
Call-ID: [email protected]
CSeq: 1 INVITE
Contact: <sip:[email protected]:5060>
Content-Type: application/sdp
Content-Length: 142

v=0
o=- 2304919776 2304919776 IN IP4 192.168.0.10
s=SDP Seminar
c=IN IP4 192.168.0.10
t=0 0
m=audio 49170 RTP/AVP 0
a=rtpmap:0 PCMU/8000

This is an example of a SIP INVITE message, which is used to initiate a session between two SIP endpoints. The header contains various fields that provide information about the message, including the sender and recipient addresses, a unique call ID, the type of message, and any session description information in the SDP (Session Description Protocol) body.

Here is another example with more details

INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds
Max-Forwards: 70
To: Bob <sip:[email protected]>
From: Alice <sip:[email protected]>;tag=1928301774
Call-ID: a84b4c76e66710
CSeq: 314159 INVITE
Contact: <sip:[email protected]>
User-Agent: model300/7.6.9
Allow: INVITE,ACK,CANCEL,BYE,OPTIONS,NOTIFY,SUBSCRIBE
Allow-Events: talk,hold,refer
Session-Expires: 3600;refresher=uas
Content-Type: application/sdp
Content-Length: 142
  • Request Line: The first line of a SIP header is called the request line, and it contains the method (INVITE), the SIP URI of the destination (sip:[email protected]), and the SIP protocol version (SIP/2.0).
  • Via: The Via header indicates the path of the message through any intermediaries (such as proxies) that it passes through on the way to its destination. In this example, the Via header indicates that the message was sent using the SIP/2.0/UDP protocol from the host pc33.atlanta.com, with a branch identifier of z9hG4bK776asdhds.
  • Max-Forwards: This header specifies the maximum number of hops (intermediaries) that the message is allowed to pass through before it is discarded. In this example, the maximum number of hops is 70.
  • To: The To header specifies the user or service that the message is intended for. It includes the display name (Bob) and the SIP URI (sip:[email protected]) of the destination.
  • From: The From header specifies the user or service that sent the message. It includes the display name (Alice), the SIP URI (sip:[email protected]), and a tag (1928301774) that uniquely identifies this request.
  • Call-ID: This header specifies a unique identifier for the call, which is used to group related messages together. In this example, the call ID is a84b4c76e66710.
  • CSeq: This header specifies the sequence number of the request within the call. In this example, the sequence number is 314159, and the method is INVITE.
  • Contact: This header specifies the SIP URI that the recipient should use to contact the sender. In this example, the sender's URI is sip:[email protected].
  • User-Agent - In this examplee indicate a model300 telephone firmware rev 7.6.9, with some voip phone syou will see the model and MAC
  • Allow: list the set of methods supported by the UA generating the message.
  • Allow-Events: details some basic events that the UA supports, here we can talk, put on hold, refer (or transfer) a call session
  • Session-Expires: conveys the session interval for a SIP call. it is placed in an invite request and is allowed in any 2XX class response to an INVITE, here it is 3600 seconds or 60 minutes, it can be updated with the UPDATE requests, if there is no Session Expires header then its implied that the session never expires.
  • Content-Type: This header specifies the type of message body that is included in the message. In this example, the message body is of type application/sdp.
  • Content-Length: This header specifies the length of the message body, in bytes. In this example, the message body is 142 bytes long.

 

Here is the 200 Response
SIP/2.0 200 OK
Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds;received=192.0.2.1;rport=5060
To: Bob <sip:[email protected]>;tag=9fxced76sl
From: Alice <sip:[email protected]>;tag=1928301774
Call-ID: a84b4c76e66710
CSeq: 314159 INVITE
Contact: <sip:[email protected]:5060>
User-Agent: server500/2.0.3
Allow: INVITE,ACK,CANCEL,BYE,OPTIONS,NOTIFY,SUBSCRIBE
Allow-Events: talk,hold,refer
Session-Expires: 1800;refresher=uac
Record-Route: <sip:192.0.2.100;lr=on>
Content-Type: application/sdp
Content-Length: 238

v=0
o=bob 2890844526 2890844526 IN IP4 192.0.2.4
s=-
c=IN IP4 192.0.2.4
t=0 0
m=audio 49170 RTP/AVP 0
a=rtpmap:0 PCMU/8000

 

  • Via: Indicates the transport protocol, IP address, and port used to send the message. It also includes the branch parameter that helps identify the transaction, they are inserted by servers into requests to detect loops and to allow responses to find their way back to the client 'VIA' the aforementioned servers.
  • To: Identifies the recipient of the message. In this case, it is Bob at the domain biloxi.com, and it includes a tag parameter to uniquely identify this dialog.
  • From: Identifies the sender of the message. In this case, it is Alice at the domain atlanta.com, and it includes a tag parameter to uniquely identify this dialog.
  • Call-ID: Uniquely identifies the call and allows responses to be associated with the correct call.
  • CSeq: Indicates the sequence number of the message within the call, and the method used for the message. In this case, it is INVITE.
  • Contact: Specifies the address where the sender can be reached for subsequent requests. In this case, it is Bob's address at IP 192.0.2.4 and port 5060.
  • User-Agent: Identifies the software or device that generated the message.
  • Allow: Lists the SIP methods that are allowed in subsequent messages.
  • Allow-Events: Lists the event packages that the User Agent is willing to receive.
  • Session-Expires: Specifies the duration of the session and the mechanism to maintain it.
  • Record-Route: details are inserted by the proxy to force future reuests in this dialog to be routed through the proxy, here it is 192.0.2.100
  • Content-Type: Indicates the format of the message body.
  • Content-Length: Indicates the length of the message body.

 

Remember that in the header the Via, From, To, Call-ID, CSeq are copied exactly from request.
TO and FROM are NOT swapped around in Request and Response headers!

Alice -> Bob:  INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds
Max-Forwards: 70
To: Bob <sip:[email protected]>
From: Alice <sip:[email protected]>;tag=1928301774
Call-ID: a84b4c76e66710
CSeq: 314159 INVITE
Contact: <sip:[email protected]>