Ticket #209 (new defect)

Opened 8 months ago

Last modified 5 days ago

Incorrect LCR algorithm

Reported by: sokhapkin Assigned to: areski
Priority: major Milestone:
Component: General Version: Trunk 1.4
Keywords: LCR Cc:

Description

Current LCR implementation doesn't select the lowest cost trunk correctly if rate cards for different trunks have different dial prefix length, current algorithm always selects longest dial prefix. Here is an example:

trunk a: 7,Russia,0.03 79,Russia mobile,0.05

trunk b: 7,Russia,0.04 7905,Russia-mobile,0.06

If the number dialed begins with 7905, current LCR algorithm will select trunk b (longer preffix match), but trunk a offers lower rate.

The patch attached fixes the problem. The idea of the patch is the following: 1. Remove "1) REMOVE THOSE THAT HAVE A SMALLER DIALPREFIX". Step 3 will do the work 2. Move step "3) REMOVE THOSE THAT USE THE SAME TRUNK - MAKE A DISTINCT" before results sort.

How it works: 1. "Superquiry" returns all matched prefixes ordered by prefix lenght in reverse order (longest prefix first). 2. Step 3 ("MAKE A DISTINCT") for each trunk will remove short prefixes, only the longest dial prefix will remain. After this step we have right matched dialprefix for each trunk. 3. Now just sort the remaining array. You got the right trunk with the lowest price.

For my example above trunk a will be selected, which is right.

Attachments

Class.RateEngine.php.diff (2.0 kB) - added by sokhapkin on 03/24/08 14:39:30.

Change History

03/24/08 14:39:30 changed by sokhapkin

  • attachment Class.RateEngine.php.diff added.

06/02/08 06:43:55 changed by stavros

Areski, what do you think of this patch? It looks like something we should consider integrating into trunk. I know you did some work on the rate engine recently so it's probably fresher in your mind than mine, but this looks broadly correct to me.

(follow-up: ↓ 3 ) 06/02/08 07:59:18 changed by areski

very interesting! Indeed it will have more sense to take the lowest route if trunk are different.

Let s give some testings and push this forward in the trunk. Rgds, Areski

(in reply to: ↑ 2 ) 11/28/08 03:23:18 changed by vardan

Replying to areski:

very interesting! Indeed it will have more sense to take the lowest route if trunk are different. Let s give some testings and push this forward in the trunk. Rgds, Areski

I think it will be best to have in this case also possibility to make some trunks priority also. For example, if the trunk a and trunk b have the same prefix with the same price, what trunk will be go on first?



Google