Skip to content

Commit

Permalink
[core] Fixed stats counting packets dropped by a group (Haivision#2934).
Browse files Browse the repository at this point in the history
Also fixed m_iAvgPayloadSize initialization.
  • Loading branch information
maxsharabayko committed Apr 26, 2024
1 parent 1cdae55 commit 9e16054
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions srtcore/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ CUDTGroup::CUDTGroup(SRT_GROUP_TYPE gtype)
, m_uOPT_MinStabilityTimeout_us(1000 * CSrtConfig::COMM_DEF_MIN_STABILITY_TIMEOUT_MS)
// -1 = "undefined"; will become defined with first added socket
, m_iMaxPayloadSize(-1)
, m_iAvgPayloadSize(-1)
, m_bSynRecving(true)
, m_bSynSending(true)
, m_bTsbPd(true)
Expand Down Expand Up @@ -2285,6 +2286,19 @@ int CUDTGroup::recv(char* buf, int len, SRT_MSGCTRL& w_mc)
}
fillGroupData((w_mc), w_mc);

// TODO: What if a drop happens before the very first packet was read? Maybe set to ISN?
if (m_RcvBaseSeqNo != SRT_SEQNO_NONE)
{
const int32_t iNumDropped = (CSeqNo(w_mc.pktseq) - CSeqNo(m_RcvBaseSeqNo)) - 1;
if (iNumDropped > 0)
{
m_stats.recvDrop.count(stats::BytesPackets(iNumDropped * static_cast<uint64_t>(avgRcvPacketSize()), iNumDropped));
LOGC(grlog.Warn,
log << "@" << m_GroupID << " GROUP RCV-DROPPED " << iNumDropped << " packet(s): seqno %"
<< m_RcvBaseSeqNo << " to %" << w_mc.pktseq);
}
}

HLOGC(grlog.Debug,
log << "grp/recv: $" << id() << ": Update m_RcvBaseSeqNo: %" << m_RcvBaseSeqNo << " -> %" << w_mc.pktseq);
m_RcvBaseSeqNo = w_mc.pktseq;
Expand Down

0 comments on commit 9e16054

Please sign in to comment.