Вы находитесь на странице: 1из 40

SIP Protocol

Protocol format and headers

Contents

SIP Protocol generally


SIP addressing, SIP URIs
SIP responses
SIP methods
SIP message format
Headers
Body

SIP Protocol generally


SIP is a text based
Similar to HTTP
SIP transaction / Call Leg
Client sends a Request
Server replies with one or more Responses
Identified by To, From and Call-ID headers

UDP or TCP is used as a transmission


protocol

SIP Protocol generally


Three way handshake in INVITE

SIP Addressing
SIP URIs are used
sip:user:password@host:port;url-parameters?headers

Several SIP headers use URI format

Request line
From
To
Contact

SIP Addressing (cont.)


SIP URIs, url-parameters
user: used to determine if username is a
telephone number (user=phone)
method: indicates the method to be used
ttl: time to live
maddr: multicast address where request should
be directed

Headers, for example subject=Hey

SIP Addressing (cont.)


tags: cryptographically random number,
added to To and From headers identifies a
call-leg

SIP Responses

1xx Informational
2xx Success
3xx Redirection
4xx Client Error resubmit after
modification

5xx Server error Message OK but cannot be


prosessed in this server

6xx Global Failure

SIP Responses, 1xx


(Informational)
100 Trying
hop-by-hop response
100 Trying is never forwarded
generated by a Proxy server or an User agent

180 Ringing
Indicates that the INVITE has been received by the
called User agent
Ringtone can be conveyd in the message body from
UAS to UAC

SIP Responses, 2xx (Success)


200 OK
Currently only Success-class response defined
in SIP
Indicates acceptance of INVITE (includes
media properties of the called UAS)

SIP Responses, 3xx (Redirection)


300 Multiple Choices
Request is responded with multiple Contact choices,
which should be used in that order in re-request

301 Moved Permanently


Response contains a permanent Contact header of the
called party address can be saved and used later

302 Moved Temporarily


Response contains a temporary Contact header of the
requested party should not be cached unless Expires
header is present

SIP Responses, 3xx (Redirection)


305 Use Proxy
Response includes an address for a proxy, to
which the request should be sent

380 Alternative Service


Indicates the type of service that the called
party would like for example voice mail or
redirect server

SIP Responses, 4xx (Client error)


400 Bad Request
Not understood by the server (missing required
header? or multiple INVITEs for same Call-ID)

401 Unauthorized
Indicates, that the user is required to perform
Authentication
Sent By User Agent or Registrar

SIP Responses, 4xx (Client error)


404 Not Found
SIP URL can not be located by the server

407 Proxy Authentication Required


Indicates, that UAC must authenticate itself to
the proxy

408 Request Timeout


INVITE has not been forwarded before request
has expired (Expires header)

SIP Responses, 4xx (Client error)


480 Temporary unavailable
Called party is not available for some reason

482 Loop Detected


Request has been routed back to the proxy that
previously forwarded the request

483 Too Many Hops


Request has been forwarded the maximum
number of times set by Max-Forwards

SIP Responses,5xx (Server error)


500 Server internal error
501 Not Implemented
503 Service unavailable
Actual message was correct and may be
sent to some other server

SIP Responses,6xx (Global error)


Should not be sent anywhere it fails
everywhere
600 Busy everywhere
606 Not Acceptable

SIP Methods
INVITE
Invite to participate in a session or change parameters
of an existing session
Includes usually message body with media information
of caller

ACK
Acknowledge a received final response (200-699)
May contain message body with media information
Invite (A-B) 200 OK (B-A) ACK (A-B)

BYE
Terminate an established media session

SIP Methods, example1

SIP Methods, example2

SIP Methods (cont.)


REGISTER
register current locations to registrar server,
redirect/proxy requests to current location
remove existing registrations (Expires = 0)

CANCEL
Request to cancel pending request
Also sent by forking proxies after succesful
response to one of the branched requests

SIP Methods, example3


REGISTER sip:feanor.pc.lut.fi SIP/2.0
Via: SIP/2.0/UDP 157.24.25.137:5060
From: athamala <sip:athamala@feanor.pc.lut.fi>
To: athamala <sip:athamala@feanor.pc.lut.fi>
Call-ID: 123456789@aradan
CSeq: 1 REGISTER
Contact: <sip:athamala@157.24.25.137>
Content-Length: 0

UA

SIP/2.0 200 OK
Via: SIP/2.0/UDP feanor.pc.lut.fi:5060
From: athamala <sip:athamala@feanor.pc.lut.fi>
To: athamala <sip:athamala@feanor.pc.lut.fi>
Call-ID: 123456789@aradan
CSeq: 1 REGISTER
Contact: <sip:athamala@157.24.25.137>;expires=3600
Content-Length: 0

UA

REGISTRAR

REGISTRAR

SIP Methods, example4

SIP Methods (cont.)


INFO
used to send call signalling information to
another user agent
it doesnt change anything
for example in SIP<->PSTN to transfer DTMF
signals

OPTIONS
Query server or user agent about its capabilities

SIP Methods (cont.)


SUBSCRIBE
To query presence information of other user

NOTIFY
To inform other users about state of presentity

MESSAGE
To send instant message body

SIP Methods (cont.)


PRACK
To acknowledge informational (1xx) messages
Not very widely used

COMET
Allows UAS to indicate, that QOS
preconditions have been met

REFER
To initiate a third-party call control

SIP Message format


1.a) Request URL in Request (contains next
hop in the path)
INVITE user@host.com SIP/2.0

1.b) Status line in responses


SIP/2.0 200 OK or similar

2) Headers (From, To, Via, ...)


3) Empty line
4) Message body

SIP Message, request example


INVITE sip:jarsku@feanor.pc.lut.fi SIP/2.0
Via: SIP/2.0/UDP 157.24.25.137:5060
From: Arto <sip:athamala@feanor.pc.lut.fi>
To: Jari <sip:jarsku@feanor.pc.lut.fi>
Call-ID: 123456789@aradan
CSeq: 1 INVITE
Contact: <sip:athamala@157.24.25.137>
Content-Type: application/sdp
Content-Length: 147
v=0
o=athamala 2890844526 2890844526 IN IP4 aradan.pc.lut.fi
s=Session SDP
c=IN IP4 157.24.25.137
t=0 0
m=audio 49172 RTP/AVP 0
a=rtpmap:0 PCMU/8000

SIP Message, response example


SIP/2.0 200 OK
Via: SIP/2.0/UDP 157.24.25.137:5060
From: Arto <sip:athamala@feanor.pc.lut.fi>
To: Jari <sip:jarsku@feanor.pc.lut.fi>;tag=314152
Call-ID: 123456789@aradan
CSeq: 1 INVITE
Contact: <sip:jarsku@157.24.25.139>
Content-Type: application/sdp
Content-Length: 149
v=0
o=jarsku 2890844527 2890844527 IN IP4 haldir.pc.lut.fi
s=Session SDP
c=IN IP4 157.24.25.139
t=0 0
m=audio 3456 RTP/AVP 0
a=rtpmap:0 PCMU/8000

SIP Message format, headers


From
Contains the initiator of the request (SIP URI),
required in all SIP messages

To
Contains the recipient of the request (SIP URI),
required in all SIP messages

SIP Message format, headers


Call-ID
Unique identification code for Call, mandatory
in all SIP requests and responses
Call-ID: 2345kjh23kjh3@feanor.pc.lut.fi

CSeq
Sequence number for requests, UAS decide if
the request is a retransmission (same CSeq) or
new request
Cseq: 1 INVITE

SIP Message format, headers


Contact
URL, which identifies the requested resource or the
request originator, mandatory in INVITE and 200
OK responses to invitations.
Contact: Arto Hamalainen
<sip:athamala@feanor.pc.lut.fi>

Via
To store addresses of all the proxies which handle the
request, helps in loop detection and routing, required
Via: SIP/2.0/UDP feanor.pc.lut.fi:5060

SIP Message format, via processing

SIP Message format, headers


WWW-Authenticate / Proxy-Authenticate
in 401 Unauthorized or 407 Proxy
authentication required

Authorization / Proxy Authorization


in reply to 401 or 407, includes user credentials

Content-Length
Content-Type (for example application/sdp)

SIP Message format, headers


Record-Route
Record Route header is used by proxies to force
that future requests in the same call will be
forwarded through this route

Route
In future requests Record-route is copied as a
Route header which forces request to go
through the proxy which inserted Record-route
in the previous request

SIP Message format, body


Some SIP messages have also message
body. It can be for example
SDP/XML media description
Instant message data (in MESSAGE)

Body type and length explained in ContentType and Content-Length headers

SIP Message format, body (SDP)


...
Content-Type: application/sdp
Content-Length: 147
v=0
o=athamala 2890844526 2890844526 IN IP4 here.com
s=Session SDP
c=IN IP4 100.101.102.103
t=0 0
m=audio 49172 RTP/AVP 0
a=rtpmap:0 PCMU/8000

SIP Protocol format


SIP is text-based signalling protocol
Client sends Requests Server responds
with a Response
Request methods: INVITE, REGISTER,
CANCEL, BYE, INFO, OPTIONS, ACK
Response codes: 1xx-6xx

SIP Protocol format


Headers: From, To, Via, Call-ID, CSeq,
Contact, ...
Payload usually SDP Description, can be
something else (XML, ...)

Вам также может понравиться