Breaking

Thursday, September 3, 2020

VoIP (Voice Over Internet Protocol) is a term that used to any end-to-end call over the internet service instead of any cellular network or the traditional telephonic line. Using VoIP we can make any kind of calls (audio, video) without any prepaid or postpaid recharges. It requires internet connectivity. We just have to make sure that our application is connected to the internet for which the voice or video data packets generated from one end could be transmitted to the other end through the internet. That is what Skype, WhatsApp, like applications, and many companies (for its internal communication between employees) do nowadays.

VoIP and SIP protocol


This is possible because of the application layer protocol "SIP". It is a signaling protocol that allows two clients to establish a media session with each other. It mostly uses UDP protocol to transfer packets, although it can use both TCP and UDP protocol for packet transfer.

SIP stands for Session Initiation Protocol which is used to initiate, modify, and terminating sessions (maybe text, voice, video, or a combination of these) with one or more participants in an IP network. Basically, it's of two entities, one is the client, and the other is the server.

1. SIP Client:- Clients are the entities who make requests.

2. SIP Server:- Server is the entity that accepts the client request and sends a response to the respective request.

There are some individual servers present inside the SIP server like- Proxy server, Registrar, Redirect Server, Location server.

Proxy Server:- When a client generates a SIP request message, it goes to the proxy server. Then the proxy server forwards the request to another proxy server or to the recipient. And a SIP request message could be:-

1. INVITE             ---> Request a session
2. ACK                   ---> Final response to the INVITE
3. OPTIONS        ---> Ask for server capability (In order to support voice, video text)
4. CANCEL          ---> Cancel a pending request
5. BYE                  ---> Terminate a session
6. REGISTER     ---> Send user address to the server
7. NOTIFY           ---> To send event notice

Registrar:- It used to register any new client into the SIP server.

Redirect Server:- It redirects back the client request in case the recipient is missing from the location server.

Location Server:- The addresses registered to the registrar are stored in the location server.

The workflow of SIP:-
Here is an example of two SIP clients communicate with each other through the SIP server given below. Here both clients are already registered with the server and client 1 is trying to initiate the voice call with client 2.

sip flow


When client 1 tries to initiate a conversation session by sending an "INVITE" request to client 2, then the request goes to the proxy server. The proxy server tries to check the registered address of client 2 from the location server if it failed to get the client 2 address it simply redirects back the request otherwise it sends a 100 Trying response to client 1 and then sends the "INVITE" request to client 2 and waiting for the client 2 response. When the server gets the "180 ringings" response from client 2, it sends the same response to client 1. When client 2 receives the call, the server gets a "200 OK" response from client 2 and acknowledges it. Then the client 1 gets the "200 OK" response from the server followed by an acknowledgment and starts their conversation.

Here is a picture of the server logs of a video call session made from client id 4002 to client id 4000.

sip logs

After the completion of the conversation, client 1 tries to end the call by sending a "BYE" request that is answered by "200 OK" from the server and the server sends a "BYE" request message to client 2 and the session is closed.  The last two lines of the above picture show that both clients have left the conversation. Now close the session.

Watch this VoIP video demo to clarify more:-


Here I am using the open-source software for both server and client i.e Asterisk and LinPhone respectively and trying to show the sip server logs of a video call session.
close