Basic Call Flow – SIP

Basic Call Flow – SIP

Key terms used in SIP:

It is important to familiarize with these terms in order to understand basic SIP call flow. Here are few of them:

Call flow: It’s a flow diagram of SIP messages — shows an ideal way how a media session carried over two endpoints. Its a must know thing and will be useful for your troubleshooting as well.

Endpoint: Any device which is used to originate and terminate a media session. For example SIP phones, SIP clients running on PCs, webRTC running in browsers etc. In terms of SIP, we formally called this endpoint as User Agent. It has two modes:

  1. UAC – User Agent Client
  2. UAS – User Agent Server

User Agent Client: [UAC] who requests something in a SIP session.

User Agent Server: [UAS] who responds after serving the request from UAC

Example to understand the term.

For example, in a school, students apply a leave request and teachers may approve or may not. Here in SIP, students are UA Clients whereas Teachers are UA Servers. It does not mean Students are always UA-Clients and Teachers are UA-Servers. Depending upon the situation, the user-agent can change the mode from UA-Client to UA-Server.

Note: It is not necessary that you will get approval from teachers for every leave request. At times there will be rejections. The same way in SIP also, you see not only success responses (200 OK), but also failure/error responses (487, 500 error etc).

peer to peer sip flow
peer to peer sip flow

Explanation of above peer to peer sip communication:

Lets assume two things here before we go to the explanation.
User-A = UA-A (User Agent-A)
User-B = UA-B (User Agent-B)
  • As per the diagram, the UA-A is calling UA-B.
  • INVITE is the request from UA-A to UA-B — which means UA-A initiated a call and inviting UA-B to have a communication session. This INVITE message carries all the related information about UA-A such as information of media-capabilities, which port UA-A can listen etc.
  • UA-B responds “100 Trying” message to UA-A. This message states about the progress of session (call) to UA-A
  • UA-B also respond with 180 Ringing message to UA-A. This message conveys the ringing status of UA-B to UA-A
  • After 180 Ringing, UA-B sends 200 OK to UA-A. This 200 OK message carries all the media-capabilities of UA-B
  • Once both the parties know each others capabilities, then they are ready to participate in the communication session. This will be confirmed by UA-A sending an ACK request to UA-B
  • Once UA-B receives the ACK request, then the media starts flowing between the UA-A and UA-B
  • Whenever any party hangs up to terminate the call, this will be conveyed as BYE request in terms of SIP. So, in our example, we see clearly that BYE request is initiated by UA-A to UA-B.
  • This BYE request has to be acknowledged by the other party i.e. UA-B
  • This concludes one SIP session (call) between two User Agents.

Given below is a step-by-step explanation of the terminology and call flow −

  • An INVITE request that is sent to a proxy server is responsible for initiating a session.
  • The proxy server sendsa 100 Trying response immediately to the caller (Alice) to stop the re-transmissions of the INVITE request.
  • The proxy server searches the address of Bob in the location server. After getting the address, it forwards the INVITE request further.
  • Thereafter, 180 Ringing (Provisional responses) generated by Bob is returned back to Alice.
  • 200 OK response is generated soon after Bob picks the phone up.
  • Bob receives an ACK from the Alice, once it gets 200 OK.
  • At the same time, the session gets established and RTP packets (conversations) start flowing from both ends.
  • After the conversation, any participant (Alice or Bob) can send a BYE request to terminate the session.
  • BYE reaches directly from Alice to Bob bypassing the proxy server.
  • Finally, Bob sends a 200 OK response to confirm the BYE and the session is terminated.
  • In the above basic call flow, three transactions are (marked as 1, 2, 3) available.

The complete call (from INVITE to 200 OK) is known as a Dialog.

sip_call_flow
sip_call_flow