Understanding SIP Responses: From Provisional to Global Failures
Photo by Sidral Mundet on Unsplash

Understanding SIP Responses: From Provisional to Global Failures

The Session Initiation Protocol (SIP) is a signaling protocol widely used for initiating, managing, and terminating real-time communication sessions such as voice and video calls over the Internet. SIP works in conjunction with other protocols like the Real-time Transport Protocol (RTP) to facilitate media transmission between endpoints.?


A key aspect of SIP is its response code mechanism. SIP response codes provide information about the status of a SIP request and help troubleshoot issues. In this post, we’ll take a deep dive into the various SIP response codes, their meanings, and how to handle them appropriately in a SIP implementation.


SIP Response Code Classes


SIP response codes are three-digit numbers classified into the following categories:


1xx - Provisional Responses

2xx - Success Responses?

3xx - Redirection Responses

4xx - Client Failure Responses

5xx - Server Failure Responses?

6xx - Global Failure Responses


Let's look at each of these categories in more detail:


1xx - Provisional Responses


1xx responses are provisional or informational responses indicating that the request was received and understood. Here are some common 1xx responses:


- 100 Trying - The request has been received by the next-hop server and the process is being continued. This is sent automatically and usually requires no special handling.


- 180 Ringing - The called party's device is ringing. This indicates progress of the request.


- 181 Call is Being Forwarded - The call is being forwarded to a different destination. The Contact header contains the new destination.


- 183 Session Progress - Used during early media scenarios to indicate progress of the session setup. Early media refers to media (e.g. audio) played to the caller before the call is formally answered.


1xx responses are provisional so the initiating client should not treat the session as established until a final response (2xx) is received.


2xx - Success Responses


2xx responses indicate that the request was successfully received, understood, and accepted. Some common 2xx responses:


- 200 OK - The request has succeeded. For an INVITE request, this indicates that the call has been answered.


- 202 Accepted - The request has been accepted but processing has not been completed. The response will be sent later asynchronously.?


When a 2xx response is received for an INVITE, it means the call has been established and media communication can begin. The client can now send an ACK to confirm receipt of the final response.


3xx - Redirection Responses?


3xx responses indicate that the caller must take additional action to complete their request. This action involves contacting an alternate server or user. Some 3xx responses:


- 301 Moved Permanently - The user can no longer be found at the address queried. The response contains the new address to be used.


- 302 Moved Temporarily - The user cannot be found at the address temporarily. The user may be available again later at this same address.?


- 305 Use Proxy - The caller must use the proxy specified in the Contact header to contact the user.


- 380 Alternative Service - The call failed, but alternatives are detailed in the message body.


When a 3xx is received, the client should send the request (e.g. INVITE) to the new location indicated in the Contact header.


4xx - Client Failure Responses


4xx responses indicate a problem with the request initiated by the client. Some common 4xx responses:


- 401 Unauthorized - The request requires user authentication. This response includes a WWW-Authenticate header with challenge information.


- 403 Forbidden - The server understood the request but is refusing to fulfill it (due to access rights or authorization issues).


- 404 Not Found - The user or service specified in the Request-URI was not found. Verify the input is correct.


- 408 Request Timeout - The server could not produce a response within the time required. The client may repeat the request without modifications.


- 415 Unsupported Media Type - The format of the session description or media type is not supported.


- 486 Busy Here - The called party's end system was contacted successfully but the user is busy and does not wish to take the call.


4xx responses mean the client must fix something on their end before re-attempting the request. This may involve providing authentication, authorization, correcting the Request-URI, or modifying the message body.


5xx - Server Failure Responses


5xx responses indicate that the server failed to fulfill a valid request due to an error on the server's end, not the client's. Some examples:


- 500 Server Internal Error - The server encountered an unexpected error condition preventing request fulfillment.?


- 503 Service Unavailable - The server is temporarily unable to process the request due to maintenance or overloading.?


- 504 Server Time-out - The server attempted to contact an external server (e.g. location server) and timed out.


- 580 Precondition Failure - The server requires validation of conditions before accepting the request, but those conditions evaluated to false or could not be evaluated.


When a 5xx is encountered, the client should not retry the same request without modification. The client must wait and possibly try the request later when the error condition may be cleared.


6xx - Global Failure Responses


6xx responses indicate failures that prevent fulfillment of the request. Unlike 5xx errors which are temporary server failures, 6xx conditions are permanent failures relating to the session or request message itself. For example:


- 600 Busy Everywhere - The called party's device was contacted but the user is unavailable on all destinations/devices.


- 603 Decline - The destination user has declined the call. The client should provide notification of this to the caller.


- 604 Does Not Exist Anywhere - The server has authoritative knowledge that the called party user does not exist anywhere.


Like the 5xx responses, 6xx failures mean the request could not be satisfied at the time of the response. The client should not retry the same request without modification.


Unique SIP Responses


In addition to the general response classes, there are some unique SIP responses worth calling out:


100 Trying - As mentioned, sent automatically by many SIP servers, so handling is not required.


180 Ringing - Provides a ringback tone to the caller so they know the destination is ringing. This response is especially useful for SIP networks without a PSTN gateway.


181 Call is Being Forwarded - Allows the client to inform the caller that their call is being forwarded. May also be used for call transfer operations.


183 Session Progress - Carries SDP which allows early media exchange before 2xx response.


489 Bad Event - Used to indicate failure of a SIP SUBSCRIBE request. Details are provided in the message body.


487 Request Terminated - Sent to indicate termination of a SIP request. Further transmissions of the request from the client will be disallowed.?


420 Bad Extension - The server did not recognize the extension number provided in the Request-URI. Verify the number is valid.?


Remote Party is Terminating - Indicates the other party has hung up the call. The BYE request will follow to terminate the session.


Handling SIP Responses


So in summary, here are some general guidelines for handling SIP responses:


- 1xx - Provisional, continue session setup


- 2xx - Success, start media communication?


- 3xx - Check Contact header for new destination?


- 4xx - Do not retry without modifying request


- 5xx - Wait, then retry request later if appropriate


- 6xx - Do not retry same request


- Unique cases like 180, 183, 487, 420 require special handling


Properly processing SIP responses ensures calls connect smoothly, errors are handled properly, and clients are notified of progress during session initiation. Troubleshooting tools for SIP networks also rely heavily on response code analysis. Mastering SIP responses unlocks the true power of SIP-based communication systems.

要查看或添加评论,请登录

Cory Barnes的更多文章

社区洞察

其他会员也浏览了