You are on page 1of 22

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.

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

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

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

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

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

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

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

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

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

From header field contains a tag parameter which serves as a dialog identifier and will be described in Section 1.37. A SIP request can contain one or more Via header fields which are used to record path of the request.100 and port 5060. CSeq is used to maintain order of requests. 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.1. They are later used to route SIP responses exactly the same way.org is called Request URI and contains URI of the next hop of the message. Other important requests are: • ACK--This message acknowledges receipt of a final response to INVITE. 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).org. Such messages have the same Call-ID identifier. From the Via field we can tell that the user agent is running on host 195. 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 body of the INVITE request contains a description of the media type accepted by the sender and encoded in SDP. The URI on the first line--sip:7170@iptel. a sequence number must be present in the messages so that recipient can identify retransmissions and out of order requests. Because requests can be sent over an unreliable transport that can re-order messages.77. In this case it will be host iptel. Message header is delimited from message body by an empty line. Establishing of a session utilizes 3-way hand-shaking due to asymmetric nature of the invitation.Chapter 1. Call-ID header field is a dialog identifier and it’s purpose is to identify messages belonging to the same call. Other header fields are not important and will be not described here.6. 1. The INVITE message contains just one Via header field which was created by the user agent that sent the request. 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.4. Contact header field contains IP aaddress and port on which the sender is awaiting further requests sent by callee. 8 .

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

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

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

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

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

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

1. See 180 Ringing response in the call flow.7. See Figure 1-10. left message flow.2. Session Termination Session termination is accomplished by sending a BYE request within dialog established bye INVITE. 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. The response is generated when callee’s phone starts ringing. Figure 1-9. The other party sends a 200 OK response to confirm the BYE and the session is terminated. 15 . The session is established at this point. Party wishing to tear down a session sends a BYE request to the other party involved in the session.Chapter 1. SIP Introduction 1.3.7. Session Invitation A session invitation consists of one INVITE request which is usually sent to a proxy. The proxy sends immediately a 100 Trying reply to stop retransmissions and forwards the request further. 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.4. All provisional responses generated by callee are sent back to the caller.7.

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

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

SIP Introduction 18 .Chapter 1.