Session Initiation Protocol (SIP)


Session Initiation Protocol (SIP)

SIP stack handled over the following layer and data transfer based on following Internet Media Protocol stack:

Application Layer: H.232, SIP, RTP, DNS, DHCP
Transport Layer: TCP, UDP
Internet Layer: IP
Physical Layer: ATM, V90, Ethernet, Wireless 802.11

1. Physical Layer: it can be following:
        - Ethernet LAN,
        - DSL,
        - ATM
        - Wireless 802.11 network.

2. Internet Layer: used to route the packet across the network using the destination IP address. IP offers following functionality and drawbacks with simplicity:
 -- Connection less
 -- Best-effort packet delivery protocol.
 -- IP packets can be lost
 -- IP packets can be delayed
 -- IP packets cab be received out of sequence.
 -- IP packet are not Acknowledged.

IP Address used over the public internet are assigned in blocks by the IANA (Internet Assigned Number Association  and IP address are globally unique.

3. Transport Layer: TCP/UDP/SCTP
   3.1 TCP: TCP provides following functionality:

- TCP provides the reliable
- Connection oriented transport over IP.
- TCP uses the sequence numbers
- TCP uses ACK for reliability of transfer of message.
- Lost segments retransmitted until they are successfully received
- TCP works on well know port number.


The TCP cleint sends SYN (synchronization) message to open the connection, which (SYN) contains initial sequence number, the client will use during the connection. The server respond with SYN message containing own initial sequence number, and an acknowledgement number, indicating that it received the SYN from client.  The client completes the three-way handshake with an ACK or a DATA packet with the AK flag set to the server acknowledging the server's sequence number. Now that the connection is open, either client or server can send data in DATA packets called segments.

After sending the the segment, sender starts the timer,and if it expires, sender resend the segment.FIN message use to close the TCP connection. Window size is use representing the initial maximum number of unacknowledged segments is sent.

                             TCP-Client                                                                        TCP-Server
                                   ------------------------SYN(SN_client)----------------------->
                                  <--------------SYN/AK(SN_server, SN_client)----------------
                                   ----------------------------ACK------------------------------->
                                   --------------------------------DATA-------------------------->
                                                                       ....................
                                   <--------------------------------FIN----------------------------
                                   ---------------------------------ACK--------------------------->

  3.2 UDP:

             - UDP provides the unreliable transport across the Internet. No Ack of sent datagram.
             - It does not have complexity like TCP.
             - Best effort delivery service.
           
  3.3 TLS:

           TLS is based on SSL (secure sockets layer) and uses TCP for transport. it is used in https URI schemes.
      TLS protocol have two layers:

    3.3.1 TLS Trasport protocol:
               - Used to provide the reliable and private transport,
                - It is encrypted so that third party can not intercept the data.

     3.3.2 TLS Handshake protocol:
               - Used to establish the connection
               - Negotiate the encryption keys used by TLS transport protocol and provide the authentication.

  3.4 SCTP: SCTP is  steam-based protocol. it is similar like TCP but have some advantage over the TCP.
        Advantage of SCTP:
          - Segmentation
          - multi hoaming
          - multi streaming
          - unicast protocol

 The SIP is an application layer protocol develop by IETF to setup, modify, and tear down multimedia session such as Internet telephony calls over IP.

DNS ( Domain Name Service): 
- DNS is used in the internet to map a symbolic name (like thomas.com) to an IP address (like 100.100.100.1).
- Domain is used to give the internet a human friendly feel.
- Domain names are organised in hierarchy. Each level of name is separated by the dot, with the highest level domain on the right hand side.

Address Record (A Record):
- CNAME (Canonical Name)
- MX (Mail Exchange)
- TXT (Free Form text record)
- SRV (Service Record)
- NAPTR (Naming Authority Pointer)

SIP Request Message:
- INVITE
- ACK
- BYE
- REGISTER
- OPTIONS
- CANCEL

SIP Responses: Response code are generated with Numerical Numbers
- 1xx  (Informational Class) like 100 Trying, 180 Ringing, 183 Session Progress.
- 2xx (Final Response Class) like 200 ok.
- 3xx (Forwarding Class)
- 4xx
- 5xx

SIP Call Flow:


                                                             UACa                                            UACb

INVITE              -------------------------------------->
100 Trying         ------------------------------------->
                                             <-----------------------------------     180 Ringing
                                    <-----------------------------------  200 OK
ACK                      ------------------------------------>

                  <-------------Media Session Established--------------->

                            <------------------------------------  BYE
                                       -------------------------------------> 200 OK

INVITE sip:marconi@test.org SIP/2.0
Via: SIP/2.0/UDP lab.high-voltage.org:5060;branch=z9hG4bKfw19b
Max-Forwards: 70
To: G. Marconi &lt;sip:Marconi@radio.org&gt;
From: Nikola Tesla &lt;sip:n.tesla@high-voltage.org&gt;;tag=76341
Call-ID: <a href="mailto:123456789@lab.high-voltage.org">123456789@lab.high-voltage.org</a>
CSeq: 1 INVITE
Subject: About That Power Outage...
Contact: &lt;sip:n.tesla@lab.high-voltage.org&gt;
Content-Type: application/sdp
Content-Length: 158
v=0
o=Tesla 2890844526 2890844526 IN IP4 lab.high-voltage.org
s=Phone Call
c=IN IP4 100.101.102.103
t= 0 0
m= audio 1201 RTP/AVP 0 98
a=rtpmap:0 PCMU/8000
a=rtpmap:98 AMR/8000
a=fmtp:98 mode-set=0,2,4,7

SIP is text-encoded protocol. Description of header information:
- Via contains the address at which sender is expecting to receive responses to this request. usually written as a host name that can  be resolved into an IP address using a DNS query. It also contains a branch parameter that identifies this transaction.

- Max-Forwards header field, which is initialized to some large integer and decremented by each SIP server, which receives and forwards the request, providing simple loop detection.

- From header fields, which show the originator  of the SIP request.

- TO header fields, which show the destination of the SIP request.

- Call-ID contains a globally unique identifier for this call, generated by the combination of a random string and the softphone's host  name or IP address.

The combination of the local tag (contained in the From header field), remote tag (contained in the To header field), and the Call-ID uniquely identifies the established session, known as a “dialog.”

- CSeq or Command Sequence contains an integer and a method name.  The CSeq number is incremented for each new request within a dialog and is a traditional sequence number.

The Via header fields plus the Max-Forwards, To, From, Call-ID, and CSeq header fields represent the minimum required header field set in any SIP request message.

- Contact contains a SIP or SIPS URI that represents a direct route to contact to sender. It is mandatory in invite request.

- Content-Type contains a description of the message body(SDP).

- Content-Length contains an octet (byte) count of the message body.

The 180 Ringing response has the following structure:
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP lab.high-voltage.org:5060;branch=z9hG4bKfw19b;received=100.101.102.103
To: G. Marconi <sip:marconi@radio.org>t;;tag=a53e42
From: Nikola Tesla <sip:n.tesla@high-voltage.org>;tag=76341
Call-ID:123456789@lab.high-voltage.org
CSeq: 1 INVITE
Contact: <sip:marconi@tower.radio.org>
Content-Length: 0

Via header field contains original branch parameter and additional received parameter, this parameter contains the literal IP address that the request was received from (IP address of requester from DNS).

To and From header field  are not reversed but same as INVITE, which show SIP indicates the direction of request, not the direction of message. To header now contains the tag. Response also contains the contact which have direct address of recipient.

SIP/2.0 200 OK
Via: SIP/2.0/UDP lab.high-voltage.org:5060;branch=z9hG4bKfw19b;received=100.101.102.103
To: G. Marconi <sip:marconi@radio.org>;tag=a53e42
From: Nikola Tesla <sip:n.tesla@high-voltage.org>;tag=76341
Call-ID:123456789@lab.high-voltage.org
CSeq: 1 INVITE
Contact: <sip:marconi@tower.radio.org>
Content-Type: application/sdp
Content-Length: 155
v=0
o=Marconi 2890844528 2890844528 IN IP4 tower.radio.org
s=Phone Call
c=IN IP4 200.201.202.203
t=0 0
m=audio 60000 RTP/AVP 0
a=rtpmap:0 PCMU/8000

ACK sip:marconi@tower.radio.org SIP/2.0
Via: SIP/2.0/UDP lab.high-voltage.org:5060;branch=z9hG4bK321g
Max-Forwards: 70
To: G. Marconi <sip:marconi@radio.org>;tag=a53e42
From: Nikola Tesla <sip:n.tesla@high-voltage.org>;tag=76341
Call-ID: <123456789@lab.high-voltage.org
CSeq: 1 ACK
Content-Length: 0

ACK have the same Cseq number but method is set to ACK. Branch parameter in the Via header field contains a new transaction identifiers than the invite, since an ACK sent to acknowledge a 200 OK is considered a separate transaction.This message exchange shows the SIP as an end-to-end signaling protocol.


a BYE request is sent by Marconi to terminate the media session:

BYE sip:n.tesla@lab.high-voltage.org SIP/2.0
Via: SIP/2.0/UDP tower.radio.org:5060;branch=z9hG4bK392kf
Max-Forwards: 70
To: Nikola Tesla <sip:n.tesla@high-voltage.org>;tag=76341
From: G. Marconi <sip:marconi@radio.org>;tag=a53e42
Call-ID: 123456789@lab.high-voltage.org
CSeq: 1 BYE
Content-Length: 0

The Via header field in this example is populated with Marconi’s host address and contains a new transaction identifier since the BYE is considered a separate transaction from the INVITE or ACK transactions shown previously. The To and From header fields reflect that this request is originated by Marconi, as they are reversed from the messages in the previous transaction. Tesla, however, is able to identify the dialog using the presence of the same local and remote tags and Call-ID as the INVITE, and tear down the correct media session.

SIP/2.0 200 OK
Via: SIP/2.0/UDP tower.radio.org:5060;branch=z9hG4bK392kf;received=200.201.202.203
To: Nikola Tesla &lt;sip:n.tesla@high-voltage.org&gt;;tag=76341
From: G. Marconi &lt;sip:marconi@radio.org&gt;;tag=a53e42
Call-ID: <a href="mailto:123456789@lab.high-voltage.org">123456789@lab.high-voltage.org</a>
CSeq: 1 BYE
Content-Length: 0

User Agent Client (UAC) initiates the request  and User Agent Server (UAS) generates the responses. During the call, a user agent will usally operate as both UAC and a UAS. A UA must understand any extensions listed in a Require header field in a request.

A UA should advertise its capabilities and features in any request it sends. This allows other UAs to learn of them without having to make an explicit capabilities query.
For example, the methods that a UA supports should be listed in an Allow header field.  SIP extensions should be listed in a Supported header field.
Message body types that are supported should be listed in an Accept header field.

SIP has two broad categories of URIs:
- Address of Record (AoR): corresponds to the user, it requires the database look-up and can be sent to more than one device. Usually it is populated in To, From.
- Contact: it is device URI, and typically not required the database lookup.

SIP call with the Proxy:

Marconi                         Proxy Server                           Tesla
==================================================
-------INVITE------------->
                                             ------------INVITE--------------->
                                             <---------------180 RINGING----
<------180 Ringing----------
                                              <--------------200 OK-----------
<------200 OK-------------

----------------------------------ACK-------------------------->
<=================Media Session Established=========>
<----------------------------BYE---------------------------------
-----------------------------200 OK------------------------------>

Proxy is not really in the call. It facilitates the two end points locating and contacting each other. Proxy can be used in further required message using the Record-Route header field.
Media is always end-to-end and not through the proxy.

REQUEST: 
INVITE, REGISTER, BYE, ACK, CANCEL and OPTIONS original six methods in SIP 3261.
The REFER, SUBSCRIBE, NOTIFY, MESSAGE, UPDATE, INFO, and PRACK methods are described in separate RFCs.

- INVITE: used to establish the media session b/w UAs. INVITE is always acknowledge by ACK method. If the media information contained in the ACK is not acceptable, then the called party must send a BYE

to cancel the session—a CANCEL cannot be sent because the session is already established. A media session is considered established when the INVITE, 200 OK, and ACK messages have been exchanged between the UAC and the UAS. A successful INVITE.

An INVITE sent for an existing dialog references the same Call-ID as the original INVITE and contains the same To and From tags. called a re-INVITE, the request is used to change the session characteristics or refresh the state of the dialog. The CSeq command sequence number is incremented so that a UAS can distinguish the re-INVITE from a retransmission of the original INVITE. UPDATE is sent to refersh the diagloue if media session did not established.

- BYE: The BYE method is used to terminate an established media session. Cancel is used to terminate the call which did not establish the media session. BYE can only initiated by user agents. Proxies can initiates it.

- ACK: The ACK method is used to acknowledge final responses to INVITE requests.An ACK may contain an application/sdp message body. This is permitted if the initial INVITE did not contain a SDP message body. If the INVITE contained a message body, the ACK may not contain a message body. The ACK may not be used to modify a media description that has already been sent in the initial INVITE; a re-INVITE must be used for this purpose.

- CANCEL: The CANCEL method is used to terminate pending searches or call attempts. User agent and or Proxy can generate it.

- OPTIONS: The OPTIONS method is used to query a user agent or server about its capabilities and discover its current availability. A success class (2xx) response can contain Allow, Accept, Accept-Encoding,  Accept-Language, and Supported headers indicating its capabilities.

- SUBSCRIBE: The SUBSCRIBE method [5] is used by a user agent to establish a subscription for the purpose of receiving notifications (via the NOTIFY method) about a particular event.

- NOTIFY: The NOTIFY method [5] is used by a user agent to convey information about the occurrence of a particular event.

REFER:  The REFER method is used by a user agent to request another user agent to access a URI or URL resource. The resource is identified by a URI or URL in the required Refer-To header field. the REFER is probably being used to implement a call transfer service.

- MESSAGE: The MESSAGE method  is used to transport instant messages (IM) using SIP.
- INFO: The INFO method is used by a user agent to send call signaling information to another user agent with which it has an established media session. This is different from a re-INVITE since it does not change the media characteristics of the call. The request is end-to-end, and is never initiated by proxies.

- PRACK:  The PRACK method is used to acknowledge receipt of reliably transported provisional responses. A PRACK is generated by a UAC when a provisional response has been received containing a RSeq reliable sequence number and a Supported: 100rel header. The PRACK echoes the number in the RSeq and the CSeq of the response in a RAck header

SIP/2.0 180 Ringing
Via: SIP/2.0/UDP lucasian.trinity.cambridge.edu.uk;branch=z9hG4bK452352;received=1.2.3.4
To: Descartes &lt;sip:rene.descartes@metaphysics.org&gt;;tag=12323
From: Newton &lt;sip:newton@kings.cambridge.edu.uk&gt;;tag=981
Call-ID: <a href="mailto:5@lucasian.trinity.cambridge.edu.uk">5@lucasian.trinity.cambridge.edu.uk</a>
RSeq: 314
CSeq: 1 INVITE
Content-Length: 0

PRACK sip:rene.descartes@metaphysics.org SIP/2.0
Via: SIP/2.0/UDP lucasian.trinity.cambridge.edu.uk;branch=z9hG4bKdtyw
Max-Forwards: 70
To: Descartes &lt;sip:rene.descartes@metaphysics.org&gt;;tag=12323
From: Newton &lt;sip:newton@kings.cambridge.edu.uk&gt;;tag=981
Call-ID: <a href="mailto:5@lucasian.trinity.cambridge.edu.uk">5@lucasian.trinity.cambridge.edu.uk</a>
CSeq: 2 PRACK
RAck: 314 1 INVITE
Content-Length: 0

SIP/2.0 200 OK
Via: SIP/2.0/UDP lucasian.trinity.cambridge.edu.uk;branch=z9hG4bKdtyw ;received=1.2.3.4
To: Descartes &lt;sip:rene.descartes@metaphysics.org&gt;;tag=12323
From: Newton &lt;sip:newton@kings.cambridge.edu.uk&gt;;tag=981
Call-ID: <a href="mailto:5@lucasian.trinity.cambridge.edu.uk">5@lucasian.trinity.cambridge.edu.uk</a>
CSeq: 2 PRACK
Content-Length: 0

-UPDATE: The UPDATE method is used to modify the state of a session without changing the state of the dialog, used when offer -answer model (media session) is not completed.


Responses:
- 180 Ringing: This response is used to indicate that the INVITE has been received by the user agent and that alerting is taken place.
- 181 Call is Being Forwarded: This response is used to indicate that the call has been handed off to another end-point.
- 182 Call Queued: This response is used to indicate that the INVITE has been received, and will be processed in a queue.
- 183 Session Progress: A typical use of this response is to allow a UAC to hear ring tone, busy tone, or a recorded announcement in calls through a gateway into the PSTN.

Headers:

CSeq: The command sequence CSeq header field is a required header field in every request. The CSeq header field contains a decimal number that increases for
each request. Usually, it increases by 1 for each new request, with the exception of CANCEL and ACK requests, which use the CSeq number of the INVITE request to which it refers.

From:
The From header field is a required header field that indicates the originator of the request.A From header field may contain a tag, used to identify a particular call.

Subject:
The contents of the header field can also be displayed during alerting to aid the user in deciding whether to accept the call.

supported:
The contents of the header field can also be displayed during alerting to aid the user in deciding whether to accept the call.

Comments

Popular posts from this blog

Intelligent Networks (IN) and CAMEL

Diameter Messages

SRVCC - Single Radio Voice Call Continuity