<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hello,<br>
      <br>
      Which OpenSIPS version are you using ?<br>
      You could use get_timestamp [1] from the Core to get the current
      second and microsecond,<br>
      and set the two variables at INVITE time, and set them as db_extra
      [2] .<br>
      <br>
      Then, at BYE time call again the get_timestamp function, store
      them in some AVPs and set those AVPs in [3]. This way you should
      get both the INVITE and BYE timestamps with microseconds precision
      in the CDR record.<br>
      <br>
      [1]
      <a class="moz-txt-link-freetext" href="http://www.opensips.org/Documentation/Script-CoreFunctions-1-10#toc18">http://www.opensips.org/Documentation/Script-CoreFunctions-1-10#toc18</a><br>
      [2]
      <a class="moz-txt-link-freetext" href="http://www.opensips.org/html/docs/modules/1.10.x/acc.html#id295028">http://www.opensips.org/html/docs/modules/1.10.x/acc.html#id295028</a><br>
      [3]
      <a class="moz-txt-link-freetext" href="http://www.opensips.org/html/docs/modules/1.10.x/acc.html#id295056">http://www.opensips.org/html/docs/modules/1.10.x/acc.html#id295056</a><br>
      <br>
      Best Regards,<br>
      <pre class="moz-signature" cols="72">Vlad Paiu
OpenSIPS Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a> </pre>
      On 12.04.2014 23:44, Maciej Bylica wrote:<br>
    </div>
    <blockquote
cite="mid:CACynCY6PZDB0kr4DfdhLfp0uAyj=atv8h-JQpQiXhSt5-TaCtQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hello Ryan,
        <div><br>
        </div>
        <div>I am using dialog accounting, so each row is fully
          qualified cdr record, not only single transaction of a call.</div>
        <div>Couldn't i just use two extra db variables which will
          gather the $time inside INVITE {} and BYE {}?</div>
        <div><br>
        </div>
        <div>Thanks,</div>
        <div>Mac</div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">2014-04-12 6:39 GMT+02:00 Ryan Mitchell
          <span dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:rjm@tcl.net" target="_blank">rjm@tcl.net</a>&gt;</span>:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">Hello Mac,
              <div><br>
              </div>
              <div>Each row in the acc table is for a transaction. &nbsp;To
                make a proper CDR out of the data, you have to combine
                rows to find the start and end of the call. &nbsp;That can be
                harder than it sounds, especially with forking
                (parallel, or the more common case of serial forking
                when you are LCR routing or simply sending calls to alt
                destinations after a timeout). &nbsp;I wrote scripts that
                implement a simple dialog state machine to make sense of
                all the distinct legs of a call, though there should be
                an easier way with the auto-cdr / multi call-legs
                accounting feature of the acc module (anyone comment on
                this please?).</div>
              <div><br>
              </div>
              <div>The time field in the acc table will be the timestamp
                of the response for the given transaction. &nbsp;If you
                assign an extra field for another timestamp, it will
                depend on where you assign that var in your script. &nbsp;In
                my case I assign it in the main routing section so the
                timestamp indicates the start of the transaction.</div>
              <div><br>
              </div>
              <div>best regards,</div>
              <div>Ryan</div>
              <div>
                <div class="h5">
                  <div><br>
                  </div>
                  <div class="gmail_extra"><br>
                    <br>
                    <div class="gmail_quote">On Fri, Apr 11, 2014 at
                      10:06 AM, Maciej Bylica <span dir="ltr">&lt;<a
                          moz-do-not-send="true"
                          href="mailto:mbsip@gazeta.pl" target="_blank">mbsip@gazeta.pl</a>&gt;</span>
                      wrote:<br>
                      <blockquote class="gmail_quote" style="margin:0 0
                        0 .8ex;border-left:1px #ccc
                        solid;padding-left:1ex">
                        <div dir="ltr">Ryan,
                          <div><br>
                          </div>
                          <div>One more question.</div>
                          <div>Currently i have some db extra attrs
                            setup. My acc table looks like following:</div>
                          <div>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">+------------+------------------+------+-----+---------+----------------+</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              Field&nbsp; &nbsp; &nbsp; | Type &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Null | Key
                              | Default | Extra&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">+------------+------------------+------+-----+---------+----------------+</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              id &nbsp; &nbsp; &nbsp; &nbsp; | int(10) unsigned | NO &nbsp; | PRI
                              | NULL&nbsp; &nbsp; | auto_increment |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              method &nbsp; &nbsp; | char(16) &nbsp; &nbsp; &nbsp; &nbsp; | NO &nbsp; | &nbsp; &nbsp;
                              | &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              from_tag &nbsp; | char(64) &nbsp; &nbsp; &nbsp; &nbsp; | NO &nbsp; | &nbsp; &nbsp;
                              | &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              to_tag &nbsp; &nbsp; | char(64) &nbsp; &nbsp; &nbsp; &nbsp; | NO &nbsp; | &nbsp; &nbsp;
                              | &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              callid &nbsp; &nbsp; | char(64) &nbsp; &nbsp; &nbsp; &nbsp; | NO &nbsp; | MUL
                              | &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              sip_code &nbsp; | char(3)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | NO &nbsp; | &nbsp; &nbsp;
                              | &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              sip_reason | char(32) &nbsp; &nbsp; &nbsp; &nbsp; | NO &nbsp; | &nbsp; &nbsp;
                              | &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              time &nbsp; &nbsp; &nbsp; | datetime &nbsp; &nbsp; &nbsp; &nbsp; | NO &nbsp; | &nbsp; &nbsp;
                              | NULL&nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              duration &nbsp; | int(11) unsigned | NO &nbsp; | &nbsp; &nbsp;
                              | 0 &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              setuptime&nbsp; | int(11) unsigned | NO &nbsp; | &nbsp; &nbsp;
                              | 0 &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              SourceAddr | char(30) &nbsp; &nbsp; &nbsp; &nbsp; | NO &nbsp; | &nbsp; &nbsp;
                              | NULL&nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              DestAddr &nbsp; | char(30) &nbsp; &nbsp; &nbsp; &nbsp; | NO &nbsp; | &nbsp; &nbsp;
                              | NULL&nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              Anum &nbsp; &nbsp; &nbsp; | char(30) &nbsp; &nbsp; &nbsp; &nbsp; | NO &nbsp; | &nbsp; &nbsp;
                              | NULL&nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              Bnum_rU&nbsp; &nbsp; | char(30) &nbsp; &nbsp; &nbsp; &nbsp; | NO &nbsp; | &nbsp; &nbsp;
                              | NULL&nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              Bnum_tU&nbsp; &nbsp; | char(30) &nbsp; &nbsp; &nbsp; &nbsp; | NO &nbsp; | &nbsp; &nbsp;
                              | NULL&nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">|
                              created&nbsp; &nbsp; | datetime &nbsp; &nbsp; &nbsp; &nbsp; | YES&nbsp; | &nbsp; &nbsp;
                              | NULL&nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">+------------+------------------+------+-----+---------+----------------+</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo"><br>
                            </p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(83,48,225)">
                              <span style="color:rgb(206,121,36)">modparam("acc",
                                "db_extra", "SourceAddr=$si</span>;
                              DestAddr=$rd; Anum=$fU; Bnum_rU=$rU;
                              Bnum_tU=$tU")</p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo">
                              <br>
                            </p>
                            <p
                              style="margin:0px;font-size:11px;font-family:Menlo"><span
style="font-family:arial;font-size:small">Now using additional data like
                                $time will give me the exact moment the
                                call is ended, nothing more, am i right?</span></p>
                            <p style="margin:0px">To have detailed call
                              duration i need to know exact answer and
                              disconnect timestamps.</p>
                            <p style="margin:0px"><br>
                            </p>
                            <p style="margin:0px">Btw: i am using<span
                                style="font-family:Menlo;font-size:11px">&nbsp;OpenSIPS
                                (1.9.1-notls (x86_64/linux))</span></p>
                            <p style="margin:0px"><br>
                            </p>
                            <p style="margin:0px">Thanks,</p>
                            <p style="margin:0px">Mac</p>
                          </div>
                        </div>
                        <div class="gmail_extra"><br>
                          <br>
                          <div class="gmail_quote">
                            <div>2014-04-10 22:03 GMT+02:00 Ryan
                              Mitchell <span dir="ltr">&lt;<a
                                  moz-do-not-send="true"
                                  href="mailto:rjm@tcl.net"
                                  target="_blank">rjm@tcl.net</a>&gt;</span>:<br>
                            </div>
                            <blockquote class="gmail_quote"
                              style="margin:0 0 0 .8ex;border-left:1px
                              #ccc solid;padding-left:1ex">
                              <div dir="ltr">Using db_extra to stuff
                                custom data into your acc table, use the
                                $time var with a format such as&nbsp;"%s.%N"
                                or similar.
                                <div>
                                  <div>
                                    <div>
                                      <br>
                                    </div>
                                    <div>Or, as you suggested, do it on
                                      the database level with a trigger
                                      or auto-update column.</div>
                                    <div><br>
                                    </div>
                                    <div class="gmail_extra"><br>
                                      <br>
                                      <div class="gmail_quote">
                                        <div>
                                          <div>On Thu, Apr 10, 2014 at
                                            10:01 AM, Maciej Bylica <span
                                              dir="ltr">&lt;<a
                                                moz-do-not-send="true"
                                                href="mailto:mbsip@gazeta.pl"
                                                target="_blank">mbsip@gazeta.pl</a>&gt;</span>
                                            wrote:<br>
                                          </div>
                                        </div>
                                        <blockquote class="gmail_quote"
                                          style="margin:0 0 0
                                          .8ex;border-left:1px #ccc
                                          solid;padding-left:1ex">
                                          <div>
                                            <div>
                                              <div dir="ltr">
                                                <div><span
                                                    style="white-space:nowrap;font-family:arial,sans-serif">Hello</span><br>
                                                </div>
                                                <div><font face="arial,
                                                    sans-serif"><span
                                                      style="white-space:nowrap"><br>
                                                    </span></font></div>
                                                <div><font face="arial,
                                                    sans-serif"><span
                                                      style="white-space:nowrap">I
                                                      just want to know
                                                      how to achieve
                                                      miliseconds
                                                      precision for
                                                      accounting module.</span></font></div>
                                                <div><span
                                                    style="white-space:nowrap;font-family:arial,sans-serif">This
                                                    is quite important
                                                    while trying to sum
                                                    up total traffic
                                                    duration with the
                                                    accuracy of hundred
                                                    of ms.</span><br>
                                                </div>
                                                <div><span
                                                    style="white-space:nowrap;font-family:arial,sans-serif"><br>
                                                  </span></div>
                                                <div><span
                                                    style="white-space:nowrap;font-family:arial,sans-serif">As
                                                    i see there is no
                                                    rounding feature
                                                    implemented as well,
                                                    but heaving ms
                                                    precision it could
                                                    be done directly on
                                                    DB level.</span></div>
                                                <div>
                                                  <span
                                                    style="white-space:nowrap;font-family:arial,sans-serif"><br>
                                                  </span></div>
                                                <div><span
                                                    style="white-space:nowrap;font-family:arial,sans-serif">Could
                                                    somebody give me a
                                                    hand.</span></div>
                                                <div><span
                                                    style="white-space:nowrap;font-family:arial,sans-serif"><br>
                                                  </span></div>
                                                <div><span
                                                    style="white-space:nowrap;font-family:arial,sans-serif">Thanks
                                                    in advanced</span></div>
                                                <div><span
                                                    style="white-space:nowrap;font-family:arial,sans-serif">Mac</span></div>
                                                <div><br>
                                                </div>
                                                <div><br>
                                                </div>
                                              </div>
                                              <br>
                                            </div>
                                          </div>
_______________________________________________<br>
                                          Users mailing list<br>
                                          <a moz-do-not-send="true"
                                            href="mailto:Users@lists.opensips.org"
                                            target="_blank">Users@lists.opensips.org</a><br>
                                          <a moz-do-not-send="true"
                                            href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users"
                                            target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
                                          <br>
                                        </blockquote>
                                      </div>
                                      <span><font color="#888888"><br>
                                          <br clear="all">
                                          <div><br>
                                          </div>
                                          -- <br>
                                          Ryan Mitchell &lt;<a
                                            moz-do-not-send="true"
                                            href="mailto:rjm@tcl.net"
                                            target="_blank">rjm@tcl.net</a>&gt;<br>
                                          Telecom Logic, LLC<br>
                                          <br>
                                        </font></span></div>
                                  </div>
                                </div>
                              </div>
                              <div>
                                <div>
                                  <br>
_______________________________________________<br>
                                  Users mailing list<br>
                                  <a moz-do-not-send="true"
                                    href="mailto:Users@lists.opensips.org"
                                    target="_blank">Users@lists.opensips.org</a><br>
                                  <a moz-do-not-send="true"
                                    href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users"
                                    target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
                                  <br>
                                </div>
                              </div>
                            </blockquote>
                          </div>
                          <br>
                        </div>
                        <br>
                        _______________________________________________<br>
                        Users mailing list<br>
                        <a moz-do-not-send="true"
                          href="mailto:Users@lists.opensips.org"
                          target="_blank">Users@lists.opensips.org</a><br>
                        <a moz-do-not-send="true"
                          href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users"
                          target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
                        <br>
                      </blockquote>
                    </div>
                    <br>
                    <br clear="all">
                    <div><br>
                    </div>
                    -- <br>
                    Ryan Mitchell &lt;<a moz-do-not-send="true"
                      href="mailto:rjm@tcl.net" target="_blank">rjm@tcl.net</a>&gt;<br>
                    Telecom Logic, LLC<br>
                    <br>
                  </div>
                </div>
              </div>
            </div>
            <br>
            _______________________________________________<br>
            Users mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
            <a moz-do-not-send="true"
              href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users"
              target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>