SIP Protocol: Understand how a VoIP call works

VOIP connections, like any information that travels on the Internet, are also based on packet traffic that uses a protocol (rules that regulate communication between two machines).

The protocol used in VOIP calls can be SIP, IAX, h.323, MGCP, XMPP, or others, however, currently the SIP protocol has been better accepted by telecom companies, having a good diffusion in the telephone market.

Today we will talk a little about how this protocol works and we will discuss SIP dialogue with a proxy server connecting two extensions.

In the SIP diagram below we can see how a VOIP connection works between two extensions registered on the same SIP server:

VOIP connection between: SIP Extension A <=> SIP Server <=> SIP Extension B

In this example of a call using the SIP protocol, it is possible to easily observe the messages exchanged to establish the call. Below is the step-by-step diagram:

1 – The user Lucien dialed the user Carlos, at this moment Lucien's extension forwarded the INVITE to the server.sip (server where he is registered);

2 – The server forwarded the INVITE to the extension of the user Carlos who is registered on the same server (internal call), and responded to Lucien “100 Trying” informing that he is trying to make the call;

3 – When Carlos’ extension receives the call request, it sends “180 Ringing” to the server, informing that it has received the INVITE and is calling;

4 – The server forwards the message to Lucien’s extension stating that the phone is calling;

5 – Carlos answers the phone, at this moment his extension sends “200 OK” informing that the phone has been answered and it is now possible to establish the media flow;

6 – The server passes the “200 OK” to the extension originating the call (Lucien) who responds with “ACK” (Acknowledge) confirming that it received the “200 OK”;

7 – The server forwards the “ACK” to Carlos’ extension, which upon receiving the confirmation opens the media session directly between the two extensions, starting the conversation between the two users.

8 – User Carlos ends the call, at that moment the extension sends the BYE message, informing the hang-up signal.

9 – The server passes the BYE to Lucien's extension, which responds with 200 Ok, confirming the end of the call.

Through this same image we can make some observations:

Whenever the destination extension is available and receives the call request (INVITE), it returns the Ring (180 Ringing) informing that it is calling. If this extension is busy, not registered or for some other reason cannot be answered, it will return an error code.

The fact that the media is passing directly from one extension to another (point-to-point) is a strong indication that Server.sip is acting as a SIP Proxy.

In a call with audio passing point-to-point, the server is unable to control the media or record the calls, but bandwidth consumption is much lower, after all, only Sip packets (purely text) travel to control the call. in Server.sip .

In this case, the VOIP call is being made between two extensions registered on the same SIP server, but the reality of telephony is not always this. How a call works between two SIP servers or to the public network is something we will cover in another post.

If there is a problem sending the call termination (BYE), “stuck calls” generally occur, which remain active because they have not received the hang-up signal. Understand more about Trapped Calls.

SIP Package (INVITE):

Below we can see in the INVITE SIP package the basic information contained in it and the field that indicates the message:

U 2013/01/30 11:01:57.455004 192.168.0.50:1024 -> 192.168.0.150:5060
INVITE sip:4031@server.sip SIP/2.0.
Via: SIP/2.0/UDP 192.168.0.50:1047;branch=z9hG4bK188800439.
From: “Lucien <4030>” ;tag=738994358.
To: .
Call-ID: 1287077758@192.168.0.43.
CSeq: 1 INVITE.
Contact: .
Content-Type: application/sdp.
Max-Forwards: 70.
Content-Length: 293.

INVITE: The commands that establish the SIP dialog are sent in this line. The INVITE message is a request for a new call. Note that in this field it is also possible to observe the destination number (B number).

From: This field identifies the originator of the call (A number).

Soon we will be making posts available about SIP Error Codes, SIP Proxy, SIP Redirect and many others, follow along!

Doubts? Suggestions? Leave your comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEN