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?
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.
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.