<div dir="ltr"><div>Thank you both for the attention and the feedbacks</div><div><br></div><div>Point clarified, it should be a new algorithms, something like :<br><div><br></div><div>   “13” - <span lang="EN-GB">location optimized routing mode, the lowest latency gets higher priority</span> (serial forking ordered by priority,  ds_ping_latency_stats is required).</div><div><br></div><div><span lang="EN-GB">The main drawback it that there is not load balancing, I would like to address this now, by making it configurable, an option to activate <span lang="EN-GB">location optimized with load balancing</span><span lang="EN-GB"> routing mode.</span></span></div><div><span lang="EN-GB"><br></span></div><div><span lang="EN-GB">I would like to find a clear and simple way to do<span lang="EN-GB"> this, that should be easy to document and understand.<br></span></span></div><div><span lang="EN-GB"><br></span></div><div><span lang="EN-GB">For example in a scenario like that, it would be best that gateways with similar latency would get traffic load balanced to them, the priority could be overloaded to represent the threshold :<br></span></div><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"></span></span></span></span><br><span lang="EN-GB"></span><span lang="EN-GB"><span lang="EN-GB"></span></span><br><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"></span></span></span></span><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"></span></span></span><div><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><br></span></span></span></span></div><div><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><br></span></span></span></span></div><div><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB">I found this simple formula : <i>ADJUSTED_PRIORITY = PRIORITY - (ROUNDDOWN(ESTIMATED_LATENCY/PRIORITY))</i></span></span></span></span></div><div><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB">Priority is also the threshold for latency priority adjustment, not sure if overloading it is creating confusion, in this example gateway 1, 4 and 6 would receive 33%/33%/33%, the other gateways would be only there for failover<br></span></span></span></span></div><div><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><br></span></span></span></span></div><div><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><br></span></span></span></span></div><div><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB">



        
        
        <span></span>
        
        
        



</span></span></span></span><table style="font-family:"Liberation Sans";font-size:x-small" cellspacing="0" border="0">
        <colgroup width="85" span="2"></colgroup>
        <colgroup width="157"></colgroup>
        <colgroup width="154"></colgroup>
        <tbody style="font-family:"Liberation Sans";font-size:x-small"><tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center">GATEWAY</td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">PRIORITY</font></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">ESTIMATED_LATENCY</font></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">ADJUSTED_PRIORITY</font></td>
        </tr>
        <tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center">1</td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">30</font></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">21</font></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">30</font></td>
        </tr>
        <tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center">2</td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">30</font></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">91</font></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">27</font></td>
        </tr>
        <tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center">3</td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">30</font></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">61</font></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">28</font></td>
        </tr>
        <tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center">4</td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">30</font></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">19</font></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">30</font></td>
        </tr>
        <tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center">5</td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">30</font></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center">32</td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">29</font></td>
        </tr>
        <tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center">6</td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">30</font></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center">0</td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">30</font></td>
        </tr>
        <tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center">7</td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">30</font></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center">201</td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><font color="#000000">24</font></td>
        </tr>
</tbody></table>



</div><div><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"></span></span></span></span></div><div><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB"><span lang="EN-GB">



        
        
        <span></span>
        
        
        



</span></span></span></span><table style="font-family:"Liberation Sans";font-size:x-small" cellspacing="0" border="0">
        <colgroup width="85"></colgroup>
        <colgroup width="157"></colgroup>
        <colgroup width="154"></colgroup>
        <tbody style="font-family:"Liberation Sans";font-size:x-small"><tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td>
        </tr>
        <tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td>
        </tr>
        <tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"></td></tr><tr style="font-family:"Liberation Sans";font-size:x-small"><td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center"></td><td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td><td style="font-family:"Liberation Sans";font-size:x-small" align="center"></td>
        </tr>
        <tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td>
        </tr>
        <tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td>
        </tr>
        <tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td>
        </tr>
        <tr style="font-family:"Liberation Sans";font-size:x-small">
                <td style="font-family:"Liberation Sans";font-size:x-small" height="17" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td>
                <td style="font-family:"Liberation Sans";font-size:x-small" align="center"><br></td></tr></tbody></table></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 28, 2020 at 9:08 AM Daniel-Constantin Mierla <<a href="mailto:miconda@gmail.com">miconda@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>
    <p>Hello,</p>
    <p>maybe a dedicated module is going to be too complex or better
      said, duplicate a lot of code for management of the destinations,
      load/reload/keepalive, ... (although I won't have anything against
      such approach, if considered better by developer).</p>
    <p>However, if done in dispatcher, I think that a new algorithm id
      should be used, leaving 8 as it is. Also, there should be a new
      field added in the internal structure to keep this "dynamic"
      priority -- it can be initialized to the "priority" value.</p>
    <p>In some cases I use different algorithms for the same group of
      destinations, so it would be good to be able to use algorithm 8
      with priority from database and the new algorithm at the same
      time.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div>On 27.05.20 21:46, Henning Westerholt
      wrote:<br>
    </div>
    <blockquote type="cite">
      
      
      
      <div>
        <p class="MsoNormal"><span>Hi
            Julien,<u></u><u></u></span></p>
        <p class="MsoNormal"><span><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">sounds interesting, a “location optimized
            routing mode”. What about making it as a dedicated mode, to
            not overloading the mode “8”?<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Cheers,<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Henning<u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">-- <u></u>
            <u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Henning Westerholt –
          </span><span><a href="https://skalatan.de/blog/" target="_blank"><span style="color:rgb(5,99,193)" lang="EN-GB">https://skalatan.de/blog/</span></a></span><span lang="EN-GB"><u></u><u></u></span></p>
        <p class="MsoNormal"><span lang="EN-GB">Kamailio services –
          </span><span><a href="https://gilawa.com/" target="_blank"><span style="color:rgb(5,99,193)" lang="EN-GB">https://gilawa.com</span></a></span><span>
            <span lang="EN-GB"><u></u><u></u></span></span></p>
        <p class="MsoNormal"><span lang="EN-GB"><u></u> <u></u></span></p>
        <div style="border-color:rgb(225,225,225) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0cm 0cm">
          <p class="MsoNormal" style="margin-left:35.4pt"><b>From:</b>
            sr-dev <a href="mailto:sr-dev-bounces@lists.kamailio.org" target="_blank"><sr-dev-bounces@lists.kamailio.org></a>
            <b>On Behalf Of </b>Julien Chavanton<br>
            <b>Sent:</b> Thursday, May 14, 2020 7:26 PM<br>
            <b>To:</b> Kamailio (SER) - Development Mailing List
            <a href="mailto:sr-dev@lists.kamailio.org" target="_blank"><sr-dev@lists.kamailio.org></a>; Kamailio (SER) - Users
            Mailing List <a href="mailto:sr-users@lists.kamailio.org" target="_blank"><sr-users@lists.kamailio.org></a><br>
            <b>Subject:</b> [sr-dev] congestion control priority for
            priority based dispatching<u></u><u></u></p>
        </div>
        <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
        <div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">Hi Folks,<u></u><u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-right:0cm;margin-bottom:12pt;margin-left:35.4pt"><br>
              Just found another simple use case of the dispatcher
              latency stats.<u></u><u></u></p>
          </div>
          <p class="MsoNormal" style="margin-left:35.4pt">Just shraing
            this idea of a feature I want to contribute.<u></u><u></u></p>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><br>
              When using dispatcher algorithm 8:<br>
              <br>
                 “8” - select destination sorted by priority attribute
              value (serial forking ordered by priority).<br>
              <br>
              If the gateway as the attribute, the priority becomes the
              estimated latency.<br>
              <br>
                 cc-priority<u></u><u></u></p>
            <div>
              <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
            </div>
            <div>
              <p class="MsoNormal" style="margin-left:35.4pt">- The
                dispatcher would automatically prioritize the closest
                one.<u></u><u></u></p>
            </div>
            <div>
              <p class="MsoNormal" style="margin-left:35.4pt">- If a
                gateway is becoming unresponsive it will automatically
                become de prioritize.<u></u><u></u></p>
            </div>
            <p class="MsoNormal" style="margin-left:35.4pt"><br>
              Consider this real life scenario where you have gateways
              in East and West Coast <u></u>
              <u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">Example <u></u><u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><br>
              URI: <a>sip:28.71.19.140</a>
                                                                       
                                                                       
                                                                       
                     
              <br>
              FLAGS: AP<br>
              PRIORITY: 10<br>
              ATTRS: {<br>
                      BODY: cc_priority=1<br>
              }<br>
              LATENCY: {<br>
                      AVG: 84.001000<br>
                      STD: 0.062000<br>
                      EST: 84.001000 (high == low priority)<br>
                      MAX: 93<br>
                      TIMEOUT: 0<br>
              URI: <a>sip:28.71.16.140</a><br>
              FLAGS: AP<br>
              PRIORITY: 10<u></u><u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">ATTRS: {<br>
                      BODY: cc_priority=1<br>
              }<u></u><u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">LATENCY: {<br>
                      AVG: 29.110000<br>
                      STD: 2.383000<br>
                      EST: 31.999000 (low == high priority)<br>
                      MAX: 1499<br>
                      TIMEOUT: 1<u></u><u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt">Another
              major improvement to all of this would be to gather stats
              on INVITE <> 100 to have a very accurate latency
              estimation even if the gateway does not support SIP
              OPTIONS pings<u></u><u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
          </div>
          <div>
            <p class="MsoNormal" style="margin-left:35.4pt"><u></u> <u></u></p>
          </div>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>_______________________________________________
Kamailio (SER) - Development Mailing List
<a href="mailto:sr-dev@lists.kamailio.org" target="_blank">sr-dev@lists.kamailio.org</a>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
    </blockquote>
    <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank">www.linkedin.com/in/miconda</a>
Funding: <a href="https://www.paypal.me/dcmierla" target="_blank">https://www.paypal.me/dcmierla</a></pre>
  </div>

_______________________________________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><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><br>
</blockquote></div>