[asterisk-dev] AstriDevCon Follow Up - Asterisk and Kamailio - smoother integration

Daniel-Constantin Mierla miconda at gmail.com
Mon Jan 12 10:53:31 CST 2015


Hey guys,

I hope everyone here enjoyed nice time during the winter (or summer for
lucky ones at this time of the year) holidays break!

Being rather busy after AstriDevCon, but I also postponed starting the
discussion, given that I expected low activity ahead and didn't want to
get it lost in the archive ... so back to the topic ... and expect large
message below ...

During AstriDevCon sessions in Las Vegas, we discussed briefly of what
can be done for a better integration between Asterisk (as media server)
and Kamailio (as a front end SIP singling server/proxy). I said I would
follow up on mailing list, so here we are. Obviously, many are using the
two together, therefore any improvement to make it simpler could make a
very good impact on both sides.

To be honest, I lost track of many new 'cool' things happening lately in
Asterisk with the newer APIs, I will have to catch up very soon,
meanwhile, if any of my ideas are already there, then even better.

The typical integration of Asterisk and Kamailio was to share somehow
user profiles via database -- relying on Asterisk realtime, either using
Asterisk database structure with kamailio connecting to it, or making
SQL views to suit the two applications. I wrote some tutorials over the
time -- for reference, just in case anyone wants to get the idea better:

  - http://kb.asipto.com/asterisk:index

The approach works very well when dealing in a more or less static
deployment. However, there is a lot to benefit on top of elasticity of
the cloud networks, where the nodes could be fired on demand, in
different locations of the world. In such situations, sharing the
database can become really slow, adds issues with replications, etc.

To set the specifics of a deployment:
  - kamailio takes care of signaling 'heavy' processing (authentication,
user location, filtering DoS attacks, etc.)
  - asterisk takes care of 'heavy' pbx features and media processing

When I fire a new asterisk, I want to give it (e.g., in config file) one
or many IP addresses that belong to kamailios and asterisk should
consider them trusted, no other authentication should be done for
traffic originating from those IPs. The rest of integration would
hopefully automagically just work.

One of my ideas was to be able to define subscriber (phone) profile
templates and the proxy will indicate which template to use for caller
and callee (when they are local subscribers). Attributes of the template
can be taken from SIP message or be statically defined. I know about the
config templates with [name](!), but that is still quite static,
extension have to be defined and templates associated with them. It
could be on same direction, but more dynamic.

For better exemplification, in pseudo code:

[template-match]
template-as-caller=${header(X-Caller-Template)
template-as-callee=${header(X-Callee-Template)

[template-user-x]
userid-as-caller=${From-Header-URI-Username}
userid-as-caller=${Request-URI-Username}
codecs=g711,g729
mwi=yes
maiboxid=${header(X-MailBoxId)}
maiboxpin=${header(X-MailBoxPin)}
location =
"sip:${From-Header-URI-Username}@${Source-IP}:${Source-Port};transport={Transport-Protocol}"
publish-dialog-info=yes
...

The proxy has to set the header X-Caller-Template if the caller is local
and X-Callee-Template if the callee is local, plus other headers than
are necessary/used in templates.

Practically, Asterisk would have to build the user profile on demand,
without needing to interogate any database or other resource over the
network (I know APIs can be used everywhere :-), but they fail also, or
in other words, SIP is an API as well). It can reuse the variable
already available on the SIP channel, I used pseudo-code to make it
easier to understand.

For the moment I would stop here, already long message. And might be
already possible ... if not, before going on other directions, lets see
the interest and maybe other proposals for a better media
server/signaling server integration.

Before the real end, some questions for the larger devel community that
should help deciding on how to get the two projects working smoother
together:
  - what would you like from the proxy (signaling server) to be exposed
easier?
  - if already using the two, what parts you would like to simplify?
  - how would you split the workload? In other words, what services you
would prefer to be done better in one or the other, given that some
features overlap?

Have a great 2015 coding Asterisk and Kamailio! Looking forward to
meeting some of you around the globe this year!
Daniel

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda




More information about the asterisk-dev mailing list