[asterisk-users] CDR accuracy
Klaus Darilion
klaus.mailinglists at pernau.at
Wed Aug 13 07:37:58 CDT 2008
Steve Murphy wrote:
> On Tue, 2008-08-12 at 16:39 +0200, Klaus Darilion wrote:
>> Hi!
>>
>> I wonder how Asterisk measures the call duration. The CDR files have a
>> accuracy of seconds. Thus, what happens if the call duration is 0.3
>> seconds. What will Asterisk report? 0 seconds? 1 second?
>>
>> What logic will be used by Asterisk: floor? ceil? round?
>>
>> thanks
>> klaus
>
> Klaus--
>
> The duration/billsec fields are stored as simple integers.
> A simple integer subtraction is performed for both; duration
> is end time minus start time; billsec is end time minus answer time.
>
> Operations are done on system time, in seconds. If the .3 sec spans
> a system second increment, then the time will be 1, if not, then the
> time will be 0. It would seem to me the probability of .3 sec spanning
> a clock tick would be .3...
>
> CDR's do, internally, store finer increments than seconds. (struct
> timeval),
> but the interface yields plain seconds. I just checked the code, and
> sure enough, just the seconds field is used. So, truncation seems to be
> the rounding method.
>
> In general, we never fussed much about the microseconds, because on
> most interfaces, the slop in how much time it took to make a connection
> made the precision laughable.
Hi Steve!
Thanks for the detailed information. What about the following scenario:
ANSWER and HANGUP happens in the same second. Thus, the call duration
will be 0 seconds. How are such use cases usually handled in the billing
system? Are you billing the user (e.g. 1 second or the minimum fee) if
the call is ANSWERED even if Asterisk reports 0 seconds?
regards
klaus
More information about the asterisk-users
mailing list