Project

General

Profile

Duration rounding

The best accuracy for storing call duration in database which is available in Smartswitch - is second-wise.
Second-wise accuracy is available in CDR for all calls which passed through the system.

Also for all calls which passed through the Billing, the call duration in minutes is stored in database which is calculated basing on Billing increment.
When performing Billing re-calculation the call duration in minutes is re-calculated again basing on Billing increment and call duration in seconds.

However 1 second is not the smallest atom for call duration measurement.
1 second consists of 1000 millisconds, and 1 millisecond consists of 1000 microseconds etc.
Here from arises an question of choosing duration rounding mode.

For example, call started at 15 sec. 300 ms, and finished at 25 sec. 900 ms.
Duration could be calculated only on second-basis as 25 - 15 = 10 sec.
Or duration could be calculated as 25.800 - 15.300 = 10.500 sec, and next could be rounded to 10 or 11 sec.

On the first sight the question of rounding of 1 second is not significant and could be forget.
However on big amounts of telephony traffic the difference in rounding between billing systems might give significant money amounts when performing settlement with partners.
Therefore it's very desirable to use the same method of duration rounding for both partners.

The difference in call duration could also happen due to VoIP network latency.
For example, originator has hanged up the call and send a message of call hangup to you, but this message arrived on your server only in 500ms.

Smartswitch has following duration rounding methods available:

To smaller, then substract.

Call start time and call end time are first rounded to smaller second.
Then, to get call duration, call end time is deducted from call start time.

Example.
  • start time: 2013-01-01 01:00:15.300
  • end time: 2013-01-01 01:00:25.900.
    Duration = 25 - 15 = 10 sec.

Substract, then to larger, halfway to larger.

Example 1.
  • start time: 2013-01-01 01:00:15.300
  • end time: 2013-01-01 01:00:25.900.
    First substract: duration = 25.900 - 15.300 = 10.600
    Then round to nearest: duration = 11 sec.
Example 2.
  • start time: 2013-01-01 01:00:15.300
  • end time: 2013-01-01 01:00:25.800.
    First substract: duration = 25.800 - 15.300 = 10.500
    Then round to nearest. As far 500 is halfway, and halfway is rounded to larger, duration = 11 сек.
Example 3.
  • start time: 2013-01-01 01:00:15.300
  • end time: 2013-01-01 01:00:25.700.
    First substract: duration = 25.700 - 15.300 = 10.400
    Then round to nearest: duration = 10 sec.

Substract, then to larger.

Example 1.
  • start time: 2013-01-01 01:00:15.300
  • end time: 2013-01-01 01:00:25.900.
    First substract: duration = 25.900 - 15.300 = 10.600
    Then round to larger: duration = 11 сек.
Example 2.
  • start time: 2013-01-01 01:00:15.300
  • end time: 2013-01-01 01:00:25.700.
    First substract: duration = 25.700 - 15.300 = 10.400
    Then round to larger: duration = 11 sec.

Русский перевод

Also available in: PDF HTML TXT