[Asterisk-code-review] Fixed wrong RTT calculation (asterisk[master])

sungtae kim asteriskteam at digium.com
Tue Feb 12 18:27:40 CST 2019


sungtae kim has uploaded this change for review. ( https://gerrit.asterisk.org/10993


Change subject: Fixed wrong RTT calculation
......................................................................

Fixed wrong RTT calculation

Currently, when the Asterisk calculating a RTT for the RTCPReceived
event, it combinging wrong types of variables. Fixed to make the
correct calculation.

Change-Id: Id48b8ba1aba7c08b836ee526bf2619243379015f
---
M res/res_rtp_asterisk.c
1 file changed, 13 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/93/10993/1

diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c
index 9e603f2..3a4dfbe 100644
--- a/res/res_rtp_asterisk.c
+++ b/res/res_rtp_asterisk.c
@@ -5286,14 +5286,18 @@
 	unsigned int lsr_a;
 	unsigned int rtt;
 	double normdevrtt_current;
+	double tmp_double;
+	double dlsr_frac;
+	unsigned int dlsr_sec;
 
 	gettimeofday(&now, NULL);
 	timeval2ntp(now, &msw, &lsw);
 
 	lsr_a = ((msw & 0x0000ffff) << 16) | ((lsw & 0xffff0000) >> 16);
-	rtt = lsr_a - lsr - dlsr;
+	rtt = lsr_a - lsr;
 	rtt_msw = (rtt & 0xffff0000) >> 16;
 	rtt_lsw = (rtt & 0x0000ffff);
+
 	rtt_tv.tv_sec = rtt_msw;
 	/*
 	 * Convert 16.16 fixed point rtt_lsw to usec without
@@ -5309,6 +5313,14 @@
 	 * component in rtt_lsw.
 	 */
 	rtt_tv.tv_usec = (rtt_lsw * 15625) >> 10;
+
+	tmp_double = dlsr / 65536;
+	dlsr_sec = tmp_double;
+	dlsr_frac = tmp_double - dlsr_sec;
+
+	rtt_tv.tv_sec -= dlsr_sec;
+	rtt_tv.tv_usec -= dlsr_frac * 1000000;
+
 	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/10993
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id48b8ba1aba7c08b836ee526bf2619243379015f
Gerrit-Change-Number: 10993
Gerrit-PatchSet: 1
Gerrit-Owner: sungtae kim <pchero21 at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190212/76f66bf9/attachment.html>


More information about the asterisk-code-review mailing list