[OpenSIPS-Users] DRouting Feature Request

Bogdan-Andrei Iancu bogdan at opensips.org
Fri Jul 25 12:34:37 CEST 2014


Hi,

Also upload the logs (in debug 4) when doing the do_routing().

Regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com

On 25.07.2014 00:05, Kneeoh wrote:
> Thats b/c the gateways are carrier facing proxies on my network. I pass headers to them to tell them where to route. Its a pain in the rear to get them to authorize new IPs so I do it this way. Not so nonsensical. I don't know why you're getting a different result than me with respect to use_next_gw. I've shared the tables and config bits, it doesn't sound like you see any issue with that other than my rather unorthodox gateway setup, no? I'll add the xlogs you suggest and report back.
>
>
>
> On Thursday, July 24, 2014 1:32 PM, Bogdan-Andrei Iancu <bogdan at opensips.org> wrote:
> Hi,
>
> Tested with latest 1.11 and works (with the setup explained below):
>
> $ ./opensips -V
> version: opensips 1.11.2-notls (x86_64/linux)
> flags: STATS: On, USE_IPV6, USE_TCP, DISABLE_NAGLE, USE_MCAST, SHM_MEM,
> SHM_MMAP, PKG_MALLOC, F_MALLOC, FAST_LOCK-ADAPTIVE_WAIT
> ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16,
> MAX_URI_SIZE 1024, BUF_SIZE 65535
> poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
> git revision: 78a8c5f
> main.c compiled on 11:05:33 Jul 24 2014 with gcc 4.8
>
>
> Works both in terms of randomly selecting the first GW and as using only
> one GW (second GW from #cr1 is not used in use_next_gw).
>
> Funny as for all three carriers you use the same set of GW. And for the
> rule you have listed all three carriers...Is is a bit of a non-sense as
> all three carriers will be used , but only one random GW from each ->
> you will get a set of 3 GWs in any combination between GW1 and GW2 :D.
>
> Try to add in your script, just after the do_routing():
>       xlog("GW IDs are      : $(avp(dr_gw)[*]) \n");
>
> Also put:
>       modparam("drouting","gw_id_avp", "$avp(dr_gw)")
>
> And paste the out of that xlog.
>
> Regards,
>
> Bogdan-Andrei Iancu
> OpenSIPS Founder and Developer
> http://www.opensips-solutions.com
>
>
>
>
> On 24.07.2014 17:27, Kneeoh wrote:
>> I ran 15 - 20 tests and was always getting gw 1 with the same settings. After digging I found I some how got back on to 1.11.2 not sure if that's relevant. But I've rolled back to 1.11.1 with the same config and DB settings. Now almost every other test alternates the gateway which is good. However, it still rolls to the next carrier gateway on: use_next_gw instead of going to the next carrier which means that the drouting module is still returning both gateways per carrier even though I have the flags set to 3 which should sort on weight and return 1 if I'm not mistaken.
>>
>>
>> My tables:
>>
>> select * from dr_rules;
>> +--------+---------+--------+---------+----------+---------+-------------------+-------+---------------+
>> | ruleid | groupid | prefix | timerec | priority | routeid | gwlist            | attrs | description   |
>> +--------+---------+--------+---------+----------+---------+-------------------+-------+---------------+
>> |      3 | 500     | 1800   |         |      100 | NULL    | #1=50,#2=50,#3 |       | Toll Free     |
>>
>>
>> select * from dr_carriers;
>> +----+-----------+-----------+-------+-------+-------+---------------------+
>> | id | carrierid | gwlist    | flags | state | attrs | description         |
>> +----+-----------+-----------+-------+-------+-------+---------------------+
>> |  3 | 1 | 1=50,2=50 | 3 |     0 | 1 | Carrier 1 Toll Free  |
>> |  6 | 2 | 1=50,2=50 | 3 |     0 | 2 | Carrier 2 Toll Free |
>> |  9 | 3 | 1=50,2=50 | 3 |     0 | 3 | Carrier 3 Toll Free   |
>> +----+-----------+-----------+-------+-------+-------+---------------------+
>>
>>
>> select * from dr_gateways;
>> +----+------+------+----------------+-------+------------+-------+------------+-------+--------+-------------+
>> | id | gwid | type | address        | strip | pri_prefix | attrs | probe_mode | state | socket | description |
>> +----+------+------+----------------+-------+------------+-------+------------+-------+--------+-------------+
>> |  3 | 1    |    2 | 192.168.2.2 |     0 | NULL       | NULL  |          0 |     1 | NULL   | gw_01      |
>> |  6 | 2    |    2 | 192.168.2.3 |     0 | NULL       | NULL  |          0 |     1 | NULL   | gw_02      |
>> +----+------+------+----------------+-------+------------+-------+------------+-------+--------+-------------+
>>
>>
>> My script:
>>
>> route[sendcall] {
>> if (is_method("INVITE")) {
>>      t_on_branch("per_branch_ops");
>>      t_on_reply("handle_nat");
>>      t_on_failure("toll free")
>>
>>      xlog("L_INFO", "In Toll Free Routing Block \n");
>>      
>>     };
>>
>> do_routing("$avp(tf_group)","W",,,,"$avp(carrier_id)")
>>
>> ..etc
>> }
>>
>> failure_route[tf] {
>>
>> if (use_next_gw(,,"$avp(carrier_id)")) {
>>
>> xlog("L_INFO", "Next Gateway $ru - CarrierID: $avp(carrier_id)\n");
>>     t_on_branch("per_branch_ops");
>>     t_on_reply("handle_nat");
>>     t_on_failure("toll free")
>>     t_relay();
>>        exit;
>>          
>>      }
>>      else {
>>       xlog("L_INFO", "No more Carriers!\n");
>>       t_reply("503", "Service Unavailable");
>>       exit;
>>      };
>>
>> }
>>
>>
>> My Results:
>>
>> Using: CarrierID: 2
>> new branch at sip:18005551212 at 192.168.2.2
>>
>> In failure route toll free
>> Next Gateway sip:18005551212 at 192.168.2.3 - CarrierID: 2
>> new branch at sip:18005551212 at 192.168.2.3
>>
>>
>> In failure route toll free
>> Next Gateway sip:18005551212 at 192.168.2.3 - CarrierID: 1
>> new branch at sip:18005551212 at 192.168.2.3
>>
>> In failure route toll free
>> Next Gateway sip:18005551212 at 192.168.2.2- CarrierID: 1
>> new branch at sip:18005551212 at 192.168.2.2
>>
>>      
>>
>> On Thursday, July 24, 2014 5:24 AM, Bogdan-Andrei Iancu <bogdan at opensips.org> wrote:
>> Hi,
>>
>> Just tested the case , see below tables:
>>
>> mysql> select * from dr_gateways;
>> +----+-------+------+----------------+-------+------------+-------+------------+-------+--------+-------------+
>> | id | gwid  | type | address        | strip | pri_prefix | attrs |
>> probe_mode | state | socket | description |
>> +----+-------+------+----------------+-------+------------+-------+------------+-------+--------+-------------+
>> |  1 | one   |    0 | 127.0.0.1:5070 |     0 | NULL       | NULL
>> |          0 |     0 | NULL   |             |
>> |  2 | two   |    0 | 127.0.0.1:5080 |     0 | NULL       | NULL
>> |          0 |     0 | NULL   |             |
>> |  3 | three |    0 | 127.0.0.1:5090 |     0 | NULL       | NULL
>> |          0 |     0 | NULL   |             |
>> +----+-------+------+----------------+-------+------------+-------+------------+-------+--------+-------------+
>> 3 rows in set (0.00 sec)
>>
>> mysql> select * from dr_carriers;
>> +----+-----------+---------------+-------+-------+-------+-------------+
>> | id | carrierid | gwlist        | flags | state | attrs | description |
>> +----+-----------+---------------+-------+-------+-------+-------------+
>> |  1 | cr1       | one=50,two=50 |     3 |     0 | |             |
>> +----+-----------+---------------+-------+-------+-------+-------------+
>> 1 row in set (0.00 sec)
>>
>> mysql> select * from dr_rules;
>> +--------+---------+--------+---------+----------+---------+------------+-------+-------------+
>> | ruleid | groupid | prefix | timerec | priority | routeid | gwlist
>> | attrs | description |
>> +--------+---------+--------+---------+----------+---------+------------+-------+-------------+
>> |      1 | 1       |        |         |        0 | NULL    | #cr1,three
>> | NULL  |             |
>> +--------+---------+--------+---------+----------+---------+------------+-------+-------------+
>> 1 row in set (0.00 sec)
>>
>>
>>
>> And it works, I get in log (for an xlog("GW IDs are      :
>> $(avp(dr_gw)[*]) \n"); after do_routing("1") )  :
>>
>> "GW IDs are      : two, three"
>>        or
>> "GW IDs are      : one, three"
>>
>> Keep in mind is a probabilistic dispersion (not a rigorous round robin),
>> so running 2-3 times may not be relevant. Do a larger set of tests (like
>> 10 or so).
>>
>> Regards,
>>
>> Bogdan-Andrei Iancu
>> OpenSIPS Founder and Developer
>> http://www.opensips-solutions.com
>>
>>
>>
>>
>> On 23.07.2014 18:37, Kneeoh wrote:
>>> I thought that would work too. But if I put (dr_carriers table) gwlist:gw1=50,gw2=50 flags:3 it Always picks gw1. I want it to alternate between gw1 and gw2
>>>
>>> Ultimately I'm trying to do something like: dr_rules: gwlist: #cr1=50,#cr2=50 lets say it picks cr1, then go to the dr_carriers table where it will pick ONE of the carrier gateways based on weight, if that gateway fails or times out use the next carrier cr2, not the next gateway for cr1
>>>
>>>
>>> On Wednesday, July 23, 2014 10:07 AM, Bogdan-Andrei Iancu <bogdan at opensips.org> wrote:
>>> Hi,
>>>
>>> Actually you can combine the flags and use 0x03 - ordering by weights
>>> and use only first. Just give it a try.
>>>
>>> Regards,
>>>
>>> Bogdan-Andrei Iancu
>>> OpenSIPS Founder and Developer
>>> http://www.opensips-solutions.com
>>>
>>>
>>>
>>>
>>> On 23.07.2014 03:29, Kneeoh wrote:
>>>> It would be great if you could combine the binary Flags for dr_carrier routing:
>>>>
>>>> flags : 0x1 - use weight for sorting the list and not definition order; 0x2 - use only the first gateway from the carrier (depending on the sorting); 0x4 - disable the usage of this carrier
>>>>
>>>> such that where 1+2 = 3 the gateways are first sorted by weight then returns only the top result for each carrier. This would allow for equitable distribution between carrier gateways. This way gw1=100,gw2=100 would have a roughly equal chance of being picked (if enabled=true). At present it either cycles through all carrier gateways OR when the binary flag is set to 2, it picks the first gateway ONLY, ALL THE TIME.
>>>>
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at lists.opensips.org
>>>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users




More information about the Users mailing list