SIP Tutorial
SIP Tutorial
March 2007
All statements are authors’ and may or may not be shared by his company.
Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
Outline
• About This Tutorial • SIP Security
• Introduction: Why SIP and SIP • SIP Services
History. • Black-belt SIP
• Where SIP Was Born: IETF • Self-education
Standardization – Get your hands on SER
• Introduction to SIP Protocol – Self-test
– SIP Architecture – References
– SIP Servers, ENUM • IMS
– SIP Message Elements
• BCPs:
– QoS
– NATs and Firewalls
– PSTN
• RTP – Multimedia Protocol
100
25
60
50
25 35
25 0
establishes presence of
user with address [email protected]
#2 REGISTER sip:iptel.org
SIP/2.0
for one hour and binds this
From: sip:[email protected] address to user’s current
To: sip:[email protected] #1 location 195.37.78.173.
Contact: <sip:195.37.78.173>
Expires: 3600
#3 SIP/2.0 200 OK
SIP Registrar
(domain iptel.org)
Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
Basic SIP Call-Flow (Proxy
Mode) to served users in location database and
SIP Proxy looks up next hops for requests
[email protected]
#3
Reply: IP Address of iptel.org SIP Server
INVITE sip:[email protected]
INVITE sip:[email protected]
jiri
From: sip:[email protected];tag=12
From: To: sip: [email protected] #4
sip:[email protected];tag=12 #1 Call-
Call-ID: [email protected]
To: sip: [email protected]
Call-ID: [email protected]
OK 200 OK 200 #5
#6
From: sip:[email protected];tag=12 From: sip:[email protected];tag=12
To: sip: [email protected];tag=34 Proxy To: sip: [email protected];tag=34
Call-
Call-ID: [email protected] Call-
Call-ID: [email protected]
#7 ACK sip:[email protected]
[email protected] sip:[email protected]
Media streams#8
Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
RFC1958
• Distributed end-
end-2-end design*
• Intelligence and states resides in end-devices
• Network maintains almost zero intelligence (except
routing) and state (except routing tables).
• End-devices speak to each other using whatever
applications they have. There is almost no logic in the
network affecting this behavior.
• Result:
– Flexibility. Introducing new applications is easy.
– Failure recovery. No state, no problem on failure.
– Scalability. No state, no memory scalability issues.
IP Router
Note:
•Every packet may take a completely different path
•Signaling takes typically different path than media does
•Both signaling and media as well as other applications (FTP,
web, email, … ) look “alike” up to transport layer and share the
same fate Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
All-IP Protocol Zoo (Hourglass
All-
Model) ENUM iLBC, G.711, ...
WWW signaling interdomain AAA media NAT
PPP AALx
• Session management
– Users may move from terminal to terminal with different
capabilities and change their willingness to communicate
– To set-up a communication session between two or more users,
a signaling protocol is needed: Session Initiation Protocol (SIP)
supports locating users, session negotiation (audio/video/instant
messaging, etc.) and changing session state
• Media Transport
– Getting packetized voice over lossy and congested network in
real-time
– RTP – protocol for transmitting real-time data such as audio,
video and games
• End-to-end delivery: underlying IP connects the whole
world
Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
Supporting Protocols: How Do I
...
• … find domain of called party? Like with email, use DNS
to resolve address of server responsible for
[email protected]!
• … authenticate users and generate Call Detail
Records? De-facto RADIUS standard.
• … get over NATs? STUN.
• More:
– … set phone clock: NTP
– … download configuration and firmware: TFTP/FTP/HTTP (no
good standard for usage of these protocols)
– … resolve phone numbers to SIP addresses? ENUM
• IETF Practice: Decomposition Principle; Separate
protocols are used for separate purposes. All of them on
top of IP.
Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
Given All Supporting Protocols are In
Place, What Do I need on SIP Part?
• SIP Registrar
– accept registration requests from users
– maintains user’s whereabouts at a Location Server (like GSM HLR)
• SIP Proxy Server
– relays call signaling, i.e. acts as both client and server
– operates in a transactional manner, i.e., it keeps no session state
– transparent to end-devices
– does not generate messages on its own (except ACK and CANCEL)
– Allows for additional services (call forwarding, AAA, forking, etc.)
• SIP Redirect Server
– redirects callers to other servers
– Used rather rarely as operators appreciate staying in communication
path. May be used to achieve very scalable load distribution.
Payload
Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
RTP Header Functions
• Provides information for:
– media content type
– talk spurts
– sender identification
– synchronization
– loss detection
– segmentation and reassembly
– security (encryption)
V P X M Payloa Sequence
d number
Timestamp
Synchronization Source Identifier (SSRC)
Payload
iptel.org
?
+49-30-3463-8271
FWD
sipphone
Ownership
• The “ENUM global directory” translates E.164 numbers into URIs,
e.g.: +49-30-3463-8271=> [email protected]
• The translation mechanism utilizes DNS: The E.164 number queries
are formed as a reversed dot-separated number digits, to which
string “.e164.arpa” is appended, e.g.:
– +4319793321 1.2.3.3.9.7.9.1.3.4.e164.arpa
• Operation of the top-level domain carried out by RIPE-NCC:
http://www.ripe.net/enum/
• Responsibility for respective countries in the ENUM DNS tree is
frequently claimed by local NICs (nic.at, nic.cz, … ) or specialized
ENUM companies (Neustar, Verisign, …). Delegation still subject to
disputes in many countries; number ownership verification is matter
of local policies.
• Resulting uncertainty causes some “private ENUM trees” to emerge.
yes yes
Report
Missed Call
Done
Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
Service composition: Added-value
Server Chains
Caller’s administrative domain Administrative domain of a PSTN gateway operator
gw01.asia.pstn.com
pstn.com asia.pstn.com
#2 #3 #4
#1
#1 INVITE
#2 Trying
#3 INVITE
#4 Ringing
#5 CANCEL
#6 OK
#7 INVITE
Redirection
• A server can be
configured to redirect an
#1 INVITE
Via:
Via SIP/2.0/UDP here.com:5060 Via:
Via SIP/2.0/UDP here.com:5060
From:
From BigGuy <sip:[email protected]>;tag=123 From:
From BigGuy <sip:[email protected]>;tag=123
To:
To LittleGuy <sip:[email protected]> To:
To LittleGuy <sip:[email protected]>;tag=65a35
Call-
Call-ID:
ID [email protected] Message Call-
Call-ID:
ID [email protected]
CSeq:
CSeq 1 INVITE Header CSeq:
CSeq 1 INVITE
Subject: Happy Christmas
Fields Subject: Happy Christmas
Contact:
Contact BigGuy <sip:[email protected]> Contact:
Contact LittleGuy <sip:[email protected]>
Content-
Content-Type:
Type application/sdp Content-
Content-Type:
Type application/sdp
Content-
Content-Length:
Length 147 Content-
Content-Length:
Length 134
v=0 v=0
o=UserA 2890844526 2890844526 IN IP4 here.com o=UserB 2890844527 2890844527 IN IP4 there.com
s=Session SDP s=Session SDP
c=IN IP4 100.101.102.103 c=IN IP4 110.111.112.113
t=0 0
m=audio 49172 RTP/AVP 0
Payload t=0 0
m=audio 3456 RTP/AVP 0
a=rtpmap:0 PCMU/8000 a=rtpmap:0 PCMU/8000
#4 Reserve
#6 180 Ringing
SRC:192.168.99.1:5060 SRC:195.37.77.101:32431
195.37.77.101
Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
draft-ietf-sipping-nat-scenarios
ICE
• All of the suggestion somewhat cumbersome:
none of them works any time
• IETF suggestion: have User Agents tried all of
them in a preference order and use whichever
works best: Interactive Connection
Establishment (ICE)
• ICE tutorial: http://www.jdrosen.net/papers/ice-
ietf-tutorial.pdf
• Problem: It is not available yet (and it will take
some time till it is).
Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
A1: NAT (?Best?) Current
Practice
• The solution space as painted before is just not
easily practicable, the industry is thus seeking
an alternate approach till ICE establishes itself.
• The big-hammer solution is media-
media-relay – it is
horribly, horribly inefficient, but it works in a
majority of cases. Basically, one trades the
CAPEX (media relay) + OPEX (relayed media)
for price of supporting other immature
alternatives.
• The media relay concept is frequently marketed
as Session Border Controller. Smarter SBCs
can at least avoid relaying media if
unnecessary, like when both call parties clearly
on the public Internet.
Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
draft-ietf-sipping-sbc-funcs
PSTN Internet
route_to_least_cost_gateway();
elseif local(“sipforfree.com.au”)
then
Frequently
SIP Proxy & Registrar
lookup_registry;
sipforfree.com.au
else proxy_to_foreign_domain(); Misunderstood
Issue
Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
Gateways Ship Today, What Is the
Problem Then? Integration!
• Identity: [email protected] calls out through PSTN
gateway. What Caller-ID will display down in
PSTN?
• Interdomain settlement: your SIP service
operator does not have the capability to
terminate anywhere in world cheaply. How can
he establish a secure channel to PSTN
termination operators?
• How do you locate a proper PSTN termination
gateway?
• And some other ugly legacy problems like
DTMF, overlap dialing.
Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
RFC3325
CLID
• Typical deployment problem: [email protected] (in
possession of a valid PSTN number) would like
to call to PSTN through his gateway operator –
how does the gateway know which telephone
number to display?
• The proxy server “knows” the number (part of
subscriber’s profile) and can append it to SIP
requests.
• Missing piece: communicating the PSTN number
a server determined to gateway in .
• The standard: “asserted identity“, RFC3325.
INVITE sip:[email protected]
INVITE sip:[email protected] From: sip:[email protected];tag=12
From: sip:[email protected];tag=12
:+14085264000
To: sip:[email protected]
To: sip:[email protected] P-Asserted-Identity: tel:+14085264000
a
PSTN
200 OK w/JPEG
SIP/2.0 200 OK
Via: SIP/2.0/UDP here.com:5060
From: BigGuy <sip:[email protected]>
To: LittleGuy <sip:[email protected]>
Call-ID: [email protected]...
Calling Me?
INVITE sip:[email protected] SIP/2.0
To: <sip:[email protected]>
From: <sip:[email protected]>; tag=c775
Authorization: Digest username=“john", realm=“iptel.org", algorithm="md5",
uri="sip:[email protected]", nonce="3edab81b7a8427be362c2a924f3171d215a8f7d3",
response="4a868f9cbffd2b1f39c778abca78f75b".
P-Asserted-Identity: tel:+14085264000
Identity: "ZYNBbHC…hVn9Yc6U="
Iptel.org Fwd.com
TLS
Digest
authentication
Security of Media
• A variety of encryption protocols for securing
media available, it is just that keying is so
troublesome that they hardly get deployed
• New emerging alternative: zRTP (work of PGP
author Phil Zimmerman)
– Works without prior knowledge of keying material and
without any change to infrastructure: solely end-
device feature
– Session key is established dynamically using Diffie-
Hellman algorithm
– Encrypted media is transmitted using SRTP
Telephony)
• This is really discomforting image: world’s
telemarketers offering you their goods over the
Internet at virtually no cost for them.
•Service space
•Internet Services (messaging, presence, …)
•PBX-services
•Service Programming
A C
#4 200 OK
#6 NOTIFY (OK)
#5
200 ACK
200 OK
#7
media
Jiri Kuthan+Dorgham Sisalem, Tekelec, March 2007
RFC3515
Call Transfer/REFER
• Accomplished using the REFER method.
• The REFER method indicates that the recipient
(identified by the Request-URI) should contact a third
party using the contact information provided in the
method.
• New header fields: Refer-To, Refer-By.
• NOTIFY method used to report on result of referral.
• Note: No changes to proxy behavior required.
• Variants:
– With Consultation Hold (SIP Hold and unattended transfer)
– Attended Transfer, I.e., with a short conference
• REFER is a general method to have a phone called
someone else, other applications than call transfer
possible.
CGI Scripts
(Perl, Python, Servlets
User Code C, …)
Java
Interpreters SIP-CGI CPL
Servlets
(CGI)
• Follows Web-CGI. Unlike Web-CGI, SIP-CGI supports
proxying and processes responses as well.
• Language-indpendent (Perl, C, ...)
• Communicates through input/output and environment
variables.
• CGI programs unlimited in their power. Drawback: Buggy
scripts may affect server behavior easily.
• Persistency token (cookie) is passed between SIP server
and CGI to keep state across requests and related
responses.
1.2.3.1
BYE sip:[email protected] BYE sip:[email protected] 1.2.3.3
From: [email protected];tag=33 1.2.3.2 From: [email protected];tag=33
Route: <sip:[email protected];lr>
signaling compression
INVITE
INVITE
compressor sends
UDVM
Compressor
Decompressor
decompression
bytecode along with
UDP / TCP
(data internal
location -uid -name -did
-has -in -belongs to -has
to SER)
-username -did -name
-uid
-did -flags -value
-contact
-expiry
0..* -registered at
1 0..*
credentials usr_attrs
1
-uid -uid
-realm -belongs to -has -name
1 -digest_username -request initiated by -value
-password
-request received for 1
digest authentication,
# field; good anti-spam practise; it
# uses module actions for RegExp and
traversal helper,
if (!search(“From:.*iptel\.org”)
• Interface:
exec_msg(“/tmp/notify.sh”);
ENUM
no
User Online? INVITE request?
Registrar
no
Transaction
Report
Missed Call
Management
SIP: forward SIP: 404
request Not Found
Processing
Transport: UDP, TCP, TLS Multidomain Etc.
Support
Memory Management
HW-specific mutexes
• Authors: [email protected],
[email protected]
• SIP Express Router: http://www.iptel.org/ser/
• SIP Products:
http://www.iptel.org/views/Product_Database
• This Tutorial: http://www.iptel.org/sip/
• SIP Site: http://www.cs.columbia.edu/sip/
Left-hand picture: Broadway, 1890: Book of Old New York, Henry Collins
Brown,1913.
Right-hand picture showing Bell Labs’ voice based radio phone in 1924. Source:
www.privateline.com/mt_digitalbasics/
M AP
M AP Mh
A pplications
& S ervices H SS R -SG W
Signalling Interfa ce
Signalling a nd D ata T ransfer Interfa ce
• Public identity
User Identity 3
IMS Implicitly
Subscription Registered ID
• Support
Mx Mx
P-CSCF Mx
IBCF
– Topology hiding
Mx
IMS-ALG THIG
– Packet screening:
IMS network
P-CSCF I-CSCF
Reg Authorization
Public, Request profile
Private ID
Reg Path (P-CSCF)
OK 200 Public,
OK 200
Service Route Private ID
S-CSCF
Service-Route (S-CSCF)
(S-CSCF)
UE Home
UE RAND,AUTN RAND,AUTN,CK,IK
AV= RAND,AUTN,CK,IK, XRES
AV = RAND||AUTN||XRES||CK||IK
HSS
RAND = Random number
AUTN = SQN ⊕ AK || AMF || MAC
MAC = Message authentication code
AMF = Authentication Management Field
AK = Anonymity key
XRES = Result
CK = Cipher key = f3(K, RAND)
IK = Integrity key = f4(k,RAND)
UE OK OK
AK = f5(K, RNAD)
SQN = AK(AUTN)
XMAC = f1(K,(SQN|RAND|AMF)
XMAC = MAC ?
RES = f1(K,RAND)
CK = f3(K, RAND)
IK = f4(k,RAND)
Zb
S-CSCF
UE Home
Subscribe
UE P-Asserted-Identity (P-CSCF)
OK 200
Notify
OK 200
Foreign
Notify
Sub.-State: Terminated
Notify
Sub.-State: Terminated
CSCF
CSCF
HSS
S-
P-
OK 200
OK 200
UE
Notify
OK 200
INV INV
Prov.
I -CSCF
CSCF
CSCF
CSCF
CSCF
P-
S-
S-
P-
OK 200
UE UE
ACK
P-CSCF
4) PRACK PRCK
5) 200 OK (PRACK) 200 OK (PRACK)
UPDATE
9) UPDATE
10) 200 OK (UPDATE) 200 OK (UPDATE)
UE 2) DIAMETER REQ
PDF
8) COPS REQ
GGSN
SGSN
P-CSCF
P-CSCF 1) BYE. 1) BYE.
2) BYE.
2) BYE.
5) BYE
5) 200 OK
CSCF
CSCF
S- 6) 200 OK
S-
8) 200 7) 200 OK
PDF
PDF
UE
OK
UE
3) 3)
GGS N
GGS N
1. Setup
2. Initial DP
(called party #)
Call Proceeding
3. Connect (IMRN)
4. IAM
(IMRN)
5.INVITE
5.INVITE
( To: IMRN,MGCF
)
Offer
6. INVITE
(To: IMRN; Offer
)
MGCF
7. INVITE
(To: Other End URL; Offer
)
MGCF
AN 200 OK 200 OK
M ACK
ACK
Connect ACK
CS Bearer
CS Bearer
1. INVITE(To: CCCF
-PSI URL; Offer
UE) 2. INVITE(To: CCCF
-PSI URL; Offer
UE)
3. UPDATE( SDPUE)
Intermediate SIP message exchange and resource reservation as
normal- skipped for brevity.
IMS Bearer