LCR vs COST Routing

Hello,
I’m testing LCR and COST Routing Type.
I have on the same RATE GROUP two rates:
57318 with force trunk TRUNKA and cost 0.01
and
5731 with force trunk TRUNKB and cost 0.08

If in the RATE GROUP configuration i use Routing Type LCR, the system select the first rate (57318)
If in the RATE GROUP configuration i use Routing Type COST the system select the same rate (57318)

I’m doing something wrong?
Any hint?
Regards

If you use force trunk the system always use force trunk you selected.

Without force trunk the result is the same.
Always rate 57318
Regards

Maybe a problem with code?
IF LCR and COST routing are from Originations Rates point of view, why the query on MySQL is the same?

LCR

SELECT * FROM routes WHERE (pattern = ‘^573182409064.’ OR pattern = '^57318240906.’ OR pattern = ‘^5731824090.’ OR pattern = '^573182409.’ OR pattern = ‘^57318240.’ OR pattern = '^5731824.’ OR pattern = ‘^573182.’ OR pattern = '^57318.’ OR pattern = ‘^5731.’ OR pattern = '^573.’ OR pattern = ‘^57.’ OR pattern = '^5.’ OR pattern =’–’) AND status = 0 AND (pricelist_id = 8 OR accountid=16) ORDER BY accountid DESC,LENGTH(pattern) DESC,cost DESC LIMIT 1

COST

SELECT * FROM routes WHERE (pattern = ‘^573182409064.’ OR pattern = '^57318240906.’ OR pattern = ‘^5731824090.’ OR pattern = '^573182409.’ OR pattern = ‘^57318240.’ OR pattern = '^5731824.’ OR pattern = ‘^573182.’ OR pattern = '^57318.’ OR pattern = ‘^5731.’ OR pattern = '^573.’ OR pattern = ‘^57.’ OR pattern = '^5.’ OR pattern =’–’) AND status = 0 AND (pricelist_id = 8 OR accountid=16) ORDER BY accountid DESC,LENGTH(pattern) DESC,cost DESC LIMIT 1

Any hint?

Good question :wink:

So, after some more tests, the solution. LCR and COST is from Termination Rates point of view so the system select the rate with the longer prefix without look at the price is the RATE GROUP Routing is LCR and select more cheaper rate, without look at prefix if RATE GROUP Routing is COST.
This is true only if:

  • each rate use a different trunk to terminate the call

  • the rates have the same number priority

Regards

Correction:
the priority option in termination rate, does not affect the behaviour
Regards

Hello @social,

Good catch, You are right. It check based on Termination rates not based on Origination rates.