[asterisk-bugs] [JIRA] (ASTERISK-26566) res_rtp_asterisk: RTT miscalculation in RTCP

George Joseph (JIRA) noreply at issues.asterisk.org
Wed Aug 2 10:12:36 CDT 2017


     [ https://issues.asterisk.org/jira/browse/ASTERISK-26566?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

George Joseph updated ASTERISK-26566:
-------------------------------------

    Target Release Version/s: 15.0.0

> res_rtp_asterisk: RTT miscalculation in RTCP
> --------------------------------------------
>
>                 Key: ASTERISK-26566
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-26566
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Resources/res_rtp_asterisk
>    Affects Versions: 13.9.0, 13.11.2
>            Reporter: Hector Royo Concepcion
>      Target Release: 13.14.0, 14.3.0, 15.0.0
>
>
> 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