Sip Messages and Call Flows
Sip Messages and Call Flows
Sip Messages and Call Flows
• SIP is a signalling protocol used to create, modify, and terminate a multimedia session over the Internet Protocol. A session is nothing but a simple call between two
endpoints.
• An endpoint can be a smartphone, a laptop, or any device that can receive and send multimedia content over the Internet.
• SIP is an application layer protocol defined by IETF (Internet Engineering Task
• Force) standard. It is defined in RFC 3261.
• SIP embodies client-server architecture and the use of URL and URI from HTTP and a text encoding scheme and a header style from SMTP.
• SIP takes the help of SDP (Session Description Protocol) which describes a session and RTP (Real Time Transport Protocol) used for delivering voice and video over IP
network.
• SIP can be used for two-party (unicast) or multiparty (multicast) sessions.
• Other SIP applications include file transfer, instant messaging, video conferencing, online games, and steaming multimedia distribution.
• There are some entities that help SIP in creating its network. In SIP, every network
element is identified by a SIP URI (Uniform Resource Identifier) which is like an address.
• Following are the network elements:
• User Agent
• Proxy Server
• Registrar Server
• Redirect Server
Network •
•
Location Server
User Agent
Elements • It is the endpoint and one of the most important network elements of a SIP network. An
endpoint can initiate, modify, or terminate a session. User agents are the most
intelligent device or network element of a SIP network. It could be a softphone, a
mobile, or a laptop.
• User agents are logically divided into two parts:
• User Agent Client (UAC): The entity that sends a request and receives a response.
• User Agent Server (UAS): The entity that receives a request and sends a response.
• SIP is based on client-server architecture where the caller’s phone acts as a client which
initiates a call and the callee’s phone acts as a server which responds the call.
• Proxy Server
• It is the network element that takes a request from a user
agent and forwards it to another user.
• Basically the role of a proxy server is much like a router.
• It has some intelligence to understand a SIP request and send it
ahead with the help of URI.
• Redirect Server
• The redirect server receives requests and looks up the intended recipient of the request in the location database
created by the registrar.
• The redirect server uses the database for getting location information and responds with 3xx (Redirect response) to
the user. We will discuss response codes later in this tutorial.
• Location Server
• The location server provides information about a caller's possible locations to the redirect and proxy servers.
• Only a proxy server or a redirect server can contact a location server.
• The following figure depicts the roles played by each of the network elements in establishing a session.
SIP Messaging
• BYE is the method used to terminate an established session. This is a SIP request
that can be sent by either the caller or the callee to end a session.
• It cannot be sent by a proxy server.
• BYE request normally routes end to end, bypassing the proxy server.
• BYE cannot be sent to a pending an INVITE or an unestablished session.
• REGISTER
• REGISTER request performs the registration of a user agent. This request is sent by
a user agent to a registrar server.
Core Methods • The REGISTER request may be forwarded or proxied until it reaches an
authoritative registrar of the specified domain.
• It carries the AOR (Address of Record) in the To header of the user that is being
Contd.. •
registered.
REGISTER request contains the time period (3600sec).
• One user agent can send a REGISTER request on behalf of another user agent. This
is known as third-party registration. Here, the From tag contains the URI of the
party submitting the registration on behalf of the party identified in the To header.
• CANCEL
• CANCEL is used to terminate a session which is not established. User agents use
this request to cancel a pending call attempt initiated earlier. It can be sent either
by a user agent or a proxy server.
• CANCEL is a hop by hop request, i.e., it goes through the elements between the
user agent and receives the response generated by the next stateful element.
Core Methods Cntd..
• ACK
• ACK is used to acknowledge the final responses to an INVITE method. An ACK always
goes
• in the direction of INVITE.ACK may contain SDP body (media characteristics), if it is not
• available in INVITE.
• ACK may not be used to modify the media description that has already been sent in the
initial INVITE.
• A stateful proxy receiving an ACK must determine whether or not the ACK should be
forwarded downstream to another proxy or user agent.
• For 2xx responses, ACK is end to end, but for all other final responses, it works on hop by
hop basis when stateful proxies are involved.
• OPTIONS
• OPTIONS method is used to query a user agent or a proxy server about its capabilities
and discover its current availability. The response to a request lists the capabilities of the
user agent or server. A proxy never generates an OPTIONS request.
Extension Methods
• Subscribe
• SUBSCRIBE is used by user agents to establish a
subscription for the purpose of getting notification
about a particular event.
• It contains an Expires header field that indicates the
duration of a subscription.
• After the time period passes, the subscription will
automatically terminate.
• Subscription establishes a dialog between the user
agents.
• You can re-subscription again by sending another
SUBSCRIBE within the dialog before the expiration
time.
• A 200 OK will be received for a subscription from User.
• Users can unsubscribe by sending another SUBSCRIBE
method with Expires value 0(zero).
Extension Methods
Contd..
• NOTIFY
• NOTIFY is used by user agents to get the occurrence of a particular event. Usually a NOTIFY will
trigger within a dialog when a subscription exists between the subscriber and the notifier.
• Every NOTIFY will get 200 OK response if it is received by notifier.
• NOTIFY contain an Event header field indicating the event and a subscriptionstate header field
indicating the current state of the subscription.
• A NOTIFY is always sent at the start and termination of a subscription.
• PUBLISH
• PUBLISH is used by a user agent to send event state information to a server.
• PUBLISH is mostly useful when there are multiple sources of event information.
• A PUBLISH request is similar to a NOTIFY, except that it is not sent in a dialog.
• A PUBLISH request must contain an Expires header field and a Min-Expires header field.
Extension Methods
• REFER
Contd..
• REFER is used by a user agent to refer another user agent to access a URI for the dialog.
• REFER must contain a Refer-To header. This is a mandatory header for REFER.
• A 202 Accepted will trigger a REFER request which indicates that other user agent has accepted the reference.
• INFO
• INFO is used by a user agent to send call signalling information to another user agent with which it has established a media
session.
• UPDATE
• UPDATE is used to modify the state of a session if a session is not established. User could change the codec with UPDATE.
• PRACK
• PRACK is used to acknowledge the receipt of a reliable transfer of provisional response (1XX).
• Generally PRACK is generated by a client when it receive a provisional response containing an RSeq reliable sequence
number and a supported:100rel header.
• The PRACK method applies to all provisional responses except the 100 Trying response, which is never reliably
transported.
• A PRACK may contain a message body; it may be used for offer/answer exchange.
Message
• MESSAGE
• It is used to send an instant message using SIP. An
IM usually consists of short messages exchanged in
real time by participants engaged in text
conversation.
• MESSAGE can be sent within a dialog or outside a
dialog.
• The contents of a MESSAGE are carried in the
message body as a MIME attachment.
• A 200 OK response is normally received to indicate
that the message has been delivered at its
destination.
Response Codes
• A SIP response is a message generated by a user agent server (UAS) or SIP server to reply a
request generated by a client. It could be a formal acknowledgement to prevent retransmission of
requests by a UAC.
• A response may contain some additional header fields of info needed by a UAC.
• SIP has six responses.
• 1xx to 5xx has been borrowed from HTTP and 6xx is introduced in SIP.
• 1xx is considered as a provisional response and the rest are final responses.
• 1. 1xx: Provisional/Informational Responses
• 2. 2xx: Success Responses
• 3. 3xx: Redirect Responses
• 4. 4xx: Client Failure Responses
• 5. 5xx: Server Failure Responses
• 6. 6xx: Global Failure Responses
Informational (1XX)
• Informational (1xx)
• Informational responses are used to indicate call progress. Normally the responses are end to end (except 100 Trying). The main objective of informational responses is to stop retransmission of INVITE
requests.
• 100 Trying
• 180 Ringing
• This response is used to indicate that an INVITE has been received by the user agent and alerting is taking place.
• This response is used to indicate that the call has been forwarded to another endpoint.
• It gives the status of the caller, as a forwarding operation may result in the calltaking longer to be answered.
• This response is used to indicate that the INVITE has been received and will be processed in a queue.
• It indicates that information about the progress of a session may be present in a message body or media stream.
• Unlike a 100 Trying response, a 183 is an end-to-end response. It establishes early dialog.
• A typical use of this response is to allow a UAC to hear a ringtone recorded announcement in calls through a gateway into the PSTN.
Success(2XX)
• This class of responses is meant for indicating that a request has been
accepted. It includes the following responses:
• 200 OK :
• 200 OK is used to accept a session invitation.
• It indicates a successful receipt of a request.
• 202 Accepted
• 202 Accepted indicates that the UAS has received and understood the
request, but that the request may not have been authorized or processed
by the server.
• It is commonly used in responses to SUBSCRIBE, REFER methods
Redirection (3xx)
• Redirection (3xx)
• Generally these class responses are sent by redirect servers in response to INVITE. They are also known as redirect class
responses. It includes the following responses:
• 300 Multiple Choices :
• It contains multiple Contact header fields to indicate that the location service has returned multiple possible locations for the SIP
URI in the Request-URI.
• 301 Moved Permanently
• This redirection response contains a Contact header field with the new URI of the called party.
• The address can be saved and used in future INVITE requests.
• 302 Moved Temporarily
• This redirection response contains a URI that is currently valid but is not permanent.
• That is, for the specified duration of time the location is valid.
• 305 Use Proxy
• This response points to certain proxy server which is having some authoritative information about the calling party.
• This response could be sent by a UAS issuing a proxy for incoming call screening.
• 380 Alternative Service
• This response returns a URI that indicates the type of service the called party would like.
• For example, a call could be redirected to a voicemail server.
Client Error(4XX)
• Client error responses indicate that the request cannot be fulfilled as some errors are identified from the UAC side. The response codes are
generally sent by UAS. Upon receiving an error message, the client should resend the request by modifying it based on the response. Discussed
below are some of the important client error responses.
• 400 Bad Request
• This indicates that the server could not understood the request.
• Request might be missing required header fields such as To, From, Call-ID, or CSeq.
• 401 Unauthorized
• It indicates that the request need to perform authentication.
• 401 Unauthorized is normally sent by a registrar server for REGISTER request.
• The response contains WWW-Authenticate header field which requests for correct credentials from the calling user agent.
• A subsequent REGISTER will trigger from the User Agent with correct credentials.
• 402 Payment Required
• It indicates payment is required for further processing of request.
• 403 Forbidden
• 403 Forbidden is sent when the server has understood the request, found the request to be correctly formulated, but will not service the request.
• This response is not used when authorization is required.
• 404 Not Found
• It indicates that server has not found the indicated SIP URI by the User.
Server Failure (5xx)
• This class response is used to indicate that the request cannot be processed because of an error with the server. The server failed to fulfil an apparently
valid request. The response may contain a Retry-After header field. The request can be tried at other locations because there are no errors indicated in
the request. Some of the important server failure responses are discussed below.
• 500 Server Internal Error
• 500 indicates that the server has experienced some kind of error that is preventing it from processing the request.
• It is one kind of server failure that indicates the client to retry the request again at this server after several seconds.
• 501 Not Implemented
• It indicates that the server is unable to process the request because it is not supported.
• This response can be used to decline a request containing an unknown method.
• 502 Bad Gateway
• This response is sent by a proxy that is acting as a gateway to another network.
• It indicates some problem in the other network is preventing the request from being processed.
• 503 Service Unavailable
• This response indicates that the requested service is temporarily unavailable at that time.
• The request can be retried after a few seconds, or after the expiration of the Retry-After header field.
• 504 Gateway Timeout
• This response comes when the request failed due to a timeout occurred in the other network to which the gateway connects.
• It is a server error class response because the call is failing due to a failure of the server in accessing resources outside the SIP network.
Global Error (6xx)
• This response class indicates that the server knows that the request will fail wherever it is tried. As a result, the request
should not be sent to other locations. Only a server having definitive knowledge of the user identified by the Request-URI
in every possible instance should send a global error class response. Otherwise, a client error class response should be
sent. A Retry-After header field can be used to indicate when the request might be successful. Some of the important
responses are discussed below:
• 600 Busy Everywhere
• This response indicates that the call to the specified Request-URI could be answered in other locations.
• 603 Decline
• This response could indicate the called party is busy, or simply does not want to accept the call.
• 604 Does Not Exist Anywhere
• This response is similar to the 404 Not Found response but indicates that the user in the Request-URI cannot be found
anywhere.
• This response should only be sent by a server having access to all the information about the user.
• 606 Not Acceptable
• This response indicates that some aspect of the desired session is not acceptable to the UAS, and as a result, the session
cannot be established.
• The response may contain a Warning header field with a numerical code describing exactly what was not acceptable.
• The request can be retried with different media session information.
SIP Headers