How Call Routing works
From AstBillWiki
When we define a Provider Trunk we can enter the following:
Relative Cost/Metric:
Specifies the metric, ie. cost for the destination. This gives higher priority to lower cost routes:
When we define a Provider Route we can enter the field
Cost Plan:
Both of this fields are used when AstBill calculate what Provider Trunk to send the call to.
To make it simple if the Relative Cost/Metric: for two trunks are equal AstBill will use the Cost Plan: field to choose the right Provider Trunk. Remember lower cost routes are allways prefeerable.
We can ilustrate this with the following table.
+--------------+--------------+-----------+----------+ | trunkname | pattern |Cost_Metric| costplan | +--------------+--------------+-----------+----------+ | defvoiptalk | 44207055XXXX | 0 | 3 | | DEFVOIPTEST3 | 44207055XXXX | 9 | 2 | | DEF | 442 | 5 | 0 | | BUZZBUD | 442 | 20 | 0 | +--------------+--------------+-----------+----------+ 4 rows in set (0.02 sec)
As you can see the trunk "defvoiptalk" have a lower Cost/Metric than "DEFVOIPTEST3" So AstBill will use "defvoiptalk" to pass the call.
If you are wondering what SQL to use in MySQL to get this table her it comes:
SELECT name trunkname, pattern, trunkcost cost_metric,costplan FROM astroute, asv_trunk_dialplan2 trunk
WHERE astroute.trunk = trunk.name and
'44207055XXXX' RLIKE CONCAT("^",pattern,".*") and usagecount < maxusage and astroute.trunk <> 'Local'
ORDER BY patternlen, LENGTH( pattern ) DESC, trunk.trunkcost, costplan;
If you can do it better. Please feel free to comment.
Are Casilla --
