SIP Introduction

Jan Janak

SIP Introduction
by Jan Janak
Copyright © 2003 FhG FOKUS

A brief overview of SIP describing all important aspects of the Session Initiation Protocol.

........................................................................................ SIP Network Elements ............... 13 1...................... 10 1.............7........................ Session Invitation....5.......3................ Record Routing.............. 17 iii ..........................................................................2.............3........................................................ SIP Dialogs.............. Session Termination...........1.........................4........................................ Typical SIP Scenarios...........1................ 15 1................................................................................ 2 1......................................................... 15 1............................................1.................................................................................................................................. 2 1................... 9 1..................7..............................7................................................................................................................2................................................................... 6 1................... SIP URI ..................................................................1...................................... SIP Introduction.................. 1 1.................... Event Subscription And Notification................ SIP Messages...... Purpose of SIP ..................6....... 3 1..........5......................................................6.................................................... SIP Transactions.................................................................................................. 13 1... 5 1..............................................3..........................................2..............................................................................3........................................................ 16 1.................... 14 1..........................3..............................................................4... 1 1........2........................ SIP Responses................................ 14 1..............................................Table of Contents 1........................... Instant Messages..........................7..................................4............................................................2.............7...................................................................................... Dialog Identifiers .... 14 1...........................6................ 1 1.......................3.........................3.......................................................................... User Agents ......... Dialogs Facilitate Routing .......................... 7 1..................... SIP Requests ................................................... 12 1....... 8 1... Redirect Server ............1... Proxy Servers............................................................................................................6....7....................................................4....4..................................7...................................................................................................................... Registrar. Registration..............................................................

................................................................................... 15 1-10........................... Session Invitation. SIP Redirection.......... Instant Messages............................................................................................................................................................................................................................................................................................... SIP Trapezoid ................................................................................... 17 iv ........... UAC and UAS ............List of Figures 1-1......... 5 1-4....................................................................................... BYE Message Flow (With and without Record Routing) .................................................................................................. REGISTER Message Flow ................................ SIP Dialog................................................................................................. 13 1-8. 2 1-2......................................... SIP Transactions ............................................................................................................... Event Subscription And Notification............................................................................................................................................... 11 1-6.......... Registrar Overview........................................................................................................................ 12 1-7.............................................................................................................. 14 1-9....................................................................................... INVITE Message Flow..................................................................... 16 1-11................................. 16 1-12... 6 1-5.................... 4 1-3................

org/rfc/rfc3261. multimedia conferences. It is an end-to-end oriented signalling protocol which means. distribution of multimedia. HTTP is probably the most successful and widely used protocol in the Internet.txt). SIP is based on HTTP protocol. negotiation of codecs used to encode media so all the participants will be able to decode it. SIP Introduction 1. The HTTP protocol inherited format of message headers from RFC822 (http://www. distributed computer games. SIP has been designed in conformance with the Internet model. good scalability. It is not meant to be a general purpose protocol. and terminating sessions with one or more participants. which is used to describe and encode capabilities of session participants. there is no single point of failure and networks designed this way scale well. Such a description is then used to negotiate the characteristics of the session so that all the devices can participate (that includes. The specification is available in form of several RFCs. etc. SIP is not the only protocol that the communicating devices will need.org/rfc/rfc822. Aim of SIP is to provide the same functionality that the traditional PSTNs have.org). Examples of a session can include Internet telephone calls.ietf. Purpose of SIP SIP stands for Session Initiation Protocol. The price that we have to pay for the distributiveness and scalability is higher message overhead. In fact. The encoding has proven to be robust and flexible over the years.ietf. but the end-to-end design makes SIP networks much more powerful and open to the implementation of new services that can be hardly implemented in the traditional PSTNs.txt). Two protocols that are most often used along with SIP are RTP and SDP. It tries to combine the best of the both. the description is encoded into a document using SDP. video. and text). Another important protocol is SDP. By sessions we understand a set of senders and receivers that communicate and the state kept in those senders and receivers during the communication. modifying. Both protocols (HTTP and SIP) have inherited encoding of message headers from RFC822 (http://www. because user agents use the protocol to tell a HTTP server in which documents they are interested in. The protocol is used for creating. State is also stored in end-devices only. Purpose of SIP is just to make the communication possible. and flexibility in mind. The protocol has been designed with easy implementation.txt) which contains the core protocol specification. the communication itself must be achieved by another means (and possibly another protocol). negotiation of transport protocol used and so on).ietf. HTTP can be classified as a signalling protocol too. 1 . that all the logic is stored in end devices (except routing of SIP messages).ietf.org/rfc/rfc822. It is worth of mentioning that the end-to-end concept of SIP is a significant divergence from regular PSTN (Public Switched Telephone Network) where all the state and logic is stored in the network and end devices (telephones) are very primitive. the most important one is RFC3261 (http://www. the protocol makes it possible to encode and split the data into packets and transport such packets over the Internet. It is an application-layer control protocol which has been developed and designed within the IETF (http://www.1. SIP is used to carry the description of session parameters. RTP protocol is used to carry the real-time multimedia data (including audio.Chapter 1. caused by the messages being sent end-to-end. for example.

but user agents can be also cellular phones. In this case the callee’s user agent (sending BYE) behaves like UAC and the caller’s user agent behaves like UAS. registrars. UAS is the part of the user agent that receives requests and sends responses. and redirect servers. to increase the speed of processing. User agents usually. a typical SIP network will contain more than one type of SIP elements. sip:joe@company. 2 . As we can see. Basic SIP elements are user agents.com. User Agents Internet end points that use SIP to find each other and to negotiate a session characteristics are called user agents. for instance.1.3. Note that the elements. PSTN gateways. 1. Callee’s user agent behaves like a UAS when it receives the INVITE and sends responses. User agents are often reffered to as User Agent Server (UAS) and User Agent Client (UAC). SIP URIs are similar to e-mail addresses.3. we often say that a user agent behaves like a UAC or UAS. are often only logical entities. UAC is the part of the user agent that sends requests and receives responses. SIP URI consists of username part and domain name part delimited by @ (at) character. SIP URI SIP entities are identified using SIP URI (Uniform Resource Identifier). We will briefly describe them in this section. automated IVR systems and so on. for instance. SIP Introduction 1. as presented in this section. such URIs are easy to remember. A SIP URI has form of sip:username@domain. for instance. proxies. but that depends on a particular implementation and configuration. reside on a user’s computer in form of an application--this is currently the most widely used approach. PDAs. but not necessarily. 1. Because a user agent contains both UAC and UAS. each user agent contains a UAC and UAS. SIP Network Elements Although in the simplest configuration it is possible to use just two user agents that send SIP messages directly to each other. It is often profitable to co-locate them together. possible to use the same URI for e-mail and SIP communication. it is. But this situation changes when the callee decides to send a BYE and terminate the session.Chapter 1. UAS and UAC are logical entities only. For instance. caller’s user agent behaves like UAC when it sends an INVITE requests and receives responses to the request.2.

3. User agents can send messages to a proxy server.2. each of them is responsible for one branch. SIP Introduction Figure 1-1. accounting and many other important functions. At this time the user agent that was previously UAS becomes a UAC and vice versa. Each user agent contains UAC and UAS. Proxy Servers In addition to that SIP allows creation of an infrastructure of network hosts called proxy servers. authentication. Such a proxy will forward the session invitation directly to the callee and the callee will then accept or decline the session invitation. In our example callee B picked up and later when he wants to tear down the call it sends a BYE. 3 . The part of the proxy that receives the INVITE from the caller in fact acts as a UAS. 1. UAC and UAS Figure 1-1 shows three user agents and one stateful forking proxy. When forwarding the request statefully the proxy creates two UACs. There are two basic types of SIP proxy servers--stateless and stateful. The most important task of a proxy server is to route session invitations “closer” to callee. They perform routing of a session invitations according to invitee’s current location. Proxy servers are very important entities in the SIP infrastructure.Chapter 1. The session invitation will usually traverse a set of proxies until it finds one which knows the actual location of the callee.

They often perform accounting. for instance.2. forking. Although messages are usually arranged into transactions (see Section 1. Stateful proxies can perform forking. Because stateful proxies must maintain the state for the duration of the transactions. It is. Stateful proxies can perform more complicated methods of finding a user. 1. Stateless Servers Stateless server are simple message forwarders. for instance) has it’s own SIP proxy server which is used by all user agents in the entity. Stateful Servers Stateful proxies are more complex. Let’s suppose that there are two companies A and B and each of them has it’s own proxy server. message translators and routers. Most SIP proxies today are stateful because their configuration is usually very complex. stateless proxies do not take care of transactions. Upon reception of a request. especially those created by INVITE. The ability to associate SIP messages into transactions gives stateful proxies some interesting features. forking or recursive traversal. Figure 1-2 shows how a session invitation from employee Joe in company A will reach employee Bob in company B. They can be used as simple load balancers. can last quite long (until callee picks up or declines the call). Stateless proxies are simple.Chapter 1.3. One of drawbacks of stateless proxies is that they are unable to absorb retransmissions of messages and perform more advanced routing. They forward messages independently of each other. from the transaction state.3.2. Stateful proxies can absorb retransmissions because they know.2.1. 1. possible to try to reach user’s office phone and when he doesn’t pick up then the call is redirected to his cell phone.3. that means upon reception of a message two or more messages will be sent out. Stateless proxies can’t do this because they have no way of knowing how the transaction targeted to the office phone finished.5). stateful proxies create a state and keep the state until the transaction finishes. their performance is limited.2. SIP Introduction 1. if they have already received the same message (stateless proxies cannot do the check because they keep no state). but faster than stateful proxy servers. for instance. Some transactions. Proxy Server Usage A typical configuration is that each centrally administered entity (a company. some sort of NAT traversal aid and all those features require a stateful proxy. 4 .3.

3.3.com or the proxy will use DNS SRV records to find B’s proxy server.4:5060 and will send the invitation there. which has IP address 1. A registrar is very often a logical entity only.2.a. 5 . The proxy knows that Bob is currently sitting in his office and is reachable through phone on his desk.bo.com is in a different company so it will look up B’s SIP proxy server and send the invitation there.3.com it will search the location database.2.a.org and contact address sip:jan@1.3. The registrar is a special SIP entity that receives registrations from users.2.com to call Bob. If everything went well then the registrar sends a 200 OK response to the phone and the process of registration is finished. extracts information about their current location (IP address. A REGISTER message containing Address of Record sip:jan@iptel. port and username in this case) and stores the information into location database. Registrar We mentioned that the SIP proxy at proxy. 1.3. The proxy server figures out that user sip:bob@b. It finds sip:bob@1.b. B’s proxy server can be either preconfigured at proxy.4 is IP address of the phone. Session Invitation User Joe uses address sip:bob@b.4:5060.3. are usually co-located with proxy servers. is sent to the registrar.com.com.com to something like sip:bob@1.4.4:5060 where 1. The registrar extracts this information and stores it into the location database. Purpose of the location database is to map sip:bob@b.2. The invitation reaches proxy. The location database is then used by B’s proxy server. Because of their tight coupling with proxies registrars.com knows current Bob’s location but haven’t mentioned yet how a proxy can learn current location of a user.Chapter 1. When the proxy receives an invitation for sip:bob@b. Bob’s user agent (SIP phone) must register with a registrar.3. SIP Introduction Figure 1-2.2. Joe’s user agent doesn’t know how to route the invitation itself but it is configured to send all outbound traffic to the company SIP proxy server proxy. so the proxy will send the invitation there. Figure 1-3 shows a typical SIP registration.

Redirect Server The entity that receives a request and sends back a reply containing a list of the current location of a particular user is called redirect server. 6 . The originator of the request then extracts the list of destinations and sends another request directly to them.3. 1. Registrar Overview Each registration has a limited lifespan. The user agent must refresh the registration within the lifespan otherwise it will expire and the user will become unavailable. A redirect server receives requests and looks up the intended recipient of the request in the location database created by a registrar. Expires header field or expires parameter of Contact header field determines for how long is the registration valid. It then creates a list of current locations of the user and sends it to the request originator in a response within 3xx class. SIP Introduction Figure 1-3.4.Chapter 1. Figure 1-4 shows a typical redirection.

realm="iptel.iptel.org>.org".128. response="53fe98db10e1074 b03b3e06438bda70f" Content-Type: application/sdp Content-Length: 451 v=0 o=jku2 0 0 IN IP4 213. SIP Introduction Figure 1-4. algorithm="MD5".20.100:5040.20.0 Via: SIP/2.0/UDP 195.0 Proxy-Authorization: Digest username="jiri".128.37. SIP Messages Communication using SIP (often called signalling) comprises of series of messages. message header.org> Call-ID: d10815e0-bf17-4afa-8412-d9130a793d96@213.iptel. Each message consist of “first line”.35:9315> User-Agent: Windows RTC/1. Requests are usually used to initiate some action or inform recipient of the request of something.35 s=session c=IN IP4 213.Chapter 1.rport Max-Forwards: 10 From: "jiri" <sip:jiri@iptel.35 CSeq: 2 INVITE Contact: <sip:213.org".128.77.35 b=CT:1000 7 . Replies are used to confirm that a request was received and processed and contain the status of the processing. nonce="3cef753900000001771328f5ae1b8b7f0d742da1feb5753c". A typical SIP request looks like this: INVITE sip:7170@iptel.4. uri="sip:jiri@bat. Messages can be transported independently by the network.tag=76ff7a07-c091-4192-84a0-d56e91fe104f To: <sip:jiri@bat.org SIP/2. There are two types of messages--requests and responses. The first line identifies type of the message.20. Usually they are transported in a separate UDP datagram each.128.20. and message body. SIP Redirection 1.

From the Via field we can tell that the user agent is running on host 195. Establishing of a session utilizes 3-way hand-shaking due to asymmetric nature of the invitation. The INVITE message contains just one Via header field which was created by the user agent that sent the request. Contact header field contains IP aaddress and port on which the sender is awaiting further requests sent by callee. Other important requests are: • ACK--This message acknowledges receipt of a final response to INVITE. From header field contains a tag parameter which serves as a dialog identifier and will be described in Section 1. It may take a while before the callee accepts or declines the call so the callee’s user agent periodically retransmits a positive final response until it receives an ACK (which indicates that the caller is still there and ready to communicate). The URI on the first line--sip:7170@iptel. Such messages have the same Call-ID identifier. Call-ID header field is a dialog identifier and it’s purpose is to identify messages belonging to the same call.org is called Request URI and contains URI of the next hop of the message.Chapter 1.4. From and To header fields identify initiator (caller) and recipient (callee) of the invitation (just like in SMTP where they identify sender and recipient of a message). Message header is delimited from message body by an empty line.org.1. a sequence number must be present in the messages so that recipient can identify retransmissions and out of order requests. A SIP request can contain one or more Via header fields which are used to record path of the request. SIP Introduction t=0 0 m=audio 54742 RTP/AVP 97 111 112 6 0 8 4 5 3 101 a=rtpmap:97 red/8000 a=rtpmap:111 SIREN/16000 a=fmtp:111 bitrate=16000 a=rtpmap:112 G7221/16000 a=fmtp:112 bitrate=24000 a=rtpmap:6 DVI4/16000 a=rtpmap:0 PCMU/8000 a=rtpmap:4 G723/8000 a=rtpmap: 3 GSM/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 The first line tells us that this is INVITE message which is used to establish a session. CSeq is used to maintain order of requests. They are later used to route SIP responses exactly the same way.100 and port 5060.77. Because requests can be sent over an unreliable transport that can re-order messages. 8 .37.6. SIP Requests We have described how an INVITE request looks like and said that the request is used to invite a callee to a session. Message body of the INVITE request contains a description of the media type accepted by the sender and encoded in SDP. Other header fields are not important and will be not described here. 1. In this case it will be host iptel.

68 req_src_port=5060 in_uri=sip:iptel.87. Registrar extracts this information and puts it into a location database.4.101:5060 "Noisy feedback tells: pid=5110 req_src_ip=66.org To: sip:sip2@iptel. and reason phrase.1. In addition to that many other request types have been defined but their description is out of the scope of this document.168.37.77.expires=120 Server: Sip EXpress router (0.87.2.0). A party wishing to tear down a session sends a BYE to the other party.11pre21xrc (i386/linux)) Content-Length: 0 Warning: 392 195.1.b713 Call-ID: 2443936363@192.received=66.0 200 OK Via: SIP/2. A provisional response is response that tells to its recipient that the associated request was received but result of the processing is not known yet. Registrations are time-limited and need to be periodically refreshed. • REGISTER--Purpose of REGISTER request is to let registrar know of current user’s location. The reply code is an integer number from 100 to 699 and indicates type of the response. A typical reply looks like this: SIP/2. The sender must stop retransmitting the request upon reception of a provisional response.48. The listed requests usually have no message body because it is not needed in most situations (but can have one).00.org via_cnt==1" As we can see. Typically proxy servers send responses with code 100 when they start processing an INVITE and user agents send responses with code 180 (Ringing) which means that the callee’s phone is ringing.48.48. 1.transport=udp>.q=0. SIP Introduction • BYE--Bye messages are used to tear down multimedia sessions.168. 9 . The first line of response contains protocol version (SIP/2.org out_uri=sip:iptel. There are 6 classes of responses: • 1xx are provisional responses.87.Chapter 1. The database can be later used by SIP proxy servers to route calls to the user.30 CSeq: 63629 REGISTER Contact: <sip:sip2@66.org.68:5060.tag=794fe65c16edfdf45da4fc39a5d2867c. • CANCEL--Cancel is used to cancel not yet fully established session. Each request must be replied except ACK requests which trigger no replies. Provisional responses are sent only when the processing doesn’t finish immediately.8. Information about current IP address and port on which a user can be reached is carried in REGISTER messages. reply code.30:5060. It is used when the callee hasn’t replied with a final response yet but the caller wants to abort the call (typically when a callee doesn’t respond for some time). responses are very similar to the requests.0/UDP 192. except for the first line. SIP Responses When a user agent or proxy server receives a request it send a reply.68 From: sip:sip2@iptel.

Redirection responses are usually sent by proxy servers. A redirection response gives information about the user’s new location or an alternative service that the caller might use to satisfy the call. Final responses also terminate transactions. A transaction is a sequence of SIP messages exchanged between SIP network elements. The request to which a particular response belongs is identified using the CSeq header field. 10 . 1. It is not very human-friendly but it is very easy to parse and understand by machines. SIP Introduction • 2xx responses are positive final responses. Therefore final responses express result of the processing of the associated request. Each response represents a distinct dialog with unambiguous dialog identifier. Clients should usually retry the request later. Therefore SIP is said to be a transactional protocol. For instance a 200 OK response is sent when a user accepts invitation to a session (INVITE request). • 5xx means that the problem is on server’s side. When a proxy receives a request and doesn’t want or can’t process it for any reason. 3xx responses are final. A UAC may receive several 200 messages to a single INVITE request. It can be the location of another proxy or the current location of the callee (from the location database created by a registrar). they are usually arranged into transactions by user agents and certain types of proxy servers. The code number is intended to be processed by machines.Chapter 1. The request couldn’t be processed because it contains bad syntax or cannot be fulfilled at that server. In addition to the response class the first line also contains reason phrase. A final response is the ultimate response that the originator of the request will ever receive. it will send a redirection response to the caller and put another location into the response which the caller might want to try. • 6xx reply code means that the request cannot be fulfilled at any server. The reason phrase usually contains a human-readable message describing the result of the processing. The caller is then supposed to re-send the request to the new location. This is because a forking proxy (described later) can fork the request so it will reach several UAS and each of them will accept the invitation. • 3xx responses are used to redirect a caller. That includes zero or more provisional responses and one or more final responses (remember that an INVITE might be answered by more than one final response when a proxy server forks the request). A transaction consists of one request and all responses to that request. This response is usually sent by a server that has definitive information about a particular user. User agents usually send a 603 Decline response when the user doesn’t want to participate in the session. • 4xx are negative final responses. Responses with code from 200 to 299 are positive responses that means that the request was processed successfully and accepted. The request is apparently valid but the server failed to fulfill it.5. a 4xx response means that the problem is on the sender’s side. A user agent should render the reason phrase to the user. In our example it was REGISTER request. In addition to the sequence number this header field also contains method of corresponding request. In this case each response is distinguished by the tag parameter in To header field. SIP Transactions Although we said that SIP messages are sent independently over the network.

org/rfc/rfc2543. Also note that only responses to INVITE are retransmitted ! SIP entities that have notion of transactions are called stateful.txt) the way of calculating transaction identifiers was completely changed. Branch parameter of Via header fields contains directly the transaction identifier. If the final response was a 2xx response then the ACK is not considered part of the transaction.ietf. Instead of complicated hashing of important header fields a SIP message now includes the identifier directly. To be able to do it it must extract a unique transaction identifier from the message and compare it to identifiers of all existing transactions. In the new RFC3261 (http://www. When a request or response comes. Therefore user agents take responsibility in this case and retransmit 200 OK responses until they receive an ACK.Chapter 1. They must be backwards compatible. a stateful entity tries to associate the request (or response) to existing transactions. This proved to be very slow and complex.txt) the transaction identifier was calculated as hash of all important message header fields (that included To. during interoperability tests such transaction identifiers used to be a common source of problems. If such a transaction exists then it’s state gets updated from the message. SIP Transactions 11 . Figure 1-5 shows what messages belong to what transactions during a conversation of two user agents. Such entities usually create a state associated with a transaction that is kept in the memory for the duration of the transaction. The reason for this separation is the importance of delivery of all 200 OK messages. From.ietf. As we can see this is quite asymmetric behavior--ACK is part of transactions with a negative final response but is not part of transactions with positive final responses. SIP Introduction If a transaction was initiated by an INVITE request then the same transaction also includes ACK. This is significant simplification. but there still exist old implementations that don’t support the new way of calculating of transaction identifier so even new implementations have to support the old way. but only if the final response was not a 2xx response.org/rfc/rfc3261. Request-URI and CSeq). Not only that they establish a session. but also 200 OK can be generated by multiple entities when a proxy server forks the request and all of them must be delivered to the calling user agent. Figure 1-5. In the previous SIP RFC2543 (http://www.

SIP Introduction 1. One could also say that a dialog is a sequence of transactions.Chapter 1. that one transaction includes INVITE and it’s responses and another transaction includes BYE and it responses when a session is being torn down. because it will be later followed by BYE request which will tear down the session established by the INVITE. SIP Dialogs We have shown what transactions are. the CSeq number identifies a transaction within a dialog because we have said that requests and associated responses are called transaction. That is easier to implement because user agent don’t have to keep the dialog state. 12 . and To tag. But we feel that those two transactions should be somehow related--both of them belong to the same dialog. This means that only one transaction in each direction can be active within a dialog. in fact it is used to order messages within a dialog. A dialog persists for some time and it is very important concept for user agents. SIP Dialog Some messages establish a dialog and some do not. For instance. In fact. Dialogs facilitate proper sequencing and routing of messages between SIP endpoints. This allows to explicitly express the relationship of messages and also to send messages that are not related to other messages outside a dialog. INVITE message establishes a dialog. We have shown that CSeq header field is used to order messages. Messages that have these three identifiers same belong to the same dialog.6. The number must be monotonically increased for each message sent within a dialog otherwise the peer will handle it as out of order request or retransmission. Figure 1-6. Dialogs are identified using Call-ID. This BYE is sent within the dialog established by the INVITE. From tag. A dialog represents a peer-to-peer SIP relationship between two user agents. Figure 1-6 extends Figure 1-5 to show which messages belong to the same dialog.

such a request doesn’t establish any dialog.com wants to talk to user sip:pete@b. Let’s suppose that user sip:bob@a. The request will be sent from proxy to proxy until it reaches one that knows current location of the callee.com) but this address doesn’t say anything about current location of the user--i.e. That’s exactly how dialogs facilitate routing. Once the request reaches the callee. This is a significant performance improvement because proxies do not see all the messages within a dialog. This process is called routing. they are used to route just the first request that establishes the dialog. SIP Introduction But if a user agent sends a MESSAGE request. He knows SIP address of the callee (sip:pete@b. 1.1. Because the user agents know location of each other. Figure 1-7 contains an example of a message within a dialog (BYE) that bypasses the proxies. Further messages within a dialog are sent directly from user agent to user agent. Any subsequent messages (even MESSAGE) will be sent independently of the previous one. SIP Trapezoid 13 . the callee’s user agent will create a response that will be sent back to the caller. let’s describe this a little bit.Chapter 1.com. Dialogs Facilitate Routing We have said that dialogs are also used to route the messages between user agents. Therefore the INVITE request will be sent to a proxy server. The original request also contained Contact header field which means that both user agents know the current location of the peer. Figure 1-7. it is not necessary to send further requests to any proxy--they can be sent directly from user agent to user agent.6. Callee’s user agent will also put Contact header field into the response which will contain the current location of the user. The direct messages are also delivered with much smaller latency because a typical proxy usually implements complex routing logic. the caller doesn’t know to which host to send the request.

Figure 1-8 shows an example of registration. 1. Call-ID is so called call identifier. Typical SIP Scenarios This section gives a brief overview of typical SIP scenarios that usually make up the SIP traffic. A call consists of one or more dialogs. 1. From tag. It must be a unique string that identifies a call. From tag is generated by the caller and it uniquely identifies the dialog in the caller’s user agent.2. This hierarchical dialog identifier is necessary because a single call invitation can create several dialogs and caller must be able to distinguish them. REGISTER Message Flow 14 .7. but it is not that clear why are dialog identifiers created exactly this way and who contributes which part. Figure 1-8. and To tag.6. A registration comprises a REGISTER message followed by a 200 OK sent by registrar if the registration was successful. To tag is generated by a callee and it uniquely identifies. All such dialogs are part of the same call and have the same Call-ID. Registration Users must register themselves with a registrar to be reachable by other users. just like From tag. Dialog Identifiers We have already shown that dialog identifiers consist of three parts. Registrations are usually authorized so a 407 reply can appear if the user didn’t provide valid credentials.Chapter 1. Each user agent that sends a 2xx establishes a separate dialog with the caller.1. SIP Introduction 1. Multiple user agents may respond to a request when a proxy along the path forks the request. Call-Id. the dialog in the callee’s user agent.7.

2. Figure 1-9. SIP Introduction 1.7. Session Invitation A session invitation consists of one INVITE request which is usually sent to a proxy. left message flow.3. Party wishing to tear down a session sends a BYE request to the other party involved in the session. See 180 Ringing response in the call flow. The proxy sends immediately a 100 Trying reply to stop retransmissions and forwards the request further. The response is generated when callee’s phone starts ringing. INVITE Message Flow A 200 OK is generated once the callee picks up the phone and it is retransmitted by the callee’s user agent until it receives an ACK from the caller. All provisional responses generated by callee are sent back to the caller. The session is established at this point.Chapter 1. 15 .4. Session Termination Session termination is accomplished by sending a BYE request within dialog established bye INVITE.7. The other party sends a 200 OK response to confirm the BYE and the session is terminated. 1. See Figure 1-10.7. BYE messages are sent directly from one user agent to the other unless a proxy on the path of the INVITE request indicated that it wishes to stay on the path by using record routing (see Section 1.

Only requests outside a dialog traverse SIP proxies.5. Messages sent within a dialog will then traverse all SIP proxies that put a Record-Route header field into the message. presence information. Such a proxy would insert Record-Route header field into SIP messages which contain address of the proxy. 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. The recipient of the request receives a set of Record-Route header fields in the message. For instance.Chapter 1. Figure 1-11 shows the basic message flow. Event Subscription And Notification The SIP specification has been extended to support a general mechanism allowing subscription to asynchronous events.7. 16 .7. SIP Introduction 1. proxies controlling a NAT box or proxies doing accounting need to stay on the path of BYE requests. Such evens can include SIP proxy statistics changes. 1. There are certain situations in which a SIP proxy need to stay on the path of all further messages.4. BYE Message Flow (With and without Record Routing) Left message flow of Figure 1-10 show how a BYE (request within dialog established by INVITE) is sent directly to the other user agent when there is no Record-Route header field in the message. Record Routing All requests sent within a dialog are by default sent directly from one user agent to the other. This approach makes SIP network more scalable because only a small number of SIP messages hit the proxies. Figure 1-10. The mechanism is used mainly to convey information on presence (willingness to communicate) of users. session changes and so on. 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. Right message flow show how the situation changes when the proxy puts a Record-Route header field into the message.

Subscriptions--as well as registrations--have limited lifespan and therefore must be periodically refreshed. The server sends a NOTIFY request to the user every time the event to which the user subscribed changes.7. MESSAGE requests do not establish a dialog and therefore they will always traverse the same set of proxies. At this point the dialog is established.6. Event Subscription And Notification A user agent interested in event notification sends a SUBSCRIBE message to a SIP server. NOTIFY messages are sent within the dialog established by the SUBSCRIBE. The SUBSCRIBE message establishes a dialog and is immediately replied by the server using 200 OK response. Instant Messages 17 . This is the simplest form of sending instant messages. The text of the instant message is transported in the body of the SIP request. Figure 1-12. SIP Introduction Figure 1-11. Note that the first NOTIFY message in Figure 1-11 is sent regardless of any event that triggers notifications.Chapter 1. Instant Messages Instant messages are sent using MESSAGE request. 1.

SIP Introduction 18 .Chapter 1.