Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Set ACK position based on RCV buffer first nonread seqno. #2931

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions srtcore/buffer_rcv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,12 @@ CRcvBuffer::PacketInfo CRcvBuffer::getFirstReadablePacketInfo(time_point time_no
return unreadableInfo;
}

int32_t CRcvBuffer::getFirstNonreadSeqNo() const
{
const int offset = offPos(m_iStartPos, m_iFirstNonreadPos);
return CSeqNo::incseq(m_iStartSeqNo, offset);
}

void CRcvBuffer::countBytes(int pkts, int bytes)
{
ScopedLock lock(m_BytesCountLock);
Expand Down
5 changes: 5 additions & 0 deletions srtcore/buffer_rcv.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ class CRcvBuffer

PacketInfo getFirstReadablePacketInfo(time_point time_now) const;

/// @brief Get the sequence number of the first packet that can't be read
/// (either because it is missing, or because it is a part of a bigger message
/// that is not fully available yet).
maxsharabayko marked this conversation as resolved.
Show resolved Hide resolved
int32_t getFirstNonreadSeqNo() const;

/// Get information on packets available to be read.
/// @returns a pair of sequence numbers (first available; first unavailable).
///
Expand Down
22 changes: 22 additions & 0 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8021,6 +8021,27 @@ void srt::CUDT::sendCtrl(UDTMessageType pkttype, const int32_t* lparam, void* rp
// [[using locked(m_RcvBufferLock)]]
bool srt::CUDT::getFirstNoncontSequence(int32_t& w_seq, string& w_log_reason)
{
if (m_config.bTSBPD || !m_config.bMessageAPI)
{
// The getFirstNonreadSeqNo() function retuens the sequence number of the first packet
// that cannot be read. In cases when a message can consist of several data packets,
// an existing packet of partially available message also cannot be read.
// If TSBPD mode is enabled, a message must consist of a single data packet only.
w_seq = m_pRcvBuffer->getFirstNonreadSeqNo();

const int32_t iNextSeqNo = CSeqNo::incseq(m_iRcvCurrSeqNo);
SRT_ASSERT(CSeqNo::seqcmp(w_seq, iNextSeqNo) <= 0);
w_log_reason = iNextSeqNo != w_seq ? "first lost" : "expected next";

if (CSeqNo::seqcmp(w_seq, iNextSeqNo) > 0)
{
LOGC(xtlog.Error, log << "IPE: NONCONT-SEQUENCE: RCV buffer first non-read %" << w_seq << ", RCV latest seqno %" << m_iRcvCurrSeqNo);
w_seq = iNextSeqNo;
}

return true;
}

{
ScopedLock losslock (m_RcvLossLock);
const int32_t seq = m_pRcvLossList->getFirstLostSeq();
Expand Down Expand Up @@ -8073,6 +8094,7 @@ int srt::CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)
// since the last full ACK. It should unblock the sender to proceed further.
const bool bNeedFullAck = (m_bBufferWasFull && getAvailRcvBufferSizeNoLock() > 0);
int32_t ack; // First unacknowledged packet sequence number (acknowledge up to ack).

if (!getFirstNoncontSequence((ack), (reason)))
return nbsent;

Expand Down
Loading