<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    can you add a log message inside c code and send the output at
    startup?<br>
    <br>
    You have to edit modules/dispatcher/dispach.c<br>
    <br>
    Locate the function:<br>
    <br>
    int dp_init_weights(ds_set_t *dset)<br>
    <br>
    And update the next block:<br>
    <br>
    randomize:<br>
        srand(time(0));<br>
        for (j=0; j<100; j++)<br>
        {<br>
            k = j + (rand() % (100-j));<br>
            t = (int)dset->wlist[j];<br>
            dset->wlist[j] = dset->wlist[k];<br>
            dset->wlist[k] = (unsigned int)t;<br>
        }<br>
    <br>
    To become:<br>
    <br>
    randomize:<br>
        srand(time(0));<br>
        for (j=0; j<100; j++)<br>
        {<br>
            k = j + (rand() % (100-j));<br>
            t = (int)dset->wlist[j];<br>
            dset->wlist[j] = dset->wlist[k];<br>
            dset->wlist[k] = (unsigned int)t;<br>
            LM_INFO("weight distribution: wlist[%d]=%u and
    wlist[%d]=%u\n", j, dset->wlist[j], k, dset->wlist[k]);<br>
        }<br>
    <br>
    Recompile, reinstall and restart kamailio. You should get many log
    messages in the syslog starting with 'weight distribution:'. Send
    them here.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <div class="moz-cite-prefix">On 05/09/14 01:36, Alejandro Recarey
      wrote:<br>
    </div>
    <blockquote
cite="mid:CA+zbGr8a5RPWNMiEeycv_pFg_0PJ7GAxAOY27kJmyc2paANa7w@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi,<br>
        <br>
        I have a kamailio with the dispatcher module setup. I use:<br>
        <br>
            ds_select_dst("1", "9");<br>
        <br>
        to load balance between 3 gateways.<br>
        <br>
        My database looks like this:<br>
        <br>
        id  setid  destination  flags priority  attrs
        <div><br>
        </div>
        <div>5 1 <a class="moz-txt-link-freetext" href="sip:1.1.1.1">sip:1.1.1.1</a> 0 0 weight=10</div>
        <div>8 1 <a class="moz-txt-link-freetext" href="sip:1.1.1.2">sip:1.1.1.2</a> 0 0 weight=45</div>
        <div>9 1 <a class="moz-txt-link-freetext" href="sip:1.1.1.3">sip:1.1.1.3</a> 0 0 weight=45</div>
        <div><br>
        </div>
        <div>As I understand it, most of the calls should be split
          evenly between gateways 8 and 9, and some calls (around 10%)
          going to gateway 5.</div>
        <div><br>
        </div>
        <div>Well, gateway 8 gets 99% of the calls. I am using kamailio
          4.1 and I really cannot understand why this is happening.
          Running ds_list shows me that all gateays and weights are
          correctly parsed into kamailio.</div>
        <div><br>
        </div>
        <div>This is the result of my ds_list:<br>
          <br>
          SET:: 1<br>
          URI:: <a class="moz-txt-link-freetext" href="sip:1.1.1.1">sip:1.1.1.1</a> flags=AP priority=0 attrs=weight=10<br>
          URI:: <a class="moz-txt-link-freetext" href="sip:1.1.1.2">sip:1.1.1.2</a> flags=AP priority=0 attrs=weight=45<br>
          URI:: <a class="moz-txt-link-freetext" href="sip:1.1.1.3">sip:1.1.1.3</a> flags=AP priority=0 attrs=weight=45<br>
        </div>
        <div><br>
        </div>
        <div>I have tried changing the priority to 100, or to 1 in every
          gateway, and the result is still the same. I have tried adding
          ; after the weight parameter, the colon is gone in the ds_list
          once kamailio parses it.</div>
        <br>
        If, keeping the same database, I use ds_select_dst("1", "0") the
        calls are split evenly across all 3 gateways. This is great, but
        not what I want, but it at least proves that something is
        working.<br>
        <br>
        Is there anything else I can try?<br>
        <br>
        Thanks a lot for the help!<br>
        <br>
        Alex<br>
        <br>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Next Kamailio Advanced Trainings 2014 - <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
Sep 22-25, Berlin, Germany</pre>
  </body>
</html>