Conversations with Internet: VoIP part 2

In part 1 of this series, we saw what VoIP is and how it is synonymous to traditional phone calls. We also listed some advantages of VoIP over traditional phone networks, that it is possible to set up your own VoIP network for use within your company. Finally, we saw that VoIP calls can be automated. One day your devices, such as home protection or a stock market ticker, will make an audio or video call to you via VoIP if something interesting occurs.

In this part, we will see how a VoIP call works, using VoIP calling software / device and a network protocol named SIP (Session Initiation Protocol).

What is SIP protocol?

SIP protocol was started specifically for VoIP calls. The protocol provides a set of instructions that must be used and understood by VoIP calling software / devices and a VoIP server. The instructions of the SIP protocol are standardised in a document called IETF 3261. This document contains the exhaustive set of instructions and their formats.

Why make a standard? This is so that all the participating devices agree upon a way to connect, disconnect and make VoIP calls. Even the world of regular telephones has standards. Wired phones are connected to a wall socket using a thin looking tape cable called RJ11. Mobile phones must connect using a SIM for GSM networks or a UIM for CDMA networks. It doesn’t matter which brand of phone you use or which operating system or which phone service provider. Calls go through as you expect them to and you are able to have conversations. Standards are established so that all manufacturers can agree upon a way to work with each other and that users do not have hurdles due to manufacturer differences.

Overview of SIP protocol

Image courtesy: CarrierBid
Image courtesy: CarrierBid
  1. SIP protocol specifies that VoIP calling devices must be connected over an Internet connection to a VoIP server. The calling device can be a dedicated device with physical buttons and a receiver. Or it can simply be a software application on your computer or smartphone. The server is usually located on the cloud and has a VoIP server software such as Asterisk running on it. This is analogous to your telephone being connected to a phone / mobile service provider via a wired connection / SIM / UIM.
  2. During connection, the VoIP device identifies itself to the server with a username. Credentials such as a password may need to be supplied to authenticate and complete the connection. After the connection is established, the VoIP server remembers that the connected device is where a particular user can be found. E.g. If a user X@abc.com uses his smartphone to connect to the VoIP server, then all calls incoming to X@abc.com will be automatically routed to the smartphone. This is similar to how mobile phone calls work. When someone tries to call you, your nearest mobile phone tower finds you and helps your phone ring.
  3. In VoIP, users are identified using a unique ID such as X@abc.com, similar to phone numbers in a phone network. Just like phones help you store person names against phone numbers, VoIP software / devices also let you store person names against VoIP IDs.
  4. VoIP has events equivalent to those of a phone network’s call, such as dialling, phone ringing, phone pickup and hangup.

Example SIP call sequence

A SIP-based VoIP call in action. Image courtesy: Askozia
A SIP-based VoIP call in action. Image courtesy: Askozia
  1. The VoIP device / app connects to a VoIP server using a REGISTER instruction. The server acknowledges the connection. Authentication may be required to complete the connection. Let’s assume that in our story, a user named arjun@comsystems.in has connected to a VoIP server voip.comsystems.in.
  2. Arjun wants to call Bindia at the company, Teltrac. So he uses his VoIP device to call her. He may dial the ID bindia@teltrac.in (similar to manually entering a phone number on a phone), or simply click on her name if he has stored her VoIP ID on his phone.
    When he does so, an INVITE message is sent to the server voip.comsystems.in. The server sees that the call is intended for a user at teltrac.in. So the server forwards the call to the VoIP server at Teltrac. This is similar to the way that you can dial phones on networks different from yours or the way you can send emails between Gmail and Yahoo.
  3. Teltrac’s VoIP server receives the INVITE message. It checks if Bindia has connected already. Hopefully, Bindia followed step 1 just like Arjun did. Otherwise a ‘user unavailable’ message is returned and Arjun’s call is rejected.
  4. If Bindia is connected, then Teltrac’s VoIP server sends the INVITE message to her VoIP device. The INVITE message includes the sender’s details, so that when Bindia’s device receives the INVITE message, it rings and shows up Arjun’s name as the caller. While the device is ringing, it sends a RINGING message to the server, which is funnelled to Arjun’s device via his server.
  5. When Bindia picks up, an OK message is sent back to her server, Arjun’s server and Arjun’s device. The two devices then exchange some information using a format called SDP or Session Description Protocol. This information is used by the two devices to agree upon an audio format (such as 3GP) and a video format in case of a video call.
  6. An RTP (Real Time Protocol) connection is established between the two devices through the two servers. This connection is used to send / receive audio and video in either directions, using the audio and video formats agreed upon.
  7. Either of the two sides can hang up the call, in which case, a BYE request is sent and channelled through the two servers to the other side. The other side responds with an OK acknowledgement.

Popular software for VoIP using SIP

Common apps used for VoIP calls are: Ekiga (Linux, Windows, Mac), Zoiper (Windows) and LinPhone (Linux, Windows, Mac, Android). Android’s phone dialer app itself supports SIP calls. iOS too allows SIP calls via its phone app through a feature called Wi-Fi calling. However, you need not use the phone dialer on either platforms. You can search the Play Store or App Store to find hundreds of SIP calling apps for both platforms.

Home screen of LinPhone. Image courtesy: Krify
Home screen of LinPhone. Image courtesy: Krify

Usually, you will subscribe to a VoIP service (either free or paid) and won’t need to bother setting up your own server. But in case you need to, then have a look at OpenSIPS or Asterisk.

If you are looking to automate SIP calls from devices using sensors, e.g. your fire alarm calling your VoIP device, then you should look for an app in the app store supported by the device manufacturer. E.g. RaspBerry Pi supports SIP calling using LinPhone or Yate.

However, as mentioned before, SIP is an openly published protocol and if all else fails, you can write your own app from scratch for the platform of your choice. This may be needed for your own custom device requiring automation.

This blog post on New Fangled Networks is another good read on the topic of VoIP.

Conclusion

We saw how SIP protocol makes it possible to perform VoIP calls in a sequence very similar to phone calls. But there are more advantages to VoIP than with a standard phone. Customisation, security and flexibility will make VoIP as commonplace in the future as phones are today.

 

[subscribe_form]

Leave a Reply

Your email address will not be published.