[SR-Users] Dispatcher algorithm 9 ignores weight=xx attribute

Daniel-Constantin Mierla miconda at gmail.com
Fri Sep 5 10:34:59 CEST 2014


Hello,

can you add a log message inside c code and send the output at startup?

You have to edit modules/dispatcher/dispach.c

Locate the function:

int dp_init_weights(ds_set_t *dset)

And update the next block:

randomize:
     srand(time(0));
     for (j=0; j<100; j++)
     {
         k = j + (rand() % (100-j));
         t = (int)dset->wlist[j];
         dset->wlist[j] = dset->wlist[k];
         dset->wlist[k] = (unsigned int)t;
     }

To become:

randomize:
     srand(time(0));
     for (j=0; j<100; j++)
     {
         k = j + (rand() % (100-j));
         t = (int)dset->wlist[j];
         dset->wlist[j] = dset->wlist[k];
         dset->wlist[k] = (unsigned int)t;
         LM_INFO("weight distribution: wlist[%d]=%u and wlist[%d]=%u\n", 
j, dset->wlist[j], k, dset->wlist[k]);
     }

Recompile, reinstall and restart kamailio. You should get many log 
messages in the syslog starting with 'weight distribution:'. Send them here.

Cheers,
Daniel

On 05/09/14 01:36, Alejandro Recarey wrote:
> Hi,
>
> I have a kamailio with the dispatcher module setup. I use:
>
>     ds_select_dst("1", "9");
>
> to load balance between 3 gateways.
>
> My database looks like this:
>
> id  setid  destination  flags priority  attrs
>
> 5 1 sip:1.1.1.1 0 0 weight=10
> 8 1 sip:1.1.1.2 0 0 weight=45
> 9 1 sip:1.1.1.3 0 0 weight=45
>
> 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.
>
> 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.
>
> This is the result of my ds_list:
>
> SET:: 1
> URI:: sip:1.1.1.1 flags=AP priority=0 attrs=weight=10
> URI:: sip:1.1.1.2 flags=AP priority=0 attrs=weight=45
> URI:: sip:1.1.1.3 flags=AP priority=0 attrs=weight=45
>
> 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.
>
> 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.
>
> Is there anything else I can try?
>
> Thanks a lot for the help!
>
> Alex
>
>
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20140905/20495f9e/attachment.html>


More information about the sr-users mailing list