Asterisk as a Media Application Server
Transcription
Asterisk as a Media Application Server
Asterisk as a Media Application Server Matt Jordan @mattcjordan Director of Technology, Digium Goal: Can we make Asterisk a generic media application server? Creative Innovation – Customer Satisfaction – Continual Quality Improvement 2 Scalability Creative Innovation – Customer Satisfaction – Continual Quality Improvement 3 Traditional Deployments Creative Innovation – Customer Satisfaction – Continual Quality Improvement 4 Traditional Deployments Asterisk front-ended with Kamailio – Kamailio acts as Registrar, provides Location – Asterisk provides media services Use Traditional Asterisk Dialplan Creative Innovation – Customer Satisfaction – Continual Quality Improvement 5 Traditional Deployments Asterisk front-ended with Kamailio – Kamailio acts as Registrar, provides Location – Asterisk provides media services Use Traditional Asterisk Dialplan Option 1: Each Asterisk server the same Creative Innovation – Customer Satisfaction – Continual Quality Improvement 6 Traditional Deployment: Option 1 Alice Kamailio 1 Bob Kamailio 2 Asterisk PBX Asterisk PBX Asterisk PBX Creative Innovation – Customer Satisfaction – Continual Quality Improvement 7 Traditional Deployment: Option 1 ● Alice ● Kamailio 1 Asterisk PBX ● ● Bob Kamailio 2 Kamailio acts as Registrar Round Robin routing Multi-tenant Asterisk systems share configuration Asterisk PBX Asterisk PBX Creative Innovation – Customer Satisfaction – Continual Quality Improvement 8 Traditional Deployment: Option 1 ● Alice ● Kamailio 1 Asterisk PBX ● ● Bob Kamailio 2 Kamailio acts as Registrar Round Robin routing Multi-tenant Asterisk systems share configuration Asterisk PBX Asterisk PBX Creative Innovation – Customer Satisfaction – Continual Quality Improvement 9 Problems with Option 1 Sharing Configuration – Not easily scaled – All systems must know all information – Requires careful dialplan construction (func_odbc) Creative Innovation – Customer Satisfaction – Continual Quality Improvement 10 [customer_one] exten => 1000,1,NoOp() same => n,ConfBridge(1000,c_one_profile) same => n,Hangup() [customer_two] exten => 1000,1,NoOp() same => n,ConfBridge(1000,c_two_profile) same => n,Hangup() Creative Innovation – Customer Satisfaction – Continual Quality Improvement 11 [customer] exten => 1000,1,NoOp() same => n,ConfBridge(1000,${ODBC_CONF_PROF(${CALLERID(num)})}) same => n,Hangup() Creative Innovation – Customer Satisfaction – Continual Quality Improvement 12 Traditional Deployment: Option 1 Alice Kamailio 1 Asterisk PBX Alice Calls 1000 (Conference) Bob Kamailio 2 Asterisk PBX Asterisk PBX Creative Innovation – Customer Satisfaction – Continual Quality Improvement 13 Traditional Deployment: Option 1 Alice Kamailio 1 Asterisk PBX Bob Calls 1000 (Conference) Bob Kamailio 2 Asterisk PBX Asterisk PBX Creative Innovation – Customer Satisfaction – Continual Quality Improvement 14 Traditional Deployment: Option 1 Alice Kamailio 1 Bob Kamailio 2 Asterisk PBX Asterisk PBX :-( Asterisk PBX Creative Innovation – Customer Satisfaction – Continual Quality Improvement 15 Problems with Option 1 Sharing Configuration – Not easily scaled – All systems must know all information – Requires careful dialplan construction (func_odbc) func_odbc: Still doesn't scale well! – Can defer customer logic to external system – Cannot easily defer routing/application logic Creative Innovation – Customer Satisfaction – Continual Quality Improvement 16 Traditional Deployments Asterisk front-ended with Kamailio – Kamailio acts as Registrar, provides Location – Asterisk provides media services Use Traditional Asterisk Dialplan Option 1: Each Asterisk server the same Creative Innovation – Customer Satisfaction – Continual Quality Improvement 17 Traditional Deployments Asterisk front-ended with Kamailio – Kamailio acts as Registrar, provides Location – Asterisk provides media services Use Traditional Asterisk Dialplan Option 1: Each Asterisk server the same Creative Innovation – Customer Satisfaction – Continual Quality Improvement 18 Traditional Deployments Asterisk front-ended with Kamailio – Kamailio acts as Registrar, provides Location – Asterisk provides media services Use Traditional Asterisk Dialplan Option 1: Each Asterisk server the same Option 2: Special purpose Asterisk servers Creative Innovation – Customer Satisfaction – Continual Quality Improvement 19 Traditional Deployment: Option 2 ● Alice ● Kamailio 1 Asterisk PBX ● Bob Kamailio 2 Asterisk Conferencing ● Kamailio acts as Registrar Route based on functional purpose (with round robin amongst those) Multi-tenant Asterisk systems share configuration Asterisk PBX Creative Innovation – Customer Satisfaction – Continual Quality Improvement 20 Traditional Deployment: Option 2 Alice Kamailio 1 Bob Kamailio 2 Asterisk PBX Asterisk Conferencing Asterisk PBX Creative Innovation – Customer Satisfaction – Continual Quality Improvement 21 Traditional Deployment: Option 2 Alice Kamailio 1 Bob Kamailio 2 Asterisk PBX Asterisk Conferencing But what if I need another Conferencing Server? Asterisk PBX Creative Innovation – Customer Satisfaction – Continual Quality Improvement 22 Traditional Deployment: Option 2 Alice Kamailio 1 Bob Kamailio 2 Asterisk PBX Asterisk Conferencing :-( Asterisk PBX Creative Innovation – Customer Satisfaction – Continual Quality Improvement 23 Traditional Deployments Asterisk front-ended with Kamailio – Kamailio acts as Registrar, provides Location – Asterisk provides media services Use Traditional Asterisk Dialplan Option 1: Each Asterisk server the same Option 2: Special purpose Asterisk servers Creative Innovation – Customer Satisfaction – Continual Quality Improvement 24 Problems with Option 1 and Option 2 Sharing Configuration – Not easily scaled – All systems must know all information – Requires careful dialplan construction (func_odbc) func_odbc: Still doesn't scale well! – Can defer customer logic to external system – Cannot easily defer application logic Functional systems only partially mitigate the problem – Application logic still affects routing decisions – Impacts how easy we can scale Creative Innovation – Customer Satisfaction – Continual Quality Improvement 25 Problems with Tradition Optimal routing should not require application logic: Not Kamailio's job Creative Innovation – Customer Satisfaction – Continual Quality Improvement 26 Problems with Tradition Optimal routing should not require application logic: Not Kamailio's job Application Logic impacts routing Creative Innovation – Customer Satisfaction – Continual Quality Improvement 27 Problems with Tradition Optimal routing should not require application logic: Not Kamailio's job Application Logic impacts routing Ideal situation – Every instance of Asterisk is generic – Kamailio just routes based on performance Creative Innovation – Customer Satisfaction – Continual Quality Improvement 28 Goal: Can we make Asterisk a generic media application server? Creative Innovation – Customer Satisfaction – Continual Quality Improvement 29 Remove the application logic from Asterisk Creative Innovation – Customer Satisfaction – Continual Quality Improvement 30 ARI: An API for building custom communications applications Creative Innovation – Customer Satisfaction – Continual Quality Improvement 31 ARI: A Super Quick Overview A REST(ful) API – Exposes the raw Asterisk primitives as resources Creative Innovation – Customer Satisfaction – Continual Quality Improvement 32 ARI: A Super Quick Overview A REST(ful) API – Exposes the raw Asterisk primitives as resources POST /channels/12345/answer DELETE /bridges/awesome_bridge PUT /deviceStates/my_dev/state=BUSY Creative Innovation – Customer Satisfaction – Continual Quality Improvement 33 ARI: A Super Quick Overview A REST(ful) API – Exposes the raw Asterisk primitives as resources POST /channels/12345/answer DELETE /bridges/awesome_bridge PUT /deviceStates/my_dev/state=BUSY JSON Events over WS { event: 'ChannelHangup', channel: { 'id': '12345', 'name': 'PJSIP/alice' A tiny bit of dialplan exten => _XXXX,1,Stasis(yourapp) Creative Innovation – Customer Satisfaction – Continual Quality Improvement 34 ARI: A Super Quick Overview Stasis dialplan app Asterisk Dialplan Execution ARI External Execution Creative Innovation – Customer Satisfaction – Continual Quality Improvement 35 Single Slide Conference Bridge import ari client = ari.connect('http://localhost:8088', 'ari_user', 's3cr3t') conf_bridge = client.bridges.create( type='mixing,dtmf_events', bridgeId='awesome_conf') def stasis_start_cb(channels, ev): channel = channels.get('channel') channel.answer() conf_bridge.play(media='sound:beep') conf_bridge.addChannel(channel=channel.id) client.on_channel_event('StasisStart', stasis_start_cb) client.run(apps='awesome_conference') Creative Innovation – Customer Satisfaction – Continual Quality Improvement 36 ARI: An API for building custom communications applications (THAT'S THE DIALPLAN) Creative Innovation – Customer Satisfaction – Continual Quality Improvement 37 Nontraditional Deployment Creative Innovation – Customer Satisfaction – Continual Quality Improvement 38 Step 1: Remove the Dialplan* * Conspiracy Theorists Rejoice Creative Innovation – Customer Satisfaction – Continual Quality Improvement 39 Getting a little extreme [default] exten => _X.,1,NoOp() same => n,Stasis(EVERYTHING) same => n,Hangup() Creative Innovation – Customer Satisfaction – Continual Quality Improvement 40 Step 2: Use a Message Bus Approach Creative Innovation – Customer Satisfaction – Continual Quality Improvement 41 Getting a little extreme def get_app_by_exten(exten): “””This is terrible, but demos the concept””” if exten == '1000': return exec_conference else: return default_app_exec def stasis_start_cb(channel, ev): exten = ev.get('exten') app = get_app_by_exten(exten) app(channel) client.on_channel_event('StasisStart', stasis_start_cb) Creative Innovation – Customer Satisfaction – Continual Quality Improvement 42 Getting a bit more extreme SIP ARI Alice Kamailio 1 Asterisk 1 App Server Bob Kamailio 2 Asterisk 2 App Server Asterisk n Creative Innovation – Customer Satisfaction – Continual Quality Improvement 43 Getting a bit more extreme SIP ARI Alice Kamailio 1 Asterisk 1 App Server Bob Kamailio 2 Asterisk 2 App Server Treat as Scalable Microservices Asterisk n Creative Innovation – Customer Satisfaction – Continual Quality Improvement 44 A philosophical taxonomy Keep things as simple as possible, but no simpler Kamailio: manage SIP Asterisk: manage media Application logic: your choice Creative Innovation – Customer Satisfaction – Continual Quality Improvement 45 Questions ? Creative Innovation – Customer Satisfaction – Continual Quality Improvement 46