<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11365">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Joshua Colp: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_rtp_asterisk: Fix sequence number cycling and packet loss count.<br><br>This change fixes two bugs which both resulted in the packet loss<br>count exceeding 65,000.<br><br>The first issue is that the sequence number check to determine if<br>cycling had occurred was using the wrong variable resulting in the<br>check never seeing that cycling has occurred, throwing off the<br>packet loss calculation. It now uses the correct variable.<br><br>The second issue is that the packet loss calculation assumed that<br>the received number of packets in an interval could never exceed<br>the expected number. In practice this isn't true due to delayed<br>or retransmitted packets. The expected will now be updated to<br>the received number if the received exceeds it.<br><br>ASTERISK-28379<br><br>Change-Id: If888ebc194ab69ac3194113a808c414b014ce0f6<br>---<br>M res/res_rtp_asterisk.c<br>1 file changed, 9 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c</span><br><span>index 023273a..c4df6a4 100644</span><br><span>--- a/res/res_rtp_asterisk.c</span><br><span>+++ b/res/res_rtp_asterisk.c</span><br><span>@@ -4126,6 +4126,14 @@</span><br><span> *lost_packets = expected_packets - rtp->rxcount;</span><br><span> expected_interval = expected_packets - rtp->rtcp->expected_prior;</span><br><span> received_interval = rtp->rxcount - rtp->rtcp->received_prior;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (received_interval > expected_interval) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* If we receive some late packets it is possible for the packets</span><br><span style="color: hsl(120, 100%, 40%);">+ * we received in this interval to exceed the number we expected.</span><br><span style="color: hsl(120, 100%, 40%);">+ * We update the expected so that the packet loss calculations</span><br><span style="color: hsl(120, 100%, 40%);">+ * show that no packets are lost.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+ expected_interval = received_interval;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> lost_interval = expected_interval - received_interval;</span><br><span> if (expected_interval == 0 || lost_interval <= 0) {</span><br><span> *fraction_lost = 0;</span><br><span>@@ -6801,7 +6809,7 @@</span><br><span> ast_log(LOG_WARNING, "scheduling RTCP transmission failed.\n");</span><br><span> }</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if ((int)rtp->lastrxseqno - (int)seqno > 100) /* if so it would indicate that the sender cycled; allow for misordering */</span><br><span style="color: hsl(120, 100%, 40%);">+ if ((int)prev_seqno - (int)seqno > 100) /* if so it would indicate that the sender cycled; allow for misordering */</span><br><span> rtp->cycles += RTP_SEQ_MOD;</span><br><span> </span><br><span> /* If we are directly bridged to another instance send the audio directly out,</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11365">change 11365</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/11365"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: If888ebc194ab69ac3194113a808c414b014ce0f6 </div>
<div style="display:none"> Gerrit-Change-Number: 11365 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>