Vous êtes sur la page 1sur 92

What’s SIP

• IETF RFC 3261


– “The Session Initiation Protocol (SIP) is an application-
layer control (signaling) protocol for creating, modifying
and terminating sessions with one or more
participants.”
• Can be used for voice, video, instant messaging, gaming,
etc., etc., etc.
• Follows on HTTP
– Text based messaging
– URIs – ex: sip:dbaron@MIT.EDU
Where’s SIP

SDP codecs

Application RTSP SIP RTP DNS(SRV)

Transport TCP UDP

Network IP

Physical/Data Link Ethernet


SIP Components
• User Agents
– Clients – Make requests
– Servers – Accept requests

• Server types
– Redirect Server
– Proxy Server
– Registrar Server
– Location Server

• Gateways
SIP Methods
• INVITE Requests a session

• ACK Final response to the INVITE

• OPTIONS Ask for server capabilities

• CANCEL Cancels a pending request

• BYE Terminates a session

• REGISTER Sends user’s address to server


SIP Responses
• 1XX Provisional 100 Trying

• 2XX Successful 200 OK

• 3XX Redirection 302 Moved Temporarily

• 4XX Client Error 404 Not Found

• 5XX Server Error 504 Server Time-out

• 6XX Global Failure 603 Decline


SIP Flows - Registration
User Registrar Location
B MIT.EDU MIT.EDU

REGISTER: sip:dbaron@MIT.EDU

401 - Unauthorized

REGISTER: (add credentials)


sip:dbaron@MIT.EDU
Contact 18.18.2.4
200 - OK
SIP Flows - Basic
User User
A B

“Calls”
INVITE: sip:18.18.2.4
18.18.2.4

180 - Ringing Rings

200 - OK Answers

ACK

Talking RTP Talking

Hangs up BYE

200 - OK
SIP Servers
● Registrar Sever
● takes registration requests from UA's, and maintains information
as to their location.

● Location Sever
● This server replaces the user's AoR (Address of Record) with the
contact address registered by user.
SIP Servers
● Proxy Server
● A SIP proxy receives SIP messages (both requests and
responses), that are generated by UA's, and forwards them on
(either to the destination UA, or the next SIP Server in the route,
as specified in the SIP message itself).
● Redirect Server
● This conceptual SIP network entity receives requests from a proxy
or UA, and responds with a specific SIP response method, telling
the originator of the request that the user is not available at that
location, and indicates where the request should be sent in order
to try again.
SIP Servers
● Application Sever
● This is the place were different features are implemented, adding
value to the VoIP platform. Among common features you can find
advanced call control applications like call blocking or call baring,
prepaid system, interactive call routing.
● Media Servers
● In order to have an active control of what happens during a call, a
device has to be 'in the media stream', as it is often called...
SIP SERVERs(decisions)
SIP Servers have a wide array of possible ways to
handle incoming messages
● Where to route the request
● Proxy/Redirect/Reject
● Stateful/Stateless forwarding
● Record-routing
● Forking—parallel/sequential/none
● Authentication
● Loop detection
SIP SERVERs(decision factors)
These decisions can be made based on many
factors, such as:
● Message destination address (Request-URI)
● Type of request (method)
● Other message fields: From, To, Date, Priority
● Response to a Request
Proxy Servers
The SIP standard defines SIP proxies as
“elements that route SIP requests to user agent
servers (UAS) and SIP responses to user agent
clients (UAC).
● Stateful proxy
● Stateless proxy
Stateful Proxy(TM)
When stateful, the proxy processes transactions
rather than individual messages
A stateful proxy is aware of the state of transactions and message
history, and can therefore perform better-informed processing on
incoming messages
● Memory consumption
● Throughput
● Implementation complexity
● Underlying SIP Stack complexity
STATELESS PROXY
A stateless proxy is a “simple message forwarder”
● A stateless proxy cannot associate responses
● A stateless proxy cannot associate retransmissions
● If the message is lost, the proxy will not retransmit it.

Note: Stateless proxies need to use a routing algorithm that always


routes copies of the same message to the same destination
Proxy Forking

A forking proxy, in the context of a


communications system using Session Initiation
Protocol (SIP), is a server that attempts to find a
correspondent by searching several locations.

SIP proxy severs that route messages to more than one


destination are called forking proxies.
Clustering scenarios

O
Inbound- service LB

Fronting small/medium size PBX-based services for


scaling, LB and HA.

Incoming Yate /
calls
Asterisk /
Freeswitch
OpenSIPS boxes
Load Balancer

O
Inbound- Call Center

Controller for a Call Center


scaling, LB and HA. Standard
operator

Incoming
calls Business
operator

OpenSIPS
Load Balancer

Advanced
operator
O
May 4-5 OpenSIPS – clustering and balancing media servers , Amoocon 2009 Rostock,Germany
OpenSER
OpenSER

from an asterisk point of view


What is OpenSER?
OpenSER is:
OpenSER is:

- a SIP proxy
OpenSER is:

- a SIP proxy
- a SIP registrar
OpenSER is:

- a SIP proxy
- a SIP registrar
- a SIP router
OpenSER is:

- a SIP proxy
- a SIP registrar
- a SIP router
- a SIP redirect server
OpenSER is:

- a SIP proxy
- a SIP registrar
- a SIP router
- a SIP redirect server
- a SIP application server
OpenSER is not:
OpenSER is not:

- a B2BUA (back to back user agent)


OpenSER is not:

- a B2BUA (back to back user agent)


- a media server
OpenSER is not:

- a B2BUA (back to back user agent)


- a media server
- a soft phone
OpenSER architecture:
OpenSER architecture:

two main logical components


OpenSER architecture:

core modules (plug-ins)


OpenSER architecture:

core modules (plug-ins)

• parsers (SIP/SDP/conf)
OpenSER architecture:

core modules (plug-ins)

• parsers (SIP/SDP/conf)
• memory system
OpenSER architecture:

core modules (plug-ins)

• parsers (SIP/SDP/conf)
• memory system
• transport layer
OpenSER architecture:

core modules (plug-ins)

• parsers (SIP/SDP/conf)
• memory system
• transport layer
• database interface
OpenSER architecture:

core modules (plug-ins)

• parsers (SIP/SDP/conf)
• memory system
• transport layer
• database interface
• synch/lock mechanism
OpenSER architecture:

core modules (plug-ins)

• parsers (SIP/SDP/conf)
• memory system
• transport layer
• database interface
• synch/lock mechanism
• management interface
OpenSER architecture:

core modules (plug-ins)

• parsers (SIP/SDP/conf)
• memory system
• transport layer
• database interface
• synch/lock mechanism
• management interface
• script variables
OpenSER architecture:

core modules (plug-ins)

• parsers (SIP/SDP/conf) • SIP protocol (tm)


• memory system
• transport layer
• database interface
• synch/lock mechanism
• management interface
• script variables
OpenSER architecture:

core modules (plug-ins)

• parsers (SIP/SDP/conf) • SIP protocol (tm)


• memory system • features
• transport layer
• database interface
• synch/lock mechanism
• management interface
• script variables
OpenSER architecture:

module 1

module 2

core

module n
OpenSER configuration:
OpenSER configuration:

openser.cfg
OpenSER configuration:

openser.cfg (three blocks)


OpenSER configuration:

global options
OpenSER configuration:

global options

modules:
loading and parameters
OpenSER configuration:

global options

modules:
loading and parameters

routing
OpenSER configuration:

global options
OpenSER configuration:

global options

- listen interfaces
OpenSER configuration:

global options

- listen interfaces

# UDP support
listen=udp:10.10.10.10:5060
OpenSER configuration:

global options

- listen interfaces

# TCP support
listen=tcp:10.10.10.10:5070
OpenSER configuration:

global options

- listen interfaces

# TLS support (port 5061)


listen=tls:10.10.10.10
OpenSER configuration:

global options

- listen interfaces
- logging
OpenSER configuration:

global options

- listen interfaces
- logging

# logging level
debug=3
OpenSER configuration:

global options

- listen interfaces
- logging

# syslog enabled
log_stderr=no
OpenSER configuration:

global options

- listen interfaces
- logging

# syslog enabled
log_stderr=no
log_facility=LOG_LOCAL3
OpenSER configuration:

global options

- listen interfaces
- logging

# syslog enabled
log_stderr=no
log_facility=LOG_LOCAL3
log_name=”oser”
OpenSER configuration:

global options

- listen interfaces
- logging
- number of processes
OpenSER configuration:

global options

- listen interfaces
- logging
- number of processes

fork=yes
OpenSER configuration:

global options

- listen interfaces
- logging
- number of processes

fork=yes
children=6 # UDP listeners
OpenSER configuration:

global options

- listen interfaces
- logging
- number of processes

fork=yes
children=6 # UDP listeners
tcp_children=5 #TCP listeners
OpenSER configuration:

global options

- listen interfaces
- logging
- number of processes
- protocol control
OpenSER configuration:

global options

- listen interfaces
- logging
- number of processes
- protocol control

disable_tcp=yes
OpenSER configuration:

global options

- listen interfaces
- logging
- number of processes
- protocol control

disable_tcp=yes
disable_tls=yes
OpenSER configuration:

global options

# Please refer to the Core CookBook at http://www.openser.org/dokuwiki/doku.php


# for a explanation of possible statements, functions and parameters.
#
####### Global Parameters #########

debug=3
log_stderror=no
log_facility=LOG_LOCAL0

fork=yes
children=4

disable_tcp=yes

listen=udp:192.168.1.2:5060
OpenSER configuration:

modules (loading and parameters)


OpenSER configuration:

modules (loading and parameters)

- path location
OpenSER configuration:

modules (loading and parameters)

- path location

mpath=”/usr/lib/openser/modules”
OpenSER configuration:

modules (loading and parameters)

- path location
- module loading
OpenSER configuration:

modules (loading and parameters)

- path location
- module loading

mpath=”/usr/lib/openser/modules”
loadmodule “tm.so”
OpenSER configuration:

modules (loading and parameters)

- path location
- module loading

loadmodule “/usr/lib/openser/modules/tm.so”
OpenSER configuration:

modules (loading and parameters)

- path location
- module loading
- module parameters
OpenSER configuration:

modules (loading and parameters)

- path location
- module loading
- module parameters

modparam(“tm”,“T1_timer”,700)
OpenSER configuration:

modules (loading and parameters)

####### Modules Section ########

# set module path


mpath="/usr/local/lib/openser/modules/"

loadmodule "sl.so"

loadmodule "tm.so"

loadmodule "rr.so"

loadmodule "maxfwd.so"

loadmodule "mi_fifo.so"
modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo")
OpenSER configuration:

routing
OpenSER configuration:

routing

- request route: route[n] {...}


OpenSER configuration:

routing

- request route: route[n] {...}


- provisional reply route: onreply_route[m] {...}
OpenSER configuration:

routing

- request route: route[n] {...}


- provisional reply route: onreply_route[m] {...}
- failure reply route: failure_route[p] {...}
OpenSER configuration:

routing

- request route: route[n] {...}


- provisional reply route: onreply_route[m] {...}
- failure reply route: failure_route[p] {...}
- request branch route: branch_route[q] {...}
OpenSER configuration:

routing

- request route: route[n] {...}


- provisional reply route: onreply_route[m] {...}
- failure reply route: failure_route[p] {...}
- request branch route: branch_route[q] {...}
- error route: error_route {...}
OpenSER configuration:

routing
####### Routing Logic ########
route{
if (loose_route()) { # mark routing logic in request
append_hf("P-hint: rr-enforced\r\n");
t_relay();
exit;;
};
if (!uri==myself) { # mark routing logic in request
append_hf("P-hint: outbound\r\n");
t_relay();
exit;
};
if (uri==myself && is_method("INVITE")) {
lookup(“location”);
t_relay();
exit;
};
}
OpenSER configuration:
Read from the network

Message parsing

SIP request SIP reply

route on_reply_route/failure_route

Processing (core/module functions)

Send to network
SIP message call flow
OpenSER/asterisk integration

- registrar/dispatcher for asterisk farm

asterisk
asterisk
OpenSER
asterisk

location db
OpenSER/asterisk integration

- SIP router for asterisk farm


high # of channels
carrier 1
medium cps rate

asterisk
high # of channels
OpenSER carrier 2
asterisk high cps rate

asterisk
low # of channels
low cps rate carrier 3
OpenSER/asterisk integration

- SIP router for asterisk farm

carrier 1
international

asterisk
OpenSER carrier 2
asterisk national

asterisk

carrier 3
911