<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255); text-align: left;" dir="auto">
Hello,</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255); text-align: left;" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255); text-align: left;" dir="auto">
you could probably combine some string transformation to get the desired result.</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255); text-align: left;" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255); text-align: left;" dir="auto">
If your requirements are related to accounting, the acc module might bei easier to use.</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255); text-align: left;" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255); text-align: left;" dir="auto">
Cheers,</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255); text-align: left;" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255); text-align: left;" dir="auto">
Henning</div>
<div id="ms-outlook-mobile-signature"><br>
-- <br>
Henning Westerholt - <a href="https://skalatan.de/blog/" target="_blank">https://skalatan.de/blog/</a><br>
Kamailio services - <a href="https://skalatan.de/services" target="_blank">https://skalatan.de/services</a></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> sr-users <sr-users-bounces@lists.kamailio.org> on behalf of Chaigneau, Nicolas <nicolas.chaigneau@capgemini.com><br>
<b>Sent:</b> Friday, September 25, 2020 6:34:30 PM<br>
<b>To:</b> Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org><br>
<b>Subject:</b> Re: [SR-Users] Computing a time difference when handling a stateless SIP request</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText"><br>
> > <br>
> > --snip <br>
> > I would like to compute a time difference (with microseconds<br>
> > precision) when handling a stateless SIP request.<br>
> > --snip<br>
><br>
> Welcome!<br>
><br>
> Take a look at:<br>
> <a href="https://www.kamailio.org/wiki/cookbooks/5.4.x/pseudovariables#timeval">
https://www.kamailio.org/wiki/cookbooks/5.4.x/pseudovariables#timeval</a><br>
><br>
> You can get down to the microsecond level.<br>
<br>
<br>
Thanks!<br>
<br>
Looking at src\modules\pv\pv_time.c, it seems TV functions just use "gettimeofday".<br>
I was looking for a time difference based on a monotonically increasing clock (to avoid possible NTP drifting imprecision).<br>
<br>
I've looked at the "benchmark" module which seems to do something like that, but I don't think I can use it for what I need...<br>
<br>
<br>
<br>
Anyhow, I have another question. Using the TV I've come up with the following.<br>
This works, except that I don't know how to convert an int to a string padded with zeroes (e.g. 51 => "051").<br>
Is there a transformation that allows to do that?<br>
<br>
<br>
        $var(start_time) = $TV(Sn); # allows to cache $TV(s) and $TV(u)<br>
<br>
        (...)<br>
<br>
        $var(end_time) = $TV(Sn);<br>
        $var(end_s) = $TV(sn);<br>
        $var(end_us) = $TV(un);<br>
        $var(diff_us) = $var(end_us) - $TV(u) + (1000000 * ($var(end_s) - $TV(s)));<br>
<br>
        # convert this to ms (integer part) and us (fractional part)<br>
        $var(diff_ms) = $var(diff_us) / 1000;<br>
        $var(diff_us_f) = $var(diff_us) - (1000 * $var(diff_ms));<br>
<br>
        $var(diff_ms_us) = $var(diff_ms) + "." + $var(diff_us_f); # need to format on 3 digits... can we do the equivalent of sprintf("%03u") somehow ?<br>
<br>
<br>
<br>
<br>
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain,
 copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.<br>
<br>
<br>
_______________________________________________<br>
Kamailio (SER) - Users Mailing List<br>
sr-users@lists.kamailio.org<br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</div>
</span></font></div>
</body>
</html>