We are using CDR for billing and we are now comparing billing information from Asterisk CDR and billing information bringed by our PSTN operator.
We have to face a minor but critical issue regarding the billsec value accuracy.
For some calls, the billsec value bringed by the operator is 1s more than the billsec value reported by Asterisk in CDR.
On the PSTN operator side, the billing process charges any second that has been initiated. Meaning that for a call that took (billsec) 62.3 s (62 s and 300 ms) the operator will report and charge a billsec value of 63.
At the same time, it looks like (as I can read in the source code) Asterisk is not managing ms in call timestamps… and therefore in the billsec calculation process (I undestand that billsec = hangup timestamp in sec - answer timestamp in sec). Meaning that for the call that took 62.3s, the billsec value reported will be 62 or 63, depending on the rounding process that have been applied on the call timestamps…
Also, is there any workaround or addon patch that can be applied on Asterisk in order to :
manage call timestamps in ms, and
get billsec in ms or control the billsec rounding rule ?
We have exactly the same problem. All of our calls is 1 second less than that of our providers.(Even 2 seconds in some cases.) Can someone confirm if Asterisk does indeed round the billsec up? Any idea where one can change this behavior?
Ended up the the problem was with our provider’s software. Can you believe it. We were the first people to complain and they traced the fault on there software.
So it looks like there is no rounding process applied on the billsec calculation : the billsec calculation does not take in account at all the ms and also (billsec = end(s) - answer(s)).
It would be more accurate to add the following line (or somelike, I’m not a C developer) :
Meaning that we would have to add 1s in case the fractional part from end time (in µs) is greater than the fractional part from answer time (in µs too).
Dev team said that billsec accuracy has been improved in Asterisk 1.6 as billsec and duration have been correct down to millisecond.
as indicated :
<<<
Note that this is only available on CDR drivers which support the new accuracy (most of the stock drivers, actually) and on database tables which allow either decimals or floats in the duration/billsec columns.
Hi,
I use Asterisk 15.6.1. How can I get call duration rounded to full second in cdr?
We conduct tests with the operator and his system works in this way…
Generally, though, you should not expect the provider to agree exactly on the time of answer and clear. For a start, these involve time of flight considerations for the signalling used.
For something that accounts for either rounding to nearest, or a bias in the measured time, rather than adding 1, you could probably change https://github.com/asterisk/asterisk/blob/master/main/cdr.c#L3052 and recompile. However, I haven’t researched this fully and there may be other places where similar calculations are performed.
Great, in the folder CDR-custom I have data with milliseconds. Thanks!
However, currently the billing information is stored in the database.
How to force the storage of these custom data in PostgreSQL?
I think you are going to have to go through the code, to find out why my suggestion wasn’t right. I don’t think you will need any deep understanding, and the changes needed should be safe, but you need to put more time into it than I can give.