SIP is basically a call and response protocol. You send a message. You get a response. In some situations, you may even get several responses for a single message.
Case in point is an INVITE transaction. A single INVITE request typically receives three responses and it’s not impossible for it to receive more. However, with most other SIP requests, a single response is received for every message sent.
A SIP response is more than simply an acknowledgement to a request. It can, and often does, carry a lot of useful information from the user agent server (UAS) back to the user agent client (UAC). For instance, a 200 Ok typically carries session description protocol (SDP) and therefore a list of codecs that the UAS supports. A 302 Moved Temporarily provides next-hop routing information. A 401 Unauthorized is used to pass the data needed to encrypt a UAC’s credentials.
Response messages fall into one of six types and those types are subsequently divided into two categories. The categories are either Provisional or Final. The types are identified by a three-digit number where the first digit indicates the class of the response.
There is also human readable text associated with every response code. This Reason Phrase is never processed by a SIP stack. It’s simply there for you to read. SIP stacks deal only with the three-digit number.
Several Provisional responses can be sent by the UAS up to the point of session establishment. Provisional responses begin with a 1.
Final responses begin with a 2, 3, 4, 5, or 6. A single Final response indicates that the session has been established (success) or the session never will be established (redirection or error).
For example, 182 Queued is a Provisional response. I know that because the leading digit is 1. The UAC might receive several 182 Queued responses as the call goes through various levels of queuing.
415 Unsupported Media Type is a Final response. I know that because the leading digit is 4. Only one Final response will be sent to the UAC for a single session. Upon receipt of the 415 Unsupported Media Type, session establishment will stop and the UAC will respond with an ACK.
The following table graphically shows what I just explained.
Let’s take a deeper look at each type starting with the 1xx responses.
1xx Response Codes
The 1xx responses are the Informational responses. As I stated earlier, they are sent while a session is being established and you can receive more than one of them.
181 Call is Being Forwarded
183 Session in Progress
199 Early Dialog Terminated
A 100 Trying is sent to indicate that the request is being processed. It will subsequently stop the SIP retransmission timer.
For a deep dive into 180 Ringing and 183 Session in Progress, please see my article, SIP Media Management: Early Media vs. Late Media.
2xx Response Codes
The 2xx responses are the Success responses. They are used to indicate that a SIP request was successfully processed. Of these, the 200 Ok is the most common. The 202 Accepted is used in REFER processing. I have never witnessed a 204 No Notification outside of SIP documentation.
204 No Notification
3xx Response Codes
The 3xx responses are the Redirection responses. They are used to inform the UAC of a different route to get to the UAS. Of these, 301 Moved Permanently and 302 Moved Temporarily are the workhorses.
I like these responses so much that I blogged about them in Move it on Over – SIP Redirection.
300 Multiple Choices
301 Moved Permanently
302 Moved Temporarily
305 Use Proxy
380 Alternate Service
4xx Response Codes
The 4xx responses are the Client Error responses. They are used to indicate that something went wrong while processing the message. They can come from the UAS or a network SIP element in the path to the UAS.
There are far more 4xx responses than I care to document in this article, so I will just list a few of the most common.
One response should look very familiar to you. 404 Page Not Found is what you see if you attempt to browse to a webpage that doesn’t exist. The fact that the same response code is used for both web browsing and SIP should not be surprising. SIP is based on the language of the web – HTTP.
400 Bad Request
404 Not Found
407 Proxy Authentication Required
408 Request Timeout
415 Unsupported Media Type
5xx Response Codes
The 5xx responses are the Server Error responses. They are generated by the likes of proxy servers, location servers, and redirect servers.
500 Server Internal Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Server Time-Out
505 Version Not Supported
513 Message Too Large
580 Precondition Failure
Avaya has a unique use for the 503 Service Unavailable response. A Session Manager sends OPTIONS messages to its configured SIP entities to determine whether they are alive or not. A Communication Manager will reply with a 200 Ok if it’s active and processing calls and a 503 Service Unavailable is returned if it’s alive, but no gateways have registered to it. This allows Session Manager to mark a Communication manager as operational, but not up.
6xx Response Codes
The 6xx responses are the Global Error responses. They indicate that a server has definitive information about a particular user and not just the particular instance indicated by the Request-URI.
600 Busy Everywhere
604 Does Not Exist Anywhere
606 Not Acceptable
That’s All Folks
I hope this all made sense to you. SIP responses aren’t that difficult to understand, yet they can be used to create some very sophisticated services. Of course, that is the beauty of SIP – power in simplicity.