sip server - kamailio · not designed as a typical telephony engine open source sip server...

21
SIP Server Optimizations for Mobile Networks Daniel-Constantin Mierla Co-Founder Kamailio Project @miconda www.asipto.com

Upload: lycong

Post on 12-Apr-2018

241 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

SIP ServerOptimizations for Mobile Networks

Daniel-Constantin MierlaCo-Founder Kamailio Project

@micondawww.asipto.com

Page 2: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

a very large set of features

kamailiocontinuos development since 2001

2002 Jun 2005 Jul 2008 Aug 2008 Nov 2008

SIP Express Router (SER)

OpenSER Kamailio

Other Forks...

Same application: Kamailio - SER

Oct 2009 Jan 2010

v3.0.0

Integration Completed

v1.5.0

Sep 2011Sep 2001

First Line Of

Code

Open Source

GPL

FhG Fokus

Institute

Berlin

rename

Awarded Best Open

Source Networking

Software 2009

By InfoWorld

10 Years

Jun 2012

v3.3.0

ITSPA UK

Award

Mar 2013

v4.0.0

Kamailio

v4.1.0

Dec 2013

………. v4.2.0

Oct 2014

now over 100 on github

June 2015

v4.3.0

Page 3: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

not designed as a typical telephony engine

open source sip serverframework - toolkit

SIP signalling routing

• fast

• reliable

• flexible

In other words

• not initiating calls

• not answering calls

• no audio-video processing

Page 4: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

Key Features

✤ Modular SIP Poxy, Registrar and Redirect server

✤ Designed for scalability and flexibility

✤ IPv4, IPv6, UDP, TCP, TLS, SCTP, WebSocket

✤ NAT Traversal, internal and external caching engines

✤ JSON, XMLRPC, HTTP APIs

✤ IMS Extensions, SIP-I/SIP-T, IM & Presence

✤ SQL and NoSQL backends

✤ Asynchronous processing (TCP/TLS, SIP routing), external event API

✤ Embedded interpreters (Lua, Perl, Python, .Net, Java)

✤ Load balancing, LCR, DID routing, Number portability

Page 5: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

SIP Servers &

Mobile Networks

optimizations for singaling

Page 6: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

Authenticationsip authentication tunings

INVITE B@Y

Alice Server Y

407 Proxy Authentication Required Proxy-Authenticate:.... ....realm=X,nonce=aaa

Proxy X

INVITE B@Y Proxy-Authorization:.... ....user=A,realm=X,uri=B@Y, ....nonce=aaa,response=bbb

INVITE B@Y Proxy-Authorization:.... ....user=alice,realm=X,uri=b@Y, ....nonce=aaa,response=bbb

401 Unauthorized WWW-Authenticate:.... ....realm=Y,nonce=ccc

401 Unauthorized WWW-Authenticate:.... ....realm=Y,nonce=ccc

INVITE B@Y Proxy-Authorization:.... ....user=A,realm=X,uri=B@Y, ....nonce=aaa,response=bbb Authorization: .... ....user=A,realm=Y,uri=B@Y ....nonce=ccc,response=ddd

INVITE B@Y Proxy-Authorization:.... ....user=A,realm=X,uri=B@Y, ....nonce=aaa,response=bbb Authorization: .... ....user=A,realm=Y,uri=B@Y ....nonce=ccc,response=ddd

Page 7: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

✤ tls

✤ signaling encryption - privacy, authentication

✤ port 443 for SIP signaling

✤ connection ids

✤ authenticate subsequent SIP traffic, avoiding round trips and lower bandwidth usage

✤ source ip, port and protocol

✤ authenticate subsequent SIP traffic, avoiding round trips and lower bandwidth usage

✤ nonce validity

✤ client may reuse nonce in short term - wake up, registration, call

Page 8: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

# check connection id for authentication

modparam("htable", "htable", "conids=>size=8;autoexpire=900;") request_route { … if(proto==TLS) { if($sht(conids=>$fU@$fd) == $conid) { # skip authentication - traffic on known connection … } else { # usual authentication route(AUTH); # associate connection id with From username@domain $sht(conids=>$fU@$fd) == $conid; } } … }

kamailio.cfg example

Page 9: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

Registrationsip registrar tunings

REGISTER (contact address)

REGISTER (contact address)

(credentials)

401 (authentication req)

200 OK (contact addresses)

SIP Registrar

Require user's authentication

Authenticate user

Save contact address

Confirm registration

Page 10: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

✤ lower registration period

✤ clients awake for short intervals, but they can move from across many cells/accept points

✤ unregister when not replying

✤ track the relaying of the requests, unregister existing location contacts on no reply

✤ one contact per device

✤ GRUU to ensure one contact per devices

✤ server config option if known that only one devices is allowed

Page 11: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

# remove location contact if not able to relay or no response from next node

request_route { … $avp(ruri) = $ru; if(!lookup(“location”) { send_reply(“404”, “Not found”); exit; } t_on_branch_failure(“unregister”); t_relay(); }

event_route[tm:branch-failure:unregister] { … if(t_check_status(”477”) || (t_branch_timeout() && !t_branch_replied())) { unregister(“location”, “$avp(ruri)”, “$T_branch_ruid”); } … }

kamailio.cfg example

Page 12: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

Forwardingsip proxy tunings

alice

bob

proxy server

INVITE sip:[email protected]

INVITE sip:[email protected]

100 Trying

100 Trying

200 OK200 OK

180 Ringing

Page 13: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

✤ remove not mandatory headers

✤ keep only what is really useful

✤ restrict to supported codecs

✤ try to support one-two codecs for each media stream, remove the the others in offer on server

✤ remove unsupported media streams

✤ if using a mix of clients, track what they support and don’t forward unsupported media types

✤ short name and compact headers

✤ not much gain, but …

✤ compress body

✤ gzcompress - client side support required

Page 14: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

✤ handle cancel transmission race

✤ fast hang up - CANCEL may arrive before the INVITE

✤ tm and tmx modules

✤ asynchronous push notifications

✤ push may take a wile to propagate, don’t block the server

✤ async or mqueue+rtimer

✤ pending calls - registration rendezvous

✤ forward new branches as new registrations are processed

✤ tsilo module

Page 15: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

# don’t reply to CANCEL if no matching active INVITE transaction request_route { … # CANCEL processing if (is_method("CANCEL")) { if (t_check_trans()) { route(RELAY); } exit; } … }

kamailio.cfg examples

request_route { … # keep only User-Agent header keep_hf(“User-Agent”); # keep only G711a and GSM codecs sdp_keep_codecs_by_name(“PCMA,GSM”); # remove video stream sdp_remove_media("video"); … }

Page 16: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

IM & Presencesip im&presence tunings

Alice (watcher)

Bob (presentity)

SUBSCRIBE (watcher list) sip:[email protected]

SUBSCRIBE (watcher list) sip:[email protected]

Server

SUBSCRIBE (presence) sip:[email protected] NOTIFY (watcher list)

PUBLISH (presence) DND

NOTIFY (watcher list)

NOTIFY (presence)

PUBLISH (presence) AvailableNOTIFY (presence)

NOTIFY (watcher list)

Page 17: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

✤ compress body

✤ again - body for presence or instant messaging can be big

✤ client support required

✤ store and forward periodically presence states

✤ some devices may change states often

✤ not critical states may get stacked (e.g., idle)

✤ store and forward instant messages

✤ expect always unreliable delivery on mobile networks

✤ throttle delivery to avoid discarding on the network

✤ msilo or sqlops+uac (uac_req_send())

✤ client side - important✤ subscribe with 0 expires ✤ subscribe only visible contacts

Page 18: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

www.kamailio.org

tutorialsmailing lists

reference documentation

Page 19: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

http://www.asipto.com/sw/kamailio-admin-book/

Page 20: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

http://www.kamailioworld.com

YouTube KamailioWorld Channelhttps://www.youtube.com/channel/UCElq4JNTPd7bs2vbfAAYVJA

Page 21: SIP Server - Kamailio · not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other

Kamailio World 2016 - Planning a Special Edition

Kamailio Project 15 YEARS OF DEVELOPMENT

2001-2016 from SER to Kamailio

www.kamailioworld.com

Thank you!Questions?@miconda