[asterisk-bugs] [JIRA] (ASTERISK-26566) RTCP miscalculation on res_rtp_asterisk.c

Asterisk Team (JIRA) noreply at issues.asterisk.org
Tue Nov 8 07:17:10 CST 2016


    [ https://issues.asterisk.org/jira/browse/ASTERISK-26566?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=233491#comment-233491 ] 

Asterisk Team commented on ASTERISK-26566:
------------------------------------------

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

> RTCP miscalculation on res_rtp_asterisk.c
> -----------------------------------------
>
>                 Key: ASTERISK-26566
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-26566
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>    Affects Versions: 13.9.0, 13.11.2
>            Reporter: Hector Royo Concepcion
>
> I have an Asterisk, with PJSIP. We are saving the RTCP stats to a CDR database, and I've found that RTT values are mostly wrong, showing values over 4.000 seconds. 
> I've been reading how the RTT is calculated on the RTCP RFC, and I think that the code on res_rtp_asterisk.c is miscalculating the LSW of the RTT.
> {quote}
> rtt_lsw = (rtt & 0x0000ffff) << 16; // This will cause overflow
> rtt_tv.tv_usec = ((rtt_lsw << 6) / 3650) - (rtt_lsw >> 12) - (rtt_lsw >> 8); // This will lose precision
> rtp->rtcp->rtt = (double)rtt_tv.tv_sec + (double)(rtt_tv.tv_usec/1000000.);
> {quote}
> This lines above can easily overflow the LSW. Since it is a *fixed point* value, I think it should be calculated like this (probably not the most efficient way):
> {quote}
> rtt_lsw = (rtt & 0x0000ffff);               // No shift!!
> rtt_tv.tv_usec = (rtt_lsw * 999985/65535);  // Better precision
> rtp->rtcp->rtt = (double)rtt_tv.tv_sec + (double)(rtt_tv.tv_usec/1000000.);
> {quote}
> Using this version of the code, values that were 4000~ seconds are now 60-70ms. This new values matches the RTT values I'm getting from Wireshark.
> Values 65535 and 999985 came from:
> {quote}
> 655535 = 0xffff = 0b1111111111111111
> 999985 = (2⁻¹ + 2⁻² + ... +2⁻¹⁵ + 2⁻¹⁶)*1000000
> {quote}



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list