Understanding SIP Protocol Basics
Understanding SIP Protocol Basics
[Link]
CORE SIP
WHAT IS SIP?
▸ SIP Stands for “Session Information Protocol” ▸ SIP is used to establish, modify and tear
down multi media sessions such as
▸ It is a Layer 7 (Application Layer) protocol. internet based phone calls, video calls
and instant messages.
▸ Really.. it’s not a layer 5 protocol, it’s layer 7
despite the word “session” in the name. ▸ It can also be used to invite other
participants into an existing session.
RFC 3261
▸ The original SIP RFC was 2543, but has been obsolete
since 2002.
Address of Record
A BACK-TO-BACK USER AGENT (B2BUA) IS A LOGICAL ENTITY THAT
RECEIVES A REQUEST AND PROCESSES IT AS A USER AGENT SERVER
(UAS). IN ORDER TO DETERMINE HOW THE REQUEST SHOULD BE
ANSWERED, IT ACTS AS A USER AGENT CLIENT (UAC) AND GENERATES
REQUESTS. UNLIKE A PROXY SERVER, IT MAINTAINS DIALOG STATE AND
MUST PARTICIPATE IN ALL REQUESTS SENT ON THE DIALOGS IT HAS
ESTABLISHED. SINCE IT IS A CONCATENATION OF A UAC AND UAS, NO
EXPLICIT DEFINITIONS ARE NEEDED FOR ITS BEHAVIOR.
Call
ANOTHER TERM FOR SIP DIALOG - NOT USED IN THE CURRENT RFC
Call Leg
PROXY IS CALL STATEFUL IF IT RETAINS STATE FOR A DIALOG FROM THE
INITIATING INVITE TO THE TERMINATING BYE REQUEST. A CALL STATEFUL
PROXY IS ALWAYS TRANSACTION STATEFUL, BUT THE CONVERSE IS NOT
NECESSARILY TRUE.
Call Stateful
A CLIENT IS ANY NETWORK ELEMENT THAT SENDS SIP REQUESTS AND
RECEIVES SIP RESPONSES. CLIENTS MAY OR MAY NOT INTERACT
DIRECTLY WITH A HUMAN USER. USER AGENT CLIENTS AND PROXIES
ARE CLIENTS.
Client
A DIALOG IS A PEER-TO-PEER SIP RELATIONSHIP BETWEEN TWO UAS
THAT PERSISTS FOR SOME TIME. A DIALOG IS ESTABLISHED BY
SIP MESSAGES, SUCH AS A 2XX RESPONSE TO AN INVITE REQUEST. A
DIALOG IS IDENTIFIED BY A CALL IDENTIFIER, LOCAL TAG, AND A
REMOTE TAG. A DIALOG WAS FORMERLY KNOWN AS A CALL LEG IN RFC
2543.
Dialog
A DIRECTION OF MESSAGE FORWARDING WITHIN A TRANSACTION THAT
FLOWS FROM THE UAC TO TO THE UAS.
Downstream
A RESPONSE THAT TERMINATES A SIP TRANSACTION, AS OPPOSED TO A
PROVISIONAL RESPONSE THAT DOES NOT. ALL 2XX, 3XX, 4XX, 5XX AND
6XX RESPONSES ARE FINAL.
Max-Forwards: 70
SIP Header
A HEADER FIELD IS A COMPONENT OF THE SIP MESSAGE HEADER. A
HEADER FIELD CAN APPEAR AS ONE OR MORE HEADER FIELD ROWS.
HEADER FIELD ROWS CONSIST OF A HEADER FIELD NAME AND ZERO
OR MORE HEADER FIELD VALUES. MULTIPLE HEADER FIELD VALUES ON
A GIVEN HEADER FIELD ROW ARE SEPARATED BY COMMAS. SOME
HEADER FIELDS CAN ONLY HAVE A SINGLE HEADER FIELD VALUE, AND
AS A RESULT, ALWAYS APPEAR AS A SINGLE HEADER FIELD ROW.
Location Services
A SIP REQUEST THAT HAS BEEN FORWARDED BY A PROXY, YET THE
REQUEST ARRIVES BACK AT THE PROXY THAT FORWARDED THE INITIAL
REQUEST.
Loop
A PROXY IS SAID TO BE LOOSE ROUTING IF IT FOLLOWS THE
PROCEDURES DEFINED IN THIS SPECIFICATION FOR PROCESSING OF THE
ROUTE HEADER FIELD. THESE PROCEDURES SEPARATE THE
DESTINATION OF THE REQUEST (PRESENT IN THE REQUEST-URI) FROM
THE SET OF PROXIES THAT NEED TO BE VISITED ALONG THE WAY
(PRESENT IN THE ROUTE HEADER FIELD). A PROXY COMPLIANT TO
THESE MECHANISMS IS ALSO KNOWN AS A LOOSE ROUTER.
Loose Routing
DATA SENT BETWEEN THE SIP ELEMENTS OF AS PART OF THE PROTOCOL.
A MESSAGE CAN BE A REQUEST OR A RESPONSE.
Message
THE METHOD IS THE PRIMARY FUNCTION THAT A REQUEST IS MEANT TO
INVOKE ON A SERVER. THE METHOD IS CARRIED IN THE REQUEST
MESSAGE ITSELF. EXAMPLE METHODS ARE INVITE AND BYE.
Method
A PROXY THAT RECEIVES REQUESTS FROM A CLIENT, EVEN THOUGH IT
MAY NOT BE THE SERVER RESOLVED BY THE REQUEST-URI. TYPICALLY, A
UA IS MANUALLY CONFIGURED WITH AN OUTBOUND PROXY, OR CAN
LEARN ABOUT ONE THROUGH AUTO-CONFIGURATION PROTOCOLS.
Outbound Proxy
A RESPONSE USED BY THE SERVER TO INDICATE PROGRESS, BUT THAT
DOES NOT TERMINATE A SIP TRANSACTION. 1XX RESPONSES ARE
PROVISIONAL, OTHER RESPONSES ARE CONSIDERED FINAL.
Provisional Response
AN INTERMEDIARY ENTITY THAT ACTS AS BOTH A SERVER AND A CLIENT FOR THE
PURPOSE OF MAKING REQUESTS ON BEHALF OF OTHER CLIENTS. A PROXY
SERVER PRIMARILY PLAYS THE ROLE OF ROUTING, WHICH MEANS ITS JOB IS TO
ENSURE THAT A REQUEST IS SENT TO ANOTHER ENTITY "CLOSER" TO THE TARGETED
USER. PROXIES ARE ALSO USEFUL FOR ENFORCING POLICY (FOR EXAMPLE,
MAKING SURE A USER IS ALLOWED TO MAKE A CALL). A PROXY INTERPRETS, AND,
IF NECESSARY, REWRITES SPECIFIC PARTS OF A REQUEST MESSAGE BEFORE
FORWARDING IT.
Recursion
A REDIRECT SERVER IS A USER AGENT SERVER THAT GENERATES 3XX RESPONSES
TO REQUESTS IT RECEIVES, DIRECTING THE CLIENT TO CONTACT AN ALTERNATE SET
OF URIS.
Redirect Server
A REGISTRAR IS A SERVER THAT ACCEPTS REGISTER REQUESTS AND PLACES THE
INFORMATION IT RECEIVES IN THOSE REQUESTS INTO THE LOCATION SERVICE FOR
THE DOMAIN IT HANDLES.
Registrar
A TRANACTION WHERE THE METHOD IS NOT INVITE, ACK OR CANCEL.
Regular Transaction
A SIP MESSAGE SENT FROM A USER AGENT CLIENT TO A USER AGENT SERVER
THAT INVOKES A CERTAIN OPERATION.
Request
A SIP MESSAGE SENT FROM A UAS TO A UAC INDICATING THE STATUS OF A
REQUEST.
Response (code)
YEAH… YOU KNOW WHEN YOU MAKE A CALL AND BEFORE THE OTHER PERSON
ANSWERS YOU HEAR RINGING. THAT’S RINGBACK. IT’S USED TO INFORM YOU
THAT THE OTHER PARTY IS BEING ALERTED.
Ringback
A ROUTE SET IS A COLLECTION OF ORDERED SIP OR SIPS URI WHICH REPRESENT
A LIST OF PROXIES THAT MUST BE TRAVERSED WHEN SENDING A PARTICULAR
REQUEST. A ROUTE SET CAN BE LEARNED, THROUGH HEADERS LIKE RECORD-
ROUTE, OR IT CAN BE CONFIGURED.
Route Set
A SERVER IS A NETWORK ELEMENT THAT RECEIVES REQUESTS IN
ORDER TO SERVICE THEM AND SENDS BACK RESPONSES TO THOSE
REQUESTS. EXAMPLES OF SERVERS ARE PROXIES, USER AGENT SERVERS,
REDIRECT SERVERS, AND REGISTRARS.
Server
IN A SEQUENTIAL SEARCH, A PROXY SERVER ATTEMPTS EACH CONTACT ADDRESS
IN SEQUENCE, PROCEEDING TO THE NEXT ONE ONLY AFTER THE PREVIOUS HAS
GENERATED A FINAL RESPONSE. A 2XX OR 6XX CLASS FINAL RESPONSE ALWAYS
TERMINATES A SEQUENTIAL SEARCH.
Sequential Searching
FROM THE SDP SPECIFICATION: "A MULTIMEDIA SESSION IS A
SET OF MULTIMEDIA SENDERS AND RECEIVERS AND THE DATA STREAMS
FLOWING FROM SENDERS TO RECEIVERS. A MULTIMEDIA CONFERENCE IS
AN EXAMPLE OF A MULTIMEDIA SESSION." (RFC 2327 [1]) (A SESSION
AS DEFINED FOR SDP CAN COMPRISE ONE OR MORE RTP SESSIONS.) AS
DEFINED, A CALLEE CAN BE INVITED SEVERAL TIMES, BY DIFFERENT
CALLS, TO THE SAME SESSION. IF SDP IS USED, A SESSION IS
DEFINED BY THE CONCATENATION OF THE SDP USER NAME, SESSION ID,
NETWORK TYPE, ADDRESS TYPE, AND ADDRESS ELEMENTS IN THE ORIGIN
FIELD.
Session
A SIP TRANSACTION OCCURS BETWEEN A CLIENT AND A
SERVER AND COMPRISES ALL MESSAGES FROM THE FIRST REQUEST SENT
FROM THE CLIENT TO THE SERVER UP TO A FINAL (NON-1XX) RESPONSE SENT
FROM THE SERVER TO THE CLIENT. IF THE REQUEST IS INVITE
AND THE FINAL RESPONSE IS A NON-2XX, THE TRANSACTION ALSO
INCLUDES AN ACK TO THE RESPONSE. THE ACK FOR A 2XX RESPONSE TO
AN INVITE REQUEST IS A SEPARATE TRANSACTION.
SIP Transaction
IS A SIP REQUEST THAT IS SENT TO A PROXY, FORWARDED ONWARDS, BUT
ARRIVES BACK AT THE PROXY, HOWEVER THE DESTINATION HAS BEEN MODIFIED.
THIS TYPICALLY IMPLIES THAT THE REQUEST URI IS LISTED AS SOMETHING OTHER
THAT WHAT THE FIRST MESSAGE STATED.
A PRIME EXAMPLE : A CALLS THAT IS FORWARDED.
Spiral
A LOGICAL ENTITY THAT MAINTAINS THE CLIENT AND
SERVER TRANSACTION STATE MACHINES DEFINED BY THIS SPECIFICATION
DURING THE PROCESSING OF A REQUEST, ALSO KNOWN AS A TRANSACTION
STATEFUL PROXY. THE BEHAVIOR OF A STATEFUL PROXY IS FURTHER
DEFINED IN SECTION 16. A (TRANSACTION) STATEFUL PROXY IS NOT
THE SAME AS A CALL STATEFUL PROXY.
Stateful Proxy
A LOGICAL ENTITY THAT DOES NOT MAINTAIN THE
CLIENT OR SERVER TRANSACTION STATE MACHINES DEFINED IN THIS
SPECIFICATION WHEN IT PROCESSES REQUESTS. A STATELESS PROXY
FORWARDS EVERY REQUEST IT RECEIVES DOWNSTREAM AND EVERY
RESPONSE IT RECEIVES UPSTREAM.
Stateless proxy
A PROXY IS SAID TO BE STRICT ROUTING IF IT FOLLOWS THE ROUTE PROCESSING
RULES OF RFC 2543 AND MANY PRIOR WORK INPROGRESS VERSIONS OF THIS
RFC. THAT RULE CAUSED PROXIES TO DESTROY THE CONTENTS OF THE REQUEST-
URI WHEN A ROUTE HEADER FIELD WAS PRESENT. STRICT ROUTING BEHAVIOR IS
NOT USED IN THIS SPECIFICATION, IN FAVOR OF A LOOSE ROUTING BEHAVIOR.
PROXIES THAT PERFORM STRICT ROUTING ARE ALSO KNOWN AS STRICT ROUTERS.
Strict Routing
A DIRECTION OF MESSAGE FLOW WHERE THE MESSAGE FLOWS FROM THE UAS TO
THE UAC
Upstream
A USER AGENT CLIENT IS A LOGICAL ENTITY
THAT CREATES A NEW REQUEST, AND THEN USES THE CLIENT
TRANSACTION STATE MACHINERY TO SEND IT. THE ROLE OF UAC LASTS
ONLY FOR THE DURATION OF THAT TRANSACTION. IN OTHER WORDS, IF
A PIECE OF SOFTWARE INITIATES A REQUEST, IT ACTS AS A UAC FOR
THE DURATION OF THAT TRANSACTION. IF IT RECEIVES A REQUEST
LATER, IT ASSUMES THE ROLE OF A USER AGENT SERVER FOR THE
PROCESSING OF THAT TRANSACTION.
I WILL REFER TO THIS AS A “UAC”
User Agent
CLIENTS AND
SERVERS
CLIENTS AND SERVERS
▸ SIP endpoints are known as User-
Agents. In the most basic form,
there are two types of user agents
the required to setup a call.
USER AGENT CLIENT
▸ User Agent Client (UAC): A user
agent client is a logical entity that
creates a new request, and then uses
the client transaction state machinery
to send it. The role of UAC lasts only
for the duration of that transaction. RFC Definition
In other words, if a piece of software
initiates a request, it acts as a UAC
for the duration of that transaction. If
it receives a request later, it assumes
the role of a user agent server for the
processing of that transaction.
USER AGENT CLIENTS
▸ Imagine this. You see your friend across the room. As you
approach, you say “Hey Dan, want to go to a movie”.
I’ll ask
Request - Alice wants to go to lunch with you
Uhhhhhhhhhhh
Ok - I will go with her
Bob Says Ok
Yay!
She Says “YAY!”
BACK TO BACK USER AGENT
▸ See what happened? Dave acted as the back to back user
agent in this scenario. He received the request from Alice,
then created a new request toward Bob. Dave also
remained in the conversation and kept track of what was
going on.
This is weird..
Opens the note. Decides his response is to go .
▸ SIP has a set of rules that must be followed for all messages.
Start line:
Message Headers
Empty Line
Message Body
SIP REQUESTS
▸
SIP REQUESTS
▸ Lets break this down a bit more. As this is a request, the
start line will present the Request Line
INVITE sip:bob@[Link] SIP/2.0
▸ Below that (red box) we have the message headers. Call-ID: 3848276298220188511@[Link]
CSeq: 1 INVITE
s=-
▸ Finally, we have the message body. In this example the
c=IN IP4 [Link]
Content-Type is “application / SDP” , so the message
t=0 0
body is an SDP here.
m=audio 49172 RTP/AVP 0
a=rtpmap:0 PCMU/8000
SIP REQUEST METHODS
▸ RFC 3261 defines six methods :
▸ RFC 3265 :
▸ RFC 3515:
▸ RFC 3262 :
▸ RFC 3903 :
▸ RFC 6086 :
▸ RFC 3311 :
▸ The status-line will present the protocol version, a three From: Alice <sip:alice@[Link]>;tag=9fxced76sl
digit status code (180 in this example), and an associated To: Bob <sip:bob@[Link]>;tag=8321234356
text description of the status code which is known as the
Call-ID: 3848276298220188511@[Link]
Reason-Phrase.
CSeq: 1 INVITE
▸ The status code required and will be interpreted by the Contact: <sip:bob@[Link];transport=tcp>
UAC’s SIP stack. Content-Length: 0
This implies that the UAS received the INVITE Request and that
the UAC should initiate local ringback while further call
processing takes place.
181 CALL IS BEING FORWARDED
A server MAY use this status code to indicate that the call is
being forwarded to a different set of destinations.
182 QUEUED
‣ Have you ever moved and notified your postal service that you
no longer live at a certain address? Sometimes the postal
service will reject delivery of new mail, and send it back to the
sender stating that you have moved. When they do this, the
postal service lets the sender know your new address
302 TEMPORARILY MOVED
‣ The requesting client SHOULD retry the request at the new
address(es) given by the Contact header field (Section 20.10).
The Request-URI of the new request uses the value of the
Contact header field in the response.
‣ Have you been around a friend that says something that makes
absolutely no sense, yet you want to let him or her know?
That’s similar to the 400 Bad Request.
‣ This is often seen when “fuzzing” a SIP stack. Fuzzing is the act
of sending malformed data to a server in an attempt to
overload, or compromise a security weakness.
401 UNAUTHORIZED ( OR 401 PROXY REQUIRES AUTHENTICATION)
‣ This states that the UAS wants the UAC to authenticate. A
common scenario for this is when a UAC is attempting to
register.
UAC UAS
REGISTER
401 Unauthorized
200 OK
403 FORBIDDEN
‣ This implies that the UAS understood the request, but refuses
to fulfill it. Authorization will do nothing, and the request
SHOULD NOT be repeated.
UAC UAS
INVITE
403 Forbidden
403 FORBIDDEN
‣ You will see this often as a security measure. Many systems will
issue this if a UAC sends an INVITE and is not registered.
UAC UAS
INVITE
403 Forbidden
404 NOT FOUND
‣ This implies that the UAS received the response, however the
user does not exists at the domain specified within the
Request URI. This could also be sent if the domain doesn’t
match.
‣ Call the wrong number, you can expect to see a SIP 404.
UAC UAS
INVITE
INVITE
100 Trying
INVITE
If a request is sent with too many headers and /or a massive SDP,
you can expect to receive this response.
414 REQUEST-URI TOO LONG
When this is sent the UAS MUST include a list of the unsupported
extensions in an Unsupported header field within the response.
Note - This does not imply that the Extension NUMBER dialed is
bad. That would be more inline with a SIP 404.
421 EXTENSION REQUIRED
The UAS needs a particular extension to process the request, but
this extension is not listed in a Supported header field in the
request.
This status indicates that the UAS received a request that does
not match any existing dialog or transaction.
482 LOOP DETECTED
The Server has detected a loop. In my experience, I’ve seen this
frequently where packet loss is occurring.
UAC UAS
REGISTER
401 Unauthorized
Note that a 405 (Method Not Allowed) is sent when the server
recognizes the request method, but that method is not allowed
or supported.
501 NOT IMPLEMENTED
The server does not support the functionality required to fulfill
the request. This is the appropriate response when a UAS does
not recognize the request method and is not capable of
supporting it for any user. (Proxies forward all requests
regardless of method.)
Note that a 405 (Method Not Allowed) is sent when the server
recognizes the request method, but that method is not allowed
or supported.
502 BAD GATEWAY
A 606 (Not Acceptable) response means that the user wishes to communicate, but cannot
adequately support the session described. The 606 (Not Acceptable) response MAY contain a list
of reasons in a Warning header field describing why the session described cannot be supported.
A message body containing a description of media capabilities MAY be present in the response,
which is formatted according to the Accept header field in the INVITE (or application/sdp if not
present), the same as a message body in a 200 (OK) response to an OPTIONS request.
It is hoped that negotiation will not frequently be needed, and when a new user is being invited
to join an already existing conference, negotiation may not be possible. It is up to the invitation
initiator to decide whether or not to act on a 606 (Not Acceptable) response.
This status response is returned only if the client knows that no other end point will answer the
request.
THE SIP URI
THE SIP URI
▸ You’ve seen an email address right?
▸ SIP is based off of the same URI (uniform resource indicator) structure.
As defined in RFC 2396
▸ sip:user:password@host:port;parameters or
sip:user@host:port;parameters
▸
THE SIP URI
▸ sip:bob@[Link];user=phone
SCHEME
The scheme provides a description of the type of URI that is in use. Typically, it’s going to represent the name
of the protocol. In the case of SIP, the scheme can be SIP or SIPS. SIPS is used for secure SIP
THE SIP URI
▸ sip:bob@[Link];user=phone
SCHEME
USER
The user section describes the resources that is being referenced. While it’s common to see this as an
extension or phone number, it is not required.
THE SIP URI
▸ sip:bob@[Link];user=phone
SCHEME HOST
USER
The host section describes the host that is providing the resource. This can be presented as an FQDN (fully
qualified domain name) IPv4 address or IPV6 address. According to the RFC, it is RECOMMENDED to use an
FQDN where possible.
THE SIP URI
▸ sip:bob@[Link];user=phone
SCHEME HOST
USER PORT
This will list the port number where the request is sent to
THE SIP URI
▸ sip:bob@[Link];user=phone
SCHEME HOST
USER PORT PARAMETERS
Parameters are used to add extra information to the URI. They are added after the port and separated by a
semi-colon (;).
There is no limit on the number of parameters that can be included in a URI, however the same parameter
name MUST NOT appear more than once.
THE SIP URI
▸ sip:bob@[Link];user=phone
SCHEME HOST
USER PORT PARAMETERS
Parameters can be a proprietary to a certain SIP stack, however common ones are:
SCHEME HOST
USER PORT PARAMETERS
The transport parameter determines the transport method for sending the message. You
will see either UDP or TCP listed here.
For SIPS URIs, a reliable transport method must be listed. Such as TLS
THE SIP URI
▸ sip:bob@[Link];user=phone
SCHEME HOST
USER PORT PARAMETERS
This defines the server to be contacted for this user. This completely overrides what you see
in the host portion of the URI.
SCHEME HOST
USER PORT PARAMETERS
The ttl parameter determines the time-to-live value of the UDP multicast packet. This MUST
only be used if the maddr parameter is a multicast address
THE SIP URI
▸ sip:bob@[Link];user=phone
SCHEME HOST
USER PORT PARAMETERS
The user parameter is used to distinguish telephone numbers usernames that look like
telephone numbers. If the user portion of the URI contains a telephone number formatted
as a subscriber, the user value SHOULD be “phone”.
Even without this param a recipient of a SIP or SIPS request may interrupt the pre @ sign
section as a phone number.
THE SIP URI
▸ sip:bob@[Link];user=phone
SCHEME HOST
USER PORT PARAMETERS
The lr parameter indicates that the device responsible for the resource implements the
routing methods as defined in RFC 3261. If a record-route header is added to a message,
you will see see the lr parameter added to the URI.
▸ They describe, who is calling, what is allowed in the call in terms of new requests and much more
v=0
SDP o=alice 2890844526 2890844526 IN IP4 [Link]
s=-
c=IN IP4 [Link]
t=0 0
m=audio 49172 RTP/AVP 0
a=rtpmap:0 PCMU/8000
SIP HEADERS
▸ A valid request from a UAC must contain a To, From, Cseq, Call-Id, Max-Forwards, and VIA header field.
▸ These six headers are the fundamental building blocks in a SIP message. .
v=0
o=alice 2890844526 2890844526 IN IP4 [Link]
s=-
c=IN IP4 [Link]
t=0 0
m=audio 49172 RTP/AVP 0
a=rtpmap:0 PCMU/8000
SIP HEADERS
▸ They provide information for :
▸ Addressing of messages.
▸ Routing of responses.
▸ Ordering of messages.
▸ Addressing of messages.
▸ Routing of responses.
▸ Ordering of messages.
▸ The initial RURI SHOULD be set to the same value found in the To
field.
▸ Should - In reality I see a lot of scenarios where this is not true. One
example is where the RURI matches the pilot user AOR, and TO field
matches the actual resource you are trying to send the message to.
▸ In a REGISTER request, the Ruri MUST NOT list the user info and “@“
components of the SIP URI. It simply lists the domain (or IP) of the
location service.
HEADER DEFINITIONS
▸ To
▸ Call-ID: 3848276298220188511@[Link]
▸ It MUST be the same for all requests within the same dialog.
▸ CSeq: 1 INVITE
▸ Max-Forwards: 70
▸ If this reaches “0” by the time it reaches the destination, the UAS will
reject the call with a “483 - Too Many Hops response.
▸ According to the RFC - the UAC generating the request SHOULD set
this value to 70.
▸ Max-Forwards: 70
Max-Forwards: 69
Max-Forwards: 68
Max-Forwards: 69
HEADER DEFINITIONS
▸ Via
▸ Via: SIP/2.0/TCP [Link];branch=z9hG4bK74bf9
▸ This is used for routing responses and identifies the transport used for this
transaction.
▸ The branch parameter must be unique across “all time and space” for requests
sent by this UAC.
▸ An ACK for a non 200 response will match the INVITE that it is
acknowledging.
HEADER DEFINITIONS
▸ Via
▸ Via: SIP/2.0/TCP [Link];branch=z9hG4bK74bf9
▸ All branch parameters that are compliant with RFC 3261 must begin with
“z9hG4bK”
▸ The contact header provides a URI that can be used to contact the UA for
subsequent requests.
▸ When the expires param is listen the UAC should attempt to re-register in
less than the time specified.
HEADER DEFINITIONS
▸ Contact
▸ Contact: <sip:alice@[Link];transport=tcp>
▸ You may receive a 30X Redirect, which presents different URIs that you
should attempt to contact.
▸ You may receive a 30X Redirect, which presents different URIs that you
should attempt to contact.
▸ Alert-Info: <[Link]
▸ Content-Length 5060;branch=z9hG4bK74bf9
Max-Forwards: 70
From: Alice <sip:alice@[Link]>;tag=9fxced76sl
To: Bob <sip:bob@[Link]>
▸ Content-Type: application/sdp
▸
HEADER DEFINITIONS
▸ Min-Expires
▸ Min-Expires: 60
▸ Require: 100rel
▸ This is used by UACs to tell UASs about options that the UAC
expects the UAS to support in order to process a request.
▸ If you touch Lync / Skype for Business you will definitely see
this.
HEADER DEFINITIONS
▸ Route
▸ Supported: 100rel
▸ This header contains information about the UA. It could contain the
Manufacturer name, SIP UA version, and other information.
▸ Note - This is often “spoofed” to that attackers hide the name of their
scanning tools.
HEADER DEFINITIONS
▸ WWW-Authenticate
▸ These messages act the same as those with long format headers,
they just look different.
▸
COMPACT HEADERS
Abbreviation Header
a Accept-Contact
b Referred-By
c Content-Type
e Content-Encoding
f From
i Call-ID
k Supported
l Content-Length
m Contact
o Event
r Refer-To
s Subject
t To
u Allow-Events
v Via
SDP OVERVIEW
SESSION DESCRIPTION PROTOCOL
v=0
SDP o=alice 2890844526 2890844526 IN IP4 [Link]
s=-
c=IN IP4 [Link]
t=0 0
m=audio 49172 RTP/AVP 0
a=rtpmap:0 PCMU/8000
SESSION DESCRIPTION PROTOCOL
▸ Session Level -
▸ Media Level -
▸ v=
▸ Required field.
▸ o=
▸ Required field.
▸ o=
▸ o=
▸ o=
▸ o=
▸ The most common value you will see here is “IN”, short for
“internet”
▸
SESSION DESCRIPTION PROTOCOL
▸ o=
▸ For IPv4-
▸ IPv6 -
▸ Required.
▸ There must be one and only one “s=“ line in a valid SDP.
▸ Required.
▸ Required.
▸ m=
▸ 0 = g.711U
▸ 9 = g.722
▸ 18 = g.729a
SESSION DESCRIPTION PROTOCOL
▸ c=
▸
SESSION DESCRIPTION PROTOCOL
▸ c=
▸ c=
The Internet
Proxy
Firewall
Firewall
UAS
UAC
INVITE sip:bob@[Link] SIP/2.0 SIP/2.0 200 OK
<headers removed> <headers removed>
v=0 v=0
o=alice 2890844526 2890844526 IN IP4 [Link] o=alice 2890844526 2890844526 IN IP4 [Link]
s=- s=-
c=IN IP4 [Link] c=IN IP4 [Link]
t=0 0 t=0 0
m=audio 49172 RTP/AVP 0 m=audio 49172 RTP/AVP 0
a=rtpmap:0 PCMU/8000 a=rtpmap:0 PCMU/8000
SESSION DESCRIPTION PROTOCOL
▸ Addition session-level field (optional)
▸ i = session information
▸ u = uri of description
▸ e = email address
▸ p = phone number
▸ b = bandwidth
▸ z = timezone adjustments
▸ k = encryption key
▸ a = attributes
SESSION DESCRIPTION PROTOCOL
▸ i= media title
▸ b= bandwidth information
▸ k= encryption key
▸ a = attributes
SESSION DESCRIPTION PROTOCOL
▸ There are times where the attributes can be extremely helpful identifying what is going on with a
session.
Proxy
UAS
UAC
INVITE sip:bob@[Link] SIP/2.0 SIP/2.0 200 OK
<headers removed> <headers removed>
v=0 v=0
o=alice 333333 4444 IN IP4 [Link] o=bob 2222 3333 IN IP4 [Link]
s=- s=-
c=IN IP4 [Link] c=IN IP4 [Link]
t=0 0 t=0 0
a=sendrecv a=sendrecv
m=audio 49172 RTP/AVP 0 m=audio 49172 RTP/AVP 0
a=rtpmap:0 PCMU/8000 a=rtpmap:0 PCMU/8000
SESSION DESCRIPTION PROTOCOL
▸ Notice that the UAC sends other INVITE, but the attribute has
changed to “sendonly”
▸ The UAS accepts the new invite, and sets their attribute to “recvonly”
Proxy
UAS
UAC
INVITE sip:bob@[Link] SIP/2.0 SIP/2.0 200 OK
<headers removed> <headers removed>
v=0 v=0
o=alice 333333 4445 IN IP4 [Link] o=bob 2222 3334 IN IP4 [Link]
s=- s=-
c=IN IP4 [Link] c=IN IP4 [Link]
t=0 0 t=0 0
a=sendonly a=recvonly
m=audio 49172 RTP/AVP 0 m=audio 49172 RTP/AVP 0
a=rtpmap:0 PCMU/8000 a=rtpmap:0 PCMU/8000
SESSION DESCRIPTION PROTOCOL
▸ This call is now on hold.
▸ When the UAC wants to resume the call, they will send another INVITE
with the a= line set to “sendrecv”
Proxy
UAS
UAC
INVITE sip:bob@[Link] SIP/2.0 SIP/2.0 200 OK
<headers removed> <headers removed>
v=0 v=0
o=alice 333333 4446 IN IP4 [Link] o=bob 2222 3335 IN IP4 [Link]
s=- s=-
c=IN IP4 [Link] c=IN IP4 [Link]
t=0 0 t=0 0
a=sendrecv a=sendrecv
m=audio 49172 RTP/AVP 0 m=audio 49172 RTP/AVP 0
a=rtpmap:0 PCMU/8000 a=rtpmap:0 PCMU/8000
SESSION DESCRIPTION PROTOCOL
▸ Additional attributes:
▸ a=cat
▸ session-level attribute
▸ a=keywords
▸ session-level attribute
▸ a=tool
▸ session-level attribute
▸ a=ptime
▸ media-level attribute
▸ a=maxptime
▸ media-level attribute
▸ a=rtpmap
▸ media-level attribute
▸ Example:
▸ a=rtpmap:0 PCMU/8000
▸ a=rtpmap:18 G729/8000
SESSION DESCRIPTION PROTOCOL
▸ Additional attributes:
▸ a=recvonly
▸ a=sendonly
▸ a=inactive
▸ a=framerate
▸ a=fmtp
▸ Example:
▸ a=fmtp:18 annexb=no
100 Trying
SIP MOBILITY
A proxy may also send INVITEs to one location,
wait for a failure, then send an INVITE to another
destination. This is known as “Sequential Call
Forking”
UAC Proxy UAS1 UAS2
INVITE
100 Trying
INVITE
100 Trying
486 Busy
ACK
INVITE
SIP MOBILITY
INVITE sip:bob@[Link]
To: <sip:bob@[Link]>
From: <sip:alice@[Link]>;tag=8983
Call-ID: 09870@[Link]
CSeq: 1 INVITE
Contact: <sip:alice@[Link]>
Require: replaces
Replaces: 425928@[Link];to-tag=7743;from-tag=6472
Replaces: 44443@[Link];to-tag=7843;from-tag=6872
REPLACES HEADER
Example :
Diversion: “9948” <sip:
9948@[Link]>;reason=unconditional;privacy=off;screen=yes
DIVERSION HEADER
The diversion parameters may contain :
5. Screening settings
DIVERSION HEADER
There are multiple options for diversion reasons:
unknown = The PBX is diverting for an unknown reason
no-answer = The user did not answer the call. This one of often seen when a
call is sent to voicemail.
time-of-day = The system is following a time of day route. This could imply
that after business hours the call needs to go to another department
DIVERSION HEADER
deflection = Often used when a caller is busy. The call is deflected to another
destination.
away = The user has specified that they are away from their phone.
DIVERSION HEADER
Refer-To: <sip:fred@[Link]>
SIP REFER
Bad REFER request :
INVITE
1xx/200
If a REFER request is ACK
200 OK
SIP TRANSACTIONS AND DIALOGS
[Link]
SIP TRANSACTIONS
‣ SIP is a transactional protocol. Everything that occurs between a UAC and a UAS consists of a
series of independent messages.
‣ In a nutshell, a SIP transaction consists of a single requests, zero or more provisional responses
AND a final response.
UAC UAS
INVITE
100 Trying
403 Forbidden
ACK
SIP TRANSACTIONS
‣ If the transaction is an INVITE transaction, AND the final response is a 200OK, the ACK is not
included within the transaction.
‣ According to the RFC - The reason for this is rooted in the importance of delivering all 200 OK
responses to an INVITE back to the UAC.
UAC UAS
INVITE
100 Trying
200 OK
ACK
SIP TRANSACTIONS
All Transaction have a client side and server side. The client side is know as the “client transaction”
and the server side is known as the “server transactions. (Yeah.. that makes sense!)
The client sends a request and the server replies with a response (aka response code).
Transactions exist between User-Agents and Stateful proxies.
UAC Proxy 1 Proxy 2 UAS
C S C S C S
SIP TRANSACTIONS
But…
When dealing with stateless proxies, the transaction only exists between the User-Agents (or
stateful proxies on each side.
C STATELESS STATELESS S
SIP DIALOG
A dialog represents a peer to peer relationship between two User-Agents that persists for some
amount of time.
The dialog is responsible for facilitating the sequences of messages between the two user-agents
and for proper routing of requests between the two UA’s.
A dialog is identified at each User-Agent by a dialog ID. This dialog ID consists of the Call ID
header value, a local tag and a remote tag.
Response
Response from UAS
From: Alice <sip:alice@[Link]>;tag=9fxced76sl
To: Bob <sip:bob@[Link]>;tag=8321234356
Call-ID: 3848276298220188511@[Link]
SIP DIALOG
Keep in mind - the dialog ID at each UA is NOT the same
For the UAC the Call -ID value of the dialog ID is set to the Call-ID header value, the remote tag is
set to the tag in the “To” field, and the local tag is set to the value in the “From” field. These rules
apply the requests and responses.
For the UAS- it’s flipped a bit. The Call-ID value remains the same, however the remote tag is set
to the value in the “From” field of the message, while the local tag is set to the value in the “To”
field.
Response
Response from UAS
From: Alice <sip:alice@[Link]>;tag=9fxced76sl
To: Bob <sip:bob@[Link]>;tag=8321234356
Call-ID: 3848276298220188511@[Link]
SIP DIALOG
Dialogs are created through the generation of non failure responses to requests within specified
methods.
Only 2xx and 101-199 responses WITH a “To” tag where the request is INVITE will establish a
dialog.
Once a dialog has been established either UA may initiate new transactions within the same
dialog.
If a UAC initiates a new INVITE transaction within an existing dialog, it is known as a RE-INVITE. If
a request is made where either the call-id, local tag or remote tag differ, the request is know as
“out of dialog”
SUMMARY
R ST PROXY CORE CT
STATEFUL PROXY - DEEP DIVE
R
ST PROXY CORE CT
STATEFUL PROXY - DEEP DIVE
ST PROXYR CORE CT
STATEFUL PROXY - DEEP DIVE
The fun thing about stateful proxies - They can
fork a request. In other words, they can send the
request to multiple destinations, each using their
own client transactions.
R CT
ST PROXYR CORE CT
R CT
STATEFUL PROXY - DEEP DIVE
When a response is received, the proxy core will
collect the response from the client transaction,
process, then send the response through the
server transaction
CT R
ST PROXY CORE CT
CT
STATEFUL PROXY - DEEP DIVE
The proxy core MUST behave like a UAS when
receiving a request. This implies that the proxy
will send a 100 trying when it has received an
INVITE request.
UAC UAS
R ST PROXY CORE CT
STATEFUL PROXY - DEEP DIVE
There are additional steps that the proxy takes
before sending the request downstream.
2. Check the URI scheme : If the URI scheme is unknown the proxy should generate a 416
Unsupported Scheme response
3. Check the Max-Forwards value : If the value is “0” the request will be reject with a 483
response code.
4. Check for loop detection through the VIA header : This reviews the “sent-by” value and
verifies that it does not contain something that the proxy has already processes for this
transaction.
6. Review the Proxy-Authorization: Does this request require authentication before it can
forward?
STATEFUL PROXY - DEEP DIVE
‣ Step 2 - Preprocess route information
‣ The proxy will inspect the RURI of the
request. If the RURI contains a value that the
proxy previous placed into a Record-Route
header, then the proxy will replace the RURI
with the last value from the Route header.
PROXY
IN OUT
STATLESS PROXY - DEEP DIVE
Add Via
Add RR
PROXY
IN OUT
STATLESS PROXY - DEEP DIVE
‣ Beyond that, the stateless proxy does not add,
remove, or modify the request.
INVITE
P1 P2
INVITE INVITE
BYE
UAC UAS
THE SIP
TRAPEZOID
THE SIP TRAPEZOID
The UAC sends an INVITE to it’s outbound proxy
(P1)
The UAS also adds a route set (through a Route header) , then
sends the response to P2
SIP/2.0 200 OK
UAC P1 P2 UAS Contact: sip:callee@[Link]
Record-Route: <sip:[Link];lr>
INVITE
Record-Route: <sip:[Link];lr>
100 Trying
INVITE Route: <sip:[Link];lr>,
INVITE
100 Trying <sip:[Link];lr>
100 Trying
200OK
THE SIP TRAPEZOID
SIP/2.0 200 OK
UAC P1 P2 UAS Contact: sip:callee@[Link]
Record-Route: <sip:[Link];lr>
INVITE
Record-Route: <sip:[Link];lr>
100 Trying
INVITE Route: <sip:[Link];lr>,
INVITE
100 Trying <sip:[Link];lr>
100 Trying
200OK
200OK
THE SIP TRAPEZOID
SIP/2.0 200 OK
UAC P1 P2 UAS Contact: sip:callee@[Link]
Record-Route: <sip:[Link];lr>
INVITE
Record-Route: <sip:[Link];lr>
100 Trying
INVITE Route: <sip:[Link];lr>,
INVITE
100 Trying <sip:[Link];lr>
100 Trying
200OK
200OK
200OK
THE SIP TRAPEZOID
The UAC receives this 200OK and says. “I see that contact header
(remote target) is “callee@[Link]”.
SIP/2.0 200 OK
UAC P1 P2 UAS Contact: sip:callee@[Link]
Record-Route: <sip:[Link];lr>
INVITE
Record-Route: <sip:[Link];lr>
100 Trying
INVITE Route: <sip:[Link];lr>,
INVITE
100 Trying <sip:[Link];lr>
100 Trying
200OK
200OK
200OK
THE SIP TRAPEZOID
Like a good SIP client, the UAC wants to create an ACK. Before it
does that, it notices that all elements in the route-set, contain the
‘lr’ parameter.
When it is time to end this dialog the UAC sends a BYE directly to the UAS.
UAC P1 P2 UAS
BYE sip:callee@[Link] SIP/2.0
INVITE Route: <sip:[Link];lr>,
100 Trying <sip:[Link];lr>
INVITE
INVITE
100 Trying 100 Trying
200OK
200OK
200OK
ACK
BYE
SIP
REGISTRATIONS
SIP REGISTRATIONS
In the world of SIP, User Agents may frequently change IP addresses. This creates an issue when one
user wants to call another and they cannot be found.
To combat this, SIP allows users to REGISTER with a special type of UAS known as a registrar.
Registrar
UAC UAS
REGISTER
bob@[Link]
SIP REGISTRATIONS
When the registrar receives the REGISTER request, it can take a number of steps.
First the Registrar may perform a lookup to see if this user even exists. If not, the Registrar will most
likely send a 404 Not Found in response.
Registrar
UAC UAS
REGISTER
bob@[Link]
It’s also possible that the registrar is configured to not accept requests from this specific user or UAC.
In this case, it’s likely that the registrar will send a 403 response
Registrar
UAC UAS
REGISTER
bob@[Link]
In the event that this user is permitted to register, the registrar will respond with a 200OK.
Of course, it could respond with a 401 Unauthorized as well before allowing registration to take
place.
Registrar
UAC UAS
REGISTER
bob@[Link]
200 OK
SIP REGISTRATIONS
In the background of the registrar server it communicates with an abstract service known as the
“Location Service”.
Keep in mind - the registrar and location service COULD be on the same server, or as diverse
elements.
REGISTER
REGISTRAR SERVICE
LOCATION SERVICE
UAS
SIP REGISTRATIONS
Once a user has successfully registered, a binding is created for this Address or Record (AOR) .
The information on how to reach is user, is taken from the “Contact” header if present.
LOCATION SERVICE
SIP/2.0 200 OK
Via: SIP/2.0/UDP [Link];branch=z9hG4bKnashd92
;received=[Link]
UAS
From: Bob <sip:bob@[Link]>;tag=a73kszlfl
To: Bob <sip:bob@[Link]>;tag=37GkEhwl6
Call-ID: 1j9FpLxk3uxtm8tn@[Link] Host : [Link]
CSeq: 2 REGISTER
Contact: <sip:bob@[Link]>;expires=3600 Registration Time : Fri, June 2 2016 22:00
Content-Length: 0
Username : Bob
State: Registered
SIP REGISTRATIONS
Now keep in mind, a REGISTER request can add, remove, or simply query
an existing binding.
But notice the username and “@“ components of the RURI are
missing.
From Header: The From header will contain the AOR of the
person responsible for the registration. The value is the same
as the To header unless it originated from a third party
registration
Call-ID: 1j9FpLxk3uxtm8tn@[Link]
CSeq: 1 REGISTER
Contact: <sip:bob@[Link]>
Content-Length: 0
SIP REGISTRATIONS
CSeq: 1 REGISTER
Contact: <sip:bob@[Link]>
Content-Length: 0
SIP REGISTRATIONS
Contact: <sip:bob@[Link]>
Content-Length: 0
SIP REGISTRATIONS
Contact: <sip:bob@[Link]>
Content-Length: 0
SIP REGISTRATIONS
Contact: <sip:bob@[Link]>
Content-Length: 0
SIP REGISTRATIONS
If the AOR is not valid for the the domain seen in the
RURI, the registrar must send a SIP 404 Not found in
response.
SIP REGISTRATIONS
Step 6 : The registrar looks for a Contact header field. If
not, it skips to the final step int he process.
▸ Hash1 =
md5hex(UserB:fakeserver:passwor
d123”)
▸
SIP AUTHENTICATION - WITH QOP
▸ Method : REGISTER
▸ Hash2 is going to be a hash of the
▸ URI : sip:[Link]
Method used and the URI.
▸ H2 =
▸ We know that this is a REGISTER 6bd40f0e73fcfbe5b5af7c8397ea
Method. the the URI is going to be 12bc
what we gleaned from the domain
in the 401 .
▸ Hash2 =
md5hex(REGISTER:sip:[Link]
[Link])
SIP AUTHENTICATION - WITH QOP
▸ H1 =b2310cc50edf3e2616d51ba7232db3d7
1ba7232db3d7:ea9c8e88df84f1c
ec4341ae6cbe5a359)
▸ H3 = [Link](h1:nonce:nc:cnonce:qop:h2)
▸ Notice the extra fields added in the middle.
SIP AUTHENTICATION
▸ Section Review :
INSIDE OUTSIDE
[Link]:5060 [Link]:5060
[Link]:5060 [Link]:5060
SIP & NAT
▸ Along with NAT which is simple translating one IP to another, we also have PAT.
▸ PAT is Port Address translation. This is where all traffic from the inside of the
network is presented as the same IP in the outside port, but from a different
source port.
INSIDE OUTSIDE
[Link]:5060 [Link]:24593
[Link]:5060 [Link]:24577
SIP & NAT
▸ NAT and PAT work very well with normal web traffic.
▸ This is because what is listed in the headers and SDP might not match the actual IP packet!
v=0 v=0
o=alice 2890844526 2890844526 IN IP4 [Link] o=alice 2890844526 2890844526 IN IP4 [Link]
s=- s=-
c=IN IP4 [Link] c=IN IP4 [Link]
t=0 0 t=0 0
m=audio 49172 RTP/AVP 0 m=audio 49172 RTP/AVP 0
a=rtpmap:0 PCMU/8000 a=rtpmap:0 PCMU/8000
SIP & NAT
INSIDE OUTSIDE
IP PACKET
IP PACKET
INVITE sip:bob@[Link] SIP/2.0
v=0
v=0 o=bob 2890844527 2890844527 IN IP4 [Link]
o=alice 2890844526 2890844526 IN IP4 [Link] s=-
s=- c=IN IP4 [Link]
c=IN IP4 [Link] t=0 0
m=audio 3456 RTP/AVP 0
t=0 0
a=rtpmap:0 PCMU/8000
m=audio 49172 RTP/AVP 0
a=rtpmap:0 PCMU/8000
SIP & NAT
▸ How do we fix this?
▸ There are a few methods that one can use to resolve this issue.
Some are better than others.
SIP & NAT
▸ STUN Server -
Payload : [Link]:24593
s=-
c=IN IP4 [Link] Payload : [Link]:24593 t=0 0
m=audio 3456 RTP/AVP 0
t=0 0 a=rtpmap:0 PCMU/8000
m=audio 24593 RTP/AVP 0
a=rtpmap:0 PCMU/8000
SIP & NAT
▸ SIP ALG
▸ The ALG modifies the SIP headers & SDP before the packet is
forward to the upstream device.
SIP ALG
INSIDE OUTSIDE
IP PACKET
v=0 v=0
o=alice 2890844526 2890844526 IN IP4 [Link] o=alice 2890844526 2890844526 IN IP4 [Link]
s=- s=-
c=IN IP4 [Link] c=IN IP4 [Link]
t=0 0 t=0 0
m=audio 49172 RTP/AVP 0 m=audio 24593 RTP/AVP 0
a=rtpmap:0 PCMU/8000 a=rtpmap:0 PCMU/8000
SIP & NAT
▸ The problem with SIP ALG
▸ Except return RTP (media) flows through the TURN server, rather
than direct
TURN
INSIDE OUTSIDE
Payload : [Link]:24593
s=-
c=IN IP4 [Link] Payload : [Link]:24593 t=0 0
m=audio 3456 RTP/AVP 0
t=0 0 a=rtpmap:0 PCMU/8000
m=audio 24593 RTP/AVP 0
a=rtpmap:0 PCMU/8000
SIP & NAT
▸ Turn guarantees communication in all NAT scenarios unless a firewall
policy is blocking communication.
▸ The TURN server must remain available through the entire session
SIP & NAT
▸ My favorite solutions for NAT issues with SIP is…
▸ A high end SBC like Oracle (Acme packet) uses a feature called “HNT”
or Header NAT Traversal to accomplish NAT detection and mitigation
▸ I’m not kidding. Two SBCs in a High Availability setup with a few
thousand concurrent session licenses can easily run $250,000.
▸ This is often related to the amount of time that a firewall keeps a NAT
pinhole open.
INSIDE OUTSIDE
[Link]:1234 [Link]:24593
REGISTER 70 seconds later
REGISTER
Pinhole
Inbound call to user
60 seconds
INVITE timeout
SIP & NAT
▸ How do we fix this?
▸ The downfall to this method is ports for RTP are typically dynamic.
▸ Method 3 - You may have lucked out and have a GOOD ALG running on
your firewall. It will handle these requests properly.
SUMMARY
▸ NAT can cause RTP and signaling issues
▸ STUN and TURN servers are often used to work around audio issues.
▸ High end Session Border Controllers work well to resolve NAT issues.
▸ RTP is not an element of SIP, but a protocol that SIP uses to transport
data with real time characteristics.
RTP OVERVIEW
▸ RTP is defined in RCF # 3550.
▸ The Real Time Protocol (RTP) - Which is used to carry data with real
time properties.
▸ The Real Time Control Protocol (RTCP) - This is used to monitor the
quality of the session and convey information.
RTP OVERVIEW
▸ As we mentioned in the SDP video when endpoints establish a session the
SDP will list elements of where RTP must be received.
v=0
v=0
o=root 12345 54321 IN IP4 [Link]
o=root 42852867 42852867 IN IP4 [Link]
s=call
s=call
c=IN IP4 [Link]
c=IN IP4 [Link]
t=0 0
t=0 0
m=audio 44444 RTP 0 8 3 101
m=audio 61896 RTP 0 8 3 101
a=rtpmap:0 pcmu/8000
a=rtpmap:0 pcmu/8000
a=rtpmap:8 pcma/8000
a=rtpmap:8 pcma/8000
a=rtpmap:3 gsm/8000
a=rtpmap:3 gsm/8000
a=rtpmap:101 telephone-event/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=fmtp:101 0-16
a=ptime:20
a=ptime:20
a=sendrecv
a=sendrecv
RTP OVERVIEW
▸ We need to begin with a few definitions and terms that you will hear
when dealing with RTP.
▸ RTCP packet : A data packet very similar to the RTP packet, but
used to send session control information
RTP OVERVIEW
▸ More Definitions:
▸ For example: You have a client that states they occasionally do not head any audio.
You perform a capture and to the naked eye, you see that RTP is flowing properly.
RTP OVERVIEW
▸ However you notice that the SSRC changes to another value a second after RTP begins.
▸ What happened? Well there may have been a call control change that occurred
upstream from your network. Traffic may have shifted to a different media gateway, but
you don’t see the RE-INVITE.
RTP OVERVIEW
▸ After you speak with the upstream partner or carrier and provide them this
information they realize that they have a device that is experiencing intermittent
issues.
▸ You just resolve the issue for your customer AND potentially thousands of others.
RTP OVERVIEW
▸ Back to definitions :
USER 3
RTP OVERVIEW
▸ Back to definitions :
▸ In the event that media is changed from one codec to another, we call this
transcoding.
G711u G722
V P X CC M PT SEQUENCE #
TIME STAMP
SSRC
CSRC
RTP OVERVIEW
▸ RTP Payload Types
▸ Recall the M line within an SDP. You will see series of numbers
after where it states “RTP”. These are the payload types.
v=0
o=root 42852867 42852867 IN IP4 [Link]
s=call
c=IN IP4 [Link]
t=0 0
m=audio 61896 RTP 0 8 3 101
a=ptime:20
a=sendrecv
RTP OVERVIEW
PT Encoding A/V Clock Rate Channel
0 PCMU A 8000 1 v=0
1 Reserved o=root 42852867 42852867 IN IP4 [Link]
2 Reserved
3 GSM A 8000 1
s=call
4 G723 A 8000 1 c=IN IP4 [Link]
5 DVI4 A 8000 1 t=0 0
6 DVI4 A 16000 1
7 LPC A 8000 1
m=audio 61896 RTP 0 8 3 101
8 PCMA A 8000 1 a=ptime:20
9 G722 A 8000 1 a=sendrecv
10 L16 A 44100 2
11 L16 A 44100 1 a=rtpmap:101 telephone-event/8000
12 QCELP A 8000 1
13 CN A 8000 1
14 MPA A 90000
15
16
G728
DVI4
A
A
8000
11025
1
1
0 = G711 (PCMU)
17 DVI4 A 22050 1
18 G729 A 8000 1
19 Reserved A 8 = G711A (PCMA)
20 Unassigned A
21 Unassigned A
22 Unassigned A
23 Unassigned A 3 = GSM
24 Unassigned V
25 CelB V 90000
26
27
JPEG V
Unassigned
90000
V
101 = RTP events
28 nv V 90000
29 Unassigned V
30 Unassigned V
31 H261 V 90000
32 MPV V 90000
33 MP2T AV 90000
34 H263 V 90000
35-71 Unassigned ?
72-76 Reserved for RTCP conflict avoidance
77-95 Unassigned ?
96-127 dynamic ?
RTP OVERVIEW
▸ Telephone events
▸ Note - When DTMF is sent within the audio stream it is known as “in
band”. When it is sent through another method such as telephone
events or SIP INFO, it is called “out of band”
RTP OVERVIEW
▸ Section Review
▸ Real Time Protocol is used for sending data (audio or video) between
devices.
▸ Real Time Control Protocol is used along with RTP to convey information
about the session.
▸ Mixers combine media from multiple sources and place them in a new
RTP packet.
▸ Translators are able to modify the encoding, yet keep the SSRC the same
BONUS!
CONVERTING VOICE INTO
PACKETS
BONUS
▸ In the early 1900s a man named
Dr. Harry Nyquist was employed
by Bell Labs.
▸
BONUS
▸ So by this logic Dr. Nyquist
thought that taking the range of
300-4000Hz would suffice for
testing.
-127
BONUS
▸ Now that we have 1 0 1 0 0 1 1 0
the samples turned The first bit specifies if this is a positive
into a number, it (1)
1 second of audio
-127
BONUS
▸ We now have 1 second of audio quantized.
Codec BW
G.711 64,000
ILBC 15,200
G.729 8,000
G.726 32,000
G.729a 8,000
▸ The four steps for converting analog signals into digital signals :
▸ 1. Sampling
▸ 2. Quantization
▸ 3. Encoding
▸ 4 Compressing (optional)
BONUS
▸ Ok, so G.711 used 64kbps and G.729a uses 8kbps right? I can
calculate bandwidth with that?
WRONG!
▸ Those values are just the payload size!
BONUS
▸ There is another process to calculate the true bandwidth
requirements!
▸ Step 2: Determine the data link (layer 2), Network and transport
layer overhead
▸ PEMDAS!
▸
BONUS
▸ Now that we have the amount of voice contained in each packet, we need to
get the overhead values added in.
▸ Layer 2 overhead:
▸ Ethernet = 20 bytes
▸ PPP = 6 Bytes
▸ IP = 20 bytes
Note - All packets will use RTP, UDP and IP -
▸ UDP = 8 bytes just sum this up as 40 bytes
▸ RTP = 12 bytes
BONUS
▸ Optional Overhead Values :
▸ GRE = 24 bytes
▸ MPLS = 4 bytes
▸ Now the packet per second. If we are using a 20ms sample rate,
what does that translate to as a PPS?
▸ 1 second = 1000 ms
▸ 1000 / 20 = 50.
220 * 50 = 110,000
110kbps
BONUS
▸ You try.
▸ Scenario :
▸ To turn analog voice into digital voice it goes the the process
of :
▸ Sampling
▸ Quantization
▸ Encoding
▸ Compression (Optional)
BONUS
▸ Summary :
CO
SIP SECURITY ISSUES
▸ Caller ID Spoofing
SIP SECURITY ISSUES
▸ Registration Hijacking
SIP SECURITY ISSUES
▸ Impersonating of a valid proxy
SIP SECURITY ISSUES
▸ Call Redirection
SIP SECURITY ISSUES
▸ Unauthenticated Calling
SIP SECURITY ISSUES
▸ Signaling Denial of Service
SIP SECURITY ISSUES
▸ Media Denial of Service
SIP SECURITY ISSUES
▸ API attacks
Switch
Router
Modem
CAPTURING SIP TRAFFIC
▸ Placing a HUB in-between switches
Switch Hub
Router
Modem
CAPTURING SIP TRAFFIC
▸ Placing a HUB in-between switches
Switch
Router
Modem
CAPTURING SIP TRAFFIC
▸ Using a managed switch
Switch
Switch
Switch
Router
Modem
CAPTURING SIP TRAFFIC
▸ Using a managed switch
DATABASE
NOC Engineer
CAPTURING SIP TRAFFIC
[Link]