Upload
others
View
18
Download
0
Embed Size (px)
Citation preview
Federico CabidduSenior VoIP Developer
Kamailio in a Mobile World
Kamailio World | © 2015 Orange Vallée
Working in VoIP since 2001
Working with OpenSER/Kamailio since 2005
Libon Voice Team Tech Coordinator
About me
What is Libon?
app available on
VoIP and VoIP out callsApp2app calls and calls to landlines and mobiles in more than 100 destinations.
Free app to app calls.
Instant messagesInstant messaging with Libon and non-
Libon users (OpenChat).
Customized voicemailCreate customized greetings for each
one of your contacts or groups of contacts.
Kamailio World | © 2015 Orange Vallée
Constraints of a mobile VoIP application A commonly used approach Multidevice scenarios The TSILO module Working example
Contents
Kamailio World | © 2015 Orange Vallée
Power consumption Data consumption Socket unreliability Constructor constraints: iOS background mode(s)
Mobile VoIP apps constraints
Kamailio World | © 2015 Orange Vallée
Push notifications
In mobile context: a short message sent to a smartphone through a centralized service and targeted to a specific app.
It can be used to trigger an action from the app.
Kamailio World | © 2015 Orange Vallée
Push notifications & VoIP
Kamailio World | © 2015 Orange Vallée
Pros• Simple way for a service to send
notifications to user's device• Available on several platforms/OS• Reliable (APNS > 99% success rate)• No need to deal with pinhole/NAT• No need to permanently store users'
location• Use resources “on demand”
Kamailio World | © 2015 Orange Vallée
Push notifications
Cons• No immediate delivery status report• No delivery guarantee • Not possible to predict delivery time• Different API per provider• Different UX per OS/Version: –Apple push before iOS 7 vs Apple
“silent push”
Kamailio World | © 2015 Orange Vallée
Push notifications
Users can have many devices Only some of them may be
reachable Each device may have a different
Push Notification system
Kamailio World | © 2015 Orange Vallée
Multi-device: new challenges
How long do we have to wait before relaying the INVITE?
Kamailio World | © 2015 Orange Vallée
Multi-device: the question
“Late” parallel forking
Instead of forking an INVITE just to the currently registered contacts, send the
INVITE to the available ones and continue adding branches as soon as new ones register and as long as the transaction
hasn't got a final reply.
TSILO = Transactions Silo
Kamailio World | © 2015 Orange Vallée
TSILO: concept
Kamailio World | © 2015 Orange Vallée
Push & multi-device
Callee's devices receive the INVITE (5,7,9) as soon as they register (4,6,8)
Kamailio World | © 2015 Orange Vallée
TSILO: details
ts_store()store the current transaction
ts_append(domain¹, ruri)add branches to all the transactionscurrently stored for ruri
ts_append_to(tindex, tlabel, domain¹) add branches to a specific transaction
identified by tindex and tlabel
(1) the table over which the internal lookup is performed
Kamailio World | © 2015 Orange Vallée
TSILO: exported functions
r-uris stored as entries of a hash table (separate chaining with linked lists for
collisions) transactions per r-uri stored as linked list
of the hash table entries t_append*() call lookup_to_dset
(REGISTRAR module) and t_append_branches (TM module)
For each transaction a TM cb for TMCB_DESTROY event is registered
Kamailio World | © 2015 Orange Vallée
TSILO: implementation details
Hibernate
Kamailio World | © 2015 Orange Vallée
TSILO: example (preamble)Based on KamailioWorld 2014 Async Push example
by Daniel Constantin-Mierla
loadmodule “tsilo.so”
# ----- htable params -----modparam("htable", "htable", "vtp=>size=10;autoexpire=120;dbtable=htable;dbmode=0")
request_route { ...
if (is_method(“INVITE”)) {
route(INVITE); }
if (is_method(“REGISTER”)) {
route(REGISTER); } ...
}
Kamailio World | © 2015 Orange Vallée
TSILO: example
# manage incoming INVITEsroute[INVITE] { if (!lookup("location")) { send_reply("100", "Trying"); route(SUSPEND); } else { t_relay();
ts_store();
$sht(vtp=>stored::$rU) = 1; xdbg("stored transaction [$T(id_index):$T(id_label)] $fU
=> $rU\n"); }
route(SENDPUSH);}
Kamailio World | © 2015 Orange Vallée
TSILO: example
# suspend the transactionroute[SUSPEND] { if(!t_suspend()) { xlog("failed suspending trasaction [$T(id_index):$T(id_label)]\n"); send_reply("501", "Unknown destination"); exit; }
xdbg("suspended transaction [$T(id_index):$T(id_label)] $fU => $rU\n");
$sht(vtp=>join::$rU) = "" + $T(id_index) + ":" + $T(id_label);
xdbg("htable key value [$sht(vtp=>join::$rU)]\n");}
Kamailio World | © 2015 Orange Vallée
TSILO: example
route[SENDPUSH] { $var(luaret) = 0; if(lua_runstring("do_push([[$hdr(X-VxTo)]], [[$tU]], [[$hdr(X-VxFrom)]], [[$fU]], [[$ci]])")<0) { send_reply("501", "No link to destination"); exit; } if($var(luaret)!=1) { send_reply("501", "Unknown destination"); exit; }}
# manage incoming REGISTERsroute[REGISTER] { if (!save("location")) sl_reply_error();
route(PUSHJOIN); exit;}
Kamailio World | © 2015 Orange Vallée
TSILO: example
# append branches or resume the transactionroute[PUSHJOIN] { $var(hjoin) = 0; lock("$tU"); $var(hjoin) = $sht(vtp=>join::$tU); $var(hstored) = $sht(vtp=>stored::$tU); $sht(vtp=>join::$tU) = $null; unlock("$tU");
if ($var(hjoin)==0) { if ($var(hstored))
ts_append("location", "$tU"); return; }
$var(id_index) = $(var(hjoin){s.select,0,:}{s.int}); $var(id_label) = $(var(hjoin){s.select,1,:}{s.int}); xdbg("resuming trasaction [$var(id_index):$var(id_label)] $tU ($var(hjoin))\n"); t_continue("$var(id_index)", "$var(id_label)", "INVRESUME");}
Kamailio World | © 2015 Orange Vallée
TSILO: example
# lookup and relay after resuming transactionroute[INVRESUME] { lookup("location"); t_relay();
ts_store();
$sht(vtp=>stored::$rU) = 1; xdbg("stored transaction [$T(id_index):$T(id_label)] $fU =>
$rU\n");}
Kamailio World | © 2015 Orange Vallée
TSILO: example
Kamailio World | © 2015 Orange Vallée
Multi-device without Push & TSILO
Kamailio World | © 2015 Orange Vallée
Multi-device with Push & TSILO
• Stats• More RPC commands• USRLOC callbacks?
Kamailio World | © 2015 Orange Vallée
TSILO: improvements