Friday, 25 January 2013

           SIP Interview Questions and Answers


SIP is Session Initiation Protocol that can establish, modify, and terminate multimedia sessions (conferences) such as Internet telephony calls. SIP can also invite participants to already existing sessions, such as multicast conferences. Media can be added to (and removed from) an existing session.
Here I am sharing some tricky SIP questions.






1. SIP Protocol belongs to which OSI layer?
A) Network Layer
B) Session Layer
C) Application Layer
D) Data Link Layer

Ans C


2. If a INVITE request by a UAC doesn't contain SDP offer then
A) INVITE Request is not valid
B) INVITE Request is valid

Ans B 
(The SDP offer can be exchanged in later stages.)



3. If a UAS rejecting an offer contained in an INVITE then

A) UAS should return a 488 (Not Acceptable Here) response.
B) UAS can't reject the offer contained by INVITE
C) INVITE request never contains a offer.
D) UAS should return a 488 (Not Acceptable Here) response SHOULD include a Warning header field value explaining why the offer was rejected.

Ans D



4. How will you recognize a looped request?

Ans) looped request can be recognized in following way:
* The Max-Forward counts is decremented to zero.
* The Expires time has elapsed.
* The server finds itself in request's VIA list including any branch parameter.
* The Server is about to proxy the request to one of the host listed in the VIA list.



5. Why ACK is separate transaction for INVITE?

Ans) The reason for this separation is rooted in importance of delivering all 200 (OK) responses to an INVITE to the UAC.
To deliver all 200 response to UAC, UAS alone takes the responsibility and UAC alone takes responsibility to acknowledge them all with ACK.
Since this ACK is only re-transmitted by the UAC, Its effectively considered its own transaction.



6. Alice calls Bob,


in this scenario what will be response of UAC (of alice)?

Ans) In this scenario, The UAC (of Alice) may continue with the session established by 2XX response, or may terminate them with BYE.
UAS of Bob will ignore the CANCEL request.



7. Why CANCEL is not be challenged?

Ans) Server should not challenge the CANCEL request, since these requests can't be resubmitted.



8. Here ACK is directly sent to Alice's SIP Phone to Bob's SIP Phone, bypassing the proxies? Why?



Ans) The endpoints have learned each other's address from the contact header fields through the INVITE/200 (OK) exchange, which was not known when the initial INVITE was sent.



9. Max-Forwards is a mandatory header field in SIP. Why? What will happen if you make Max-Forwards as a optional header? 

Ans) The Max-Forwards header field serves to limit the number of hops a request can transmitted on the way to its destination. Max-Forwards field decremented by one at each hop.
Max-Forwards field is helpful to detect loop/re-transmission.



10. What happens in below case after 20 Secs ?



Ans) The UAS core sets a timer for the number of seconds indicated in the header field value. When the timer fires, the invitation is considered to be expired. If the invitation expires before the UAS has generated a final response, a 487 (Request Terminated) response SHOULD be generated.

The UAC core also sets a timer for the number of seconds indicated int the header field value. When the timer fires and UAC didn't receive final response, a CANCEL request should be generated.




11. What are the mandatory header fields in any SIP message? Explain each mandatory header field.

Ans) Via, Max-Forwards, To, From, Call-ID, CSeq are the minimum required header fields in any SIP Message.

mandatory header

Remember, Request line is also mandatory which has Method, Request-URI and SIP Version.

12. What is the difference between Transaction, Dialog and Session? 

Ans) 
Transaction : A Transaction refers to fundamental unit of message exchange, between the SIP user agents, consist of one request and all responses to that request. It basically includes a request-response cycle.
Dialog : A peer-to-peer relationship between two use agents. It is usually created through generation of SUCCESSFUL final response.
Session : A Session refers to the exchange of media between two or more endpoints.


Transaction (1+2+3) =======> Dialog






13. Why SDP Protocol is used with SIP protocol?

Ans) SDP is short for Session Description Protocol. SDP is used to describe and encode capabilities of session participants. Such a description is then used to negotiate the characteristics of the session so all the device can participate.
(for example, it includes negotiation of codes used to encode media so all the participants will be able to decode it, negotiation of transport protocol used n so on. )


14. What is proxy server?

Ans) Proxy Server performs routing of a session invitations according to invitee's current location, authentication, accouting and many other important functions.
The most important task of a proxy server is to route session invitations closer to callee.



15. What you mean by stateless proxy servers? Why they are useful? What are drawbacks?

Ans) Stateless proxy servers are simple message forwarders. They forward messages independently of each other. Although messages are usually arranged into transactions, but stateless proxies don't take care of transactions.
Stateless proxies are simple, but faster than stateful proxy servers. they can be used as simple load balancers, message translators and routers.
The drawback of stateless proxy servers is that they are unable to absorb re-transmission of messages and perform more advanced routing for instance, forking or recursive traversal.




16. What is difference between call transfer and call redirect?

Ans) In Call Transfer, the UA first establish a dialog with the calee, and then initiates setting up a new dialog between the callee and the another UA.
In Call Redirect, the UA doesn't answer the call, but inform the callee to resend the INVITE to another SIP URI.




17. What is difference between Inside Dialog, & Outside Dialog?

Ans) Before getting into this, Lets understand how a Dialog gets establish. The Dialog-ID is constitutes with To-TAG, From-TAG and Call-ID. Means If we have all these 3 musketeers (To-TAG, From-TAG and Call-ID) while getting a request, Its Inside of the Dialog else its Outside of the Dialog.
Very good, You learn so quickly.
But What is a early Dialog state?
A Dialog established by a non-final response to a request is in the early state and it is called early dialog state.
The early dialog will be needed if the UAC needs to send a
request to its peer within the dialog before the initial INVITE
transaction completes.  Header fields present in a provisional
response are applicable as long as the dialog is in the early state
(for example, an Allow header field in a provisional response
contains the methods that can be used in the dialog while this is
in the early state). Means before INVITE transaction completes you can send any request other than new INVITE request.
When our favorite guy, Alice & Bob,
Alice send a INVITE Request to Bob, for Bob the INVITE Request is outside of the Dialog.
When Alice receives 180 response, its early Dialog state for Alice and this goes to confirmed state after 200 OK response.

After receiving 200 OK Response, any request will be inside the Dialog.




18. What is the major difference between SIP Network and old PSTN Network?

Ans) In PSTN (Public Switched Telephone Network), All the state and logic stored in the network and device(telephone) are very primitive.
Whereas SIP is used to provide the same functionality that the traditional PSTNs have, but the end-to-end design makes SIP networks much more powerful and open the implementation of new services that can be hardly implemented in traditional PSTNs.
SIP is end-to-end based design protocol, means all the logic stored in end devices (except routing of SIP messages). State is also stored in end devices only, there is no single point of failure and netwrok designed this way scale well.




19. What are the use of provisional responses? 100 Trying and 180 Ringing, both are provisional responses. What are the major differences?

Ans) Provisional responses are informational responses which are used for informational purpose and they stops the further retransmission of INVITE by a UAC.
100 Trying responses indicate that request is received by the next-hop server and stops retransmission of INVITE by a UAC. The 100 Trying responses is different from other provisional responses, in that it is never forwarded upstream by a stateful proxy.
180 Ringing responses is use to alert the UA (caller party) that other UA is receiving hte INVITE. 180 Ringing creates early Dialog state, but 100 Trying doesn't.




20. Simple Call flow in SIP?


Ans)





21. Brief introduction to SIP's layered Architecture?

Ans) We will have a brief introduction about

  • Transport Layer
  • Transaction Layer
  • Transaction User
Transport Layer defines how a client sends request and receives response and how a server receives requests and send responses over the network.
Transaction Layer, transactions are fundamental components of SIP. A transaction is a request sent by a client transaction (using the transport layer) to a server transaction, along with all responses to that request sent from server transaction back to the client.
The transaction layer handles application-layer re transmission, matching of responses to requests, and application layer time outs.
Transaction User, Each of the SIP entities, except the stateless proxy, is a transaction user.



22. What the difference between both the schemes,
SIP: username@domain.com and
SIPS: username@domain.com?

Ans) SIP uses Universal Resource Identifiers (URIs) for identifying users. A URI identifies resources on the Internet, and those used by SIP incorporate phone numbers or names in the username. At the beginning of this is SIP:, which indicates the protocol being used. This is similar to Web site addresses, which begin with HTTP: to indicate the protocol to use when accessing the site.
When the beginning of the address is with SIP: transmission is not encrypted.
Those beginning with SIPS: require encryption for the session.



23. SIMPLE stands for?

Ans) SIMPLE is short for Session Initiation Protocol for Instant Messaging and Presence Leveraging Extensions. It is an extension of SIP, and used to determine the presence of individuals on an IP network and manage messages exchanged between participants.

Instant messaging (IM) is used to communicate using text messages
in a private chat room environment. IM applications can also be used to transfer files, video, and other media and data between participants.

Presence technology is used to display the availability of contacts in a Buddy List.




24. What is the purpose of REGISTER request?
Ans) The purpose of REGISTER request is to let Registrar know user's current location. The REGISTER request carries IP address and the port number on which user is listening or can be reached. The Registrar server stores information in location database, Which can be used later by SIP proxy servers to route calls to the user.




25. A Loop and a Spiral are differ? How?
Ans) 
Loop
          A request that arrives at a proxy, is forwarded, and later arrives back at the same proxy. When it arrives the second time, its Request-URI is identical to the first time, and other header fields that affect proxy operation are unchanged, so that the proxy would make the same processing decision on the request it made the first time. Looped requests are errors, and the procedures for detecting them and handling them are described by the protocol.
Spiral
          A spiral is a SIP request that is routed to a proxy, forwarded on wards, and arrives once again at that proxy, but this time differs in a way that will result in a different processing decision than the original request. Typically, this means that the request's Request-URI differs from its previous arrival. A spiral is not an error condition, unlike a loop. A typical cause for this is call forwarding. A user calls joe@example.com. The example.com proxy forwards it to Joe's PC, which in turn, forwards it to bob@example.com. This request is proxied back to the example.com proxy. However, this is not a loop. Since the request is targeted at a different user, it is considered a spiral, and is a valid condition.




26. What is an early media? give an example.
Ans)
Early media refers to media (e.g., audio and video) that is exchanged before a particular session is accepted by the called user.  Within a dialog, early media occurs from the moment the initial INVITE is sent until the User Agent Server (UAS) generates a final response.  It may be unidirectional or bidirectional, and can be generated by the caller, the callee, or both.  Typical examples of early media generated by the callee are ringing tone and announcements (queuing status).  Early media generated by the caller typically consists of voice commands or dual tone multi-frequency (DTMF) tones to drive interactive voice response (IVR) systems.



27. What is Handshaking? Why 3-way Handshaking used in SIP for INVITE?
Ans)
Handshaking makes it possible to connect relatively heterogeneous systems or equipment over a communication channel.
Typically, 2 SIP entities negotiate communication parameters(such as codec for media - audio/video) for a brief period when a connection is first established, and thereafter use those parameters to provide optimal information (can be audio, video, text etc.) transfer over the channel as a function of its quality and capacity.
3-Way Handshaking is used in SIP, to confirm that the 200 OK response is delivered successfully to the caller party. For this confirmation ACK is send from caller party to called party.




28. SIP timers?
Ans) Here is a short summary of SIP timers :


Timer
Value
Description
T1
500ms default
RTT estimates



T2
4S
4The Max retransmit interval for non-INVITE Request & Response



T4
5S
Max Duration a message will remain in the network



Timer A
Initially T1
INVITE Request retransmit interval, for UDP Only



Timer B
64*T1
INVITE transaction timeout timer



Timer D
>32s for UDP
0 for TCP/SCTP
Wait time for response retransmit



Timer E
Initially T1
NON-INVITE transaction retransmit interval, UDP Only



Timer F
64*T1
NON-INVITE transaction timeout timer



Timer G
Initially t1
INVITE response retransmission interval



Timer H
64*T1
Wait time for ACK receipt



Timer I
T4 for UDP
0 forTCP/SCTP
Wait time for ACK retransmits



Timer J
64*T1 for UDP
0s for TCP/SCTP
Wait time for NON-INVITE request retransmits



Timer K
T4 for UDP
0s for TCP/SCTP
Wait time for response retransmits


29. All requests sent __________ are by default sent directly from one user agent to the other user agent.
Only requests ____________ traverse SIP proxies (by default).
Ans) Hint, SIP dialog.
within a dialog.
outside a dialog.



30. What is the use of Registrar Server and Redirect Server?
Ans) A Registrar Server is a SIP endpoint that accepts REGISTER requests and places the information it receives in those requests into a location service for the domain it handles. The location service links one or more IP addresses to the SIP URI of the registering agent.
SIP registrars are logical elements, and are commonly co-located with SIP proxies. But it is also possible and often good for network scalability to place this location service with a Redirect Server.



31. Why PRACK is added in SIP?
Ans) SIP defines two types of responses, provisional and final. Final responses convey the result of the request processing, and are sent reliably.  Provisional responses provide information on the progress of the request processing, but are not sent reliably in earlier.
It was later observed that reliability was important in several
cases, including interoperability scenarios with the PSTN.
Therefore, an optional capability was needed to support reliable
transmission of provisional responses. That capability is provided by PRACK (Provisional Response Acknowledgement).
In order to achieve reliability for provisional responses, Reliable provisional responses are retransmitted by the TU with an exponential backoff. Those retransmissions cease when a PRACK message is received. The PRACK request plays the same role as ACK, but for provisional responses.



32. Which request doesn't trigger any reply?
A) BYE
B) CANCEL
C) ACK
D) None of these

Ans C


33. Use of OPTION method in SIP?
Ans) OPTION method allows a UA to query another UA or a proxy server  as to its capabilities. So basically OPTION method allows a client to discover information about the supported methods, content types, extensions, codec etc. without "Ringing" the other party.


34. What you understand by Record Routing?
Ans) Record Routing is mechanism by which a proxy can inform user agents that it wishes to stay on the path of all further messages is called record routing. Such a proxy would insert Record-Route header field into SIP messages which contain address of the proxy. Messages sent within a dialog will then traverse all SIP proxies that put a Record-Route header field into the message.

The recipient of the request receives a set of Record-Route header fields in the message. It must mirror all the Record-Route header fields into responses because the originator of the request also needs to know the set of proxies.




35. What you mean by Strict Routing and Loose Routing?
Ans) Strict Record routing according to RFC2543 rewrote the Request-URI. That means the Request-URI always contained URI of the next hop (which can be either next proxy server which inserted Record-Route header field or destination user agent). Because of that it was necessary to save the original Request-URI as the last Route header field. This approach is called strict routing.

Loose routing, as specified in RFC3261, works in a little bit different way. The Request-URI is no more overwritten, it always contains URI of the destination user agent. If there are any Route header field in a message, than the message is sent to the URI from the topmost Route header field. This is significant change--Request-URI doesn't necessarily contain URI to which the request will be sent. In fact, loose routing is very similar to IP source routing.



36. How does the UPDATE differ from re-INVITE?
Ans) First, Lets have a brief about both methods.

What the hell is this re-INVITE actually? Always confusing? Lets discover, an INVITE request sent within an existing dialog is known as a re-INVITE.  A re-INVITE is used to modify session parameters, dialog parameters, or both.

re-INVITE/INVITE
          SIP defines the INVITE method for the initiation and modification of sessions.  However, this method actually affects two important pieces of state.  It impacts the session (the media streams SIP sets up) and also the dialog (the state that SIP itself defines).

So why we need UPDATE?
       The primary difficulty is when aspects of the session need to be modified before the initial INVITE has been answered.  An example of this situation is "early media", a condition where the session is established, for the purpose of conveying progress of the call, but before the INVITE itself is accepted.  It is important that either caller or callee be able to modify the characteristics of that session (putting the early media on hold, for example), before the call is answered.  However, a re-INVITE cannot be used for this purpose, because the re-INVITE has an impact on the state of the dialog, in addition to the session.
As a result, here comes UPDATE that allows the caller or callee to provide updated session information before a final response to the initial INVITE request is generated. UPDATE can be sent by a UA within a dialog (early or confirmed) to update session parameters without impacting the dialog state itself.

The important difference between an UPDATE and a re-INVITE is
      * In the case of a re-INVITE it may impact both the session and the dialog parameters.  Conversely, an UPDATE allows session information to be updated without affecting the state of the dialog.
      * In UPDATE, either offer is accepted or ignored but the entity which receives UPDATE can't send it's allowed media parameters in the response, like what happens in 200OK for INVITE or re-INVITE.