SlideShare a Scribd company logo
Surfing BigWaves of SIP with Style
Daniel-Constantin Mierla @miconda - www.asipto.com - Co-Founder Kamailio
October 2015
a very large set of features
kamailio
continuos 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
not designed as a typical telephony engine
open source sip server
framework - toolkit
SIP signalling routing
• fast
• reliable
• flexible
In other words
• not initiating calls
• not answering calls
• no audio-video processing
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
Dealing with high
SIP traffic volume
Detect and require a retry after a while
Increase performances of a Kamailio
instance
Scale the RTC platform
detect and require a retry after a while
Registration
sip 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
✤ registration storms
✤ reply to retry after
✤ randomize expires value
…
modparam("registrar", "expires_range", 30) # expires within [0.7*expires .. expires]
modparam("registrar", "retry_after", 30)
…
$var(retry) = 10 + ($RANDOM mod 300);
append_to_reply(“Retry-After: rn”);
send_reply(“500”, “Try later”);
…
Authentication
sip 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
✤ caching user profile
✤ password and other attributes
✤ check first the cache, if not found, then fetch from database and store in memory
…
loadmodule "auth.so"
loadmodule “auth_db.so"
loadmodule "htable.so"
…
modparam("auth_db", "db_url", DBURL)
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "load_credentials", “$avp(password)=password”)
modparam("auth_db", "use_domain", MULTIDOMAIN)
…
modparam("htable", "htable", "users=>size=10;autoexpire=300;")
…
…
route[AUTH] {
….
if (is_method("REGISTER") || from_uri==myself)
{
# authenticate requests
if($sht(users=>$fU)!=$null) {
if (!pv_auth_check(“$fd”, “$sht(users=>$fU)”, “0”, ”1”)) {
auth_challenge("$fd", "0");
exit;
}
} else {
if (!auth_check("$fd", "subscriber", "1")) {
auth_challenge("$fd", "0");
exit;
}
$sht(users=>$fU) = $avp(password);
}
# user authenticated - remove auth header
if(!is_method("REGISTER|PUBLISH"))
consume_credentials();
}
…
✤ client certificate or key based authentication
✤ avoid the auth challenge extra round trip
✤ tls with client certificate
✤ auth_xkey module
…
modparam("auth_xkeys", "xkey", "id=abc;name=xyz;value=secret;expires=72000")
…
…
auth_xkeys_add("X-My-Key", "abc", "sha256", "$Ri:$fu:$ru:$hdr(CSeq)");
…
if(!auth_xkeys_add("X-My-Key", "abc", "sha256", "$si:$fu:$ru:$hdr(CSeq)")) {
send_reply("403", "Forbidden");
exit;
}
remove_hf("X-My-Key");
…
Forwarding
sip proxy tunings
alice
bob
proxy
server
INVITE
sip:b@sipserver.net
INVITE
sip:b@newaddress.ip
100 Trying
100 Trying
200 OK
200 OK
180 Ringing
✤ pipelimit
✤ reply with retry after
✤ send redirect to another node
…
$var(retry) = 10 + ($RANDOM mod 300);
append_to_reply(“Retry-After: rn”);
send_reply(“503”, “Try later”);
…
…
$var(limit) = 20;
if (!pl_check("$au", "TAILDROP", "$var(limit)")) {
pl_drop(“10”, “60”);
exit;
}
…
…
if (!pl_check("$au", "TAILDROP", "$var(limit)")) {
$ru = “sip:” + $rU + “@newserver.net”;
send_reply(“302”, “Moved temporarily”);
exit;
}
…
increase performances of a sip server instance
✤ timer processes
✤ lazy operations for many modules
✤ keep alives, cleaning expired data
✤ increase (or reduce) the timer interval
…
modparam("usrloc", "timer_procs", 4)
…
modparam("nathelper", "natping_processes", 6)
…
modparam("dialog", "timer_procs", 4)
modparam("dialog", "ka_timer", 10)
modparam("dialog", "ka_interval", 300)
…
✤ internal hash sizes
✤ indexing of data in memory
✤ location records (usrloc), dialogs, generic hash tables
…
modparam("usrloc", "hash_size", 12)
…
modparam("htable", "htable", “a=>size=4;autoexpire=7200;")
modparam("htable", "htable", "b=>size=8;")
…
modparam("dispatcher", "ds_hash_size", 9)
…
https://en.wikipedia.org/wiki/Hash_table
Hash Table Head
name:test
size: 2
key: alice
slots
“xyz”
0
1
2
3
key: bob
123
key: john
“1ab”
✤ asynchronous processing
✤ delegate the execution to other workers than sip routing processes
✤ async module
✤ tmx (suspend) - mqueue (transmit) - rtimer (process)
✤ async database queries (mysql)
✤ async http/jsonrpc interactions
…
async_workers=4
…
modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname")
sql_query_async("ca", "delete from domain");
…
modparam("acc", "db_insert_mode", 2)
…
http://www.kamailio.org/events/2014-KamailioWorld/day2/26-Daniel-Constantin.Mierla-Kamailio.cfg-Async.pdf
✤ bonus
✤ children
✤ number of worker processes
✤ tcp - tls
✤ max connections
✤ file description limits
✤ internal dns caching
✤ blacklisting
✤ don’t forget
✤ database indexes
✤ syslog asynchronous mode
✤ dns infrastructure availability
✤ api services responsiveness
scale the rtc platform
dispatcher module
• list of balancing nodes from file or database
• monitoring of nodes (activate/inactivate
automatically)
• re-route in case of failure
• various algorithms: hashing, weight distribution, round
robin, call load distribution, priority routing
• reload list of nodes without restart
# Dispatch requests
route[DISPATCH] {
# round robin dispatching on gateways group '1'
if(!ds_select_dst("1",“4")) {
send_reply("404", "No destination");
exit;
}
xdbg("--- SCRIPT: going to <$ru> via <$du>n");
t_on_failure("RTF_DISPATCH");
route(RELAY);
exit;
}
# Re-route in case of failure
failure_route[RTF_DISPATCH] {
if (t_is_canceled()) {
exit;
}
# next node - only for 500 or local timeout
if (t_check_status(“500") || (t_branch_timeout() && !t_branch_replied())) {
if(ds_next_dst()) {
t_on_failure("RTF_DISPATCH");
route(RELAY);
exit;
}
}
}
Load balancing
Parallel Forking
request_route {
...
append_branch(“sip:103@kamailio.org”);
append_branch(“sip:104@kamailio.org”);
$var(newdst) = “sip:105@kamailio.org”;
append_branch(“$var(newdst)”);
t_relay();
}
Serial Forking
request_route {
...
$ru = “sip:102@kamailio.org”;
$xavp(newdst) = “sip:103@kamailio.org”;
$xavp(newdst) = “sip:104@kamailio.org”;
t_on_failure(“RETRY”);
t_relay();
}
failure_route[RETRY] {
if (t_is_canceled()) {
exit;
}
if($xavp(newdst) != $null) {
$ru = $xavp(newdst);
$xavp(newdst) = $null;
t_on_failure(“RETRY”);
t_relay();
exit;
}
}
Externalize services
the sip routing basics
✤ lack of resources (e.g., development)
✤ centralized management
✤ large volume of data
✤ number portability database
✤ billing, dids routing, etc
❖ fetching the next routing hops
❖ raw data
❖ http/rpc results + parsing
❖ structured data
❖ rtjson
❖ processing
❖ synchronous
❖ config wait & act
❖ asynchronous
❖ evapi, mqueue & rtimer
Building Blocks
❖ kamailio config - combine:
❖ evapi
❖ jansson
❖ rtjson
❖ external application
❖ node.js
❖ json data response
❖ predfined structure
http://kb.asipto.com/kamailio:k43-async-sip-routing-nodejs
Platform Scalability
USERS
CALLS
USERS
CALLS
USERS
CALLS
forking
✤ not found on local location table and not coming from the other nodes
✤ set destination to the other nodes (update $ru and append_branch())
✤ parallel forking (or serial forking with low transmission timeout)
USERS
CALLS
USERS
CALLS
USERS
CALLS
replication
central node
- redirect server
- proxy without record routing
# Handle SIP registrations
route[REGISTRAR] {
if (is_method("REGISTER")) {
if(isflagset(FLT_NATS)) {
setbflag(FLB_NATB);
# uncomment next line to do SIP NAT pinging
## setbflag(FLB_NATSIPPING);
}
if (!save("location"))
sl_reply_error();
$uac_req(method)=“KUSRLOC"
$uac_req(ruri)="sip:store@centralnode.kamailio.org";
$uac_req(furi)="sip:server@server1.kamailio.org";
$uac_req(hdrs)="Content-Type: text/kusrlocrn";
pv_printf(“$uac_req(body)”, "$fu@fd");
uac_send_req();
exit;
}
}
route[TOMAIN] {
$du = "sip:CENTRALNODEIP";
route(RELAY);
exit;
}
# USER location service
route[LOCATION] {
#!ifdef WITH_SPEEDDIAL
# search for short dialing - 2-digit extension
if($rU=~"^[0-9][0-9]$")
if(sd_lookup("speed_dial"))
route(SIPOUT);
#!endif
#!ifdef WITH_ALIASDB
# search in DB-based aliases
if(alias_db_lookup("dbaliases"))
route(SIPOUT);
#!endif
$avp(oexten) = $rU;
if (!lookup("location")) {
if(src_ip!=CENTRALNODEIP)
route(TOMAIN);
...
}
modparam(“htable”, “htable”, “kusrloc=>size=10;autoexpire=7200;”)
...
request_route {
# add here ip authorization, etc…
# handle location update notification
if(method=="KUSRLOC" && $rU=="store") {
$sht(kusrloc=>$rb) = “sip:” + $si + “:” + $sp + “;transport=” + $pr;
send_reply("200", "Stored");
exit;
}
# handle standard SIP requests
if($sht(kusrloc=>$rU@$rd)!=$null) {
$du = $sht(kusrloc=>$rU@$rd);
t_relay();
exit;
}
send_reply(“404”, “Not found”);
exit;
}
forking
replication
www.kamailio.org
tutorials
mailing lists
reference documentation
http://www.asipto.com/sw/kamailio-admin-book/
http://www.kamailioworld.com
YouTube KamailioWorld Channel
https://www.youtube.com/channel/UCElq4JNTPd7bs2vbfAAYVJA
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

More Related Content

What's hot

Kamailio and VoIP Wild World
Kamailio and VoIP Wild WorldKamailio and VoIP Wild World
Kamailio and VoIP Wild World
Daniel-Constantin Mierla
 
Expanding Asterisk with Kamailio
Expanding Asterisk with KamailioExpanding Asterisk with Kamailio
Expanding Asterisk with Kamailio
Fred Posner
 
Kamailio - Secure Communication
Kamailio - Secure CommunicationKamailio - Secure Communication
Kamailio - Secure Communication
Daniel-Constantin Mierla
 
Static Typing in Vault
Static Typing in VaultStatic Typing in Vault
Static Typing in Vault
GlynnForrest
 
Securing Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp VaultSecuring Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp Vault
Bram Vogelaar
 
PSGI and Plack from first principles
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principles
Perl Careers
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
Bram Vogelaar
 
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-ThonApache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Masahiro Nagano
 
How to build a High Performance PSGI/Plack Server
How to build a High Performance PSGI/Plack Server How to build a High Performance PSGI/Plack Server
How to build a High Performance PSGI/Plack Server
Masahiro Nagano
 
Puppet and the HashiStack
Puppet and the HashiStackPuppet and the HashiStack
Puppet and the HashiStack
Bram Vogelaar
 
Lua tech talk
Lua tech talkLua tech talk
Lua tech talk
Locaweb
 
Ground Control to Nomad Job Dispatch
Ground Control to Nomad Job DispatchGround Control to Nomad Job Dispatch
Ground Control to Nomad Job Dispatch
Michael Lange
 
Zabbix Console
Zabbix ConsoleZabbix Console
Zabbix Console
Ricardo Santos
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLite
charsbar
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
Bram Vogelaar
 
Roll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and LuaRoll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and Lua
Jon Moore
 
Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
Bram Vogelaar
 
{{more}} Kibana4
{{more}} Kibana4{{more}} Kibana4
{{more}} Kibana4
琛琳 饶
 
Observability with Consul Connect
Observability with Consul ConnectObservability with Consul Connect
Observability with Consul Connect
Bram Vogelaar
 
Redis And python at pycon_2011
Redis And python at pycon_2011Redis And python at pycon_2011
Redis And python at pycon_2011
sunilar0ra
 

What's hot (20)

Kamailio and VoIP Wild World
Kamailio and VoIP Wild WorldKamailio and VoIP Wild World
Kamailio and VoIP Wild World
 
Expanding Asterisk with Kamailio
Expanding Asterisk with KamailioExpanding Asterisk with Kamailio
Expanding Asterisk with Kamailio
 
Kamailio - Secure Communication
Kamailio - Secure CommunicationKamailio - Secure Communication
Kamailio - Secure Communication
 
Static Typing in Vault
Static Typing in VaultStatic Typing in Vault
Static Typing in Vault
 
Securing Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp VaultSecuring Prometheus exporters using HashiCorp Vault
Securing Prometheus exporters using HashiCorp Vault
 
PSGI and Plack from first principles
PSGI and Plack from first principlesPSGI and Plack from first principles
PSGI and Plack from first principles
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
 
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-ThonApache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-Thon
 
How to build a High Performance PSGI/Plack Server
How to build a High Performance PSGI/Plack Server How to build a High Performance PSGI/Plack Server
How to build a High Performance PSGI/Plack Server
 
Puppet and the HashiStack
Puppet and the HashiStackPuppet and the HashiStack
Puppet and the HashiStack
 
Lua tech talk
Lua tech talkLua tech talk
Lua tech talk
 
Ground Control to Nomad Job Dispatch
Ground Control to Nomad Job DispatchGround Control to Nomad Job Dispatch
Ground Control to Nomad Job Dispatch
 
Zabbix Console
Zabbix ConsoleZabbix Console
Zabbix Console
 
On UnQLite
On UnQLiteOn UnQLite
On UnQLite
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
 
Roll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and LuaRoll Your Own API Management Platform with nginx and Lua
Roll Your Own API Management Platform with nginx and Lua
 
Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
 
{{more}} Kibana4
{{more}} Kibana4{{more}} Kibana4
{{more}} Kibana4
 
Observability with Consul Connect
Observability with Consul ConnectObservability with Consul Connect
Observability with Consul Connect
 
Redis And python at pycon_2011
Redis And python at pycon_2011Redis And python at pycon_2011
Redis And python at pycon_2011
 

Similar to Kamailio - Surfing Big Waves Of SIP With Style

Kamailio and VoIP Wild World
Kamailio and VoIP Wild WorldKamailio and VoIP Wild World
Kamailio and VoIP Wild World
2600Hz
 
Go Web Development
Go Web DevelopmentGo Web Development
Go Web Development
Cheng-Yi Yu
 
Kamailio - SIP Servers Everywhere
Kamailio - SIP Servers EverywhereKamailio - SIP Servers Everywhere
Kamailio - SIP Servers Everywhere
Daniel-Constantin Mierla
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
Dongmin Yu
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
NAVER D2
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
DataStax Academy
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
Edward Capriolo
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup PerformanceJustin Cataldo
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
aaronheckmann
 
Leveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL EnvironmentLeveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL Environment
Jim Mlodgenski
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with Prometheus
Shiao-An Yuan
 
HashiConf Digital 2020: HashiCorp Vault configuration as code via HashiCorp T...
HashiConf Digital 2020: HashiCorp Vault configuration as code via HashiCorp T...HashiConf Digital 2020: HashiCorp Vault configuration as code via HashiCorp T...
HashiConf Digital 2020: HashiCorp Vault configuration as code via HashiCorp T...
Andrey Devyatkin
 
How Secure Are Docker Containers?
How Secure Are Docker Containers?How Secure Are Docker Containers?
How Secure Are Docker Containers?
Ben Hall
 
Web Performance Workshop - Velocity London 2013
Web Performance Workshop - Velocity London 2013Web Performance Workshop - Velocity London 2013
Web Performance Workshop - Velocity London 2013Andy Davies
 
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry PiMonitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
InfluxData
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
Daniel Cukier
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
Ohad Kravchick
 
KazooCon 2014 - Playing Kazoo Dudka Style
KazooCon 2014 - Playing Kazoo Dudka StyleKazooCon 2014 - Playing Kazoo Dudka Style
KazooCon 2014 - Playing Kazoo Dudka Style
2600Hz
 
Building an ML Platform with Ray and MLflow
Building an ML Platform with Ray and MLflowBuilding an ML Platform with Ray and MLflow
Building an ML Platform with Ray and MLflow
Databricks
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天
tblanlan
 

Similar to Kamailio - Surfing Big Waves Of SIP With Style (20)

Kamailio and VoIP Wild World
Kamailio and VoIP Wild WorldKamailio and VoIP Wild World
Kamailio and VoIP Wild World
 
Go Web Development
Go Web DevelopmentGo Web Development
Go Web Development
 
Kamailio - SIP Servers Everywhere
Kamailio - SIP Servers EverywhereKamailio - SIP Servers Everywhere
Kamailio - SIP Servers Everywhere
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
 
Leveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL EnvironmentLeveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL Environment
 
Monitoring with Prometheus
Monitoring with PrometheusMonitoring with Prometheus
Monitoring with Prometheus
 
HashiConf Digital 2020: HashiCorp Vault configuration as code via HashiCorp T...
HashiConf Digital 2020: HashiCorp Vault configuration as code via HashiCorp T...HashiConf Digital 2020: HashiCorp Vault configuration as code via HashiCorp T...
HashiConf Digital 2020: HashiCorp Vault configuration as code via HashiCorp T...
 
How Secure Are Docker Containers?
How Secure Are Docker Containers?How Secure Are Docker Containers?
How Secure Are Docker Containers?
 
Web Performance Workshop - Velocity London 2013
Web Performance Workshop - Velocity London 2013Web Performance Workshop - Velocity London 2013
Web Performance Workshop - Velocity London 2013
 
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry PiMonitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
Monitoring Your ISP Using InfluxDB Cloud and Raspberry Pi
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
 
KazooCon 2014 - Playing Kazoo Dudka Style
KazooCon 2014 - Playing Kazoo Dudka StyleKazooCon 2014 - Playing Kazoo Dudka Style
KazooCon 2014 - Playing Kazoo Dudka Style
 
Building an ML Platform with Ray and MLflow
Building an ML Platform with Ray and MLflowBuilding an ML Platform with Ray and MLflow
Building an ML Platform with Ray and MLflow
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天
 

More from Daniel-Constantin Mierla

TAD Summit 2016 - The Mobile World Up Side Down
TAD Summit 2016 - The Mobile World Up Side DownTAD Summit 2016 - The Mobile World Up Side Down
TAD Summit 2016 - The Mobile World Up Side Down
Daniel-Constantin Mierla
 
Snappy Kamailio
Snappy KamailioSnappy Kamailio
Snappy Kamailio
Daniel-Constantin Mierla
 
SIP Server Optimizations for Mobile Networks
SIP Server Optimizations for Mobile NetworksSIP Server Optimizations for Mobile Networks
SIP Server Optimizations for Mobile Networks
Daniel-Constantin Mierla
 
Kamailio - SIP Routing in Lua
Kamailio - SIP Routing in LuaKamailio - SIP Routing in Lua
Kamailio - SIP Routing in Lua
Daniel-Constantin Mierla
 
10 Years SER - Awards
10 Years SER - Awards10 Years SER - Awards
10 Years SER - Awards
Daniel-Constantin Mierla
 
Sculpturing SIP World
Sculpturing SIP WorldSculpturing SIP World
Sculpturing SIP World
Daniel-Constantin Mierla
 
CPDL - Charging Plan Definition Language
CPDL - Charging Plan Definition LanguageCPDL - Charging Plan Definition Language
CPDL - Charging Plan Definition Language
Daniel-Constantin Mierla
 
SER - SIP Express Router
SER - SIP Express RouterSER - SIP Express Router
SER - SIP Express Router
Daniel-Constantin Mierla
 
SIP Router Project
SIP Router ProjectSIP Router Project
SIP Router Project
Daniel-Constantin Mierla
 
Kamailio - Large Unified Communication Platforms
Kamailio - Large Unified Communication PlatformsKamailio - Large Unified Communication Platforms
Kamailio - Large Unified Communication Platforms
Daniel-Constantin Mierla
 
Kamailio - Unifying SIP and Web Worlds with Lua
Kamailio - Unifying SIP and Web Worlds with LuaKamailio - Unifying SIP and Web Worlds with Lua
Kamailio - Unifying SIP and Web Worlds with Lua
Daniel-Constantin Mierla
 
Kamailio - The Story for Asterisk
Kamailio - The Story for AsteriskKamailio - The Story for Asterisk
Kamailio - The Story for Asterisk
Daniel-Constantin Mierla
 

More from Daniel-Constantin Mierla (12)

TAD Summit 2016 - The Mobile World Up Side Down
TAD Summit 2016 - The Mobile World Up Side DownTAD Summit 2016 - The Mobile World Up Side Down
TAD Summit 2016 - The Mobile World Up Side Down
 
Snappy Kamailio
Snappy KamailioSnappy Kamailio
Snappy Kamailio
 
SIP Server Optimizations for Mobile Networks
SIP Server Optimizations for Mobile NetworksSIP Server Optimizations for Mobile Networks
SIP Server Optimizations for Mobile Networks
 
Kamailio - SIP Routing in Lua
Kamailio - SIP Routing in LuaKamailio - SIP Routing in Lua
Kamailio - SIP Routing in Lua
 
10 Years SER - Awards
10 Years SER - Awards10 Years SER - Awards
10 Years SER - Awards
 
Sculpturing SIP World
Sculpturing SIP WorldSculpturing SIP World
Sculpturing SIP World
 
CPDL - Charging Plan Definition Language
CPDL - Charging Plan Definition LanguageCPDL - Charging Plan Definition Language
CPDL - Charging Plan Definition Language
 
SER - SIP Express Router
SER - SIP Express RouterSER - SIP Express Router
SER - SIP Express Router
 
SIP Router Project
SIP Router ProjectSIP Router Project
SIP Router Project
 
Kamailio - Large Unified Communication Platforms
Kamailio - Large Unified Communication PlatformsKamailio - Large Unified Communication Platforms
Kamailio - Large Unified Communication Platforms
 
Kamailio - Unifying SIP and Web Worlds with Lua
Kamailio - Unifying SIP and Web Worlds with LuaKamailio - Unifying SIP and Web Worlds with Lua
Kamailio - Unifying SIP and Web Worlds with Lua
 
Kamailio - The Story for Asterisk
Kamailio - The Story for AsteriskKamailio - The Story for Asterisk
Kamailio - The Story for Asterisk
 

Recently uploaded

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 

Recently uploaded (20)

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 

Kamailio - Surfing Big Waves Of SIP With Style

  • 1. Surfing BigWaves of SIP with Style Daniel-Constantin Mierla @miconda - www.asipto.com - Co-Founder Kamailio October 2015
  • 2. a very large set of features kamailio continuos 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
  • 3. not designed as a typical telephony engine open source sip server framework - toolkit SIP signalling routing • fast • reliable • flexible In other words • not initiating calls • not answering calls • no audio-video processing
  • 4. 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
  • 5. Dealing with high SIP traffic volume Detect and require a retry after a while Increase performances of a Kamailio instance Scale the RTC platform
  • 6. detect and require a retry after a while
  • 7. Registration sip 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
  • 8. ✤ registration storms ✤ reply to retry after ✤ randomize expires value … modparam("registrar", "expires_range", 30) # expires within [0.7*expires .. expires] modparam("registrar", "retry_after", 30) … $var(retry) = 10 + ($RANDOM mod 300); append_to_reply(“Retry-After: rn”); send_reply(“500”, “Try later”); …
  • 9. Authentication sip 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
  • 10. ✤ caching user profile ✤ password and other attributes ✤ check first the cache, if not found, then fetch from database and store in memory … loadmodule "auth.so" loadmodule “auth_db.so" loadmodule "htable.so" … modparam("auth_db", "db_url", DBURL) modparam("auth_db", "calculate_ha1", yes) modparam("auth_db", "password_column", "password") modparam("auth_db", "load_credentials", “$avp(password)=password”) modparam("auth_db", "use_domain", MULTIDOMAIN) … modparam("htable", "htable", "users=>size=10;autoexpire=300;") …
  • 11. … route[AUTH] { …. if (is_method("REGISTER") || from_uri==myself) { # authenticate requests if($sht(users=>$fU)!=$null) { if (!pv_auth_check(“$fd”, “$sht(users=>$fU)”, “0”, ”1”)) { auth_challenge("$fd", "0"); exit; } } else { if (!auth_check("$fd", "subscriber", "1")) { auth_challenge("$fd", "0"); exit; } $sht(users=>$fU) = $avp(password); } # user authenticated - remove auth header if(!is_method("REGISTER|PUBLISH")) consume_credentials(); } …
  • 12. ✤ client certificate or key based authentication ✤ avoid the auth challenge extra round trip ✤ tls with client certificate ✤ auth_xkey module … modparam("auth_xkeys", "xkey", "id=abc;name=xyz;value=secret;expires=72000") … … auth_xkeys_add("X-My-Key", "abc", "sha256", "$Ri:$fu:$ru:$hdr(CSeq)"); … if(!auth_xkeys_add("X-My-Key", "abc", "sha256", "$si:$fu:$ru:$hdr(CSeq)")) { send_reply("403", "Forbidden"); exit; } remove_hf("X-My-Key"); …
  • 14. ✤ pipelimit ✤ reply with retry after ✤ send redirect to another node … $var(retry) = 10 + ($RANDOM mod 300); append_to_reply(“Retry-After: rn”); send_reply(“503”, “Try later”); … … $var(limit) = 20; if (!pl_check("$au", "TAILDROP", "$var(limit)")) { pl_drop(“10”, “60”); exit; } … … if (!pl_check("$au", "TAILDROP", "$var(limit)")) { $ru = “sip:” + $rU + “@newserver.net”; send_reply(“302”, “Moved temporarily”); exit; } …
  • 15. increase performances of a sip server instance
  • 16. ✤ timer processes ✤ lazy operations for many modules ✤ keep alives, cleaning expired data ✤ increase (or reduce) the timer interval … modparam("usrloc", "timer_procs", 4) … modparam("nathelper", "natping_processes", 6) … modparam("dialog", "timer_procs", 4) modparam("dialog", "ka_timer", 10) modparam("dialog", "ka_interval", 300) …
  • 17. ✤ internal hash sizes ✤ indexing of data in memory ✤ location records (usrloc), dialogs, generic hash tables … modparam("usrloc", "hash_size", 12) … modparam("htable", "htable", “a=>size=4;autoexpire=7200;") modparam("htable", "htable", "b=>size=8;") … modparam("dispatcher", "ds_hash_size", 9) … https://en.wikipedia.org/wiki/Hash_table Hash Table Head name:test size: 2 key: alice slots “xyz” 0 1 2 3 key: bob 123 key: john “1ab”
  • 18. ✤ asynchronous processing ✤ delegate the execution to other workers than sip routing processes ✤ async module ✤ tmx (suspend) - mqueue (transmit) - rtimer (process) ✤ async database queries (mysql) ✤ async http/jsonrpc interactions … async_workers=4 … modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname") sql_query_async("ca", "delete from domain"); … modparam("acc", "db_insert_mode", 2) … http://www.kamailio.org/events/2014-KamailioWorld/day2/26-Daniel-Constantin.Mierla-Kamailio.cfg-Async.pdf
  • 19. ✤ bonus ✤ children ✤ number of worker processes ✤ tcp - tls ✤ max connections ✤ file description limits ✤ internal dns caching ✤ blacklisting
  • 20. ✤ don’t forget ✤ database indexes ✤ syslog asynchronous mode ✤ dns infrastructure availability ✤ api services responsiveness
  • 21. scale the rtc platform
  • 22. dispatcher module • list of balancing nodes from file or database • monitoring of nodes (activate/inactivate automatically) • re-route in case of failure • various algorithms: hashing, weight distribution, round robin, call load distribution, priority routing • reload list of nodes without restart # Dispatch requests route[DISPATCH] { # round robin dispatching on gateways group '1' if(!ds_select_dst("1",“4")) { send_reply("404", "No destination"); exit; } xdbg("--- SCRIPT: going to <$ru> via <$du>n"); t_on_failure("RTF_DISPATCH"); route(RELAY); exit; } # Re-route in case of failure failure_route[RTF_DISPATCH] { if (t_is_canceled()) { exit; } # next node - only for 500 or local timeout if (t_check_status(“500") || (t_branch_timeout() && !t_branch_replied())) { if(ds_next_dst()) { t_on_failure("RTF_DISPATCH"); route(RELAY); exit; } } } Load balancing
  • 23. Parallel Forking request_route { ... append_branch(“sip:103@kamailio.org”); append_branch(“sip:104@kamailio.org”); $var(newdst) = “sip:105@kamailio.org”; append_branch(“$var(newdst)”); t_relay(); } Serial Forking request_route { ... $ru = “sip:102@kamailio.org”; $xavp(newdst) = “sip:103@kamailio.org”; $xavp(newdst) = “sip:104@kamailio.org”; t_on_failure(“RETRY”); t_relay(); } failure_route[RETRY] { if (t_is_canceled()) { exit; } if($xavp(newdst) != $null) { $ru = $xavp(newdst); $xavp(newdst) = $null; t_on_failure(“RETRY”); t_relay(); exit; } } Externalize services the sip routing basics ✤ lack of resources (e.g., development) ✤ centralized management ✤ large volume of data ✤ number portability database ✤ billing, dids routing, etc
  • 24. ❖ fetching the next routing hops ❖ raw data ❖ http/rpc results + parsing ❖ structured data ❖ rtjson ❖ processing ❖ synchronous ❖ config wait & act ❖ asynchronous ❖ evapi, mqueue & rtimer Building Blocks
  • 25. ❖ kamailio config - combine: ❖ evapi ❖ jansson ❖ rtjson ❖ external application ❖ node.js ❖ json data response ❖ predfined structure http://kb.asipto.com/kamailio:k43-async-sip-routing-nodejs
  • 26. Platform Scalability USERS CALLS USERS CALLS USERS CALLS forking ✤ not found on local location table and not coming from the other nodes ✤ set destination to the other nodes (update $ru and append_branch()) ✤ parallel forking (or serial forking with low transmission timeout)
  • 28. # Handle SIP registrations route[REGISTRAR] { if (is_method("REGISTER")) { if(isflagset(FLT_NATS)) { setbflag(FLB_NATB); # uncomment next line to do SIP NAT pinging ## setbflag(FLB_NATSIPPING); } if (!save("location")) sl_reply_error(); $uac_req(method)=“KUSRLOC" $uac_req(ruri)="sip:store@centralnode.kamailio.org"; $uac_req(furi)="sip:server@server1.kamailio.org"; $uac_req(hdrs)="Content-Type: text/kusrlocrn"; pv_printf(“$uac_req(body)”, "$fu@fd"); uac_send_req(); exit; } } route[TOMAIN] { $du = "sip:CENTRALNODEIP"; route(RELAY); exit; } # USER location service route[LOCATION] { #!ifdef WITH_SPEEDDIAL # search for short dialing - 2-digit extension if($rU=~"^[0-9][0-9]$") if(sd_lookup("speed_dial")) route(SIPOUT); #!endif #!ifdef WITH_ALIASDB # search in DB-based aliases if(alias_db_lookup("dbaliases")) route(SIPOUT); #!endif $avp(oexten) = $rU; if (!lookup("location")) { if(src_ip!=CENTRALNODEIP) route(TOMAIN); ... }
  • 29. modparam(“htable”, “htable”, “kusrloc=>size=10;autoexpire=7200;”) ... request_route { # add here ip authorization, etc… # handle location update notification if(method=="KUSRLOC" && $rU=="store") { $sht(kusrloc=>$rb) = “sip:” + $si + “:” + $sp + “;transport=” + $pr; send_reply("200", "Stored"); exit; } # handle standard SIP requests if($sht(kusrloc=>$rU@$rd)!=$null) { $du = $sht(kusrloc=>$rU@$rd); t_relay(); exit; } send_reply(“404”, “Not found”); exit; }
  • 34. 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