I have the following basic script:
request_route{
record_route();
$var(enumres) = enum_query();
switch( $var(enumres) ) {
case -1:
xlog("enum_query lookup failure - To URI $tU");
sl_reply("503", "Temporary lookup failure");
return(0);
case 1:
break; # uri replaced
}
xlog("INVITE ENUM query - To URI $tU");
t_relay();
I have the following ENUM records for a test setup:
;; ANSWER SECTION:
x.x.x.1.5.1.8.3.0.3.1.e164.arpa. 60 IN NAPTR 100 10 "U" "E2U+sip" "!^.*$!sip:+13038151xxx@10.20.20.198!" .
x.x.x.1.5.1.8.3.0.3.1.e164.arpa. 60 IN NAPTR 110 10 "U" "E2U+sip" "!^.*$!sip:+13038151xxx@10.20.20.75!" .
What happens is the following:
tcpdump: listening on ens3, link-type EN10MB (Ethernet), capture size 262144 bytes
17:57:19.961041 IP (tos 0x10, ttl 64, id 59648, offset 0, flags [none], proto UDP (17), length 1481)
10.20.20.40.5060 > 10.20.20.198.5060: SIP, length: 1453
INVITE sip:+13038151xxx@10.20.20.198 SIP/2.0
…
17:57:19.961058 IP (tos 0x10, ttl 64, id 24143, offset 0, flags [none], proto UDP (17), length 1480)
10.20.20.40.5060 > 10.20.20.75.5060: SIP, length: 1452
INVITE sip:+13038151xxx@10.20.20.75 SIP/2.0
…
These basically go out at the same time.
Eventually I get a ICMP Port Unreachable on the .198 one because that’s a dummy I just set up for testing.
My question is, with this kind of setup, is there a way to tell Kamailio to respect the NAPTR order value (note, 100, 110 above) and only try the 2nd route if the first fails?
Thanks,
Jawaid
Hi,
The documentation for the `enum` module says:
"Finally, enum_query associates a q value with each new URI based on the <order, preference> of the corresponding NAPTR record."
Then just read this whole section of the TM module docs. :-)
https://kamailio.org/docs/modules/5.6.x/modules/tm.html#tm.serial_forking
What you're after is serialising what is by default parallelised. I believe this should help you take control of that process.
-- Alex
Hi Alex,
That is working, however, on subsequent messages in the dialog (e.g., ACK, INFO, BYE) the proxy tries the failed destination for each message. Eventually it gets to the right place, but, is there a way to delete the failed destination from the XAVP so this doesn't happen? Or just to force subsequent messages in the transaction to use the same (working) destination?
Sorry for all the questions, I'm a newbie!
Thanks in advance,
Jawaid
--
On 12/13/22, 1:27 PM, "sr-users on behalf of Alex Balashov" <sr-users-bounces@lists.kamailio.org on behalf of abalashov@evaristesys.com> wrote:
Hi,
The documentation for the `enum` module says:
"Finally, enum_query associates a q value with each new URI based on the <order, preference> of the corresponding NAPTR record."
Then just read this whole section of the TM module docs. :-)
https://kamailio.org/docs/modules/5.6.x/modules/tm.html#tm.serial_forking
What you're after is serialising what is by default parallelised. I believe this should help you take control of that process.
-- Alex
-- Alex Balashov | Principal | Evariste Systems LLC
Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
__________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions sr-users@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
On Dec 13, 2022, at 10:09 PM, Jawaid Bazyar bazyar@gmail.com wrote:
That is working, however, on subsequent messages in the dialog (e.g., ACK, INFO, BYE) the proxy tries the failed destination for each message. Eventually it gets to the right place, but, is there a way to delete the failed destination from the XAVP so this doesn't happen? Or just to force subsequent messages in the transaction to use the same (working) destination?
Sorry for all the questions, I'm a newbie!
Not at all!
Forcing subsequent in-dialog messages to go to the same destination is inherent to correct proxy behaviour; it just requires some additional logic that is part of typical Kamailio boilerplate. (You can only get away with having a 'minimalistic' config for so long. :)
Check this out:
https://github.com/kamailio/kamailio/blob/master/etc/kamailio.cfg#L658-L698
You'll want to put that near the top of your config, well before you handle any initial INVITEs.
A simplified version that will work for your purposes:
if(has_totag()) { if(loose_route()) { if(!t_relay()) sl_reply_error();
exit; } else if(is_method("ACK")) { if(t_check_trans()) { if(!t_relay()) sl_reply_error();
exit; }
exit; }
sl_send_reply("404", "Not here"); }
-- Alex
Alex, that did it! Now to understand it 😊
Thanks again,
Jawaid
From: Alex Balashov abalashov@evaristesys.com Reply-To: "Kamailio (SER) - Users Mailing List" sr-users@lists.kamailio.org Date: Wednesday, December 14, 2022 at 2:56 PM To: "Kamailio (SER) - Users Mailing List" sr-users@lists.kamailio.org Subject: [SR-Users] Re: Failover - how does it work?
On Dec 13, 2022, at 10:09 PM, Jawaid Bazyar bazyar@gmail.com wrote:
That is working, however, on subsequent messages in the dialog (e.g., ACK, INFO, BYE) the proxy tries the failed destination for each message. Eventually it gets to the right place, but, is there a way to delete the failed destination from the XAVP so this doesn't happen? Or just to force subsequent messages in the transaction to use the same (working) destination?
Sorry for all the questions, I'm a newbie!
Not at all!
Forcing subsequent in-dialog messages to go to the same destination is inherent to correct proxy behaviour; it just requires some additional logic that is part of typical Kamailio boilerplate. (You can only get away with having a 'minimalistic' config for so long. :)
Check this out:
https://github.com/kamailio/kamailio/blob/master/etc/kamailio.cfg#L658-L698
You'll want to put that near the top of your config, well before you handle any initial INVITEs.
A simplified version that will work for your purposes:
if(has_totag()) {
if(loose_route()) {
if(!t_relay())
sl_reply_error();
exit;
} else if(is_method("ACK")) {
if(t_check_trans()) {
if(!t_relay())
sl_reply_error();
exit;
}
exit;
}
sl_send_reply("404", "Not here");
}
-- Alex
"Loose routing" of in-dialog requests is a complex, byzantine topic in SIP proxy science. :-)
The highlights:
1. Requests which are scoped inside a "call" occur within a dialog -- e.g. end-to-end ACK, INFO, BYE, etc.
This is to distinguish them from "initial" requests, which are subject to an original routing decision. In contrast, in-dialog requests follow an essentially predetermined (see #6) "route set".
The most salient characteristic of an in-dialog request is a ';tag=xxxxx' parameter in the 'To' header. A tag will always be present in the 'From' header, but is only present in the 'To' header on in-dialog requests;
2. In-dialog requests are, by default, directed to a Request URI that is equal to the Contact URI of the other party. This implies that they would normally flow around the proxy;
3. The Record-Route header added by the proxy to the initial INVITE changes that. It says, "No, you need to shunt your in-dialog requests through me." The Record-Route header is copied into the 200 OK that is sent back to the calling party, so that it knows about the shunt, too.
4. There can be multiple Record-Route headers if multiple proxies are in the path;
5. In the construction of an in-dialog request, the Record-Route headers are turned into a stack of Route headers; these then traverse intermediate proxies, with each proxy stripping off Route headers that refer to itself ("hey, that's me!"), and forwarding the request to the next hop based on the next available Route header.
Vitally, the Request URI is kept the same, and continues to match the remote Contact URI; the Route hops only have the effect of changing the destination on a practical (that is, network and transport) level;
6. The Contact URI at which a dialog party is targeted, known as the "remote target", can be changed in a re-INVITE or UPDATE, which are known as "target refresh" requests. These requests are better known for changing media parameters, but this is another thing they can do, though it is seldom done;
In essence, loose_route() implements the logic behind #5.
The other parts of this whole stanza concern the relationship between ACKs and transactions. The function t_check_trans() has very different behaviour that is highly contextually sensitive, depending on what is being checked, and does more than its name might imply:
https://kamailio.org/docs/modules/5.6.x/modules/tm.html#tm.f.t_check_trans
-- Alex
On Dec 14, 2022, at 6:19 PM, Jawaid Bazyar bazyar@gmail.com wrote:
Alex, that did it! Now to understand it 😊 Thanks again, Jawaid From: Alex Balashov abalashov@evaristesys.com Reply-To: "Kamailio (SER) - Users Mailing List" sr-users@lists.kamailio.org Date: Wednesday, December 14, 2022 at 2:56 PM To: "Kamailio (SER) - Users Mailing List" sr-users@lists.kamailio.org Subject: [SR-Users] Re: Failover - how does it work?
On Dec 13, 2022, at 10:09 PM, Jawaid Bazyar bazyar@gmail.com wrote:
That is working, however, on subsequent messages in the dialog (e.g., ACK, INFO, BYE) the proxy tries the failed destination for each message. Eventually it gets to the right place, but, is there a way to delete the failed destination from the XAVP so this doesn't happen? Or just to force subsequent messages in the transaction to use the same (working) destination?
Sorry for all the questions, I'm a newbie!
Not at all! Forcing subsequent in-dialog messages to go to the same destination is inherent to correct proxy behaviour; it just requires some additional logic that is part of typical Kamailio boilerplate. (You can only get away with having a 'minimalistic' config for so long. :) Check this out: https://github.com/kamailio/kamailio/blob/master/etc/kamailio.cfg#L658-L698 You'll want to put that near the top of your config, well before you handle any initial INVITEs. A simplified version that will work for your purposes: if(has_totag()) { if(loose_route()) { if(!t_relay()) sl_reply_error(); exit; } else if(is_method("ACK")) { if(t_check_trans()) { if(!t_relay()) sl_reply_error(); exit; } exit; } sl_send_reply("404", "Not here"); } -- Alex -- Alex Balashov | Principal | Evariste Systems LLC
Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
__________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: