We’re using CDR for billing, and we’re now comparing billing data from Asterisk CDR to billing data from our PSTN operator.
For some calls, the operator’s billsec value is 1s higher than the billsec value reported by Asterisk in CDR.
The billing process charges any second that has been initiated on the PSTN operator’s side. That is, for a call that took (billsec) 62.3 seconds (62 seconds and 300 milliseconds), the operator will report and charge a billsec value of 63.
I tried to edit cdr.conf
; Normally, the 'billsec' field logged to the backends (text files or databases)
; is simply the end time (hangup time) minus the answer time in seconds. Internally,
; asterisk stores the time in terms of microseconds and seconds. By setting
; initiatedseconds to 'yes', you can force asterisk to report any seconds
; that were initiated (a sort of round up method). Technically, this is
; when the microsecond part of the end time is greater than the microsecond
; part of the answer time, then the billsec time is incremented one second.
; The default value is "no".
initiatedseconds = yes```
> Is there a fix? Thank you
Did you reload the configuration after you edited it?
In any case, I don’t think it is reasonable to expect exact equality when propagation delays are vastly greater than light travel time, and even if they weren’t there will still be some effect of propagation delays.
More generally, it won’t work if the provider bills by anything other than seconds.
Asterisk doesn’t bill. Whatever subsequently reads the CDR data can tweak it in that way.
I think you would still have a problem that the two systems will always differ as to when events occurred, in the worst case by up to about 30 seconds, if the handshake goes to the maximum number of retransmissions, and assuming SIP.
Incidentally, initiatedseconds values are rounded to the nearest second, rather than rounded up. If the provider is rounding up, and you add 1 second, you may find that roughly half your calls are recorded as being half a second too long. It’s only roughly half, as, if most of your calls are very short, there may be a tendency for round ups and downs not to balance.