FreeSWITCH-driven routing in OpenSIPS
Liviu Chircu
- Aug 10th, 2017 -
Got stuck?
2
- ClueCon 2017 -
liviu@opensips.org
Outline
3
- ClueCon 2017 -
liviu@opensips.org
Routing
Stateless routing
5
25%
25%
50%
OpenSIPS
FreeSWITCH
- ClueCon 2017 -
liviu@opensips.org
Stateless routing
6
Pros
Cons
- ClueCon 2017 -
liviu@opensips.org
Stateful routing
7
60/100 ch
39/80 ch
OpenSIPS
FreeSWITCH
- ClueCon 2017 -
liviu@opensips.org
Stateful routing
8
- ClueCon 2017 -
liviu@opensips.org
Limitation
Limitations
10
???
50/100 calls
60/100 calls
???
OpenSIPS
FreeSWITCH
- ClueCon 2017 -
liviu@opensips.org
Limitations
11
50/100 calls
60/100 calls
60/100
50/100
OpenSIPS
FreeSWITCH
- ClueCon 2017 -
liviu@opensips.org
Limitations
12
50/100 calls
60/100 calls
60/100
50/100 (transcoded!)
OpenSIPS
FreeSWITCH
100% CPU
10% CPU
- ClueCon 2017 -
liviu@opensips.org
Limitations
13
50/100 calls
60/100 calls
30/100 calls
50/100 calls
90/100
100/100
OpenSIPS
FreeSWITCH
- ClueCon 2017 -
liviu@opensips.org
Solution
Requirements
15
- ClueCon 2017 -
liviu@opensips.org
Solution
16
communication channel with the backend layer
- ClueCon 2017 -
liviu@opensips.org
Solution
17
50/50 calls
60/70 calls
30/40 calls
50/50 calls
90/100
100/100
90/100
100/100
OpenSIPS
- ClueCon 2017 -
liviu@opensips.org
FreeSWITCH integration
Event Socket Layer
19
FreeSWITCH
127.0.0.1:8021
- ClueCon 2017 -
liviu@opensips.org
ESL Heartbeats
20
FreeSWITCH
127.0.0.1:8021
OpenSIPS
subscribe()
HEARTBEAT
HEARTBEAT
HEARTBEAT
HEARTBEAT
- ClueCon 2017 -
liviu@opensips.org
ESL Heartbeats
21
{
...� "Event-Date-GMT": "Mon, 30 Jan 2017 14:44:00 GMT",� "Event-Name": "HEARTBEAT",� "FreeSWITCH-Hostname": "pbx2",� "FreeSWITCH-IPv4": "172.17.0.3",� "Idle-CPU": "78.400000", � "Max-Sessions": "1000", � "Session-Count": "0",
...�}
- ClueCon 2017 -
liviu@opensips.org
the “freeswitch” OpenSIPS module
22
dispatcher
load
balancer
freeswitch
ESL
ESL
ESL
- ClueCon 2017 -
liviu@opensips.org
OpenSIPS module
enhancements
The OpenSIPS “dispatcher”
24
- ClueCon 2017 -
liviu@opensips.org
Dispatcher algorithms
25
- ClueCon 2017 -
liviu@opensips.org
Dispatcher
26
“If you require dumb load balancing,
dispatcher is the smartest module that can do it”
- ClueCon 2017 -
liviu@opensips.org
Dispatcher: enable FreeSWITCH stats
27
loadmodule “freeswitch.so”
modparam(“dispatcher”, “fetch_freeswitch_stats”, 1)
modparam(“dispatcher”, “max_freeswitch_weight”, 100)
- ClueCon 2017 -
liviu@opensips.org
Dispatcher: provisioning
28
mysql> SELECT * FROM dispatcher;�+----+-------+------------------+----------------------------+----------+�| id | setid | destination | weight | priority |�+----+-------+------------------+----------------------------+----------+�| 1 | 1 | sip:192.168.1.38 | fs://:ClueCon@192.168.1.38 | 0 |�| 2 | 1 | sip:192.168.1.39 | fs://:ClueCon@192.168.1.39 | 0 |
| 2 | 2 | sip:192.168.1.50 | 10 | 0 |
| 2 | 2 | sip:192.168.1.51 | 10 | 0 |�+----+-------+------------------+----------------------------+----------+�
fs://:ClueCon@192.168.1.38
- ClueCon 2017 -
liviu@opensips.org
The OpenSIPS “load_balancer”
29
channels / video-conf / audio-conf / etc.
- ClueCon 2017 -
liviu@opensips.org
Load_balancer operation
30
50/100 calls
60/100 calls
2/10 conf
1/5 conf
OpenSIPS
FreeSWITCH
- ClueCon 2017 -
liviu@opensips.org
Load_balancer: enable FreeSWITCH stats
31
loadmodule “freeswitch.so”
modparam(“load_balancer”, “fetch_freeswitch_stats”, 1)
modparam(“load_balancer”, “initial_freeswitch_load”, 100)
- ClueCon 2017 -
liviu@opensips.org
Load_balancer: provisioning
32
mysql> SELECT * FROM opensips.load_balancer;�+----+----------+----------------+-------------------------------------+�| id | group_id | dst_uri | resources |�+----+----------+----------------+-------------------------------------+�| 1 | 1 | sip:10.0.0.237 | ch=fs://:ClueCon@10.0.0.237;conf=10 |�| 2 | 1 | sip:10.0.0.238 | ch=fs://:ClueCon@10.0.0.238;chan=75 |�| 3 | 1 | sip:10.0.0.239 | ch=fs://:ClueCon@10.0.0.239 | +----+----------+----------------+-------------------------------------+�
ch=fs://:ClueCon@10.0.0.237;conf=10
- ClueCon 2017 -
liviu@opensips.org
Library dependencies
33
- ClueCon 2017 -
liviu@opensips.org
Improvements
Improvements
35
Optimize network throughput
Better service quality
- ClueCon 2017 -
liviu@opensips.org
Demo
Demo Setup
37
VirtualBox
FS
FS
FS
FS
UAS
OpenSIPS
UAC
InfluxDB
OpenSIPS
- ClueCon 2017 -
liviu@opensips.org
Demo Setup: provisioning
38
VirtualBox
?
?
?
?
UAS
OpenSIPS
UAC
15
15
15
15
- ClueCon 2017 -
liviu@opensips.org
Demo Setup: provisioning
39
VirtualBox
45
5
5
5
UAS
OpenSIPS
UAC
15
15
15
15
- ClueCon 2017 -
liviu@opensips.org
Demo Setup: runtime
40
VirtualBox
39
0
0
0
UAS
OpenSIPS
UAC
9
10
10
10
- ClueCon 2017 -
liviu@opensips.org
Demo Setup: runtime
41
VirtualBox
39
0
0
0
UAS
OpenSIPS
UAC
26
0
0
0
- ClueCon 2017 -
liviu@opensips.org
video
Deployment
Firewalling
44
ESL port 8021/tcp
- ClueCon 2017 -
liviu@opensips.org
FreeSWITCH Configuration
45
autoload_configs/switch.conf.xml
- ClueCon 2017 -
liviu@opensips.org
ESL Configuration
46
autoload_configs/event_socket.conf.xml
https://freeswitch.org/confluence/display/FREESWITCH/mod_event_socket
- ClueCon 2017 -
liviu@opensips.org
Documentation
47
Freeswitch module doc:
http://www.opensips.org/html/docs/modules/2.4.x/freeswitch.html
dispatcher / load_balancer docs:
http://www.opensips.org/html/docs/modules/2.4.x/dispatcher.html
http://www.opensips.org/html/docs/modules/2.4.x/load_balancer.html
Tutorial:
https://blog.opensips.org/2017/03/01/freeswitch-driven-routing-in-opensips-2-3/
Demo scripts:
http://opensips.org/pub/opensips-scripts/2017/2017-cluecon-fslb.cfg
http://opensips.org/pub/opensips-scripts/2017/2017-cluecon-lb.cfg
- ClueCon 2017 -
liviu@opensips.org
Future developments
48
- ClueCon 2017 -
liviu@opensips.org
FreeSWITCH-driven LB is trivial to enable, robust, and will improve service quality
Take-Away Message