Sip Protocol
Sip Protocol
May 2001
hgs/SIP Tutorial
Overview
protocol architecture typical component architectures addressing and locating SIP entities protocol operation and extensions reliability services, features and caller preferences security and QoS programming SIP services
May 2001
hgs/SIP Tutorial
Introduction
SIP = core protocol for establishing sessions in the Internet transports session description information from initiator (caller) to callees allows to change parameters in mid-session terminate session
May 2001
hgs/SIP Tutorial
peertopeer
RTSP
masterslave
May 2001
hgs/SIP Tutorial
MGCP/Megaco
reservation
measurement
RSVP
RTCP
RTP
transport
UDP
network
link
Sonet
physical
May 2001
kernel
application daemon
hgs/SIP Tutorial
LDAP
address lookup
DNS
nexthop
signaling
may trigger
SIP SDP
sets up
RSVP
media
RTP UDP
RTP UDP
May 2001
hgs/SIP Tutorial
SIP applications
setting up voice-over-IP calls setting up multimedia conferences event notication (subscribe/notify) IM and presence text and general messaging signaling transport
May 2001
hgs/SIP Tutorial
SIP addressing
May 2001
hgs/SIP Tutorial
Personal mobility
SIP uses email-style addresses to identify users
[email protected] (also used by [email protected])
yahoo.com
tel:12128541111
May 2001
hgs/SIP Tutorial
10
SIP addressing
typically, same as users email address: [email protected] [email protected] written as URL, e.g., sip:[email protected] can add parameters, such as type (user=phone) or transport protocol
May 2001
hgs/SIP Tutorial
11
May 2001
hgs/SIP Tutorial
12
SIP user agent SIP redirect server SIP stateless proxy SIP (forking) proxy
A@ B@ C@
IP phone, PC, conference bridge returns new location for requests routes call requests routes call requests maintains mappings from names to addresses
SIP registrar
May 2001
hgs/SIP Tutorial
13
Back-to-back UA (B2BUA)
two (or more) user agents, where incoming calls trigger outgoing calls to somebody else also, third-party call control (later) useful for services and anonymity
200 OK
May 2001
hgs/SIP Tutorial
14
May 2001
hgs/SIP Tutorial
15
May 2001
hgs/SIP Tutorial
16
Internet
RTP audio
128.119.40.186
128.59.19.141
CATV Ethernet
May 2001
hgs/SIP Tutorial
17
outbound proxy
Internet
registrar proxy
wonderland.com
INVITE sip:[email protected] SIP/2.0 INVITE sip:[email protected] SIP/2.0
[email protected]
INVITE sip:[email protected] SIP/2.0
May 2001
hgs/SIP Tutorial
18
TRIP
SIP H.248
tel:+12125551234
outbound proxy
IP 010
May 2001
hgs/SIP Tutorial
19
SCP
enum sip:[email protected]
IP 010
INVITE sip:[email protected]
May 2001
hgs/SIP Tutorial
20
? location server
1 2
hgs@play
henning
cs.tuberlin.de
INVITE hgs@play 5
3
200 OK
6
play
tune
8
ACK hgs@play
media stream
May 2001
hgs/SIP Tutorial
21
?
2 columbia.edu
location server
columbia.edu
hgs
hgs/SIP Tutorial
22
May 2001
hgs/SIP Tutorial
23
location server
INVITE [email protected] INVITE [email protected]
proxy
May 2001
hgs/SIP Tutorial
24
May 2001
hgs/SIP Tutorial
25
May 2001
hgs/SIP Tutorial
26
Outbound proxies
normally, proxy serves one or more domains outbound proxies are used for all outbound requests from within a domain typically, for managing corporate rewalls and policy enforcement may also provide dial plans or route tel/fax URLs other uses: lawyer client billing, . . .
May 2001
hgs/SIP Tutorial
27
SIP: use a newer record for general-purpose mapping, SRV (RFC 2782) mapping from service and transport protocol to one or more servers, including protocols
_sip._tcp _sip._udp SRV SRV SRV SRV 0 1 0 1 0 0 0 0 5060 5060 5060 5060 sip-server.cs.columbia.edu. backup.ip-provider.net. sip-server.cs.columbia.edu. backup.ip-provider.net.
hgs/SIP Tutorial
28
a*@example.com
s1.example.com
s2.example.com
b*@example.com sip:[email protected]
s3.example.com
b1.example.com, b2.example.com
May 2001
hgs/SIP Tutorial
29
May 2001
hgs/SIP Tutorial
30
May 2001
hgs/SIP Tutorial
31
May 2001
hgs/SIP Tutorial
32
SIP syntax
request method URL SIP/2.0 response SIP/2.0 status reason
Via: SIP/2.0/ protocol host:port From: user <sip:from_user@source> To: user <sip:to_user@destination> CallID: localid@host CSeq: seq# method ContentLength: length of body ContentType: media type of body Header: parameter ;par1=value ;par2="value" ;par3="value folded into next line" blank line
V=0 o= origin_user timestamp timestamp IN IP4 host c=IN IP4 media destination address t=0 0 m= media type port RTP/AVP payload types
message
message body
message header
May 2001
hgs/SIP Tutorial
33
SIP syntax
eld names and some tokens (e.g., media type) are case-insensitive everything else is case-sensitive white space doesnt matter except in rst line lines can be folded multi-valued header elds can be combined as a comma-list
May 2001
hgs/SIP Tutorial
34
SIP methods
INVITE ACK BYE CANCEL OPTIONS REGISTER INFO COMET PRACK SUBSCRIBE NOTIFY REFER initiate call conrm nal response terminate (and transfer) call cancel searches and ringing features support by other side register with location service mid-call information (ISUP) precondition met provisional acknowledgement subscribe to event notify subscribers ask recipient to issue SIP request (call transfer)
May 2001
hgs/SIP Tutorial
35
calls
[email protected]
SIP/2.0 200 OK From: sip:[email protected] To: sip:[email protected] CallID: [email protected] CSeq: 42 INVITE ContentType: application/sdp v=0 o=user1 535 687637 IN IP4 m.macrosoft.com c=IN IP4 m.macrosoft.com m=audio 1200 RTP/AVP 1 m=video 0 RTP/AVP accept audio, decline video
May 2001
hgs/SIP Tutorial
36
Tagging To
after forking and merging, hard to tell who responded UAS responds with random tag added to disambiguate To: "A. G. Bell" <sip:[email protected]> ;tag=a48s future requests are ignored if they contain the wrong tag
May 2001
hgs/SIP Tutorial
37
May 2001
hgs/SIP Tutorial
38
SIP responses
Informational
100 Trying 180 Ringing 181 Call forwarded 182 Queued 183 Session Progress
Success
200 OK
Redirection
300 Multiple Choices 301 Moved Perm. 302 Moved Temp. 380 Alternative Serv.
Request Failure
400 Bad Request 401 Unauthorized 403 Forbidden 404 Not Found 405 Bad Method 415 Unsupp. Content 420 Bad Extensions 486 Busy Here
500 Server Error 501 Not Implemented 503 Unavailable 504 Timeout
600 Busy Everwhere 603 Decline 604 Doesnt Exist 606 Not Acceptable
Server Failure
Global Failure
May 2001
hgs/SIP Tutorial
39
May 2001
hgs/SIP Tutorial
40
INvITE
Via: a.example.com Via: y1.yahoo.com Via: a.example.com
Via: sip.columbia.edu Via: y1.yahoo.com Via: a.example.com Via: sip.columbia.edu Via: y1.yahoo.com Via: a.example.com
[email protected] 200 OK
Via: cs.columbia.edu Via: sip.columbia.edu Via: y1.yahoo.com Via: a.example.com
May 2001
hgs/SIP Tutorial
41
SIP spirals
INVITE sip:[email protected] SIP/2.0 Via: sales.acme.com;branch= h(info,alice,17,1,kelly@sales) Via: acme.com;branch= h(info,alice,17,1,kelly@acme) Via: sales.acme.com;branch= h(info,alice,17,1,bob@sales) Via: acme.com;branch= h(info,alice,17,1,info) Via: ph123.wonderland.com
acme.com
sales.acme.com
INVITE sip:[email protected] SIP/2.0 h(info,alice,17,1,kelly@acme) Via: acme.com;branch= Via: sales.acme.com;branch= h(info,alice,17,1,bob@sales) Via: acme.com;branch= h(info,alice,17,1,info) Via: ph123.wonderland.com
branch= h(To,From,CallID,CSeq,URL)
INVITE sip:[email protected] SIP/2.0 h(info,alice,17,1,bob@sales) Via: sales.acme.com;branch= Via: acme.com;branch= h(info,alice,17,1,bob@sales) Via: ph123.wonderland.com
May 2001
hgs/SIP Tutorial
42
May 2001
hgs/SIP Tutorial
43
Request routing
A INVITE PB
Contact: A
PA INVITE PB
Contact: A RecordRoute: PA
PB INVITE B
Contact: A RecordRoute: PB, PA
200 OK
Contact: B RecordRoute: PB, PA
200 OK
Contact: B RecordRoute: PB, PA
200 OK
Contact: B RecordRoute: PB, PA
ACK PA
Route: PB,B
ACK PB
Route: B
ACK B
BYE A
BYE A
Route: A;maddr=PB
BYE A
Route: A;maddr=PB Route: A;maddr=PA Route: A;maddr=A
May 2001
hgs/SIP Tutorial
44
a.wonderland.com
INVITE [email protected]
INVITE bob@b
ACK
200 OK
200 OK
May 2001
hgs/SIP Tutorial
45
q=1.0
1
q=0.7
INVITE
q=0.1 200 OK
May 2001
hgs/SIP Tutorial
46
May 2001
hgs/SIP Tutorial
47
INVITE bob@portal
100 Trying 180 Ringing 200 OK Contact: bob@home 200 OK CANCEL bob@work 200 OK (CANCEL) 487 Cancelled (INVITE) ACK bob@work ACK bob@home
UAC
proxy server
UAS
UAS
May 2001
hgs/SIP Tutorial
48
May 2001
hgs/SIP Tutorial
49
used for BYE, OPTIONS, SUBSCRIBE, NOTIFY, . . . 1xx sent by UAS or proxy only if no nal answer expected within 200 ms if provisional response, retransmit with T 2 (4) seconds
1s
May 2001
hgs/SIP Tutorial
50
INVITE reliability
INVITE is special long time between request and nal response 100 (by proxy) indicates request has been received proxy usually forwards 1xx from all branches only retransmit until 100 ACK conrms receipt of nal response
status ACK event request sent T1*2 INVITE
n
Initial
INVITE
Calling
1xx
status ACK
Call proceeding
status ACK
Completed
May 2001
hgs/SIP Tutorial
51
May 2001
hgs/SIP Tutorial
52
IP signaling meets media only at end systems, while PSTN out-of-band intersects at every switch
May 2001
hgs/SIP Tutorial
53
May 2001
hgs/SIP Tutorial
54
MGCP/SIP architecture
STP call agent MG controller
SIP H.323
SIP H.323
TCAP
SS7 gwy
ISUP
SCP
MGCP/Megaco
MGCP/Megaco
SS7
Internet
PSTN
May 2001
hgs/SIP Tutorial
55
Extending SIP
extension new headers new headers new method new body type new status code new URL type behavior ignored mandatory determine? Supported OPTIONS Accept ?
class-based
May 2001
hgs/SIP Tutorial
56
S->C:
S->C:
May 2001
hgs/SIP Tutorial
57
User identication
May 2001
hgs/SIP Tutorial
58
May 2001
hgs/SIP Tutorial
59
May 2001
hgs/SIP Tutorial
60
draft-ietf-sip-privacy
To/headerFrom are chosen by end system may lie need privacy indications similar to caller id Remote-Party-ID: "John Doe" <sip:[email protected]>;party=calling; id-type=subscriber;privacy=full screen=yes: was veried by proxy type can be subscriber, user, alias, return (calls), term (terminal) may add geographic user location
May 2001
hgs/SIP Tutorial
61
SIP services
May 2001
hgs/SIP Tutorial
62
Invitation modes
signaling unicast multicast media unicast multicast telephony multicast session reach rst dept. conference
May 2001
hgs/SIP Tutorial
63
SIP-based services
Call forwarding: basic INVITE behavior (proxy/redirect) Call transfer: REFER method (see later) Call hold: set media address to 0.0.0.0 can be done individually per media Caller id: From, plus extensions DTMF carriage: carry as RTP payload (RFC 2833) Calling card: B2BUA + voice server Voice mail: UA with special URL(s) + possibly RTSP
May 2001
hgs/SIP Tutorial
64
Call transfer
B1
BYE A
REFER B2 ReferredBy: B1
INVITE B2 ReferredBy: B1
B2
May 2001
hgs/SIP Tutorial
65
SQL, LDAP
text
May 2001
hgs/SIP Tutorial
66
200 200 2 5 INVITE SDP (from 2) ACK SDP (from 4) INVITE no SDP 4 3 6
SIP SIP
ACK
May 2001
hgs/SIP Tutorial
67
SIP billing/charging
What for? transport resource reservation protocol SIP services (call processing) authentication PSTN gateway services media server services (translation, storage) How? resource reservation protocols SIP-in-DIAMETER approach server log les
May 2001
hgs/SIP Tutorial
68
Security issues
May 2001
hgs/SIP Tutorial
69
Threats
spoong From in REGISTER: call redirection spoong From in INVITE: bypass call ltering snooping media packets billing confusion (identier munging) denial-of-service attacks
May 2001
hgs/SIP Tutorial
70
SIP security
layer/mechanism network layer transport layer SIP INVITE SIP REGISTER SIP general approach IPsec TLS basic/digest basic/digest S/MIME characteristics adjacent nodes, all or nothing, hard to congure adjacent nodes, all or nothing shared secrets with random parties securing headers? in progress
Basic (plaintext password) and digest (challenge-response) are very similar to HTTP security mechanisms.
May 2001
hgs/SIP Tutorial
71
SIP authentication
Basic: include plain-text password in request, immediately or after 401 (Unauthorized) or 407 (Proxy Authorization) response Digest: challenge-response with shared secret Certicate: sign non-Via parts of request headers, body with PGP, PKCS #7 SSL, SSH: but only for TCP but: need more elaborate cryptographic capability indication in SDP
May 2001
hgs/SIP Tutorial
72
Basic authentication
Challenge by UAS: SIP/2.0 401 Unauthorized WWW-Authenticate: Basic realm="business" client responds with INVITE sip:[email protected] SIP/2.0 CSeq: 2 INVITE Authorization: QWxhZGRpbjpvcGVuIHNlc2FtZQ== where authorization is base64(userid:password) usually caller callee, but challenge can be in request
May 2001
hgs/SIP Tutorial
73
Digest authentication
A calls B and fails:
SIP/2.0 401 Unauthorized Authenticate: Digest realm="GW service", domain="wcom.com", nonce="wf84f1ceczx41ae6cbe5aea9c8e88d359", opaque="42", stale="FALSE", algorithm="MD5"
A tries again:
INVITE sip:[email protected] SIP/2.0 Authorization:Digest username="UserA", realm="GW service", nonce="wf84f1ceczx41ae6cbe5aea9c8e88d359", opaque="42", uri="sip:[email protected]", response="42ce3cef44b22f50c6a6071bc8"
May 2001
hgs/SIP Tutorial
74
Digest authentication
username: user authenticating herself realm: several per user, used also for display nonce: copied into Authorization opaque: copied into Authorization uri: original request URL response: 32 hex digits: KD (H(A1 ), nonce-value : H(A2 )) for MD5: H(H(A1 ) : nonce-value : H(A2 ))) where A1 = username : realm : passwd A2 = method : uri
May 2001
hgs/SIP Tutorial
75
Quality of Service
May 2001
hgs/SIP Tutorial
76
Quality of service
SIP and data paths disjoint SIP cant reserve resources but: SDP may provide information to end systems on desired QoS SDP contains range of codecs to allow mid-call adaptation
May 2001
hgs/SIP Tutorial
77
UAC
UAS
May 2001
hgs/SIP Tutorial
78
May 2001
hgs/SIP Tutorial
79
Preferences
callee: scripts, CPL, REGISTER advice in Contact, . . . caller: help guide routing (no home number) and order of attempts when forking (try videophone rst, then phone, then answering service) caller proposes, callee disposes
May 2001
hgs/SIP Tutorial
80
May 2001
hgs/SIP Tutorial
81
Contact example
q=quality gives preference.
SIP/2.0 302 Moved temporarily Contact: sip:[email protected] ;action=redirect ;service=IP,voice-mail ;media=audio ;duplex=full ;q=0.7; Contact: tel:+1-415-555-1212 ; service=ISDN ;mobility=fixed ;language=en,es,iw ;q=0.5 Contact: tel:+1-800-555-1212 ; service=pager ;mobility=mobile ;duplex=send-only;media=text; q=0.1; priority=urgent; ;description="For emergencies only" Contact: mailto:[email protected]
May 2001
hgs/SIP Tutorial
82
May 2001
hgs/SIP Tutorial
83
Request-Disposition
proxy or redirect cancel ringing second phone after rst picked up? allow forking? search recursively? search sequentially or in parallel? queue the call? Request-Disposition: proxy, recurse, parallel
May 2001
hgs/SIP Tutorial
84
May 2001
hgs/SIP Tutorial
85
PUA
PUA PA NOTIFY
May 2001
hgs/SIP Tutorial
86
May 2001
hgs/SIP Tutorial
87
200 OK
May 2001
hgs/SIP Tutorial
88
Forked to all PUAs that have REGISTERed with method SUBSCRIBE. 200 (OK) response contains current state.
May 2001
hgs/SIP Tutorial
89
May 2001
hgs/SIP Tutorial
90
SIP events
single-valued (light-switch) to complex (CD changer) to multi-valued (temperature samples) both built-in and mediated (X10) often combined with audio/video in same system: security, industrial control, home entertainment notication rates vary gradual transition to continuous media
IR detector 0.01
process control
May 2001
hgs/SIP Tutorial
91
SUBSCRIBE [email protected] NOTIFY [email protected] SIP user agent DO [email protected] INVITE [email protected] SIP proxy (RGW)
May 2001
hgs/SIP Tutorial
92
SIP IM
send text or any other MIME type either as SDP-initiated session or as individual messages use MESSAGE
May 2001
hgs/SIP Tutorial
93
May 2001
hgs/SIP Tutorial
94
May 2001
hgs/SIP Tutorial
95
Programming services
caller proposes, callee disposes, administrator decides web = static pages cgi-bin Java if somebody is trying to call for the 3rd time, allow mobile try ofce and lab in parallel, if that fails, try home allow call to mobile if Ive talked to person before if on telemarketing list, forward to dial-a-joke phone: CTI = complex, not generally for end users
May 2001
hgs/SIP Tutorial
96
May 2001
hgs/SIP Tutorial
97
Examples
Call forward on busy/no answer Administrative screening (rewall) Central phone server Intelligent user location
Third-party registration control Calendarbook access Client billing allocation (lawyers ofce) End system busy Phone bank tion/queueing) (call distribu-
May 2001
hgs/SIP Tutorial
98
May 2001
hgs/SIP Tutorial
99
May 2001
hgs/SIP Tutorial
100
May 2001
hgs/SIP Tutorial
101
$destination = $addresses{$to}; if (! defined( $destination )) { fail("404", "No such user"); } print "CGI-PROXY-REQUEST-TO $destination SIP/2.0\n"; print "CGI-Reexecute-On: never\n\n"; untie %addresses; # Close db file
May 2001
hgs/SIP Tutorial
102
May 5, 2000
May 2001
hgs/SIP Tutorial
103
Purpose
Allow users to create simple Internet telephony services Features: Creatable and editable by simple graphical tools Independent of signalling protocol Safe to run in servers
May 2001
hgs/SIP Tutorial
104
Abstract structure
busy location url: sip:jones@ example.com proxy timeout: 10s timeout failure
Call
redirect
May 2001
hgs/SIP Tutorial
105
May 2001
hgs/SIP Tutorial
106
Textual representation
<cpl> <subaction id="voicemail"> <location url="sip:[email protected]"> <redirect /> </location> </subaction>
May 2001
hgs/SIP Tutorial
107
Textual representation
<incoming> <address-switch field="origin" subfield="host"> <address subdomain-of="example.com"> <location url="sip:[email protected]"> <proxy> <busy> <sub ref="voicemail" /> </busy> <noanswer> <sub ref="voicemail" /> </noanswer> <failure> <sub ref="voicemail" /> </failure> </proxy> </location> </address> <otherwise> <sub ref="voicemail" /> </otherwise> </address-switch> </incoming> </cpl>
May 2001
hgs/SIP Tutorial
108
Textual representation
Represent scripts as XML documents Incoming, outgoing scripts are separate top-level tags Nodes and outputs are both tags Parameters are tag attributes Multiple outputs to one input represented by subactions
May 2001
hgs/SIP Tutorial
109
Switch nodes
Switch nodes make decisions. Structure:
<type-switch field=var> <type condition1="value1"> action1 </type> <type condition2="value2"> action2 </type> <not-present> action3 <otherwise> action4 </otherwise> </type-switch>
May 2001
hgs/SIP Tutorial
110
May 2001
hgs/SIP Tutorial
111
May 2001
hgs/SIP Tutorial
112
May 2001
hgs/SIP Tutorial
113
May 2001
hgs/SIP Tutorial
114
May 2001
hgs/SIP Tutorial
115
Location nodes
A number of CPL actions (proxy, redirect) take locations Location nodes let you specify them These are full-featured nodes because we might want to make decisions based on outcomes of location lookups, or cascade locations A CPL script has an implicit global list of locations Location nodes can add to this list, or clear the list
May 2001
hgs/SIP Tutorial
116
May 2001
hgs/SIP Tutorial
117
May 2001
hgs/SIP Tutorial
118
May 2001
hgs/SIP Tutorial
119
May 2001
hgs/SIP Tutorial
120
May 2001
hgs/SIP Tutorial
121
May 2001
hgs/SIP Tutorial
122
May 2001
hgs/SIP Tutorial
123
May 2001
hgs/SIP Tutorial
124
Subactions
XML syntax denes a tree; we want CPLs to be represented as directed acyclic graphs. Subactions are dened at the top level of the script, outside other actions. for acyclicity, top-level actions and subactions may only call subactions which were dened earlier in the script. Anywhere a node is expected, you can instead have a sub tag, with a ref parameter which refers to a subactions id.
May 2001
hgs/SIP Tutorial
125
May 2001
hgs/SIP Tutorial
126
May 2001
hgs/SIP Tutorial
127
May 2001
hgs/SIP Tutorial
128
May 2001
hgs/SIP Tutorial
129
May 2001
hgs/SIP Tutorial
130
May 2001
hgs/SIP Tutorial
131
3G networks
successor to 2G mobile networks: GSM (TDMA) and IS-95 (CDMA) in 900/1800 MHz range 2.5G: GSM GPRS EDGE use different air interfaces in 2 GHz range: W-CDMA, CDMA 2000, TD-CDMA 3GPP standardizes for W-CDMA (GSM follow-on), while 3GPP2 does CDMA 2000 identied by releases (1999, R4, R5)
May 2001
hgs/SIP Tutorial
132
3G and VoIP
GPRS not suitable for VoIP: low bandwidth, high delay (500-600 ms RTT) initially (R4), CS voice to base station, then ATM/IP packets later (R5), in Internet multimedia (IM) subsystem IP to UE (user equipment) uses AMR audio codec, with variable rate of 4.75 to 12.2 kb/s, or GSM HR or EFR UTRAN delays: see TR 25.932
May 2001
hgs/SIP Tutorial
133
May 2001
hgs/SIP Tutorial
134
3G SIP registration
interrogating
interrogating
home IM domain
registration signaling (SIP)_
visited IM domain
May 2001
hgs/SIP Tutorial
135
May 2001
hgs/SIP Tutorial
136
RFCs
draft-ietf-sip-rfc2543bis-03 RFC 3087 RFC 3050 RFC 2916 RFC 2833 RFC 2806 RFC 2543 base protocol spec Control of Service Context using SIP Request-URI Common Gateway Interface for SIP E.164 number and DNS RTP Payload for DTMF Digits, Telephony Tones and Telephony Signals URLs for Telephone Calls SIP: Session Initiation Protocol
May 2001
hgs/SIP Tutorial
137
May 2001