Hello, I have a question about LCR which I have been unable to solve. I have 4 upstream carrier gateways owned by 2 carriers. Each carrier provides a primary and secondary gateway for load balancing purposes. On a 5XX error I am trying to send the same call to the other carrier. If both carriers reject the call with 5XX, I allow the response to go downstream to my asterisk server. The issue I am running into is that in a scenario where both my carriers respond with a 5XX, I end up presenting the same call to all 4 gateways. I would like to present the call to one gateway on each carrier and not try the same carriers second gateway for the same call. Here is what is happening now:
ASTERISK --> INVITE --> KAMAILIO INVITE --> CARRIER A/GATEWAY 1 <-- 5XX Error INVITE --> CARRIER A/GATEWAY 2 <-- 5XX Error INVITE --> CARRIER B/GATEWAY 1 <-- 5XX Error INVITE --> CARRIER B/GATEWAY 2 <-- 5XX Error KAMAILIO --> 5XX Error --> ASTERISK
OR any combination of the above... i.e.
ASTERISK --> INVITE --> KAMAILIO INVITE --> CARRIER A/GATEWAY 1 <-- 5XX Error INVITE --> CARRIER B/GATEWAY 2 <-- 5XX Error INVITE --> CARRIER B/GATEWAY 1 <-- 5XX Error INVITE --> CARRIER A/GATEWAY 2 <-- 5XX Error KAMAILIO --> 5XX Error --> ASTERISK
What I want to happen is:
ASTERISK --> INVITE --> KAMAILIO INVITE --> CARRIER A/GATEWAY 1 or 2 <-- 5XX Error INVITE --> CARRIER B/GATEWAY 1 or 2 <-- 5XX Error KAMAILIO --> 5XX Error --> ASTERISK
I tried dealing with the issue using some flags on the gateway, but i couldn't get the logic to work properly. Here is the path I was heading down, but my plan fell apart after some testing.
CARRIER A has a gateway flag of "1" CARRIER B has a gateway flag of "2"
failure_route[1]{ $var(gw_flag) = $avp(i:712);
while(next_gw()){ if($var(gw_flag) != $avp(i:712)){ xlog("L_INFO","Found an LCR destination which is different than current, routing. ($ci)"); t_on_reply("1"); t_on_failure("1"); t_relay(); exit; }else{ xlog("L_INFO","The next destination in LCR has the same AVP flag, skipping. ($ci)"); } }
# let the reply go upstram - it is the default action xlog("L_ERR", "No Next Gateway - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); exit; }
Any help would be greatly appreciated.
Thanks, Geoff
Hello,
I am not an extensive user of lcr module, but probably next_gw() adds a branch each time is called in failure route.
If yes (when true you should see some parallel forking, depending o how the addresses are selected), you can mark the "bad" branches with a branch flag and drop them in a branch_route.
while(next_gw()){ if($var(gw_flag) != $avp(i:712)){ xlog("L_INFO","Found an LCR destination which is different than current, routing. ($ci)"); t_on_reply("1"); t_on_failure("1"); t_on_branch("1"); t_relay(); exit; }else{ xlog("L_INFO","The next destination in LCR has the same AVP flag, skipping. ($ci)"); setbflag(10); } }
branch_route[1] { if(isbflagset(10)) drop; }
However, if the destinations are selected like provider 1, provider 2, provider 1, provider 2, the condition you have in config file failure route is not good, since you check for change of the provider in each step, which happens in this case. Maybe you can use flags to check if a provider was used (or avps).
Cheers, Daniel
On Tue, Mar 8, 2011 at 11:35 PM, Geoffrey Mina geoffreymina@gmail.comwrote:
Hello, I have a question about LCR which I have been unable to solve. I have 4 upstream carrier gateways owned by 2 carriers. Each carrier provides a primary and secondary gateway for load balancing purposes. On a 5XX error I am trying to send the same call to the other carrier. If both carriers reject the call with 5XX, I allow the response to go downstream to my asterisk server. The issue I am running into is that in a scenario where both my carriers respond with a 5XX, I end up presenting the same call to all 4 gateways. I would like to present the call to one gateway on each carrier and not try the same carriers second gateway for the same call. Here is what is happening now:
ASTERISK --> INVITE --> KAMAILIO INVITE --> CARRIER A/GATEWAY 1 <-- 5XX Error INVITE --> CARRIER A/GATEWAY 2 <-- 5XX Error INVITE --> CARRIER B/GATEWAY 1 <-- 5XX Error INVITE --> CARRIER B/GATEWAY 2 <-- 5XX Error KAMAILIO --> 5XX Error --> ASTERISK
OR any combination of the above... i.e.
ASTERISK --> INVITE --> KAMAILIO INVITE --> CARRIER A/GATEWAY 1 <-- 5XX Error INVITE --> CARRIER B/GATEWAY 2 <-- 5XX Error INVITE --> CARRIER B/GATEWAY 1 <-- 5XX Error INVITE --> CARRIER A/GATEWAY 2 <-- 5XX Error KAMAILIO --> 5XX Error --> ASTERISK
What I want to happen is:
ASTERISK --> INVITE --> KAMAILIO INVITE --> CARRIER A/GATEWAY 1 or 2 <-- 5XX Error INVITE --> CARRIER B/GATEWAY 1 or 2 <-- 5XX Error KAMAILIO --> 5XX Error --> ASTERISK
I tried dealing with the issue using some flags on the gateway, but i couldn't get the logic to work properly. Here is the path I was heading down, but my plan fell apart after some testing.
CARRIER A has a gateway flag of "1" CARRIER B has a gateway flag of "2"
failure_route[1]{ $var(gw_flag) = $avp(i:712);
while(next_gw()){ if($var(gw_flag) != $avp(i:712)){ xlog("L_INFO","Found an LCR destination which is different
than current, routing. ($ci)"); t_on_reply("1"); t_on_failure("1"); t_relay(); exit; }else{ xlog("L_INFO","The next destination in LCR has the same AVP flag, skipping. ($ci)"); } }
# let the reply go upstram - it is the default action xlog("L_ERR", "No Next Gateway - M=$rm RURI=$ru F=$fu T=$tu IP=$si
ID=$ci\n"); exit; }
Any help would be greatly appreciated.
Thanks, Geoff
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Daniel-Constantin Mierla writes:
The issue I am running into is that in a scenario where both my carriers respond with a 5XX, I end up presenting the same call to all 4 gateways. I would like to present the call to one gateway on each carrier and not try the same carriers second gateway for the same call.
currently only lcr rule can be a stopper rule, i.e., if it matches, other matching rules are not tried.
you can disable a failing gateway for some number of seconds, which should reduce unsuccessful attempts.
-- juha
There is nothing wrong with the carriers, so I wouldn't want to mark them. Just no route to destination type scenario.
I like daniels option with the drop on_branch. Only challenge I have is keeping a list of all the flags I have already tried. Say I have five carrier groups and I set the flags in gw to 1 2 3 4 or 5 respectivley. How could I use an AVP to efficiently keep a running list and then check against that list?
Thanks! On Mar 8, 2011 9:02 PM, "Juha Heinanen" jh@tutpro.com wrote:
Daniel-Constantin Mierla writes:
The issue I am running into is that in a scenario where both my carriers respond with a 5XX, I end up presenting the same call
to
all 4 gateways. I would like to present the call to one gateway on each carrier and not try the same carriers second gateway for the same call.
currently only lcr rule can be a stopper rule, i.e., if it matches, other matching rules are not tried.
you can disable a failing gateway for some number of seconds, which should reduce unsuccessful attempts.
-- juha
Hello,
AVPs are multi-value variables, so:
$avp(x) = 1; $avp(x) = 2;
Create a list with two values, the last added is first retrieved. You can use indexes to access them.
For example: - $avp(x) will return now 2 (same as $(avp(x)[0]) ) - $(avp(x)[1]) will return 1
You can use variable as index:
$var(i) = 0;
then: $(avp(x)[$var(i)]))
To go through the list, you can use while(...) { ... } statement with an variable for index that increments in each step.
When there is no value for avp at that index, then the returned value is $null, e.g.,
while($(avp(x)[$var(i)]) != $null) { ... $var(i) = $var(i) + 1; }
Cheers, Daniel
On Wed, Mar 9, 2011 at 2:07 PM, Geoffrey Mina geoffreymina@gmail.comwrote:
There is nothing wrong with the carriers, so I wouldn't want to mark them. Just no route to destination type scenario.
I like daniels option with the drop on_branch. Only challenge I have is keeping a list of all the flags I have already tried. Say I have five carrier groups and I set the flags in gw to 1 2 3 4 or 5 respectivley. How could I use an AVP to efficiently keep a running list and then check against that list?
Thanks! On Mar 8, 2011 9:02 PM, "Juha Heinanen" jh@tutpro.com wrote:
Daniel-Constantin Mierla writes:
The issue I am running into is that in a scenario where both my carriers respond with a 5XX, I end up presenting the same call
to
all 4 gateways. I would like to present the call to one gateway on
each
carrier and not try the same carriers second gateway for the same call.
currently only lcr rule can be a stopper rule, i.e., if it matches, other matching rules are not tried.
you can disable a failing gateway for some number of seconds, which should reduce unsuccessful attempts.
-- juha
Aha, so using an AVP as loop counter (I need the counter for the whole transcation lifetime) like:
$avp(count) = $avp(count) + 1;
would work (it does), but creates a new array element every calculation?
I guess the workaround to not create an array is to use always an index, at least on the left side, eg:
$(avp(count)[0]) = $avp(count) + 1;
btw: Is there a function to dump all currently defined AVPs, XAVPs and variables?
regards Klaus
Am 10.03.2011 09:49, schrieb Daniel-Constantin Mierla:
Hello,
AVPs are multi-value variables, so:
$avp(x) = 1; $avp(x) = 2;
Create a list with two values, the last added is first retrieved. You can use indexes to access them.
For example:
- $avp(x) will return now 2 (same as $(avp(x)[0]) )
- $(avp(x)[1]) will return 1
You can use variable as index:
$var(i) = 0;
then: $(avp(x)[$var(i)]))
To go through the list, you can use while(...) { ... } statement with an variable for index that increments in each step.
When there is no value for avp at that index, then the returned value is $null, e.g.,
while($(avp(x)[$var(i)]) != $null) { ... $var(i) = $var(i) + 1; }
Cheers, Daniel
On Wed, Mar 9, 2011 at 2:07 PM, Geoffrey Mina <geoffreymina@gmail.com mailto:geoffreymina@gmail.com> wrote:
There is nothing wrong with the carriers, so I wouldn't want to mark them. Just no route to destination type scenario. I like daniels option with the drop on_branch. Only challenge I have is keeping a list of all the flags I have already tried. Say I have five carrier groups and I set the flags in gw to 1 2 3 4 or 5 respectivley. How could I use an AVP to efficiently keep a running list and then check against that list? Thanks! On Mar 8, 2011 9:02 PM, "Juha Heinanen" <jh@tutpro.com <mailto:jh@tutpro.com>> wrote: > Daniel-Constantin Mierla writes: > >> > The issue I am running into is that in a scenario where >> > both my carriers respond with a 5XX, I end up presenting the same call to >> > all 4 gateways. I would like to present the call to one gateway on each >> > carrier and not try the same carriers second gateway for the same >> > call. > > currently only lcr rule can be a stopper rule, i.e., if it matches, > other matching rules are not tried. > > you can disable a failing gateway for some number of seconds, which > should reduce unsuccessful attempts. > > -- juha
-- Daniel-Constantin Mierla http://www.asipto.com
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Hello,
On Thu, Mar 10, 2011 at 10:33 AM, Klaus Darilion < klaus.mailinglists@pernau.at> wrote:
Aha, so using an AVP as loop counter (I need the counter for the whole transcation lifetime) like:
$avp(count) = $avp(count) + 1;
would work (it does), but creates a new array element every calculation?
yes.
I guess the workaround to not create an array is to use always an index, at least on the left side, eg:
$(avp(count)[0]) = $avp(count) + 1;
The right would be: $(avp(count)[*]) = $avp(count) + 1;
btw: Is there a function to dump all currently defined AVPs, XAVPs and variables?
For avps:
http://kamailio.org/docs/modules/stable/modules/avpops.html#id2867544
Not sure now the one for xavps was exported to config, but it is available internally.
Cheers, Daniel
regards Klaus
Am 10.03.2011 09:49, schrieb Daniel-Constantin Mierla:
Hello,
AVPs are multi-value variables, so:
$avp(x) = 1; $avp(x) = 2;
Create a list with two values, the last added is first retrieved. You can use indexes to access them.
For example:
- $avp(x) will return now 2 (same as $(avp(x)[0]) )
- $(avp(x)[1]) will return 1
You can use variable as index:
$var(i) = 0;
then: $(avp(x)[$var(i)]))
To go through the list, you can use while(...) { ... } statement with an variable for index that increments in each step.
When there is no value for avp at that index, then the returned value is $null, e.g.,
while($(avp(x)[$var(i)]) != $null) { ... $var(i) = $var(i) + 1; }
Cheers, Daniel
On Wed, Mar 9, 2011 at 2:07 PM, Geoffrey Mina <geoffreymina@gmail.com mailto:geoffreymina@gmail.com> wrote:
There is nothing wrong with the carriers, so I wouldn't want to mark them. Just no route to destination type scenario. I like daniels option with the drop on_branch. Only challenge I have is keeping a list of all the flags I have already tried. Say I have five carrier groups and I set the flags in gw to 1 2 3 4 or 5 respectivley. How could I use an AVP to efficiently keep a running list and then check against that list? Thanks! On Mar 8, 2011 9:02 PM, "Juha Heinanen" <jh@tutpro.com <mailto:jh@tutpro.com>> wrote: > Daniel-Constantin Mierla writes: > >> > The issue I am running into is that in a scenario where >> > both my carriers respond with a 5XX, I end up presenting the same call to >> > all 4 gateways. I would like to present the call to one gateway on each >> > carrier and not try the same carriers second gateway for the
same
>> > call. > > currently only lcr rule can be a stopper rule, i.e., if it matches, > other matching rules are not tried. > > you can disable a failing gateway for some number of seconds, which > should reduce unsuccessful attempts. > > -- juha
-- Daniel-Constantin Mierla http://www.asipto.com
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users