[OpenSIPS-Users] Limit calls over IP between Opensips Servers

Bogdan-Andrei Iancu bogdan at opensips.org
Wed Dec 12 17:20:58 CET 2012


Hi Bakko,

But do you get some error on startup or what is the exact problem ?

Regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com


On 12/12/2012 04:42 PM, Bakko wrote:
> Hello,
>
> maybe I resolved this configuration. My escenario:
>
> - load balancing environment
> - some clients register to opensips with a softphone and IP change.
> - some clients sending only INVITE to Opensips and Asterisk Servers 
> authenticate the INVITE.
>
> Configuration:
>
> I created a new table on Opensips database with this fields:
> IP
> Max calls permitted
> company name
>
> On both Opensips configuration I created a shared profile dialog:
>
> Opensips 1
> #### DIALOG module
> loadmodule "dialog.so"
> modparam("dialog","cachedb_url","redis://localhost:6379/")
> modparam("dialog", "default_timeout", 21600)
> modparam("dialog", "profiles_with_value", "calls/s")
>
> Opensips2
> loadmodule "dialog.so"
> modparam("dialog","cachedb_url","redis://localhost:6380/")
> modparam("dialog", "default_timeout", 21600)
> modparam("dialog", "profiles_with_value", "calls/s")
>
> On both record route:
>
> record_route();
>
>         setflag(1); # do accounting
>
>                 if (load_balance("1","voip/s")) {
>                 set_dlg_profile("calls/s","$si");
>                 get_profile_size("calls/s","$si","$avp(size)");
>                 avp_db_query("select canales from canales where 
> IP='$si'","$avp(calls)");
>                 if($retcode == 1){
>                 xlog("L_INFO", "Canales activos = $avp(size) Canales 
> disponibles = $avp(calls) $si\n");
>                         if($avp(size) <= $avp(calls)){
>                         xlog("L_INFO", "Llamada de $fu a $tu para $du 
> \n");
>                         route(RELAY);
>                         exit;
>                         }
>                         else {
>                         xlog("L_INFO", "Se ha superado el numero de 
> canales disponibles [$avp(size)/$avp(calls)]\n");
>                         route(2);
>                         exit;
>                         }
>                 }
>                 xlog("L_INFO", "Llamada de $fu a $tu para $du \n");
>                 route(RELAY);
>                 exit;
>                 }
>
>
> route[RELAY] {
>         if (!t_relay()) {
>                 xlog("L_ERR", "route [RELAY]\n");
>                 sl_reply_error();
>
>         };
>         exit;
> }
>
> route[2] {
>         xlog("desviando la llamada a contexto Opensip - extension 
> canales\n");
>         rewriteuri("sip:canales at sip.mydomain.net");
>         forward();
>         exit;
> }
>
> The logic:
>
> when Opensips receive a INVITE set the profile size for the 
> originating IP and get the profile size saving the value on the 
> $avp(size) variable, then check the database to looking for for the IP 
> on the INVITE. If IP exist, the function return 1 and save the max 
> channels value on the $avp(calls) variable. If  $avp(size) is <= 
> $avp(calls) opensips route the call to one of Asterisk servers else  
> process route(2). In process route[2] rewrite the URI and send the 
> calls to one of Asterisk Servers where on context opensip, extension 
> canales, a prompt announce to caller "no more channels availables" and 
> hangup the call.
>
> With this configuration I can share between the two opensips servers 
> the MAX calls over IP permitted.
>
> Maybe there is some syntax error on the script. Any suggestion?
>
> Regards
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>



More information about the Users mailing list