SIP Session Initiation Protocol Laurent Réveillère Enseirb Département Télécommunications reveillere@enseirb.fr Session Initiation Protocol Raisin 2007
Overview This is a funny movie! I bet Laura would love to watch it How could I tell her about it? The Internet SIP enables us to invite users to multimedia sessions 2
Functionality Provided by SIP Session establishment, modification, and termination Used to create brand new sessions Used to invite new members to an existing session Sessions are established only if The callee accepts the call Caller and callee agree on the media parameters that will be used Independence of The type of multimedia session handheld» Videoconferences, audio calls, shared whiteboards, gaming sessions, The mechanism used to describe the session» Usually SDP for RTP streams carrying audio and video» Probably another protocol for gaming sessions 3
Where to find SIP? SIP IM, Web phones, Multimedia Applications Interconnect IP PBX and IP Centrex Voice over LAN / Broadband Cable Telephony 4
SIP Philosophy Internet Standard IETF - http://www.ietf.org Based on Client- Model Clients send requests, receive responses s receive requests, send responses Reuse Internet addressing (URIs, DNS, proxies) Utilizes rich Internet features set Reuse HTTP coding Text based Makes no assumptions about underlying protocol TCP, UDP, X.25, frame relay, ATM, etc. Support of multicast 5
Where is SIP in the Protocol Zoo? Source: Henning Schulzrinne http://www.cs.columbia.edu/~hgs/internet/ 6
SIP Architecture SIP Components Location Feature Registrar User Agent Proxy Proxy User Agent SIP Network 7
SIP Architecture SIP Components Location Feature Registrar User Agent Proxy Proxy User Agent SIP Network 8
User Agent (UA) SIP entity that interacts with the user Has an interface towards the user May respond or forward invitations on user s behalf» Does not necessary maintain interaction with the user UAC (User Agent Client) Caller application that initiates and sends SIP requests UAS (User Agent ) Receives and responds to SIP requests on behalf of clients Accepts, redirects or refuses calls Both software and hardware available 9
SIP Architecture SIP Components Location Feature Registrar User Agent Proxy Proxy User Agent SIP Network 10
Registrar Accept registrar requests Usually co-located with a location or proxy server Store current location of users A user can register from different locations SIP Registrar at company.com 147.210.123.456 I am Bob.Johnson Today I will be reachable at: sip:bob@147.210.123.456 11
SIP Architecture SIP Components Location Feature Registrar User Agent Proxy Proxy User Agent SIP Network 12
Location Not really a SIP entity General term used for a database (RFC 2543) SIP servers use non-sip protocols to query, update, and retrieve records from a location server» Example: LDAP (Lightweight Directory Access Protocol) Main purpose Stores and returns information about a user» Current URI» IP address» User preferences» Usually accessed through a registrar server and/or a proxy server 13
SIP Architecture SIP Components Location Feature Registrar User Agent Proxy Proxy User Agent SIP Network 14
Proxy Acts as both a server and a client Make requests on behalf of other clients Performs routing function Determine to which hop signaling should be relayed» User agent, proxy, Interprets, rewrites or translates a request message before forwarding it Forking Tries more than one location for a user Parallel call» Trying all possible locations at the same time Sequential search» Trying each location individually until success 15
Programming SIP SIP Components Location Feature Registrar User Agent Proxy Proxy User Agent SIP Network 16
Programming SIP A SIP based system can support rapid service creations Example of services Basic call features» Call waiting, call forwarding, call blocking, etc. Click to call Call center Find me / follow me Service logic options Call Processing Language (CPL) Session Processing Language (SPL) SIP Common Gateway Interface (SIP-CGI) SIP Java Servlet (SIP-Servlet) SIP Java API for Integrated Networks (SIP-JAIN) SIP Express Router Language (SER) Microsoft SIP Processing Language (MSPL) 17
SIP Protocol Laurent Réveillère Enseirb Département Télécommunications reveillere@enseirb.fr Session Initiation Protocol Raisin 2007
Client/ Transaction Client Request Response 1 Transaction Response n 19
Requests and Responses Similarities with HTTP Text format (readability vs size) Headers Response code» Classes» Hierarchy Body of requests and responses Parameters (e.g., Session Description Protocol) Explanations (e.g., reason phrase) 20
Session Description Protocol (SDP) Format to describe a session (not a protocol) Examples: Name and purpose of the session Media parameters of the underlying audio and video streams IP addresses and port numbers Session descriptions transferred via other protocols (SIP, SAP, RTSP, HTTP ) No parameter negotiation 21
SDP Syntax A set of lines of the form Type = value Type: One character value: Format depends on type Two sections Session-level information» First line SDP version: v=0» Applies to the whole session» Examples: originator or session name Media-level information (if present)» First line media type: m» Applies to a particular media stream» Example: codec for encoding the audio stream 22
Example v=0 o=bob 2890844526 28900842807 IN IP4 131.160.1.112 s=sip seminar i=a seminar on the Session Initiation Protocol u=http://www.cs.columbia.edu/sip e=bob@university.edu c=in IP4 224.2.17.12/127 t=2873397496 2873404696 a=recvonly m=audio 49170 RTP/AVP 0 a=rtpmap:0 PCMU/8000 m=video 51372 RTP/AVP 31 a=rtpmap:31 H261/9000 m=video 53 RTP/AVP 32 a=rtpmap:32 MPV/9000 o : creator of the session and his IP addr s : name of the session i : general information about the session u : URI for more information e : e-mail address of the contact person c : multicast address of the session t : when the session is active a : not an interactive session m =<media type> <port #> <transp. prot.> <media fmt> a : information about media format Pars: clock rate, number of channels Introduction of new attributes Examples E.g., a=volume:8 Audio, media format=0 single-channel PCM encoding, 8-kHz sampling Video, media format=31 H.261, 9 khz 23
SIP Responses Range Response class 100-199 Informational (provisional) 200-299 Success 300-399 Redirection 400-499 Client error 500-599 error 600-699 Global Failure 24
Protocol Operations/Methods OPTIONS Querying capabilities» Supported methods (future extensions)» Supported SDP» Supported message body encoding REGISTER Register current location Multiple locations can be registered for a user INVITE ACK BYE CANCEL 25
Session Invitation (INVITE) Bob Laura (1)INVITE (2) 180 Ringing (3) 200 OK (4) ACK Conversation 26
Three-way Handshake (1) (1)INVITE (2) 180 Ringing (3) 200 OK (4) ACK Conversation Response delay Client still there Successful session Billing Parallel requests 27
Three-way Handshake (2) Unreliable Protocol (UDP) (1)INVITE (2)INVITE (3)INVITE Bob gives up (4)INVITE (5) 200 OK? 28
End of Session (BYE) (1)INVITE (2) 180 Ringing (3) 200 OK Abandon by the issuing participant (4) ACK Conversation (5) BYE (6) 200 OK 29
Session Cancellation (CANCEL) (1)INVITE (2) 180 Ringing (3) CANCEL (4) 200 OK (5) 487 Transaction Cancelled (6) ACK Interpretation If session not established» Cancel If session established» No effect Three-way handshake even for cancellation Usage context Parallel calls 30
Forking Proxy and Cancellation Forking Proxy comp.com 131.160.1.112 university.com (1)INVITE (2)INVITE (3)INVITE (4)INVITE (5) 200 OK (6) 200 OK (7) ACK Conversation (8) CANCEL (9) 200 OK (10) 487 Cancelled (11) ACK (12) CANCEL (13) 200 OK (14) 487 Cancelled (15) ACK 31
Format of SIP messages Request-line Header Request Status line Header Response Header-name : Header-value Header Empty Line Message body (optional) Request-line Method Request-URI (next hop) Protocol version Header-name : Header-value Header Empty Line Message body (optional) Status line Protocol version Status code Reason phrase 32
The SIP Headers Accept Content-encoding Max-forwards Route Accept-encoding Content-language MIME-version Accept-language Content-length Organization Subject Alert-info Content-type Priority Supported Allow Cseq Proxy-authenticate Timestamp Also Date Proxy-authorization To Authorization Encryption Proxy-require Unsupported Call-ID Error-info Record-route User-agent Call-info Expires Require Via Contact From Response-key Warning Content-disposition In-reply-to Retry-after WWW-authenticate 33
To Header Laura P2 131.6.2.1 university.com (1) INVITE SIP:Bob@comp.com SIP/2.0 To:SIP:Bob@comp.com (2) INVITE SIP:Bob@131.6.1.2 SIP/2.0 To:SIP:Bob@comp.com (3) INVITE SIP:Bob@university.com SIP/2.0 To:SIP:Bob@comp.com Recipient of the request Also the public address Unchanged throughout the session (not changed by proxies) Different from the Request-URI, which is The next hop in the signaling path Changed by every proxy in the path 34
Call-ID Header (1)INVITE Call-ID: 123@131.160.1.112 (2) 200 OK Call-ID: 123@131.160.1.112 (3) ACK Call-ID: 123@131.160.1.112 Game (4)INVITE Call-ID: 567@131.160.1.112 (5) 200 OK Call-ID: 567@131.160.1.112 (6) ACK Call-ID: 567@131.160.1.112 Conversation (7) BYE Call-ID: 567@131.160.1.112 (8) 200 OK Call-ID: 567@131.160.1.112 signaling relationship among 2 or more users Unique identifier of an invitation and subsequent related transactions Association mechanism of messages for servers 35
Contact Header Bob SIP proxy Laura (1)INVITE sip:laura@comp.com SIP/2.0 Contact: sip:bob@15.11.3.33 (2)INVITE sip:laura@13.16.1.11 SIP/2.0 Contact: sip:bob@15.11.3.33 (4) 200 OK Contact: sip:laura@13.16.1.11 (5) ACK (3) 200 OK Contact: sip:laura@13.16.1.11 Where the user can be reached Enabling server(s) to be skipped Conversation (6) BYE sip:laura@13.16.1.11 SIP/2.0 (7) 200 OK 36
Cseq Header (1)INVITE Cseq: 1 INVITE (2) 200 OK Cseq: 1 INVITE (3) ACK Cseq: 1 ACK (4)INVITE Cseq: 2 INVITE (5) 200 OK Cseq: 2 INVITE (6) ACK Cseq: 2 ACK (7) BYE Cseq: 3 BYE (8) 200 OK Cseq: 3 BYE Re-invite Command sequence (Cseq) An integer: request order within a session (Call-ID) Method name: to distinguish OK response from CANCEL and INVITE Request/response matching New Cseq only generated by UA for 2 methods INVITE BYE Cseq generated independently between sender receiver CANCEL s Cseq = INVITE s Cseq cancelled 37
Responses for INVITEs and CANCELs Differ Thanks to Cseq (1)INVITE Cseq: 1 INVITE (2) CANCEL Cseq: 1 CANCEL (3)200 OK Cseq: 1 CANCEL (4)487 Transaction cancelled Cseq: 1 INVITE (5) ACK Cseq: 1 ACK The response OK is either for INVITE CANCEL Method name of the Cseq enables to make the distinction 38
Via Header Laura SIP Proxy Bob (1) INVITE SIP:Bob@comp.com SIP/2.0 Via:SIP/2.0/UDP Workst 100.univ.com:5060 (2) INVITE SIP:Bob@131.6.2.9 SIP/2.0 Via:SIP/2.0/UDP 131.6.2.1:5060 Via:SIP/2.0/UDP Workst 100.univ.com:5060 (4) 200 OK Via:SIP/2.0/UDP Workst 100.univ.com:5060 (3) 200 OK Via:SIP/2.0/UDP 131.6.2.1:5060 Via:SIP/2.0/UDP Workst 100.univ.com:5060 (5) ACK SIP:Bob@comp.com SIP/2.0 Via:SIP/2.0/UDP Workst 100.univ.com:5060 Conversation (6) BYE SIP:Bob@comp.com SIP/2.0 Via:SIP/2.0/UDP Workst 100.univ.com:5060 (7) OK SIP:Bob@comp.com SIP/2.0 Via:SIP/2.0/UDP Workst 100.univ.com:5060 Workst 100.univ.com 131.6.2.1 131.6.2.9 Via headers store all proxies that handle the request They contain the signaling path Used to detect loop Also used to route the response (opposite of request route) 39
Record-Route and Route Headers (1) Laura (1)INVITE SIP:Bob@comp.com SIP/2 SIP proxy 131.6.1.99 Bob 131.6.1.2 (4) 200 OK Contact:<SIP:Bob@131.6.1.2> Record-Route:<SIP:proxy@comp.com; maddr=131.6.1.99 (5) ACK SIP:Bob@comp.com SIP/2 Route:<SIP:Bob@131.6.1.2> (7) BYE SIP:Bob@comp.com SIP/2.0 Route:<SIP:Bob@131.6.1.2> (2)INVITE SIP:Bob@131.6.1.2 SIP/2 Record-Route:<SIP:proxy@comp.com; maddr=131.6.1.99 Conversation (3) 200 OK Contact:<SIP:bob@131.6.1.2> Record-Route:<SIP:proxy@comp.com; maddr=131.6.1.99 (6) ACK SIP:Bob@131.6.1.2 SIP/2 (8) BYE SIP:Bob@comp.com SIP/2.0 Headers used by proxies Opposite of Contact header (aimed to short-circuit proxies) Proxies stay in signaling path Security: filtering incoming messages Service provision: sessionrelated service needs (e.g., duration) (10) 200 OK (9) 200 OK 40
Record-Route and Route Headers (2) Laura P1 P2 P3 Bob (1)INVITE (2)INVITE Record-Route:P1 (3)INVITE Record-Route:P1 (4)INVITE Record-Route:P3 Record-Route:P1 (8)200 OK Contact:Bob Record-Route:P3 Record-Route:P1 (7)200 OK Contact:Bob Record-Route:P3 Record-Route:P1 (6)200 OK Contact:Bob Record-Route:P3 Record-Route:P1 (5)200 OK Contact:Bob Record-Route:P3 Record-Route:P1 (9) ACK Route:P3 Route:Bob (10) ACK Route:Bob (11) ACK Conversation (12) BYE Route:P3 Route:Bob (17) 200 OK (13) BYE Route:Bob (16) 200 OK (14) BYE (15) 200 OK 41