OpenSIPS - an event-driven SIP routing engine Liviu Chircu - 4th - - PowerPoint PPT Presentation

opensips an event driven sip routing engine
SMART_READER_LITE
LIVE PREVIEW

OpenSIPS - an event-driven SIP routing engine Liviu Chircu - 4th - - PowerPoint PPT Presentation

OpenSIPS - an event-driven SIP routing engine Liviu Chircu - 4th Feb 2017 - Outline Architecture timeline Event subscribe-notify Usage scenarios OpenSIPS scripts Conclusions Liviu Chircu - OpenSIPS Project -


slide-1
SLIDE 1

Liviu Chircu

  • 4th Feb 2017 -

OpenSIPS - an event-driven SIP routing engine

slide-2
SLIDE 2
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Outline

  • Architecture timeline
  • Event subscribe-notify
  • Usage scenarios
  • OpenSIPS scripts
  • Conclusions

2

slide-3
SLIDE 3

Architecture timeline

slide-4
SLIDE 4
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Step 1: “Linear” architecture

OpenSIPS 1.X

4

Time SIP packet arrivals T h r e a d 1 T h r e a d 2 CPU bound I/O bound

slide-5
SLIDE 5
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Step 2: “Async” architecture

OpenSIPS 2.1, 2.2

5

Time SIP packet arrivals T h r e a d 1 CPU bound I/O bound

slide-6
SLIDE 6
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Limitation: Processing is still linear!

Advanced SIP scenarios:

  • Push Notifications
  • FreeSWITCH ESL Events (e.g. DTMF)
  • Call Pick-up

What’s missing:

  • Communication & data exchange between different

processing contexts

6

slide-7
SLIDE 7
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Step 3: “Event-driven” architecture

7

Time SIP packet arrivals T h r e a d 1 T h r e a d 2

SIP msg A SIP msg B

wait(event X) resume() event X

slide-8
SLIDE 8
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Step 3: “Event-driven” architecture

8

Time SIP packet arrival T h r e a d 1

SIP msg A 4xx SIP reply

wait(event X) resume()

timeout!

slide-9
SLIDE 9
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Step 3: “Event-driven” architecture

9

Time SIP packet arrivals T h r e a d 1 T h r e a d 2

SIP msg A SIP msg B

trigger(handler, eventX) eventX handler

slide-10
SLIDE 10

Event subscribe/notify

slide-11
SLIDE 11
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Event Definition

  • Triggered by actions / data processing during runtime
  • Events hold key/value attributes
  • OpenSIPS has a list of predefined events

11

slide-12
SLIDE 12
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Subscribe

  • interested OpenSIPS workers subscribe to events
  • event subscriptions may contain filtering attributes

12

slide-13
SLIDE 13
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Notify

  • Notification == event
  • Events are generated during runtime
  • They are dispatched to all relevant subscribers
  • Events are parametrized (e.g. DTMF digit, REG Contact)

13

slide-14
SLIDE 14

Usage scenarios

slide-15
SLIDE 15
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Push Notifications

15

INVITE bob 1xx PN REGISTER INVITE bob

slide-16
SLIDE 16
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Push Notifications

Current way

  • 1. incoming call for “bob”
  • 2. send PN to “bob”’s mobile device
  • 3. async sleep (N)
  • 4. call(“bob”) if registered(“bob”) else goto 3.

16

slide-17
SLIDE 17
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Push Notifications

Current way (limitations)

  • 1. performance killer
  • 2. inflexible, cannot handle complex scenarios
  • parallel forking (desk + mobile devices)
  • multiple gateways

17

slide-18
SLIDE 18
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Push Notifications

In 2.3:

  • 1. incoming call for “bob”
  • 2. subscribe(“REGISTER”, “aor=bob”, “reg_handler”)
  • 3. send PN to “bob”’s mobile device
  • 4. fork calls to existing registrations

...

route [reg_handler] { fork_call(“$event(contact)”); }

18

slide-19
SLIDE 19
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

DTMF-based fax/voicemail detection

In 2.3:

  • 1. incoming call for “bob”
  • 2. subscribe(“DTMF”, “callid=$ci”, “dtmf_handler”)
  • 3. send call to “bob”

... route [dtmf_handler] { hangup() if $event(digit) != 2 }

19

slide-20
SLIDE 20

OpenSIPS Script

slide-21
SLIDE 21
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Push Notifications

subscribe("REGISTER", "aor=bob", "reg_handler"); route(SEND_APN); if (lookup("location")) t_relay(); halt();

21

slide-22
SLIDE 22
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Push Notifications

route [SEND_APN] { rest_append_hf("Authorization: key=CONSOLE_API_KEY"); rest_append_hf("Content-Type: \"application/json\""); rest_post("https://android.googleapis.com/gcm/send", "{ \"data\" : {\"foo\": \"bar\"}, \"registration_ids\":[\"REGISTRATION_ID\"] }"...); }

22

slide-23
SLIDE 23
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Push Notifications

route [reg_handler] { route(CHECK_IF_MOBILE, "$event(contact)"); t_relay(); }

23

slide-24
SLIDE 24

Conclusions

slide-25
SLIDE 25
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

Conclusions

Event-driven approach:

  • powerful & easy to use
  • complex scenarios with simple script
  • lightning fast!

25

slide-26
SLIDE 26
  • FOSDEM ‘17 -

Liviu Chircu - OpenSIPS Project

OpenSIPS 2.3 - “integration”

  • SIP capturing - Homer/SIPCapture
  • billing - CGRateS
  • software PBX - FreeSWITCH
  • middleware - RabbitMQ

26

slide-27
SLIDE 27
  • Liviu Chircu

○ OpenSIPS Project: www.opensips.org ○ liviu@opensips.org

Take-Away Message Under development!