Hi Carlos,
Sorry for coming late on this one.
the ruri value in my example is '10.97.116.36'
and i have tried to configure kamailio to only cater 100 simultaneous calls
on this SIP Server (10.97.116.36), after that it is to send 403.
Below is the sample logic from kamailio.cfg
***********************************************************************************************************************
#Below lines to show an example of how I am maintaining the business for
Concurrent Call Restriction
route[CNXCC]
{
$var(client1) = "10.97.116.36";
$var(max_chan) = 100;
#!ifdef CNXCC_CHANNEL
xlog("L_INFO", "Setting up channel based credit control");
$var(max_chan1) = 0;
$var(retcode) = cnxcc_set_max_channels("$var(client1)",
"$var(max_chan)");
if ($var(retcode) == -1) {
xlog("Error setting up credit control");
return;
}
$var(count1) = -1;
if (!cnxcc_get_channel_count("$rd", "$var(count1)")) {
xlog("Error getting customer's channel count");
}
xlog("RAHUL : CNXCC ROUTE: $var(client1) has $var(count1)
call(s)");
xlog("L_INFO", "CNXCC ROUTE: $var(client1) has $var(count1)
call(s)");
if ($var(count1) == $var(max_chan1)) {
xlog("Too many channels for customer");
sl_send_reply(403, "Forbidden");
exit;
}
#!endif
******************************************************************************************************************************************************
Now the problem that I am facing is that with multiple UACs (all with same
ruri - 10.97.116.36) dialing some pstn numbers, the value of "count1"
remains 1 for all cases. Hence, my purpose is defeated because the
restriction is not being laid and more than 'max_chan' no. of callers are
able to make the call.
Could you please help me achieve this goal.
Thanks !
On Sat, May 17, 2014 at 2:22 AM, Carlos Ruiz Díaz <carlos.ruizdiaz(a)gmail.com
wrote:
> max_chan is equal to zero? You should put a positive value in here in
> order to make sense the function call.
>
> Also, you are using for one call the ID "x.y.z.a", and for the other one
> $rd. Both should be the same for calls that suppose to be organized in the
> same group.
>
> Please take a look at the docs.
>
>
> On Fri, May 16, 2014 at 7:52 PM, Rahul MathuR <rahul.ultimate(a)gmail.com>
wrote:
>
>> Further, from the logs it seems that cnxcc_set_max_channels is returning
>> -1 and I have no idea why it is failing.
>>
>>
>> On Sat, May 17, 2014 at 5:48 AM, Rahul MathuR <rahul.ultimate(a)gmail.com>
>
wrote:
>>
>>> Hello Carlos,
>>>
>>> Many thanks for your help.
>>> I followed the steps you mentioned for CNXCC. But even after making the
>>> max. calls to 0, I am still able to connect the call. Below is the excerpt
>>> from kamailio.cfg
>>>
>>> request_route {
>>> setflag(DLG_FLAG);
>>> # per request initial checks
>>> route(REQINIT);
>>> # NAT detection
>>> route(NATDETECT);
>>> .
>>> .
>>> .
>>>
>>> if (is_method("INVITE")) {
>>> route(CNXCC);
>>> }
>>> }
>>>
>>> #Below lines added by Rahul for Concurrent Call Restriction
>>> route[CNXCC]
>>> {
>>>
>>> $var(client1) = "x.y.z.a";
>>>
>>> #!ifdef CNXCC_CHANNEL
>>> xlog("L_INFO", "Setting up channel based credit
control");
>>>
>>> $var(max_chan1) = 0;
>>> $var(retcode) = cnxcc_set_max_channels("$var(client1)",
>>> "$var(max_chan)");
>>>
>>> if ($var(retcode) == -1) {
>>> xlog("Error setting up credit control");
>>> return;
>>> }
>>>
>>> $var(count1) = -1;
>>>
>>> if (!cnxcc_get_channel_count("$rd",
"$var(count1)")) {
>>> xlog("Error getting customer's channel
count");
>>> }
>>> xlog("RAHUL : CNXCC ROUTE: $var(client) has $var(count)
>>> call(s)");
>>> xlog("L_INFO", "CNXCC ROUTE: $var(client) has
$var(count)
>>> call(s)");
>>>
>>> if ($var(count1) == $var(max_chan1)) {
>>> xlog("Too many channels for customer");
>>> sl_send_reply(403, "Forbidden");
>>>
>>> #if (!cnxcc_terminate_all("$var(client)")) {
>>> # xlog("Error terminating customer's
calls");
>>> #}
>>>
>>> exit;
>>> }
>>> #!endif
>>>
>>>
>>> Could you please guide me where am I doing wrong ?
>>>
>>>
>>> On Sat, May 17, 2014 at 3:01 AM, Carlos Ruiz Díaz <
>>> carlos.ruizdiaz(a)gmail.com
wrote:
>>>
>>>> Any pseudo variable should work.
>>>>
>>>> I don't exactly know how your business work, but I'd suggest
that
>>>> instead of using from header domain, use the domain part of the
>>>> request-uri, $rd.
>>>>
>>>> Regards,
>>>> Carlos
>>>>
>>>>
>>>> On Fri, May 16, 2014 at 4:28 PM, Rahul MathuR
<rahul.ultimate(a)gmail.com
>>>>
wrote:
>>>>
>>>>> Thank you very much Carlos !
>>>>>
>>>>> One last thing, can I use $fd in cnxcc_set_max_channels as below -
>>>>> cnxcc_set_max_channels("$fd", "$var(max_chan)");
>>>>> to restrict the simultaneous calls hitting a particular domain ?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Sat, May 17, 2014 at 2:03 AM, Carlos Ruiz Díaz <
>>>>> carlos.ruizdiaz(a)gmail.com
wrote:
>>>>>
>>>>>> Create a profile [1], and count the number of calls of that
profile
>>>>>> [2].
>>>>>>
>>>>>> Alternatively, you can use cnxcc module [3].
>>>>>>
>>>>>> [1]
>>>>>>
http://kamailio.org/docs/modules/stable/modules/dialog.html#idp1919576
>>>>>> [2]
>>>>>>
http://kamailio.org/docs/modules/stable/modules/dialog.html#idp1964064
>>>>>> [3]
>>>>>>
http://kamailio.org/docs/modules/stable/modules/cnxcc.html#idp132608
>>>>>>
>>>>>>
>>>>>> On Fri, May 16, 2014 at 3:28 PM, Rahul MathuR <
>>>>>> rahul.ultimate(a)gmail.com
wrote:
>>>>>>
>>>>>>> *Hello,*
>>>>>>>
>>>>>>> *Please accept my apologies for asking a simple question - Is
there any example which shows how can I create the dialog profile **value based on the SIP
domain or SIP Server IP (IP like- 112.23.134.5). I** need to control many SIP Server IPs
with limited channels to each with my** Kamailio Proxy.*
>>>>>>>
>>>>>>> *I am a newbie to kamailio world.*
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> *-- Warm Regds.MathuRahul*
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> sr-dev mailing list
>>>>>>> sr-dev(a)lists.sip-router.org
>>>>>>>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Carlos
>>>>>>
http://caruizdiaz.com
>>>>>>
http://ngvoice.com
>>>>>> +52 55 3048 3303
>>>>>>
>>>>>> _______________________________________________
>>>>>> sr-dev mailing list
>>>>>> sr-dev(a)lists.sip-router.org
>>>>>>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Warm Regds.
>>>>> MathuRahul
>>>>>
>>>>> _______________________________________________
>>>>> sr-dev mailing list
>>>>> sr-dev(a)lists.sip-router.org
>>>>>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Carlos
>>>>
http://caruizdiaz.com
>>>>
http://ngvoice.com
>>>> +52 55 3048 3303
>>>>
>>>> _______________________________________________
>>>> sr-dev mailing list
>>>> sr-dev(a)lists.sip-router.org
>>>>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
>>>>
>>>>
>>>
>>>
>>> --
>>> Warm Regds.
>>> MathuRahul
>>>
>>
>>
>>
>> --
>> Warm Regds.
>> MathuRahul
>>
>> _______________________________________________
>> sr-dev mailing list
>> sr-dev(a)lists.sip-router.org
>>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
>>
>>
>
>
> --
> Carlos
>
http://caruizdiaz.com
>
http://ngvoice.com
> +52 55 3048 3303
>
> _______________________________________________
> sr-dev mailing list
> sr-dev(a)lists.sip-router.org
>
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
>
>
--
Warm Regds.
MathuRahul