CDRTool Rating computation problem.

After installing everything (OpenSIPS, FreeRadius, Mediaproxy, and CDRTool) and it seems that all the installed applications are running properly I was wondering why all the calls where Identified as free call. Using the testing instruction posted on the ag-projects wiki I tested my rating engine and it works fine.
Using this command
ShowPrice From=sip:123@example.com To=sip:0031650222333@example.com Gateway=10.0.0.1 Duration=59

Result
0.2173
Duration: 59 s
App: audio
Destination: 31650
Customer: domain=example.com
Connect: 0.0000
StartTime: 2009-06-26 04:47:41

Span: 1
Duration: 59 s
ProfileId: grn_premium / weekday
RateId: grn_premium / 0-24h
Rate: 0.2210 / 60 s
Price: 0.2173

But when I tried to substitute values using my own users
ShowPrice From=sip:1000@mydomain.com To=sip:1001@mydomain.com Gateway=10.0.0.1 Duration=59
the result was always zero.
As advised in the mailing list to read the rating.txt documentation for information I can not still resolve the issue. The documentation fails to explain how to set the canonical uri value properly. I checked if I was able to properly placed this statement $avp(s:can_uri) = $ru;. By the way, this statement assigns the value for the canonical URI for the radius accounting. I have tested my opensips.cfg configuration, both the clients hear each other and the accounting records contains all fields except for the price field which was either empty or 0.

This was a puzzle for me for many many weeks, but I stumbled on a mailing list article that discusses the E164 class on the cdr_generic.php. Upon studying the code I realized that my opensips.cfg configuration was not handling any dial plan, infact, I realized that I did not set any dial plan. Having this idea I again tested my rating engine using the command below

ShowPrice From=sip:1000@mydomain.com To=sip:001001@mydomain.com Gateway=10.0.0.1 Duration=59

Voila!!! the rating engine price computation works!!!

If you notice on the To=sip:001001@mydomain.com I have prefix 00. If the canonical URI does not have a prefix the rating engine would not be able to compute the price of the call because it will fail to determine the destination id. As documented in rating.txt the canonical URI is used in the determination of the destination id.

I have created a custom E164 class in cdr_generic.php according to the dial plan I have right now. Currently I am still working on configuring my dial plan and integrate it in the opensips.cfg config file.

In short, the canonical URI value is affected how you set your dial plan. Lets say for example you dialled 1001@mydomain.com. If you are going to examine CDR record for this call you will notice that the canonical uri is 1001@mydomain.com. If this is the case the rating engine will not be able to compute the price for the call because it will fail to determine the destination id. As I have said that I am still working on my dial plan, I have hard coded the 00 prefix on my opensips.cfg.
if (uri=~”^sip:[1-9][0-9]*”)
{
prefix(“00”);
$avp(s:can_uri) = $ru;
strip(2);
};
After assigning it to AVP variable for the canonical uri the prefix ’00’ was remove/strip.
WARNING:
I am not 100% sure if this procedure is correct, all I can say that my CDRTool Web application is working, specially the price computation.

One Response to CDRTool Rating computation problem.

Leave a comment