M2 Quality Routing
Quality Routing allows ordering Terminators by quality. This is a very flexible way of routing because quality is determined by mathematical formulas that contain various parameters.
These parameters are used to calculate the Quality Index by which Terminators are ordered in a Dial Peer.
Quality is calculated for Dial Peer - Terminator pair that means single Terminator can have different Quality Index values in different Dial Peers.<be>
Enabling Quality Routing in core module
By default, Quality Routing is disabled in the core module which is responsible for routing all calls. To enable Quality Routing, please use these commands:
In a server where Radiusd service is located, in file /etc/m2/system.conf change disable_advanced_routing value from 0 to 1
After the value has been changed, reload the settings:
More information about core settings can be found here.
Quality Routing Rules
You can view and create Quality Routing Rules in ROUTING -> Quality Routing
In the Quality Routing list you can see how many Originators have a specific Quality Routing Rule assigned to them in a USED column. Routing Rules can be assigned in Originator settings.
Press ADD NEW and you will be redirected to a page where you will be able to define your own Quality Routing Rules.
- Name - name for your Quality Routing Rule
- Quality Index Formula - formula by which Quality Index is calculated (if entered formula is incorrect input borders will turn red)
Quality Index Parameters
Quality Index Parameter value represents for how many last Calls each Parameter is calculated. Lower amount of last Calls used in Quality Index Parameters will result in faster response to Quality Index change but it will be less accurate. Higher amount of last Calls used in Quality Index Parameters will result in more accurate Quality Index but it will change slower. Currently each Quality Index Parameter can be calculated for maximum 200 last Calls.
Information on Formula's Parameters
Here you can find a list of Quality Index Parameters that can be used in formulas.
Quality Index is an evaluation of Quality Index Formula that is calculated for each Dial Peer - Terminator pair. When Quality Routing Algorithm is in use Terminators are ordered by Quality Index in a Dial Peer.
To calculate Quality Index, these Parameters can be used:
- TOTAL_CALLS - number of total Calls
- TOTAL_ANSWERED - number of answered Calls
- TOTAL_FAILED - number of failed Calls (read section about failed Calls)
- TOTAL_BILLSEC - total Call duration (in seconds)
- ASR - answer seizure ratio (%)
- ACD - average Call duration (in seconds)
- PRICE - Terminator’s Call price (Tariff Rate) in default Currency
- WEIGHT - Terminator’s weight in a Dial Peer
- PERCENT - Terminator’s percent in a Dial Peer
Note that each variable is calculated for a Dial Peer - Terminator pair. This means that the same Terminator can have X total Calls in one Dial Peer and Y total Calls in another Dial Peer.
Quality Index Formula is written in mathematical expressions, for example:
WEIGHT + (ASR * ACD * PRICE) / 2
This formula is just an example to show how formulas are written and is not intended to be used in production for Quality Routing.
For each Quality Index Parameter you can set a specific amount of last Calls used in the calculation. For example if you set 50 Calls for ASR then the last 50 Calls made through a Dial Peer - Terminator pair will be used to calculate ASR. Lower amount of last Calls used in Quality Index Parameters will result in faster response to Quality Index change but it will be less accurate. Higher amount of last Calls used in Quality Index Parameters will result in more accurate Quality Index but it will change slower. Currently each Quality Index Parameter can be calculated for maximum 200 last Calls.
Quality Routing Stats
Quality Routing Stats page allows to check current quality statistics for selected Dial Peer. You can select specific Quality Formula and it will be applied to a Dial Peer. Quality Routing Statistics table can be ordered by Quality Index so that you could know which Terminators will be dialed first.
Note that if your formula contains a PRICE variable, you will be asked to enter a Destination number in a Destination input field. This number will be used to calculate the PRICE variable. Terminator’s rate will be assigned to the PRICE variable. If the Rate is not found or the Destination number is not entered, PRICE variable will have a value of 0.
This page is useful if you just want to know quality statistics in a Dial Peer or if you want to experiment with different Quality Routing formulas. You can even check Quality Routing formulas that are not assigned to any Originator.
Another way to test your Quality Routing formulas is to create a test Originator, assign Quality Routing and do Call Tracing. In the output you will find useful information on how Terminators are ordered.
Terminators are ordered by Quality Index (QI) in a descending order (Terminators with higher QI will be dialed first). If two or more Terminators in the same Dial Peer have equal QI, then these Terminators will be ordered by TP priority in Dial Peer‘s settings. If two or more Terminators in the same Dial Peer have equal QI and TP priority, then these Terminators will be ordered randomly. This is default behavior for any Routing Algorithm – order by Originator‘s Routing Algorithm and reorder matching Terminators by TP priority in Dial Peer‘s settings.
Note that Terminators are ordered in Dial Peer‘s level. There may be situations where lower quality Terminators are dialed first. For example, we have two Dial Peers - Standard DP and Premium DP. Standard DP has priority 0 in Routing Group and Premium DP has priority 1 in Routing Group. Both are selected when routing a call but Standard DP has lower priority numbed therefore it will be used first. Terminators in both DP are ordered by quality and Premium DP might have better quality Terminators but Standard DP has lower priority value so Terminators from this DP are used first. Terminators in Standard DP are still ordered by quality.
Division can be used to achieve ascending order. For example, you want to order Terminators by lowest total call duration so that Terminators with lowest call duration are called first. One way to do this is to use this formula:
1 / TOTAL_BILLSEC
Situation when quality is unknown
Quality is calculated for a Dial Peer – Terminator pair. That means that the same Terminator can have different quality in different Dial Peers. But what happens when you create new Dial Peer and assign some Terminators to it? What is the quality for each Terminator in this particular Dial Peer? We don‘t know since there are no calls made through this new Dial Peer.
In this case M2 will generate initial quality stats for each Terminator by retrieving calls from the database that were made through any Dial Peer. In database there is no relationship between Terminator and Dial Peer. Just by looking in a database we don‘t know which Dial Peer was used when making a call therefore each time the quality is calculated from the database it will be more general and may differ from what it is in particular Dial Peer. In practice this is not a big problem since quality is calculated by most recent calls and these calls are differentiated between Dial Peer. Initial general quality statistics will be eventually replaced by Dial Peer specific quality statistics.
Another case is when we add completely new Terminator that does not have any calls. We can not calculate initial quality from the database since there are no calls made through this Terminator. In this case the initial Quality Index will be 0 and there is a risk that this Terminator will always be at the end of routing list.
There is a way to temporarily force higher Quality Index to Terminators that have none or few calls. Let’s analyze situation where we are routing calls by ASR (for last 50 Calls) and add new Terminator. In this case our Quality Routing Formula is:
Quality Index (QI) is ASR - Terminators with higher ASR will be dialed first. If we add a new Terminator it will have an initial QI 0 (ASR 0) and it will be at the end of routing list. Let’s modify our Quality Routing Formula by including TOTAL_CALLS variable:
ASR + 100 * (50 - TOTAL_CALLS)
Now QI will depend not only on ASR but on total Calls made as well. If Terminator has 0 Calls then Formula is ASR + 5000 but when Terminator has 50 Calls, Formula is ASR. Note that number 50 here is chosen by the number of last Calls variable will hold so variable TOTAL_CALLS will have the minimum value of 0 and the maximum value of 50. When every Terminator in a Dial Peer makes 50 or more calls our modified formula will represent only ASR. This way we can force all Terminators to be dialed at least N times (similar to Round-robin algorithm) and after enough Calls are accumulated we can do routing by quality.
Calls may fail due to various reasons, for example code 327 Terminator's capacity reached. This particular hangup reason does not reflect Terminator’s quality since this is an internal reason why a Call failed. These M2 specific hangup reasons (codes between 300 and 399) are not calculated in Quality Routing. One exception is code 312 Caller cancelled the call. This code is accepted in Quality Routing as it may reflect Terminator’s quality. Each real attempt to dial Terminator is calculated in Quality Routing.
Note that most statistics in M2 count internal hangup reasons (codes between 300 and 399) as FAILED calls.