<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Per <a moz-do-not-send="true"
href="https://www.opensips.org/Documentation/Script-CoreVar-3-1">https://www.opensips.org/Documentation/Script-CoreVar-3-1</a><br>
</p>
<p>$Tsm - reference to current microseconds <u><b>of the current
second</b></u> <br>
</p>
<p>This means that if the second counter cycles up, the microsecond
counter will cycle back to zero and you'll get a negative.</p>
<p>e.g. Let's assume that at the time of the first reading of $Tsm
it is 12:00:00.99999 and, at the time of the second reading, it's
12:00:01.00003, then you'll get a result of -0.99996, because
you're looking at the fraction of a second in isolation to the
second counter.</p>
<p>So you probably need something like:</p>
<pre class="moz-quote-pre" wrap=""> $var(t0s) = $Ts;
$var(t0ms) = $Tsm;
$var(node_number) = route(get_my_node_number);
$var(dur) = (($Ts - $var(t0s))*1000000) + $Tsm - $var(t0ms);
</pre>
<p>Note: I'm not sure whether the syntax above is correct (I've
never tried to do arithmetic operations within OpenSIPS), but the
basic idea is there.<br>
</p>
<p>--Greg<br>
</p>
<div class="moz-cite-prefix">On 2021-06-25 22:01, Kingsley Tart
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:ec32eae5f32e18c729b34bf37ab1528bfc578bbd.camel@dns99.co.uk">
<pre class="moz-quote-pre" wrap="">Hi,
For testing, this code at the top of my route script:
$var(t0) = $Tsm;
$var(node_number) = route(get_my_node_number);
$var(dur) = $Tsm - $var(t0);
xlog("My node number is $var(node_number) and it took $var(dur) microsecconds to find out\n");
has just logged this:
Jun 25 20:55:01 [598]: My node number is -1 and it took 65 microsecconds to find out
Jun 25 20:55:03 [598]: My node number is -1 and it took 67 microsecconds to find out
Jun 25 20:55:05 [598]: My node number is -1 and it took 64 microsecconds to find out
Jun 25 20:55:05 [578]: My node number is -1 and it took 602523 microsecconds to find out
Jun 25 20:55:06 [579]: My node number is -1 and it took -79396 microsecconds to find out
Jun 25 20:55:07 [598]: My node number is -1 and it took 63 microsecconds to find out
Jun 25 20:55:07 [580]: My node number is -1 and it took -455503 microsecconds to find out
Jun 25 20:55:07 [579]: My node number is -1 and it took 108 microsecconds to find out
Jun 25 20:55:09 [598]: My node number is -1 and it took 78 microsecconds to find out
Jun 25 20:55:11 [598]: My node number is -1 and it took 68 microsecconds to find out
Jun 25 20:55:13 [598]: My node number is -1 and it took 66 microsecconds to find out
Jun 25 20:55:15 [598]: My node number is -1 and it took 68 microsecconds to find out
Jun 25 20:55:17 [598]: My node number is -1 and it took 65 microsecconds to find out
Jun 25 20:55:18 [578]: My node number is -1 and it took 107 microsecconds to find out
Jun 25 20:55:19 [598]: My node number is -1 and it took 71 microsecconds to find out
which is weird because time seems to have gone backwards a couple of times.
Using OpenSIPS 3.1.2 in a VM running Debian 10, with the host being a
CentOS 7 machine running Qemu KVM.
Any idea what's happening here?
Cheers,
Kingsley.
_______________________________________________
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>
<div class="moz-signature"><span
style="font-size:11.0pt;font-family:Assistant;color:#32444B"><br>
</span></div>
</body>
</html>