SIP Nguyen Thi Mai Trang LIP6/PHARE Thi-Mai-Trang.Nguyen@lip6.fr UPMC/PUF - M2 Networks - PTEL 1 Outline Introduction SIP architecture SIP messages Session establishment exemples Registration UPMC/PUF - M2 Networks - PTEL 2
Introduction The idea of voice transmission over the Internet is not new Network Voice Protocol RFC 741 proposed in 1977 However, circuitswitched networks were the dominent technology for telephony Today, IP-based telephony is widely used Source: http://www.cisco.com/en/us/products/hw/phones/ps379/prod_view_selector.html UPMC/PUF - M2 Networks - PTEL 3 Multimedia Internet SDP CODEC H.323 SIP RTP DNS DHCP TCP SCTP UDP IP Signaling Media Utilities IP : Internet Protocol TCP: Transmission Control Protocol UDP: User Datagram Protocol SCTP: Stream Control Transmission Protocol SIP: Session Initiation Protocol SDP: Session Description Protocol RTP: Real Time Transport Protocol DNS: Domain Name System DHCP: Dynamic Host Configuration Protocol UPMC/PUF - M2 Networks - PTEL 4
SIP Session Initiation Protocol, RFC 3261 Standardized in 1999 by the IETF (Internet Engineering Task Force) Signaling protocol for multimedia session (e.g. telephony, videoconference) establishment, modification and termination UPMC/PUF - M2 Networks - PTEL 5 Signaling protocol Main functions Call location Contact the callee to know their willingness of accepting the call Exchange media information to establish the multimedia session Modify existing multimedia sessions Terminate existing multimedia sessions UPMC/PUF - M2 Networks - PTEL 6
Presence Allow the caller to know the presence and the preferences of the callee before making a call SIP has been extended to support the presence service Publish and register presence information Request for the delivery of presence information of a user Notify the presence of a user UPMC/PUF - M2 Networks - PTEL 7 SIP architecture (1) UA server (callee) Proxy server Proxy server UA client (caller) Registration server Location service UPMC/PUF - M2 Networks - PTEL 8
SIP architecture (2) User entity User Agent(UA) User Agent Client (UAC) The entity sending SIP requests Initialize sessions on user demandes User Agent Server (UAS) The entity responding to SIP requests Process all incoming sessions UA is as the same time UAC and UAS A SIP terminal must implement both SIP client and SIP server because it must send SIP requests (SIP client) and send SIP response (SIP server) UPMC/PUF - M2 Networks - PTEL 9 SIP architecture (3) Network entities Proxy Server Has the relay function Registration Server Register the mapping between the user identity and its IP address Redirect Server Respond to the requests by giving the IP address of the user or the location server Location Server Database containing user information Usually associated with the registration server A system of location servers provides a location service similar to a DNS server UPMC/PUF - M2 Networks - PTEL 10
SIP architecture (4) Two communication modes Direct mode Direct communication between user entities SIP is an end-to-end signaling protocol Servers are not necessary if user entities know the IP addresses each other Indirect mode Network entities relay the exchanged messages Used when the caller don t know the IP address of the callee UPMC/PUF - M2 Networks - PTEL 11 SIP messages Two message types Request (i.e. method) Messages sent by UAC to one or more UASes Response Messages sent by UAS to respond to a request Encoded using text format UPMC/PUF - M2 Networks - PTEL 12
Structure du message SIP Method + Destination/Responder URI Start line Header 1: Value 1 Header 2: Value 2 Headers Empty line X1 = parameter 1 X2 = parameter 2 Message body UPMC/PUF - M2 Networks - PTEL 13 SIP methods (i.e. requests) INVITE Initialize a communication by inviting a correspondent entity to participate ACK Acknowledge or confirm the session parameters BYE Terminate a communication OPTIONS Interrogate a SIP server, including UAS, for different information (Codecs, presence) CANCEL Cancel a request when the response has not been arrived at the entity sending the request REGISTER Allow a user to register its IP address with the registration server UPMC/PUF - M2 Networks - PTEL 14
SIP Responses 1xx Information Example: 100 Trying 2xx Success Example: 200 OK 3xx Redirection Example: 305 Use Proxy 4xx Client error Example: 400 Bad Request 5xx Server error Example: 500 Server Internal Error 6xx Global error Example: 600 Busy Everywhere UPMC/PUF - M2 Networks - PTEL 15 SIP address Each user has a SIP identity (i.e. a SIP address) under the URI (Uniform Resource Identifier) format Example: sip:alice@lip6.fr A SIP address can be associated with one or more IP addresses because of mobility UPMC/PUF - M2 Networks - PTEL 16
SDP (1) Session Description Protocol A syntax for media description Standardized in 1988 by the IETF RFC 4566 Use text encoding Used with SIP to exchange media characteristics UPMC/PUF - M2 Networks - PTEL 17 SDP (2) Describe media details v: SDP version o: message origin s: message subject c: connection t: time m: media a: attributes UPMC/PUF - M2 Networks - PTEL 18
Session establishment exemples Signaling functionalities User location Contact the user to establish a session Exchange media information to establish a session Modify an existing session Terminate an existing session Two scenarios Example 1: Session establishment in direct mode Example 2: Session establishment in indirect mode UPMC/PUF - M2 Networks - PTEL 19 Exemple 1 Direct mode tesla@high-voltage.org lab.high-voltage.org 100.101.102.103 INVITE 180 Ringing 200 OK ACK marconi@radio.org tower.radio.org 200.201.202.203 BYE 200 OK UPMC/PUF - M2 Networks - PTEL 20
INVITE (1) INVITE sip:marconi@radio.org SIP/2.0 Via: SIP/2.0/UDP lab.high-voltage.org:5060;branch=z9hg4bkfw19b Max-Forwards: 70 To: G. Marconi <sip:marconi@radio.org> From: Nikola Tesla <sip:n.tesla@high-voltage.org>;tag=76341 Call-ID: 123456789@lab.high-voltage.org CSeq: 1 INVITE Subject: About That Power Outage Contact: <sip:n.tesla@lab.high-voltage.org> Content-Type: application/sdp Content-Length: 158 v=0 o=tesla 2890844526 2809844526 IN IP4 lab.high-voltage.org s=phone Call c=in IP4 100.101.102.103 t=0 0 m=audio 49170 RTP/AVP 0 a=rtpmap:0 PCMU/8000 UPMC/PUF - M2 Networks - PTEL 21 INVITE (2) Start line Method INVITE Destination URI sip:marconi@radio.org SIP version SIP/2.0 Via: Each SIP element (terminal or server) generating or retransmitting a SIP request adds its address in a Via header SIP version and the transport protocol used (e.g. SIP/2.0/UDP) DNS name or IP address of the machine and the port number (e.g. lab.highvoltage.org:5060) to which the response can be sent Transaction ID (i.e. branch) is the same as in the request UPMC/PUF - M2 Networks - PTEL 22
INVITE (3) Max-Forwards: Similar to the TTL in IP An integer to detect loops Decreased by each SIP server receiving the message To: Destination address of the request From: Request sender address Tag A random number generated by each participant of the call Tag associated with «From» is generated by the caller Tag associated with «To» is generated by the callee UPMC/PUF - M2 Networks - PTEL 23 INVITE (4) Call-ID ID of the call A string generated by the caller followed by the host name The set Call-ID + From Tag + To Tag identifies a session called a «dialog» CSeq Sequence number of the request Increased for each request of the same type sent Via, Max-forwards, To, From, Call-ID, CSeq are mandatory headers in all SIP requests UPMC/PUF - M2 Networks - PTEL 24
INVITE (5) Contact Mandatory for INVITE SIP URI of the terminal hosting the UA of the user Allow directly contacting the user once the session is established Subject Optional for INVITE Not used by the protocol but can appear on the screen of the callee during the call alert Content-Type Specify the protocol used for the message body (e.g. SDP Session Description Protocol) Content-Length The size of the message body (e.g. 158 octets) UPMC/PUF - M2 Networks - PTEL 25 INVITE (6) Message body contains the media information provided by the caller IP address of the connection (100.101.102.103) Media type (audio) Port number (49170) Media transport protocol (RTP) Codec used (PCM loi µ) Sampling frequency (8000 Hz) UPMC/PUF - M2 Networks - PTEL 26
180 Ringing (1) SIP/2.0 180 Ringing Via: SIP/2.0/UDP lab.highvoltage.org:5060;branch=z9hg4bkfw19b;received=100.101. 102.103 To: G. Marconi <sip:marconi@radio.org>;tag=a53e42 From: Nikola Tesla <sip:n.tesla@high-voltage.org>;tag=76341 Call-ID: 123456789@lab.high-voltage.org CSeq: 1 INVITE Contact: <sip:marconi@tower.radio.org> Content-Length: 0 UPMC/PUF - M2 Networks - PTEL 27 180 Ringing (2) Response to the INVITE message Indicate that the INVITE message is received by the callee and the call alert is ongoing Start line SIP version SIP/2.0 Response code 180 Informational response (1xx) Description Ringing (suggested by the standard) All texts are possible (e.g. «Hold on, please») UPMC/PUF - M2 Networks - PTEL 28
180 Ringing (3) The headers Via, To, From, Call-ID et CSeq are copied from the INVITE message and added with callee information Via Add the «received» parameter which is the same URI of this Via header (lab.high-voltage.org) but in the format of IP address converted by the DNS If the URI contains already the IP address, the «received» parameter is not necessary To and From The values in To and From header are not inversed in the response because they indicate the direction of the request A callee tag is added Contact SIP address containing the address of the terminal where the callee can be contacted directly once the session is established UPMC/PUF - M2 Networks - PTEL 29 200 OK (1) SIP/2.0 200 OK Via: SIP/2.0/UDP lab.high-voltage.org:5060;branch=z9hg4bkfw19b;received=100.101.102.103 To: G. Marconi <sip:marconi@radio.org>;tag=a53e42 From: Nikola Tesla <sip:n.tesla@high-voltage.org>;tag=76341 Call-ID: 123456789@lab.high-voltage.org CSeq: 1 INVITE Contact: <sip:marconi@tower.radio.org> Content-Type: application/sdp Content-Length: 155 v=0 o=marconi 2890844528 2890844528 IN IP4 tower.radio.org s=phone Call c=in IP4 200.201.202.203 t=0 0 m=audio 6000 RTP/AVP 0 a=rtpmap:0 PCMU/8000 UPMC/PUF - M2 Networks - PTEL 30
200 OK (2) The OK response is sent when the callee decide to accept the call The Via, To, From, Call-ID and CSeq headers are the same as in the Ringing message The body of the OK message contains the media information of the callee UPMC/PUF - M2 Networks - PTEL 31 ACK (1) ACK sip:marconi@tower.radio.org SIP/2.0 Via: SIP/2.0/UDP lab.highvoltage.org:5060;branch=z9hg4bk321g Max-Forwards: 70 To: G. Marconi <sip:marconi@radio.org>;tag=a53e42 From: Nikola Tesla <sip:n.tesla@highvoltage.org>;tag=76341 Call-ID: 123456789@lab.high-voltage.org CSeq 1 ACK Content-Length: 0 UPMC/PUF - M2 Networks - PTEL 32
ACK (2) Acknowledgment Last message to send in session establishment Confirm that the caller received the response of the callee CSeq The same command number as in the INVITE message but with another method name Via The «branch» parameter contains another transaction ID The ACK message is a request, thus considered as a new transaction separated from the transaction initiated by the INVITE message A transaction is considered as a request followed by the responses to this request UPMC/PUF - M2 Networks - PTEL 33 Session termination One of the participant terminates the call BYE message is sent as a request 200 OK message is sent as a confirmation UPMC/PUF - M2 Networks - PTEL 34
BYE (1) BYE sip:n.tesla@lab.high-voltage.org SIP/2.0 Via: SIP/2.0/UDP tower.radio.org:5060;branch=z9hg4bk392kf Max-Forwards: 70 To: Nikola Tesla <sip:n.tesla@high-voltage.org>;tag=76341 From: G. Marconi <sip:marconi@radio.org>;tag=a53e42 Call-ID: 123456789@lab.high-voltage.org CSeq: 1 BYE Content-Length: 0 UPMC/PUF - M2 Networks - PTEL 35 BYE (2) Notice that the entities in the To and From header are inversed To: Nikola Tesla <sip:n.tesla@highvoltage.org>;tag=76341 From: G. Marconi <sip:marconi@radio.org>;tag=a53e42 Because the direction of the BYE request is now from Marconi to Tesla The set {Call-ID, To-tag, From-tag} remains unchanged because it is still in the same session A new Via header is generated UPMC/PUF - M2 Networks - PTEL 36
200 OK SIP/2.0 200 OK Via: SIP/2.0/UDP tower.radio.org:5060;branch=z9hg4bk392kf;receiv ed=200.201.202.203 To: G. Marconi <sip:marconi@radio.org>;tag=a53e42 From: Nikola Tesla <sip:n.tesla@highvoltage.org>;tag=76341 Call-ID: 123456789@lab.high-voltage.org CSeq: 1 BYE Content-Length: 0 UPMC/PUF - M2 Networks - PTEL 37 Example 2 Indirect mode Alice@lip6.fr nemo.lip6.fr 100.101.102.103 INVITE 180 Ringing 200 OK ACK INVITE 180 Ringing 200 OK Bob@lip6.fr dory.lip6.fr 200.201.202.203 BYE 200 OK UPMC/PUF - M2 Networks - PTEL 38
Why a proxy server? IP address is not fixed like a telephone number IP address is usually dynamically assigned to a host via DHCP SIP UA of the caller do not always know the IP address of the callee to send the INVITE message Proxy server is an intermedia entity to orient the SIP requests towards the destination in this case Proxy server neither initiates nor terminates a session but only forwards SIP messages It is possible to have more than one proxy server along the signaling path UPMC/PUF - M2 Networks - PTEL 39 INVITE (Alice Proxy) INVITE sip:bob@lip6.fr SIP/2.0 Via: SIP/2.0/UDP 100.101.102.103:5060;branch=z9hG4bKmp17a Max-Forwards: 70 To: Bob <sip:bob@lip6.fr> From: Alice <sip:alice@lip6.fr>;tag=42 Call-ID: 10@100.101.102.103 CSeq: 1 INVITE Subject: Where are you? Contact: <sip:alice@nemo.lip6.fr> Content-Type: application/sdp Content-Length: 159 v=0 o=alice 2890844526 2890844526 IN IP4 100.101.102.103 s=phone Call t=0 0 c=in IP4 100.101.102.103 m=audio 49170 RTP/AVP 0 a=rtpmap:0 PCMU/8000 UPMC/PUF - M2 Networks - PTEL 40
Processing INVITE message in proxy server Convert destination SIP address sip:bob@lip6.fr into Bob s IP address (100.101.202.203) Forward the INVITE message to Bob Add a Via header in the message The Via header allows the response to follow the same path of the request Decrease the Max-Forwards value UPMC/PUF - M2 Networks - PTEL 41 INVITE (Proxy Bob) INVITE sip:bob@100.101.202.203 SIP/2.0 Via: SIP/2.0.UDP proxy.lip6.fr:5060;branch=z9hg4bk83842.1 Via: SIP/2.0/UDP 100.101.102.103:5060;branch=z9hG4bKmp17a Max-Forwards: 69 To: Bob <sip:bob@lip6.fr> From: Alice <sip:alice@lip6.fr>;tag=42 Call-ID: 10@100.101.102.103 CSeq: 1 INVITE Subject: Where are you? Contact: <sip:alice@nemo.lip6.fr> Content-Type: application/sdp Content-Length: 159 v=0 o=alice 2890844526 2890844526 IN IP4 100.101.102.103 s=phone Call t=0 0 c=in IP4 100.101.102.103 m=audio 49170 RTP/AVP 0 a=rtpmap:0 PCMU/8000 UPMC/PUF - M2 Networks - PTEL 42
180 Ringing (Bob Proxy) SIP/2.0 180 Ringing Via: SIP/2.0/UDP proxy.lip6.fr:5060;branch=z9hg4bk83842.1;received=100.1 01.102.105 Via: SIP/2.0/UDP 100.101.102.103:5060;branch=z9hG4bKmp17a To: Bob <sip:bob@lip6.fr>;tag=314159 From: Alice <sip:alice@lip6.fr>;tag=42 Call-ID: 10@100.101.102.103 CSeq: 1 INVITE Contact: <sip: bob@100.101.202.203> Content-Length: 0 UPMC/PUF - M2 Networks - PTEL 43 180 Ringing (Proxy Alice) (1) SIP/2.0 180 Ringing Via: SIP/2.0/UDP 100.101.102.103:5060;branch=z9hG4bKmp17a To: Bob <sip:bob@lip6.fr>;tag=314159 From: Alice <sip:alice@lip6.fr>;tag=42 Call-ID: 10@100.101.102.103 CSeq: 1 INVITE Contact: <sip: bob@100.101.202.203> Content-Length: 0 UPMC/PUF - M2 Networks - PTEL 44
180 Ringing (Proxy Alice) (2) The proxy server recognizes its address in the first Via header It uses the transaction ID (i.e. the «branch» parameter) to identify the transaction, remove its Via header, and forward the message to the IP address indicated in the following Via header The Via header simplifies the response routing in the proxy server because the IP address of the next hop is indicated in the message UPMC/PUF - M2 Networks - PTEL 45 200 OK (Bob Proxy) SIP/2.0 200 OK Via: SIP/2.0/UDP proxy.lip6.fr:5060;branch=z9hg4bk83842.1;received=100.101.102.105 Via: SIP/2.0/UDP 100.101.102.103:5060;branch=z9hG4bKmp17a To: Bob <sip:bob@lip6.fr>;tag=314159 From: Alice <sip:alice@lip6.fr>;tag=42 Call-ID: 10@100.101.102.103 CSeq: 1 INVITE Contact: <sip: bob@100.101.202.203> Content-Length: 159 v=0 o=bob 2890844526 2890844526 IN IP4 100.101.202.203 s=phone Call t=0 0 c=in IP4 100.101.202.203 m=audio 49172 RTP/AVP 0 a=rtpmap:0 PCMU/8000 UPMC/PUF - M2 Networks - PTEL 46
200 OK (Proxy Alice) SIP/2.0 200 OK Via: SIP/2.0/UDP 100.101.102.103:5060;branch=z9hG4bKmp17a To: Bob <sip:bob@lip6.fr>;tag=314159 From: Alice <sip:alice@lip6.fr>;tag=42 Call-ID: 10@100.101.102.103 CSeq: 1 INVITE Contact: <sip: bob@100.101.202.203> Content-Length: 159 v=0 o=bob 2890844526 2890844526 IN IP4 100.101.202.203 s=phone Call t=0 0 c=in IP4 100.101.202.203 m=audio 49170 RTP/AVP 0 a=rtpmap:0 PCMU/8000 UPMC/PUF - M2 Networks - PTEL 47 ACK (Alice Bob) (1) ACK sip:bob@lip6.fr SIP/2.0 Via: SIP/2.0/UDP 100.101.102.103:5060;branch=z9hG4bKka42 Max-Forwards: 70 To: Bob <sip:bob@lip6.fr>;tag=314159 From: Alice <sip:alice@lip6.fr>;tag=42 Call-ID: 10@100.101.102.103 CSeq 1 ACK Content-Length: 0 UPMC/PUF - M2 Networks - PTEL 48
ACK (Alice Bob) (2) The ACK request is directly sent to Bob this time without the participation of the proxy server because Alice knows already the IP adresse of Bob thanks to the «Contact» header in the Bob s response UPMC/PUF - M2 Networks - PTEL 49 ACK via server It is possible to oblige that all messages go through the proxy server (a) ACK is directly sent to the callee (b) ACK is forced to go through the proxy server UPMC/PUF - M2 Networks - PTEL 50
BYE (Bob Alice) BYE sip:alice@nemo.lip6.fr SIP/2.0 Via: SIP/2.0/UDP 100.101.202.203:5060; branch=z9hg4bk4332 Max-Forwards: 70 To: Alice <alice@lip6.fr>;tag=42 From: Bob <bob@lip6.fr>;tag=314159 Call-ID: 10@100.101.102.103 CSeq: 2000 BYE Content-Length: 0 UPMC/PUF - M2 Networks - PTEL 51 OK (Alice Bob) SIP/2.0 200 OK Via: SIP/2.0/UDP 100.101.202.203:5060; branch=z9hg4bk4332 To: Alice <alice@lip6.fr>;tag=42 From: Bob <bob@lip6.fr>;tag=314159 Call-ID: 10@100.101.102.103 CSeq: 2000 BYE Content-Length: 0 UPMC/PUF - M2 Networks - PTEL 52
Registration procedure The UA registers the mapping between IP address and SIP address with the registration server The registration server maintains a database which is used by the proxy server to route the SIP request towards the destination User agent Registration server REGISTER 200 OK UPMC/PUF - M2 Networks - PTEL 53 REGISTER (1) REGISTER sip:registrar.lip6.fr SIP/2.0 Via: SIP/2.0/UDP 100.101.202.203:5060;branch=z9hG4bKus19 Max-Forwards: 70 To: Bob <sip:bob@lip6.fr> From: Bob <sip:bob@lip6.fr>;tag=3431 Call-ID: 23@100.101.202.203 CSeq: 1 REGISTER Contact: sip:bob@100.101.202.203 Content-Length: 0 UPMC/PUF - M2 Networks - PTEL 54
REGISTER (2) The To header contains the user SIP address The Contact header contains the IP address where the user can be reached directly The registration is automatically realized after starting a SIP terminal UPMC/PUF - M2 Networks - PTEL 55 200 OK (1) SIP/2.0 200 OK Via: SIP/2.0/UDP 100.101.102.103:5060;branch=z9hG4bKus19 To: Bob <sip:bob@lip6.fr>;tag=8771 From: Bob <sip:bob@lip6.fr>;tag=3431 Call-ID: 23@100.101.202.203 CSeq: 1 REGISTER Contact: <sip:bob@dory.lip6.fr>;expires=3600 Content-Length: 0 UPMC/PUF - M2 Networks - PTEL 56
200 OK (2) expires parameter [second] Ex: 3600 seconds (i.e. 1 hour) Bob must renew the registration before its expiration Several terminals (i.e. several IP addresses) can be registered for the same SIP address The proxy server can forward a request to one or more registered terminals Other operations allow user to remove a mapping or to ask for a list of currently registered terminals UPMC/PUF - M2 Networks - PTEL 57 References G. Pujolle, Les réseaux, édition 2008, Eyrolles 2007 A. B. Johnston, SIP Understanding the Session Initiation Protocol, second edition, Artech House 2004 UPMC/PUF - M2 Networks - PTEL 58