1 of 49

FreeSWITCH-driven routing in OpenSIPS

Liviu Chircu

- Aug 10th, 2017 -

2 of 49

Got stuck?

  • opensips.org
  • users@opensips.org
  • “opensips” tag on stackoverflow.com
  • #opensips on FreeNode

2

- ClueCon 2017 -

liviu@opensips.org

3 of 49

Outline

  • routing with OpenSIPS
  • limitations
  • solutions
  • OpenSIPS 2.3 enhancements
  • demo!

3

- ClueCon 2017 -

liviu@opensips.org

4 of 49

Routing

5 of 49

Stateless routing

5

25%

25%

50%

OpenSIPS

FreeSWITCH

- ClueCon 2017 -

liviu@opensips.org

6 of 49

Stateless routing

6

Pros

  • fastest
  • minimal provisioning
  • unlimited channels

Cons

  • uneven call distribution
  • uneven resource distribution

- ClueCon 2017 -

liviu@opensips.org

7 of 49

Stateful routing

7

60/100 ch

39/80 ch

OpenSIPS

FreeSWITCH

- ClueCon 2017 -

liviu@opensips.org

8 of 49

Stateful routing

8

  • channel aware
  • even call distribution

- ClueCon 2017 -

liviu@opensips.org

9 of 49

Limitation

10 of 49

Limitations

10

???

50/100 calls

60/100 calls

???

OpenSIPS

FreeSWITCH

- ClueCon 2017 -

liviu@opensips.org

11 of 49

Limitations

11

50/100 calls

60/100 calls

60/100

50/100

OpenSIPS

FreeSWITCH

- ClueCon 2017 -

liviu@opensips.org

12 of 49

Limitations

12

50/100 calls

60/100 calls

60/100

50/100 (transcoded!)

OpenSIPS

FreeSWITCH

100% CPU

10% CPU

- ClueCon 2017 -

liviu@opensips.org

13 of 49

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

14 of 49

Solution

15 of 49

Requirements

  • CPU
  • Sessions

15

- ClueCon 2017 -

liviu@opensips.org

16 of 49

Solution

16

communication channel with the backend layer

  • minimal provisioning / FS box
  • scales well: 1 channel / FS box

- ClueCon 2017 -

liviu@opensips.org

17 of 49

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

18 of 49

FreeSWITCH integration

19 of 49

Event Socket Layer

19

FreeSWITCH

127.0.0.1:8021

  • FS C&C API
  • commands
  • event sub/pub
  • clients: Python, PHP, perl...

- ClueCon 2017 -

liviu@opensips.org

20 of 49

ESL Heartbeats

20

FreeSWITCH

127.0.0.1:8021

OpenSIPS

subscribe()

HEARTBEAT

HEARTBEAT

HEARTBEAT

HEARTBEAT

- ClueCon 2017 -

liviu@opensips.org

21 of 49

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

22 of 49

the “freeswitch” OpenSIPS module

22

  • starting with OpenSIPS 2.3
  • driver for the FS ESL
  • delivers data to subscribing modules

dispatcher

load

balancer

freeswitch

ESL

ESL

ESL

- ClueCon 2017 -

liviu@opensips.org

23 of 49

OpenSIPS module

enhancements

24 of 49

The OpenSIPS “dispatcher”

24

  • Stateless balancing
  • High traffic volume
  • no restrictions

- ClueCon 2017 -

liviu@opensips.org

25 of 49

Dispatcher algorithms

  • random
  • weighted round-robin
  • hashing (Call-ID, From, To, R-URI)

25

- ClueCon 2017 -

liviu@opensips.org

26 of 49

Dispatcher

26

“If you require dumb load balancing,

dispatcher is the smartest module that can do it”

- ClueCon 2017 -

liviu@opensips.org

27 of 49

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

28 of 49

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

29 of 49

The OpenSIPS “load_balancer”

29

  • Stateful balancing
  • High traffic volumes
  • “resource” management

channels / video-conf / audio-conf / etc.

- ClueCon 2017 -

liviu@opensips.org

30 of 49

Load_balancer operation

30

50/100 calls

60/100 calls

2/10 conf

1/5 conf

OpenSIPS

FreeSWITCH

- ClueCon 2017 -

liviu@opensips.org

31 of 49

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

32 of 49

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

33 of 49

Library dependencies

33

  • no additional library dependencies
  • plug and play

- ClueCon 2017 -

liviu@opensips.org

34 of 49

Improvements

35 of 49

Improvements

35

Optimize network throughput

  • less re-tries

Better service quality

  • lower PDD

- ClueCon 2017 -

liviu@opensips.org

36 of 49

Demo

37 of 49

Demo Setup

37

VirtualBox

FS

FS

FS

FS

UAS

OpenSIPS

UAC

InfluxDB

OpenSIPS

- ClueCon 2017 -

liviu@opensips.org

38 of 49

Demo Setup: provisioning

38

VirtualBox

?

?

?

?

UAS

OpenSIPS

UAC

15

15

15

15

- ClueCon 2017 -

liviu@opensips.org

39 of 49

Demo Setup: provisioning

39

VirtualBox

45

5

5

5

UAS

OpenSIPS

UAC

15

15

15

15

- ClueCon 2017 -

liviu@opensips.org

40 of 49

Demo Setup: runtime

40

VirtualBox

39

0

0

0

UAS

OpenSIPS

UAC

9

10

10

10

- ClueCon 2017 -

liviu@opensips.org

41 of 49

Demo Setup: runtime

41

VirtualBox

39

0

0

0

UAS

OpenSIPS

UAC

26

0

0

0

- ClueCon 2017 -

liviu@opensips.org

42 of 49

video

43 of 49

Deployment

44 of 49

Firewalling

44

ESL port 8021/tcp

- ClueCon 2017 -

liviu@opensips.org

45 of 49

FreeSWITCH Configuration

45

autoload_configs/switch.conf.xml

  • max-sessions = 1000 !
  • event-heartbeat-interval

- ClueCon 2017 -

liviu@opensips.org

46 of 49

ESL Configuration

46

autoload_configs/event_socket.conf.xml

  • listen-ip
  • password
  • apply-inbound-acl

https://freeswitch.org/confluence/display/FREESWITCH/mod_event_socket

- ClueCon 2017 -

liviu@opensips.org

47 of 49

Documentation

47

- ClueCon 2017 -

liviu@opensips.org

48 of 49

Future developments

48

  • Asterisk ARI, other projects?
  • commonly agreed SIP-based approach?

- ClueCon 2017 -

liviu@opensips.org

49 of 49

FreeSWITCH-driven LB is trivial to enable, robust, and will improve service quality

    • OpenSIPS Project: www.opensips.org
    • Email:
  • Liviu Chircu
    • OpenSIPS Project: www.opensips.org
    • Email: liviu@opensips.org

Take-Away Message