Hi,
I just committed in SVN trunk (1.4, next major release) support for dialog profiling.
What dialog profiling is =========================
Dialog profiling is a mechanism that helps in classifying, sorting and keeping trace of certain types of dialogs, using whatever properties of the dialog (like caller, destination, type of calls, etc). Dialogs can be dynamically added in different (and several) profile tables - logically, each profile table can have a special meaning (like dialogs outside the domain, dialogs terminated to PSTN, etc). Information provided by the profiles can be used also for doing real load-balancing - by real, I mean routing decisions based on load. So far dispatcher module can do probabilistic dispatching with no feedback on the actual load of the peer (or about the call success). See example 3 - load balancing between 2 asterisk boxes with identical capacities.
Being able to actually trace the ongoing dialog, gives liberty to do more complex routing logics.
There are two types of profiles: * with no value - a dialog simply belongs to a profile. (like outbound calls profile). There is no other additional information to describe the dialog's belonging to the profile; * with value - a dialog belongs to a profile having a certain value (like in caller profile, where the value is the caller ID). The belonging of the dialog to the profile is strictly related to the value.
A dialog can be added to multiple profiles in the same time.
What it should be used for ===========================
Example 1:
Count the calls terminating to PSTN in order to monitor the load. Before routing the call the GW, check if the number of ongoing calls (to the GW) do not exceed some value.
modparam("dialog","profiles_no_value","pstn_calls") .... /* do some checking */ get_dialog_size("pstn_calls","$avp(cnt)"); if ( $avp(cnt) > 32 ) { sl_send_reply("500","GW full"); exit; } set_dlg_profile("pstn_calls"); /* route to the GW */ .....
Example 2:
Allow only 2 parallel calls per user - use a profile with value to count the outgoing calls for each subscriber
modparam("dialog","profiles_with_value","caller") .... /* do some checking */ get_dialog_size("caller","$fu","$avp(cnt)"); if ( $avp(cnt) > 2 ) { sl_send_reply("403","Not allowed"); exit; } set_dlg_profile("caller","$fu"); /* route the call */ .....
Example 3:
Do load balancing between 2 asterisk boxes with identical capacities - use a profile with values to count the ongoing calls through each Asterisk box.
modparam("dialog","profiles_with_value","asterisk") .... /* do some checking */ get_dialog_size("asterisk","box1","$avp(cnt1)"); get_dialog_size("asterisk","box2","$avp(cnt2)");
if ( $avp(cnt1) > $avp(cnt2) ) { setdsturi("sip:IP_BOX2:PORT_BOX2"); set_dlg_profile("asterisk","box2"); } else { setdsturi("sip:IP_BOX1:PORT_BOX1"); set_dlg_profile("asterisk","box1"); } /* route the call */ .....
Of course, this can be extended for asymmetric load or for multiple boxes.
Regards, Bogdan