2600hz cto karl anderson speaks at kamailio world 2014

Post on 26-May-2015

1.231 Views

Category:

Technology

4 Downloads

Preview:

Click to see full reader

DESCRIPTION

2600hz CTO Karl Anderson's spoke at KamailioWorld on April 4th in Berlin, Germany. Here's his PPT presentation!

TRANSCRIPT

Presented By:

Kamailio and Kazoo

Karl Anderson

Karl AndersonSenior Bit Herder

My name is Karl Anderson, I am one of the senior bit herders at 2600hz. I have no credentials that will “wow” you, but hopefully you will still find this talk informative and at the very least interesting.

www.2600hz.com

What is Kazoo

At 2600hz we are building an ambitious open-source project called Kazoo. Kazoo is a distributed communication platform

This is Kazoo from a high level, it is a control layer focused on the telecom problem domain. It provides modern interfaces to the communication revolution and allows anybody to quickly enter the telecom industry. At the border you can see the SBC, which in our case is Kamailio. We also use Kamailio for as presence and registration servers, which is why we created the Kamailio module db_kazoo to connect to Kazoo’s internal AMQP message bus.

www.2600hz.com

What is AMQP

• Enterprise messaging• Initially John O'Hara with JP Morgan

Chase• 2005 formed a working group, which

grew to include:

Cisco, Bank of America, Red Hat, Microsoft, VM Ware, Goldman Sachs, Software AG and Others

• Originated from the demands of financial services. Completely open, version 1.0 accepted by OASIS (Organization for the Advancement of Structured Information Standards) this year.

• It is a document, standard specification. We use a implementation called RabbitMQ.

• AMQP is a wire-level messaging protocol that offers organizations an efficient, reliable approach to passing real-time data and business transactions with confidence. AMQP provides a platform-agnostic method for ensuring information is safely transported between applications, among organizations, within mobile infrastructures, and across the Cloud.

• Solves the a lot of really hard distributed system problems.

What Does this Mean?

• Messages are published to exchanges, which are often compared to post offices or mailboxes. Exchanges then distribute message copies to queues using rules called bindings. Then AMQP brokers either deliver messages to consumers subscribed to queues, or consumers fetch/pull messages from queues on demand.

• A direct exchange delivers messages to queues based on the message routing key. A direct exchange is ideal for the unicast routing of messages

• A fanout exchange routes messages to all of the queues that are bound to it and the routing key is ignored.

• Topic exchanges route messages to one or many queues based on matching between a message routing key and the pattern that was used to bind a queue to an exchange. The topic exchange type is often used to implement various publish/subscribe pattern variations.

www.2600hz.com

What is db_kazoo

db_kazoo presents the Kazoo AMQP message bus a database type to Kamailio. This allows lookups to preform response/request operations in Kazoo which in turn draw from our database.

Discuss why we use the db interface in Kamailio and how in this architecture Kazoo is a middle man for the Bigcouch, providing a layer of realtime logic…

www.2600hz.com

How do we use it

modparam("auth_db|usrloc", "db_url", "kazoo://guest:guest@127.0.0.1:5672/callmgr")

modparam("presence", "db_url", "kazoo://guest:guest@127.0.0.1:5672/dialoginfo")

####### Authentication module ##########

loadmodule "auth.so"

loadmodule "auth_db.so"

modparam("auth_db", "version_table", 0)

modparam("auth_db", "password_column", "password")

modparam("auth_db", "load_credentials", "$avp(password)=password")

####### User Location module ##########

loadmodule "usrloc.so"

modparam("usrloc", "db_mode", 1)

modparam("usrloc", "db_update_as_insert", 1)

route[HANDLE_REGISTER]

{

if (is_method("REGISTER")) {

if (auth_check("$fd", "subscriber", "1")) {

consume_credentials();

save("location");

} else {

auth_challenge("$fd", "0");

}

exit;

}

}

######## Generic Hash Table in shared memory ########

modparam("htable", "htable", "dbkp=>size=16;autoexpire=7200")

######## Presence User Agent ########

loadmodule "pua_dialoginfo.so"

modparam("pua_dialoginfo", "library_mode", 1)

######## Presence Server ########

loadmodule "presence.so"

loadmodule "presence_dialoginfo.so"

modparam("presence", "subs_db_mode", 1)

####### Presence Logic ########

route[HANDLE_SUBSCRIBE]

{

if (is_method("SUBSCRIBE")) {

if (!t_newtran()) {

sl_reply_error();

exit;

}

handle_subscribe();

t_release();

exit;

}

}

•How does it work

int db_kazoo_bind_api(db_func_t *dbb)

{

dbb->init = db_kazoo_init;

dbb->use_table = db_kazoo_use_table;

dbb->close = db_kazoo_close;

dbb->query = db_kazoo_query;

dbb->free_result = db_kazoo_free_result;

dbb->insert = db_kazoo_insert;

dbb->replace = db_kazoo_replace;

dbb->insert_update = db_kazoo_insert_update;

dbb->delete = db_kazoo_delete;

dbb->update = db_kazoo_update;

dbb->raw_query = db_kazoo_raw_query;

dbb->cap = DB_CAP_ALL;

return 0;

}

int dbk_credentials_query(const db1_con_t* _h, ..., db1_res_t** _r) {

amqp_mb.len = sprintf(messagebody, "{\"Method\":\"REGISTER\","

"\"Auth-Realm\":\"%.*s\","

"\"Auth-User\":\"%.*s\","

"\"From\":\"%.*s@%.*s\","

"\"To\":\"%.*s@%.*s\","

"\"Server-ID\":\"%s\","

"\"Node\":\"kamailio@%.*s\","

"\"Msg-ID\":\"%.*s\","

"\"App-Version\":\"%s\","

"\"App-Name\":\"%s\","

"\"Event-Name\":\"authn_req\","

"\"Event-Category\":\"directory\"}",

_v[1].val.str_val.len, _v[1].val.str_val.s,

_v[0].val.str_val.len, _v[0].val.str_val.s,

_v[0].val.str_val.len, _v[0].val.str_val.s,

_v[1].val.str_val.len, _v[1].val.str_val.s,

_v[0].val.str_val.len, _v[0].val.str_val.s,

_v[1].val.str_val.len, _v[1].val.str_val.s,

serverid,

dbk_node_hostname.len, dbk_node_hostname.s,

unique_string.len, unique_string.s,

VERSION, NAME);

amqp_mb.bytes = messagebody;

if (!amqp_basic_publish(rmq->conn, rmq->channel, ..., amqp_mb)) {

goto error;

}

while (body_received < body_target) {

if (dbk_rmq_wait_for_data(rmq->conn) < 0 ) {

goto error;

}

memcpy(body + body_received, frame.payload.body_fragment.bytes,

frame.payload.body_fragment.len);

body_received += frame.payload.body_fragment.len;

if (body_received != body_target) {

goto error;

}

}

body[body_received] = '\0';

db1_res_t* db_res = dbk_creds_build_result(body, _c, _nc);

*_r = db_res;

return 0;

}

www.2600hz.com

What next

www.2600hz.com

Make it More Generic

www.2600hz.com

Commit it Upstream

www.2600hz.com

Add Support to Multiple AMQP Brokers

github.com/2600hz www.2600hz.com

415-886-7900

info@2600hz.com

www.2600hz.com

CONTACT US

Thank You!

FOLLOW US

/2600hzOfficial

@2600hertz

/2600hzOfficial

top related