<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-AU" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">To FreeSWITCH users,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">I have a question in regard to correct billing of a SIP call within FreeSWITCH (to align with Telco billing),
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">since I have asked this question below of BT (direct to their SIP compliance testing team) and received their response today.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">Based on the diagram below of a simple SIP call:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">BT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FreeSWITCH<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">| --- INVITE ------&gt; |<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">| &lt;-- 100 Trying --- |<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">| &lt;-- 200 OK ------- |<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">| --- ACK ---------&gt; |<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">| &lt;-- RTP ---------&gt; |<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">| --- BYE ---------&gt; |<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">| &lt;-- 200 OK ------- |<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">In order to best match the BT billing records for call duration (that will be sent to my client for their SIP service) I want to make sure that our timers are correct.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">In the above diagram shows an inbound call from BT to FreeSWITCH.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">Which of the below statements are correct (2 out of the 4 should be correct):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">1)&nbsp;&nbsp; The answer (or connect) timer should start from when FreeSWITCH sends the &#8220;200 OK&#8221; to indicate that the call is connected?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">2)&nbsp;&nbsp; The answer (or connect) timer should start from when FreeSWITCH receives the ACK message back from BT (after sending the &#8220;200 OK&#8221; to indicate that the call was connected)?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">3)&nbsp;&nbsp; The timer for call duration should end when FreeSWITCH receives the &#8220;BYE&#8221; message from BT?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">4)&nbsp;&nbsp; The timer for call duration should end when FreeSWITCH sends the &#8220;200 OK&#8221; to BT (after it received the &#8220;BYE&#8221; message from BT)?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">If the call was reversed ie. an outbound call made from FreeSWITCH to BT (simply swap BT and FreeSWITCH in the above diagram)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">Which of the below statements are correct (2 out of the 4 should be correct):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">1)&nbsp;&nbsp; The answer (or connect) timer should start from when FreeSWITCH receives the &#8220;200 OK&#8221; to indicate that the call is connected?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">2)&nbsp;&nbsp; The answer (or connect) timer should start from when FreeSWITCH sends the ACK message back to BT (after receiving the &#8220;200 OK&#8221; to indicate that the call was connected)?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">3)&nbsp;&nbsp; The timer for call duration should end when FreeSWITCH sends the &#8220;BYE&#8221; message to BT?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">4)&nbsp;&nbsp; The timer for call duration should end when FreeSWITCH receives the &#8220;200 OK&#8221; from BT (after it sent the &#8220;BYE&#8221; message to BT)?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">BT's response:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">...<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">Out of the first 4 statements, numbers 2 and 3 are closest. After BT sends the ACK the call timer will start, it will then stop again when BT sends the BYE.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">Out of the second 4 statements, numbers 2 and 3 are closest. After BT receives the ACK the call timer will start, it will then stop again after BT receives the BYE.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">...<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">Therefore, when looking at FreeSWITCH this becomes more interesting, if I base BT's response to be true and correct.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">Since currently the events generated at the end of a call CHANNEL_HANGUP and CHANNEL_HANGUP_COMPLETE, which align as follows:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">CHANNEL_HANGUP when BYE received or sent<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">CHANNEL_HANGUP_COMPLETE when 200 OK sent or received
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">Which brings me to my actual question:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">Since billing timing is done from the point of call connect (or when the ACK is received or sent after the 200 OK) to the point of receiving the BYE message (or sending it, depending on the direction
 of the call)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">then why does FreeSWITCH return all the billing variables inside the CHANNEL_HANGUP_COMPLETE based on call timer ending when CHANNEL_HANGUP_COMPLETE is generated and not based on when CHANNEL_HANGUP
 is generated?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">Here is a snipet of the CHANNEL_HANGUP_COMPLETE variables:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">variable_duration:14<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">variable_billsec:14<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">...<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">variable_billmsec:14041<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">...<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">variable_billusec:14041103<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">...<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">variable_answerusec:58543<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">In order to test this, I delayed a Lua script after HUNGUP (or CHANNEL_HANGUP event) was detected (for about 10 seconds) prior to ending the Lua script.&nbsp; I know this is not recommended, however it
 is just to explain this case.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">As you can see the call duration and all the billing variables show the time up to CHANNEL_HANGUP_COMPLETE not CHANNEL_HANGUP.&nbsp; However, the interesting variable is: variable_answerusec, which seems
 correct up to CHANNEL_HANGUP.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">I would appreciate any comments regarding this since obviously I would like the call durations on FreeSWITCH to match BT.&nbsp;
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">If BT are not correct with their timer points, then I am happy to go back to them with some evidence to dispute their claims.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">Andrew Keil<o:p></o:p></span></p>
</div>
</body>
</html>