<div dir="ltr">Hi again Pyry, it would be great if you could cherry-pick the commit/patch and test it and add a comment in the MR.<br><div><div><br><a href="https://github.com/kamailio/kamailio/pull/3232">https://github.com/kamailio/kamailio/pull/3232</a></div><div><br></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 6, 2022 at 10:34 AM Julien Chavanton <<a href="mailto:jchavanton@gmail.com">jchavanton@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi Pyry, I just made some tests and found the misalignment, I am preparing a patch.<br><br><div>I made some tests with 3 and 6 gateways, disabling one and then two, I found how the indexes could get mixed up between the call to<br></div><div>ds_sorted_by_priority() and ds_manage_routes_fill_reordered_xavp().<br><br></div><div>Hopefully you can help with testing once I have the MR ready, shortly.<br></div><div><br></div><div><br></div><div>Some test data :<br></div><div><br></div><div>INSERT INTO dispatcher VALUES(1,1,'sip:<a href="http://192.168.0.1:5060" target="_blank">192.168.0.1:5060</a>',0,12,'','');<br>INSERT INTO dispatcher VALUES(2,1,'sip:<a href="http://192.168.0.2:5060" target="_blank">192.168.0.2:5060</a>',0,12,'','');<br>INSERT INTO dispatcher VALUES(3,1,'sip:<a href="http://192.168.0.3:5060" target="_blank">192.168.0.3:5060</a>',0,12,'','');<br>INSERT INTO dispatcher VALUES(4,1,'sip:<a href="http://192.168.0.4:5060" target="_blank">192.168.0.4:5060</a>',0,12,'','');<br>INSERT INTO dispatcher VALUES(5,1,'sip:<a href="http://192.168.0.5:5060" target="_blank">192.168.0.5:5060</a>',0,12,'','');<br>INSERT INTO dispatcher VALUES(6,1,'sip:<a href="http://192.168.0.6:5060" target="_blank">192.168.0.6:5060</a>',0,12,'','');<br></div><div><br></div><div>Then disabling 2 gateways :<br></div><div><br>dispatcher.set_state i 1 sip:<a href="http://192.168.0.1:5060" target="_blank">192.168.0.1:5060</a><br>dispatcher.set_state i 1 sip:<a href="http://192.168.0.3:5060" target="_blank">192.168.0.3:5060</a><br><br></div><div><br></div><span style="font-family:monospace">// ----------------- Routing Logic -----------------<br>//<br>route {<br>        xinfo("[MAIN][$rm][$ci]from[$fU]to[$tU]ruri[$ru]Rp[$Rp]Ri[$Ri]\n");<br>        if (!ds_select_dst("1","13", "-1")) {<br>                xinfo("[MAIN] no gateway available !\n");<br>        }                                                                                                                                                                                      <br>        while (defined $xavp(_dsdst_)) {<br>                xinfo("[MAIN] URI : $xavp(_dsdst_=>uri) \n");<br>                pv_unset("$xavp(_dsdst_)");<br>        }<br>        return;<br>}<br><br></span></div><span style="font-family:monospace">// Logs showing the gateways returned.<br></span><div><span style="font-family:monospace"><br> 0(398491) DEBUG: dispatcher [dispatch.c:2263]: ds_manage_route_algo13(): [active][0]idx[1]uri[sip:192.168.0.5:5060]priority[12-0=12]latency[0ms]flag[0]<br> 0(398491) DEBUG: dispatcher [dispatch.c:2263]: ds_manage_route_algo13(): [active][1]idx[2]uri[sip:192.168.0.4:5060]priority[12-0=12]latency[0ms]flag[0]<br> 0(398491) DEBUG: dispatcher [dispatch.c:2270]: ds_manage_route_algo13(): [inactive][2]idx[-1]uri[sip:192.168.0.3:5060]priority[12]latency[0ms]flag[1]<br> 0(398491) DEBUG: dispatcher [dispatch.c:2263]: ds_manage_route_algo13(): [active][3]idx[4]uri[sip:192.168.0.2:5060]priority[12-0=12]latency[0ms]flag[0]<br> 0(398491) DEBUG: dispatcher [dispatch.c:2270]: ds_manage_route_algo13(): [inactive][4]idx[-1]uri[sip:192.168.0.1:5060]priority[12]latency[0ms]flag[1]<br> 0(398491) DEBUG: dispatcher [dispatch.c:2263]: ds_manage_route_algo13(): [active][5]idx[0]uri[sip:192.168.0.6:5060]priority[12-0=12]latency[0ms]flag[0]<br><br> 0(398491) DEBUG: dispatcher [dispatch.c:2128]: ds_manage_routes_fill_reordered_xavp(): [4|sip:192.168.0.3:5060|idx:-1]skipped 1 || 1<br> 0(398491) DEBUG: dispatcher [dispatch.c:2128]: ds_manage_routes_fill_reordered_xavp(): [5|sip:192.168.0.1:5060|idx:-1]skipped 1 || 1<br> 0(398491) DEBUG: dispatcher [dispatch.c:2300]: ds_manage_route_algo13(): priority[12]gateway_selected[1]next_index[2]<br> 0(398491) DEBUG: dispatcher [dispatch.c:2465]: ds_manage_routes(): using alg [13] hash [1]<br> 0(398491) DEBUG: dispatcher [dispatch.c:2512]: ds_manage_routes(): selected [13-1-0/1] <sip:<a href="http://192.168.0.5:5060" target="_blank">192.168.0.5:5060</a>><br> 0(398491) DEBUG: dispatcher [dispatch.c:2107]: ds_select_dst_limit(): selected target destinations: 4<br> 0(398491) INFO: <script>: [MAIN][sip:<a href="http://192.168.0.5:5060" target="_blank">192.168.0.5:5060</a>]<br> 0(398491) INFO: <script>: [MAIN] URI : sip:<a href="http://192.168.0.5:5060" target="_blank">192.168.0.5:5060</a> <br> 0(398491) INFO: <script>: [MAIN] URI : sip:<a href="http://192.168.0.4:5060" target="_blank">192.168.0.4:5060</a> <br> 0(398491) INFO: <script>: [MAIN] URI : sip:<a href="http://192.168.0.2:5060" target="_blank">192.168.0.2:5060</a> <br> 0(398491) INFO: <script>: [MAIN] URI : sip:<a href="http://192.168.0.6:5060" target="_blank">192.168.0.6:5060</a> </span><br> </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 5, 2022 at 9:02 AM Julien Chavanton <<a href="mailto:jchavanton@gmail.com" target="_blank">jchavanton@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">Seems like you are on the right track, FYI I will have a look by the end of the day tomorrow.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 5, 2022, 6:06 AM Pyry Aaltonen <<a href="mailto:pyry.aaltonen@cuuma.com" target="_blank">pyry.aaltonen@cuuma.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="en-FI">
<div>
<p class="MsoNormal"><span style="font-size:11pt" lang="FI">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="FI"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">I´ve looked now closer the commit and overall the dispatch.c, and I think the problem is related to that problem which was fixed in that commit which I linked previously.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">(I looked the code from master in github)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">As a background I need to mention that its been over 10years since I´ve last read this much c-code so might be that I’m wrong
</span><span style="font-size:11pt;font-family:"Apple Color Emoji"" lang="EN-US">😊</span><span style="font-size:11pt" lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">But..<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">I cant quite tell you what the problem exactly is but to me it looks like there is something with the
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">ds_sorted list and its reordering, combined with the function call of the ds_add_xavp_record with ds_sorted[i].idx, in the function ds_manage_routes_fill_reodered_xavp.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">(btw it probably should be reoRdered instead of reodered)  <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">I think the loop there messes up the referencing order of destinations in a situation where the highest priority destination is inactive.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">And it seems like It is happening only when the original order of the set is changing (which was fixed in the commit I linked previously)
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">Because when for example set with 2 destination<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">Dest1 prio 10<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">Dest2 prio 0
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">Both active -> xavp -> has values<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">Dest2 inactive -> xavp -> has values<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">Dest1 inactive -> xavp -> null<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">So I guess somehow the same thing should need a fix in the ds_add_xavp_record or probably in the call for that in the ds_amange_routes_fille_reodered_xavp function.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">Does this make any sense to anyone else?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">-Pyry<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"><u></u> <u></u></span></p>
<div style="border-color:rgb(181,196,223) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">sr-users <<a href="mailto:sr-users-bounces@lists.kamailio.org" rel="noreferrer" target="_blank">sr-users-bounces@lists.kamailio.org</a>> on behalf of Pyry Aaltonen <<a href="mailto:pyry.aaltonen@cuuma.com" rel="noreferrer" target="_blank">pyry.aaltonen@cuuma.com</a>><br>
<b>Date: </b>Friday, 2. September 2022 at 7.56<br>
<b>To: </b>Kamailio (SER) - Users Mailing List <<a href="mailto:sr-users@lists.kamailio.org" rel="noreferrer" target="_blank">sr-users@lists.kamailio.org</a>><br>
<b>Subject: </b>Re: [SR-Users] Dispatcher module and xavp_dst<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11pt" lang="FI">Hi,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="FI"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">Thank you for your responses!
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">I don’t have latency stats enabled, but I do want to have load balance using round-robin by priorities, and that’s why I’m using algo13 instead algo 8, cause algo 8
 doesn’t round-robin if the priorities are the same, and still, I do want to have priorities and not only round-robin and that’s why I’m not using algo4 either.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">So algo13 should be fine and the dispatching works just like it is described in the documentation, only the xavp_dst values aren’t updated like it should (I think
</span><span style="font-size:11pt;font-family:"Apple Color Emoji"" lang="EN-US">😊</span><span style="font-size:11pt" lang="EN-US">)
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">Yesterday when I was searching around this issue of mine, I found out this quite recent commit <a href="https://github.com/kamailio/kamailio/commit/adba3caa2d12d1f8b89d720fbb9a6a9cdc8b2573" rel="noreferrer" target="_blank">https://github.com/kamailio/kamailio/commit/adba3caa2d12d1f8b89d720fbb9a6a9cdc8b2573</a></span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">The description of that commit looks quite same that what I’m now facing with only the xavp_dst values.
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">If the highest priority destination is inactive the destination is updated but the corresponding xavp_dst values are not correct(or missing completely).</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">With my previous destination examples
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">If first trunk is inactive, the destination is set correctly to second one, but the xavp_dst values are null, and I think xavp_dst values should be “type=2” or something
 like that.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">10 sip:</span><span style="font-size:11pt" lang="EN-US">1.2.3.4</span><span style="font-size:11pt">;transport=tcp 10 1 type=</span><span style="font-size:11pt" lang="EN-US">type1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">1</span><span style="font-size:11pt" lang="EN-US">0</span><span style="font-size:11pt"> sip:</span><span style="font-size:11pt" lang="EN-US">4.3.2.1</span><span style="font-size:11pt">;transport=tcp
 10 1 type=</span><span style="font-size:11pt" lang="EN-US">type2</span><span style="font-size:11pt" lang="EN-US">
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">-Pyry</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<div style="border-color:rgb(181,196,223) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0cm 0cm">
<p class="MsoNormal" style="margin-bottom:12pt"><b><span style="font-size:12pt;color:black">From:
</span></b><span style="font-size:12pt;color:black">sr-users <<a href="mailto:sr-users-bounces@lists.kamailio.org" rel="noreferrer" target="_blank">sr-users-bounces@lists.kamailio.org</a>> on behalf of Julien Chavanton <<a href="mailto:jchavanton@gmail.com" rel="noreferrer" target="_blank">jchavanton@gmail.com</a>><br>
<b>Date: </b>Thursday, 1. September 2022 at 16.33<br>
<b>To: </b>Kamailio (SER) - Users Mailing List <<a href="mailto:sr-users@lists.kamailio.org" rel="noreferrer" target="_blank">sr-users@lists.kamailio.org</a>><br>
<b>Subject: </b>Re: [SR-Users] Dispatcher module and xavp_dst</span><u></u><u></u></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:11pt">The rest of the dispatcher "features", like failover should be supported based on what I remember from the way it was integrated and tested.</span><u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:11pt">If it is not the case I can have a look.<br>
<br>
<br>
</span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">On Thu, Sep 1, 2022 at 9:21 AM Julien Chavanton <<a href="mailto:jchavanton@gmail.com" rel="noreferrer" target="_blank">jchavanton@gmail.com</a>> wrote:</span><u></u><u></u></p>
</div>
<blockquote style="border-color:currentcolor currentcolor currentcolor rgb(204,204,204);border-style:none none none solid;border-width:medium medium medium 1pt;padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:11pt">On second thought, the documentation looks accurate to me.</span><u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:11pt">Do you have the latency stats enabled ?</span><u></u><u></u></p>
<h3>3.26. <code><span style="font-size:10pt">ds_ping_latency_stats</span></code> (int)<u></u><u></u></h3>
<p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
<p class="MsoNormal"><span style="font-size:11pt">If yes, the priority values you are using seem a bit low 1ms and 10ms.</span><u></u><u></u></p>
</div>
<p class="MsoNormal"><span style="font-size:11pt">If not, the algorithm should behave simply like that :</span><u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:11pt">"The algorithm will load balance using round-robin prioritizing the gateways with the highest priority. "</span><u></u><u></u></p>
<div>
<div>
<div>
<h3> <u></u><u></u></h3>
</div>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">On Thu, Sep 1, 2022 at 9:09 AM Julien Chavanton <<a href="mailto:jchavanton@gmail.com" rel="noreferrer" target="_blank">jchavanton@gmail.com</a>> wrote:</span><u></u><u></u></p>
</div>
<blockquote style="border-color:currentcolor currentcolor currentcolor rgb(204,204,204);border-style:none none none solid;border-width:medium medium medium 1pt;padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:11pt">Maybe the documentation should be improved, it seems the first bullet point should say.<br>
<br>
"The algorithm will load balance using round-robin prioritizing the gateways with the highest
<b>adjusted</b> priority. "<br>
<br>
<br>
</span><u></u><u></u></p>
</div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">On Thu, Sep 1, 2022 at 9:06 AM Julien Chavanton <<a href="mailto:jchavanton@gmail.com" rel="noreferrer" target="_blank">jchavanton@gmail.com</a>> wrote:</span><u></u><u></u></p>
</div>
<blockquote style="border-color:currentcolor currentcolor currentcolor rgb(204,204,204);border-style:none none none solid;border-width:medium medium medium 1pt;padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Hi, did you look at the documentation of  algorithm 13 ?</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">The priority is used in combination with the latency to determine the preferred gateway.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Once you confirm that this is what you want "latency latency optimized dispatching", we can help to clarify why and how this may not work as expected.</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12pt"><span style="font-size:11pt"> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">Regards</span><u></u><u></u></p>
</div>
<p class="MsoNormal"><span style="font-size:11pt"><br>
<br>
<a href="https://kamailio.org/docs/modules/devel/modules/dispatcher.html" rel="noreferrer" target="_blank">https://kamailio.org/docs/modules/devel/modules/dispatcher.html</a></span><u></u><u></u></p>
<ul type="disc">
<li class="MsoNormal">
<span style="font-size:11pt">“13” - latency optimized dispatching <u></u><u></u></span></li></ul>
<p style="margin-left:36pt">- The algorithm will load balance using round-robin prioritizing the gateways with the highest priority.
<u></u><u></u></p>
<p style="margin-left:36pt">- If ds_ping_latency_stats is active the algorithm will adjust the priority of the gateway automatically, the priority will be lowered by 1 point every time the latency ms is as high as the priority.
<u></u><u></u></p>
<p style="margin-left:36pt">- If the attribute 'cc=1' is set, the latency used is congestion ms : estimate (current latency ms) - average (normal condition latency ms).
<u></u><u></u></p>
<div>
<p style="margin-left:36pt"><strong><span style="font-family:"Calibri",sans-serif">Example 1.46. </span></strong><code><b><span style="font-size:10pt">latency_optimized_dispatching</span></b></code><strong><span style="font-family:"Calibri",sans-serif">
 usage</span></strong> <u></u><u></u></p>
<div>
<pre style="margin-left:36pt">Using this simple formula :<u></u><u></u></pre>
<pre style="margin-left:36pt">    ADJUSTED_PRIORITY = PRIORITY - (ESTIMATED_LATENCY_MS/PRIORITY)<u></u><u></u></pre>
<pre style="margin-left:36pt"> <u></u><u></u></pre>
<pre style="margin-left:36pt">GATEWAY | PRIORITY | ESTIMATED | ADJUSTED | LOAD<u></u><u></u></pre>
<pre style="margin-left:36pt">   #    |          |  LATENCY  | PRIORITY | DISTRIBUTION<u></u><u></u></pre>
<pre style="margin-left:36pt">   1    |    30    |    21     |    30    | 33%<u></u><u></u></pre>
<pre style="margin-left:36pt">   2    |    30    |    91     |    27    | 0%<u></u><u></u></pre>
<pre style="margin-left:36pt">   3    |    30    |    61     |    28    | 0%<u></u><u></u></pre>
<pre style="margin-left:36pt">   4    |    30    |    19     |    30    | 33%<u></u><u></u></pre>
<pre style="margin-left:36pt">   5    |    30    |    32     |    29    | 0%<u></u><u></u></pre>
<pre style="margin-left:36pt">   6    |    30    |    0      |    30    | 33%<u></u><u></u></pre>
<pre style="margin-left:36pt">   7    |    30    |    201    |    24    | 0%<u></u><u></u></pre>
<pre style="margin-left:36pt"> <u></u><u></u></pre>
<pre style="margin-left:36pt"> <u></u><u></u></pre>
<pre style="margin-left:36pt">With congestion control the formula becomes :<u></u><u></u></pre>
<pre style="margin-left:36pt">    CONGESTION_MS = CURRENT_LATENCY_MS - NORMAL_CONDITION_LATENCY_MS<u></u><u></u></pre>
<pre style="margin-left:36pt">    ADJUSTED_PRIORITY = PRIORITY - (CONGESTION_MS/PRIORITY)<u></u><u></u></pre>
</div>
</div>
<p class="MsoNormal" style="margin-left:36pt">
<span style="font-size:11pt"> </span><u></u><u></u></p>
<ul type="disc">
<li class="MsoNormal">
<span style="font-size:11pt"> </span><u></u><u></u></li></ul>
</div>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt">On Thu, Sep 1, 2022 at 2:38 AM Pyry Aaltonen <<a href="mailto:pyry.aaltonen@cuuma.com" rel="noreferrer" target="_blank">pyry.aaltonen@cuuma.com</a>> wrote:</span><u></u><u></u></p>
</div>
<blockquote style="border-color:currentcolor currentcolor currentcolor rgb(204,204,204);border-style:none none none solid;border-width:medium medium medium 1pt;padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">Hello,
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">I’m quite new user with kamailio (heard first time about it a year ago and joined the list yesterday) and now wondering how the xavp_dst
 should work.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">I had read from the documentation that
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">”</span><span style="font-size:11pt">The first XAVP is the current selected destination.</span><span style="font-size:11pt" lang="EN-US">”</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">I use ds_select_dst with alg 13. And my kamailio version is kamailio 5.5.3 (x86_64/linux)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">So when my dispatcher list is like (I have also tried to differ the priority value like 10 and 1, but doesn’t make difference)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">10 sip:</span><span style="font-size:11pt" lang="EN-US">1.2.3.4</span><span style="font-size:11pt">;transport=tcp 10 1 type=</span><span style="font-size:11pt" lang="EN-US">type1</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt">1</span><span style="font-size:11pt" lang="EN-US">0</span><span style="font-size:11pt"> sip:</span><span style="font-size:11pt" lang="EN-US">4.3.2.1</span><span style="font-size:11pt">;transport=tcp
 10 1 type=</span><span style="font-size:11pt" lang="EN-US">type2</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">If one of the destinations fails (dx/ip), and it happens to be the one with higher priority or the one that just gets higher position
 in the dispatcher list if the prio Is equal.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">My xavp_</span><span style="font-size:11pt">$xavp(dsdst=>attrs)
</span><span style="font-size:11pt" lang="EN-US">get null value. And, if I try to seek
</span><span style="font-size:11pt">$(xavp(dsdst[</span><span style="font-size:11pt" lang="EN-US">0</span><span style="font-size:11pt">]=>attrs)
</span><span style="font-size:11pt" lang="EN-US">or </span><span style="font-size:11pt">$(xavp(dsdst[</span><span style="font-size:11pt" lang="EN-US">1</span><span style="font-size:11pt">]=>attrs)
</span><span style="font-size:11pt" lang="EN-US">I also got nothing. </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">If both destinations are up with equal priority, it selects them with round-robin, and the xavp_</span><span style="font-size:11pt">$xavp(dsdst=>attrs)
</span><span style="font-size:11pt" lang="EN-US">has the type value of the selected destination as expected, also the
</span><span style="font-size:11pt">$(xavp(dsdst[</span><span style="font-size:11pt" lang="EN-US">0</span><span style="font-size:11pt">]=>attrs)
</span><span style="font-size:11pt" lang="EN-US">or </span><span style="font-size:11pt">$(xavp(dsdst[</span><span style="font-size:11pt" lang="EN-US">1</span><span style="font-size:11pt">]=>attrs)
</span><span style="font-size:11pt" lang="EN-US">contains the destinations so that the selected is 0 and the other is at position 1.
</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">The $du is updated as I expect so if one fails the other one is selected always, why the xavp_dst isn’t working same way, or am I missing
 something?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">If needed I’ll try to provide more information,</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">Thanks already in advance</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US">-Pyry</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11pt" lang="EN-US"> </span><u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><span style="font-size:11pt">__________________________________________________________<br>
Kamailio - Users Mailing List - Non Commercial Discussions<br>
  * <a href="mailto:sr-users@lists.kamailio.org" rel="noreferrer" target="_blank">sr-users@lists.kamailio.org</a><br>
Important: keep the mailing list in the recipients, do not reply only to the sender!<br>
Edit mailing list options or unsubscribe:<br>
  * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a></span><u></u><u></u></p>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
</div>

__________________________________________________________<br>
Kamailio - Users Mailing List - Non Commercial Discussions<br>
  * <a href="mailto:sr-users@lists.kamailio.org" rel="noreferrer" target="_blank">sr-users@lists.kamailio.org</a><br>
Important: keep the mailing list in the recipients, do not reply only to the sender!<br>
Edit mailing list options or unsubscribe:<br>
  * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>