Template is not defined.

SIP (Session Initiation Protocol) – Understanding the most popular VoIP Protocol

Introduction

SIP (Session Initiation Protocol) is a widely-used protocol for initiating and terminating real-time communication sessions over the Internet. It is an application-layer protocol that is used to set up, manage, and terminate multimedia sessions such as voice and video calls, instant messaging, and online meetings. SIP is required to be adapted for use in a decentralized environment instead of overlay infrastructure-based networks. In this article, we will dive into SIP and discuss its architecture, features, and benefits.

SIP Architecture

SIP is a client-server protocol, which means that it involves two types of entities: user agents and network servers. User agents are software applications that run on endpoints, such as phones, softphones, and computers, and they interact with the network servers to initiate and terminate SIP sessions. Network servers are servers that are responsible for routing and forwarding SIP messages between user agents.

SIP Network Architecture  

The main components of a SIP architecture are as follows:

  1. User-Agents: User agents are devices or software applications that can initiate, receive, and terminate SIP sessions. They can be classified into two types: User Agents Clients (UACs) and User Agent Servers (UASs).
    • UACs: UACs initiate SIP requests to establish a session with another user agent. Examples of UACs include softphones, SIP phones, and SIP-enabled web browsers.
    • UASs: UASs respond to SIP requests that are sent by UACs. They can accept or reject incoming calls and send SIP responses back to the UACs. Examples of UASs include SIP proxies and SIP servers.
  2. Proxy Servers: Proxy servers act as intermediaries between user agents. They receive SIP requests from UACs and forward them to the appropriate UASs. Proxy servers can also perform various tasks, such as routing requests based on predefined rules, modifying SIP headers, and authenticating users.
  3. Redirect Servers: Redirect servers are similar to proxy servers, but they do not forward SIP requests. Instead, they respond to requests with a SIP redirect message that includes the address of the appropriate UAS. The UAC then sends the SIP request directly to the UAS.
  4. Registrar Servers: Registrar servers are responsible for registering user agents with a SIP domain. When a user agent registers with a registrar server, it provides its contact information, such as its SIP address and IP address. This information is used by other user agents to locate and initiate sessions with the registered user agent.

SIP Messages

SIP uses text-based messages to initiate, modify, and terminate sessions. The main types of SIP messages are as follows:

  1. Request Messages: Request messages are sent by UACs to initiate a session. Some examples of request messages include INVITE (used to initiate a session), ACK (used to confirm that a session has been established), and BYE (used to terminate a session).
  2. Response Messages: Response messages are sent by UASs to respond to request messages. Some examples of response messages include:
    • 1xx (informational) – e.g. SIP Response 100 (Trying), SIP 180 (Ringing)
    • 2xx (success), – e.g. SIP Response 200 (OK)
    • 3xx (redirection), e.g. SIP Response 302 Moved Temporarily 
    • 4xx (client error), e.g. SIP Response 404 User not found (Number does not Exist)
    • 5xx (server error), e.g. SIP Response 504 Server Time-out – no timely response
    • 6xx (global failure). e.g. 603 Decline – Destination cannot/doesn’t wish to participate in the call
  3. Provisional Response Messages: Provisional response messages are used to provide information about the progress of a request. They are in the 1xx range and indicate that the request has been received and is being processed.
  4. ACK Messages: ACK messages are used by UACs to confirm that a response message has been received.

SIP Call Flow

A typical SIP call flow involves several steps:

SIP Call Flow between UACs and UAS
SIP Call Flow, Showing User-agent registration, Session initiation, Session acceptance, Session modification and Session termination and Accounting
  1. User-agent registration: The user agent sends a registration request to a registrar server to register its contact information.
  2. Session initiation:
    • F1 – The user agent sends an INVITE request (makes a call) to initiate a session with another user agent. In a real-world scenario, there may be more than one proxy server transmitting the INVITE (as will be shown in a later example.
    • F2 – The proxy server sends a SIP:100 Trying response immediately to the UAC caller (John) to stop the re-transmissions of the INVITE request. A 100 Trying response indicates that the request has been received by the next-hop server and that some unspecified action is being taken on behalf of this call (for example, a database is being consulted). This response, like all other provisional responses, stops retransmissions of an INVITE by a UAC. The 100 (Trying) response is different from other provisional responses, in that it is never forwarded upstream by a stateful proxy.
    • F3 – INVITE is forwarded to Jane (UAC 2).
    • F4 – Jane sends a SIP:100 Trying to inform the Proxy not to forward any more invites.
    • F5 – A SIP:180 Ring Response is initiated and then sent to the proxy
    • F6 – The Proxy Fowards the SIP:180 Ring Response to UAC 1 (Now, John can hear it ringing).
  3. Session acceptance: The receiving user agent sends a response to the INVITE request to indicate whether the session can be established.
    • F7 – Immediately Jane accepts the call, a SIP:200 OK Response is Forwarded to the Proxy Server
    • F8 – The Proxy Server forwards the SIP:200 OK Response to John (UAC1), Letting him know that Jane has Accepted the call
    • F9 – UAC1 (John) sends an ACK message to confirm that a response message sent (SIP:200 OK Response) from UAC 2 (Jane) has been received. Now, the Phone Call is active.
  4. Session modification: During the session, using the Real-time Transport Protocol, the user agents may exchange SIP messages (Audio, Video and other media formats) – That is, when the session gets established, RTP packets (conversations) start flowing from both ends. Note that SIP doesn’t handle Packets transfer, RTP does.
  5. Session termination: When the session is finished, one of the user agents sends a BYE request to terminate the session. (F11 and F12). UAC 1 and 2 send acknowledgements (F13 and 14). While Simultaneously Storing the Call Detail records (e.g. Call duration, initiation and termination time, etc). Thus a complete call cycle.

SIP Addresses

SIP addresses are used to identify user agents and other SIP entities. SIP addresses have the following format:

sip:user@domain.com:port

  • sip: indicates that the address is a SIP address.
  • user is the user ID or username of the user agent.
  • domain.com is the domain name of the SIP entity a.k.a SIP Domain.
  • port is the transport layer port number used by the SIP entity.

SIP addresses are used in SIP messages to identify the sender and receiver of the messages. They are also used in SIP requests to locate user agents and other SIP entities.

SIP Codecs

Codecs determine the compression and decompression algorithms used to transmit and receive audio and video data. Here are some commonly used audio codecs in SIP:

Audio CodecDescription
G.711It is a widely supported and uncompressed codec that provides excellent voice quality but consumes higher bandwidth. It has two variants: G.711u (also known as PCMU) and G.711a (also known as PCMA).
G.729It is a popular compressed codec that offers good voice quality with lower bandwidth requirements compared to G.711. However, it is a proprietary codec and may require licensing.
G.722It is a high-definition (HD) codec that delivers superior voice quality at higher bit rates. It is commonly used in SIP-based video conferencing and applications that require high-fidelity audio.
OpusIt is a versatile and open-source codec that supports both voice and music with low latency. Opus is known for its high audio quality and efficient compression, making it suitable for various SIP applications
AMR (Adaptive Multi-Rate)It is a codec primarily designed for mobile networks and provides good voice quality while optimizing bandwidth usage
Popular SIP Audio Codecs
Learn more about Supported Audio Codecs Translators

In addition to audio codecs, SIP also supports various video codecs for video conferencing and multimedia communication. Some commonly used video codecs include:

Video CodecDescription
H.264It is a widely adopted video codec that offers high video quality with efficient compression. H.264 is supported by most SIP-compatible devices and is commonly used in video conferencing systems.
VP8 and VP9These are open-source video codecs developed by Google. They offer good video quality and are commonly used in SIP-based video communication, particularly in web-based applications.
H.263It is an older video codec that provides moderate video quality but consumes less bandwidth compared to newer codecs.
Popular SIP Video Codecs
Learn more about Supported Video Codecs Translators

The choice of codecs in SIP can depend on factors such as network bandwidth, device capabilities, and the desired balance between audio/video quality and bandwidth usage. Both the calling parties negotiate and agree upon a mutually supported codec during the SIP signalling process to establish a media session.

SIP Features

SIP has several features that make it a popular protocol for real-time communication. Here are some of its key features:

  1. Call Setup and Teardown: SIP is used to set up and tear down real-time communication sessions between two or more parties. It uses a request-response model to initiate, modify, and terminate calls.
  2. User Mobility: SIP allows users to move between devices and locations without losing their SIP addresses or the ability to receive calls.
  3. Multimedia Support: SIP supports various multimedia types, including voice, video, instant messaging, and file transfer.
  4. Session Management: SIP enables session management by allowing users to control various aspects of a call, such as a call transfer, call hold, and call forwarding.
  5. Security: SIP supports various security mechanisms such as Transport Layer Security (TLS) and Secure Real-time Transport Protocol (SRTP) to secure communications.

SIP Benefits

SIP provides several benefits to organizations that use it for real-time communication. Here are some of its key benefits:

  1. Cost Savings: SIP is a cost-effective alternative to traditional telephone systems since it uses the Internet to transmit voice and video data. It eliminates the need for expensive hardware and dedicated circuits, resulting in significant cost savings.
  2. Scalability: SIP is highly scalable and can support thousands of users, making it an ideal solution for businesses of all sizes.
  3. Flexibility: SIP is a flexible protocol that can be used with a variety of devices and platforms, including desktops, laptops, mobile devices, and IP phones.
  4. Unified Communications: SIP can be used to enable unified communications, allowing users to communicate seamlessly across multiple channels, including voice, video, instant messaging, and email.
  5. Improved Productivity: SIP enables real-time communication, which can improve collaboration and productivity among team members.

SIP Implementations

SIP can be implemented using different software applications and systems. Here are some popular implementations of SIP:

  1. Asterisk: Asterisk is an open-source telephony platform that supports SIP and other communication protocols. It provides a wide range of features and is highly customizable.
  2. FreeSWITCH: FreeSWITCH is an open-source telephony platform that supports SIP, WebRTC, and other communication protocols. It provides high scalability and reliability.
  3. Kamailio: Kamailio is an open-source SIP server that provides high scalability and performance. It can handle thousands of simultaneous calls and supports advanced routing features.
  4. OpenSIPS: OpenSIPS is an open-source SIP server that provides high scalability and flexibility. It can be used

Table of Contents