[Asterisk-code-review] res rtp asterisk: RTT miscalculation in RTCP (asterisk[13])

Hector Royo Concepcion asteriskteam at digium.com
Fri Nov 11 08:17:26 CST 2016


Hector Royo Concepcion has uploaded a new change for review. ( https://gerrit.asterisk.org/4397 )

Change subject: res_rtp_asterisk: RTT miscalculation in RTCP
......................................................................

res_rtp_asterisk: RTT miscalculation in RTCP

When retrieving RTCP stats for PJSIP channels, RTT values are unrealaible.
RTT calculation is correct, but the data representation isn't. RTT is
represented by a 32-bit fixed-point number with the integer part in the
first 16 bits and the fractional part in the last 16 bits. In order to get
the RTT value, the fractional part is miscalculated, there is an unnecesary
16bit shift that causes overflow.Besides this there is another mistake, when
transforming the integer value to the fixed point fractional part via bitwise
operation, that loses precision.

* RTT fractional part is no longer shifted, avoiding overflow
* RTT fractional part is transformed to its fixed-point value more precisely

ASTERISK-26566
Reported by Hector Royo Concepcion

Change-Id: Ie09bdabfee75afb3f1b8ddfd963e5219ada3b96f
---
M res/res_rtp_asterisk.c
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/97/4397/1

diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 6dc0d3a..4165b0a 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -4020,9 +4020,9 @@
 	lsr_a = ((msw & 0x0000ffff) << 16) | ((lsw & 0xffff0000) >> 16);
 	rtt = lsr_a - lsr - dlsr;
 	rtt_msw = (rtt & 0xffff0000) >> 16;
-	rtt_lsw = (rtt & 0x0000ffff) << 16;
+	rtt_lsw = (rtt & 0x0000ffff);
 	rtt_tv.tv_sec = rtt_msw;
-	rtt_tv.tv_usec = ((rtt_lsw << 6) / 3650) - (rtt_lsw >> 12) - (rtt_lsw >> 8);
+	rtt_tv.tv_usec = ((rtt_lsw*999985)/65535);
 	rtp->rtcp->rtt = (double)rtt_tv.tv_sec + ((double)rtt_tv.tv_usec / 1000000);
 	if (lsr_a - dlsr < lsr) {
 		return 1;

-- 
To view, visit https://gerrit.asterisk.org/4397
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie09bdabfee75afb3f1b8ddfd963e5219ada3b96f
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Hector Royo Concepcion <hectorroyo92 at gmail.com>



More information about the asterisk-code-review mailing list