Download as pdf or txt
Download as pdf or txt
You are on page 1of 47

hgs/SIP Tutorial

The Session Initiation Protocol (SIP)


Henning Schulzrinne Dept. of Computer Science Columbia University New York, New York (sip:)schulzrinne@cs.columbia.edu

May 2001

hgs/SIP Tutorial

Overview
protocol architecture typical component architectures protocol operation reliability features security

May 2001

hgs/SIP Tutorial

Introduction
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

Protocol architecture
Languages/APIs JAIN CPL voiceXML servlets Parlay sipcgi Directory/Discovery DNS/enum LDAP TRIP SLP Signaling SIP SDP MGCP H.248 PINT
SPIRITS

peertopeer

RTSP

masterslave

QoS DiffServ IntServ

Transport RTP TLS SCTP

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

Personal mobility
SIP uses email-style addresses to identify users
alice@columbia.edu (also used by bob@columbia.edu)

yahoo.com
tel:12128541111

alice17@yahoo.com alice@columbia.edu 7000@columbia.edu Alice.Cary@columbia.edu columbia.edu


tel:12015551234

alice@host.columbia.edu

May 2001

hgs/SIP Tutorial

SIP addressing
typically, same as users email address: alice@example.com 12125551212@gateways-r-us.com written as URL, e.g., sip:alice@example.com also can use tel URLs for telephone numbers, e.g., tel:+12125551212 or fax:+358.555.1234567

May 2001

hgs/SIP Tutorial

Building blocks

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

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

SIP UA1 (UAS)


INVITE b2b 200 OK

SIP UA2 (UAC)


INVITE callee

200 OK

May 2001

hgs/SIP Tutorial

10

Maintaining state in SIP entities


Stateless: each request and response handled indepdently (Transaction) stateful: remember a whole request/response transaction Call stateful: remember a call from beginning to end

May 2001

hgs/SIP Tutorial

11

SIP building block properties


media yes no no stateless no yes no stateful unlikely common yes call state common possible (rewall) N/A

UA (UAC, UAS) proxy redirect registrar

May 2001

hgs/SIP Tutorial

12

SIP architecture: peer-to-peer


SIP redirect server

user agent (UA)

user agent (UA)

user agent (UA)

Internet
RTP audio

128.119.40.186

128.59.19.141

CATV Ethernet

May 2001

hgs/SIP Tutorial

13

SIP architecture: outbound proxy


wonderland.com macrosoft.com
REGISTER sip:macrosoft.com SIP/2.0 To: sip:bob@macrosoft.com From: sip:bob@macrosoft.com Contact: sip:bob@p42.macrosoft.com

outbound proxy

Internet

registrar proxy

wonderland.com
INVITE sip:bob@macrosoft.com SIP/2.0 INVITE sip:bob@macrosoft.com SIP/2.0

alice@ph7.wonderland.com

bob@p42.macrosoft.com
INVITE sip:bob@p42.macrosoft.com SIP/2.0

May 2001

hgs/SIP Tutorial

14

SIP architecture: VoIP to PSTN


location server

TRIP

SLP?, TRIPGW? sip:12125551234@gwrus.com


sip:12125551234@domain

SIP H.248

tel:+12125551234
outbound proxy

IP 010

May 2001

hgs/SIP Tutorial

15

SIP architecture: PSTN to VoIP


enum database
DNS 4.3.2.1.5.5.5.2.1.2.1.e164.arpa

SCP

enum sip:alice@wonderland.com

IP 010

INVITE sip:alice@wonderland.com

May 2001

hgs/SIP Tutorial

16

SIP operation in proxy mode


cs.columbia.edu

? location server
1 2

hgs@play

henning

cs.tuberlin.de

INVITE henning@columbia.edu 200 OK

INVITE hgs@play 5
3

200 OK
6

cz@cs.tuberlin.de

play

tune
8

ACK hgs@play

media stream

May 2001

hgs/SIP Tutorial

17

SIP operation in redirect mode


ieee.org
1
henning

?
2 columbia.edu

location server

tu-berlin.de INVITE henning@ieee.org 302 Moved temporarily Contact: hgs@columbia.edu


4 5 ACK henning@ieee.org

6 INVITE hgs@columbia.edu 7 200 OK 8 ACK hgs@columbia.edu

columbia.edu

hgs

(302: redirection for single call; 301 permanently)


May 2001

hgs/SIP Tutorial

18

Locating users: registrars and location servers


registrar example.com
REGISTER alice@example.com Contact: alice@pc17 A@ B@ C@ SQL, LDAP, Corba, proprietary, ...

location server
INVITE alice@example.com INVITE alice@pc17.example.com

proxy

May 2001

hgs/SIP Tutorial

19

Basic user location mechanism


1. host(SIP URL) host name of proxy 2. DNS: host name of proxy SIP server(s) 3. if SIP UAS: alert user; done 4. if SIP proxy/redirect server: map URLn URLn+1 , using any information in request 5. go to step 1 One minor exception. . .

May 2001

hgs/SIP Tutorial

20

Basic SIP routing mechanisms


will ll in details later route using request URIs all but rst request in call typically bypass proxies and go direct UAC UAS however, can use record-routing to force certain proxies to be visited all the time responses always traverse the same route as requests

May 2001

hgs/SIP Tutorial

21

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

22

Locating users: DNS SRV


email: DNS MX record allows mapping of domain to mail host, e.g. host -t mx yahoo.com yahoo.com yahoo.com yahoo.com yahoo.com MX MX MX MX 1 1 1 9 mx2.mail.yahoo.com mx3.mail.yahoo.com mx1.mail.yahoo.com mta-v1.mail.yahoo.com

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.

allows priority (for back-up) and weight (for load balancing)


May 2001

hgs/SIP Tutorial

23

Using DNS SRV for scalable load-balancing


a.example.com _sip._udp SRV 0 0 a1.example.com SRV 1 0 a2.example.com
a1.example.com, a2.example.com

a*@example.com

s1.example.com

s2.example.com

b*@example.com sip:bob@a.example.com

sip:bob@example.com

s3.example.com

_sip._udp SRV 0 0 s1.example.com SRV 0 0 s2.example.com SRV 0 0 s3.example.com

b1.example.com, b2.example.com

May 2001

hgs/SIP Tutorial

24

Differences to classical signaling


name in-band out-of-band IP examples E&M, DTMF ISUP, Q.931 SIP network same different typically same channel same different different

IP signaling meets media only at end systems, while PSTN out-of-band intersects at every switch

May 2001

hgs/SIP Tutorial

25

Aside: Alternative architecture: master-slave


master-slave: MGC (media gateway controller) controls one or more gateways allows splitting of signaling and media functionality please send audio from circuit 42 to 10.1.2.3 uses MGCP (implemented) or Megaco/H.248 (standardized, but just beginning to be implemented) gateway can be residential basis of PacketCable NCS (network control system) architecture service creation similar to digital PBX or switch end system has no semantic knowledge of whats happening can charge for caller id, call waiting

May 2001

hgs/SIP Tutorial

26

MGCP/SIP architecture
STP call agent MG controller
SIP H.323

call agent MG controller

SIP H.323

TCAP

SS7 gwy
ISUP

SCP

MGCP/Megaco

MGCP/Megaco

SS7

RGW TGW RTP RGW

Internet

PSTN

May 2001

hgs/SIP Tutorial

27

SIP requests and responses


text, not binary, format look very similar to HTTP/1.1 requests and responses are similar except for rst line requests and responses can contain message bodies: typically session descriptions, but also ASCII or HTML

May 2001

hgs/SIP Tutorial

28

SIP syntax
request method URL SIP/2.0 response SIP/2.0 status reason

Via: SIP/2.0/ protocol host:port user <sip:from_user@source> From: 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

29

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

30

SIP methods
INVITE ACK BYE CANCEL OPTIONS REGISTER INFO COMET PRACK SUBSCRIBE NOTIFY 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, DTMF) precondition met provisional acknowledgement subscribe to event notify subscribers

May 2001

hgs/SIP Tutorial

31

Tagging To
after forking and merging, hard to tell who responded UAS responds with random tag added to disambiguate To: "A. G. Bell" <sip:agb@bell-telephone.com> ;tag=a48s future requests are ignored if they contain the wrong tag

May 2001

hgs/SIP Tutorial

32

SIP call legs


call leg: From, To, Call-ID requests from callee to caller reverse To and From caller and callee keep their own CSeq space either side can send more INVITEs or BYE

May 2001

hgs/SIP Tutorial

33

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

34

SIP response routing


requests are routed via URL response traces back request route without proxy server state forward to host, port in next Via TCP: re-use connection if possible, create new one if needed UDP: may send responses to same port as requests Via: SIP/2.0/UDP server.domain.org:5060 ;received=128.1.2.3

May 2001

hgs/SIP Tutorial

35

SIP response routing


alice@example.com bob_doe@yahoo.com
Via: y1.yahoo.com Via: a.example.com Via: a.example.com

bob@columbia.edu

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

Via: cs.columbia.edu Via: sip.columbia.edu Via: y1.yahoo.com Via: a.example.com

bob@cs.columbia.edu 200 OK
Via: cs.columbia.edu Via: sip.columbia.edu Via: y1.yahoo.com Via: a.example.com

bob@pc42.cs.columbia.edu

May 2001

hgs/SIP Tutorial

36

Forcing request paths


usually, bypass proxies on subsequent requests some proxies want to stay in the path call-stateful: rewalls anonymizer proxies proxies controlling PSTN gateways use Record-Route and Route

May 2001

hgs/SIP Tutorial

37

SIP request forking


macrosoft.com
bob@b.macrosoft.com

a.wonderland.com
INVITE sales@macrosoft.com

INVITE bob@b

CANCEL bob@c INVITE carol@c


carol@c.macrosoft.com

ACK

200 OK

BYE carol@c.macrosoft.com

200 OK

May 2001

hgs/SIP Tutorial

38

SIP request forking


branches tried in sequence or parallel (or some combination) recursion: may try new branches if branch returns 3xx return best nal answer = lowest status code forward provisional responses

May 2001

hgs/SIP Tutorial

39

SIP transport issues


SIP operates over any packet network, reliable or unreliable choices: UDP: most common low state overhead small max. packet size TCP: can combine multiple signaling ows over one link use with SSL connection setup overhead HOL blocking for trunks SCTP: new protocol no HOL blocking fallback address (but SRV provides this already) connection setup overhead

May 2001

hgs/SIP Tutorial

40

Transport reliability for all but INVITE


client BYE 500 ms UAS, proxy

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

2s 4s 4s ... no more than 11 packets

200, 4xx, 5xx, 6xx

May 2001

hgs/SIP Tutorial

41

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

1xx 7 INVITE sent

Completed

May 2001

hgs/SIP Tutorial

42

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

43

SIP extensions and feature negotiation


if crucial, mark with Require: feature IANA-registered features are simple names, private features use reverse domain names indicate features supported in Supported:
C->S: INVITE sip:watson@bell-telephone.com SIP/2.0 Require: com.example.billing Supported: 100rel Payment: sheep_skins, conch_shells SIP/2.0 420 Bad Extension Unsupported: com.example.billing SIP/2.0 421 Extension Required Require: 183

S->C:

S->C:

May 2001

hgs/SIP Tutorial

44

Invitation modes
signaling unicast multicast media unicast multicast telephony multicast session reach rst dept. conference

SIP for all modes, SAP/SDP also for multicast/multicast

May 2001

hgs/SIP Tutorial

45

SIP-based services
Call forwarding: basic INVITE behavior (proxy/redirect) Call transfer: REFER method (see later) 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

46

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

47

For more information. . .


SIP: http://www.cs.columbia.edu/sip SDP: http://www.cs.columbia.edu/hgs/internet/sdp.html RTP: http://www.cs.columbia.edu/hgs/rtp Papers: http://www.cs.columbia.edu/IRT

May 2001

You might also like