Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
33 changes: 15 additions & 18 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ void srt::CUDT::clearData()
// XXX use some constant for this 16
m_iDeliveryRate = 16;
m_iByteDeliveryRate = 16 * m_iMaxSRTPayloadSize;
m_iAckSeqNo = 0;
m_iAckJournal = 0;
m_tsLastAckTime = steady_clock::now();

// trace information
Expand Down Expand Up @@ -8543,7 +8543,7 @@ int srt::CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)
// than sequence number (it's a "journal" for ACK request-response,
// and starts from 0, unlike sequence, which starts from a random
// number), but still the numbers are from exactly the same domain.
m_iAckSeqNo = CAckNo::incack(m_iAckSeqNo);
m_iAckJournal = CAckNo::incack(m_iAckJournal);
data[ACKD_RCVLASTACK] = m_iRcvLastAck;
data[ACKD_RTT] = m_iSRTT;
data[ACKD_RTTVAR] = m_iRTTVar;
Expand Down Expand Up @@ -8572,12 +8572,12 @@ int srt::CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)
}
// ELSE: leave the buffer with ...UDTBASE size.

ctrlpkt.pack(UMSG_ACK, &m_iAckSeqNo, data, ctrlsz);
ctrlpkt.pack(UMSG_ACK, &m_iAckJournal, data, ctrlsz);
m_tsLastAckTime = steady_clock::now();
}
else
{
ctrlpkt.pack(UMSG_ACK, &m_iAckSeqNo, data, ACKD_FIELD_SIZE * ACKD_TOTAL_SIZE_SMALL);
ctrlpkt.pack(UMSG_ACK, &m_iAckJournal, data, ACKD_FIELD_SIZE * ACKD_TOTAL_SIZE_SMALL);
}
bufflock.unlock();

Expand All @@ -8586,7 +8586,7 @@ int srt::CUDT::sendCtrlAck(CPacket& ctrlpkt, int size)
nbsent = m_pSndQueue->sendto(m_PeerAddr, ctrlpkt, m_SourceAddr);
DebugAck(CONID() + "sendCtrl(UMSG_ACK): ", local_prevack, ack);

m_ACKWindow.store(m_iAckSeqNo, m_iRcvLastAck);
m_ACKWindow.store(m_iAckJournal, m_iRcvLastAck);

enterCS(m_StatsLock);
m_stats.rcvr.sentAck.count(1);
Expand Down Expand Up @@ -8956,19 +8956,21 @@ void srt::CUDT::processCtrlAckAck(const CPacket& ctrlpkt, const time_point& tsAr
int32_t ack = 0;

// Calculate RTT estimate on the receiver side based on ACK/ACKACK pair.
const int rtt = m_ACKWindow.acknowledge(ctrlpkt.getAckSeqNo(), ack, tsArrival);

if (rtt == -1)
int rtt = 0;
const ACKWindow::Status astat = m_ACKWindow.acknowledge(ctrlpkt.getAckSeqNo(), tsArrival, (ack), (rtt));
if (astat != ACKWindow::OK)
{
if (ctrlpkt.getAckSeqNo() > (m_iAckSeqNo - static_cast<int>(ACK_WND_SIZE)) && ctrlpkt.getAckSeqNo() <= m_iAckSeqNo)
if (astat != ACKWindow::OLD) // ignore old - can't measure, but that's not a problem
{
string why;
if (frequentLogAllowed(FREQLOGFA_ACKACK_OUTOFORDER, tsArrival, (why)))
{
LOGC(inlog.Note,
log << CONID() << "ACKACK out of order, skipping RTT calculation "
<< "(ACK number: " << ctrlpkt.getAckSeqNo() << ", last ACK sent: " << m_iAckSeqNo
<< ", RTT (EWMA): " << m_iSRTT << ")." << why);
// For WIPED and ROGUE report this by an error log; this is an unwanted situation.
LOGC(inlog.Error,
log << CONID() << "IPE/EPE: ACK node overwritten when acknowledging "
<< ctrlpkt.getAckSeqNo()
<< (astat == ACKWindow::WIPED ? ": No such node recorded when ACKing"
: ": ROGUE journal value"));
}
#if SRT_ENABLE_FREQUENT_LOG_TRACE
else
Expand All @@ -8977,13 +8979,8 @@ void srt::CUDT::processCtrlAckAck(const CPacket& ctrlpkt, const time_point& tsAr
}
#endif

return;
}

LOGC(inlog.Error,
log << CONID() << "ACK record not found, can't estimate RTT "
<< "(ACK number: " << ctrlpkt.getAckSeqNo() << ", last ACK sent: " << m_iAckSeqNo
<< ", RTT (EWMA): " << m_iSRTT << ")");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ class CUDT
int32_t m_iDebugPrevLastAck;
#endif
int32_t m_iRcvLastAckAck; // (RCV) Latest packet seqno in a sent ACK acknowledged by ACKACK. RcvQTh (sendCtrlAck {r}, processCtrlAckAck {r}, processCtrlAck {r}, connection {w}).
int32_t m_iAckSeqNo; // Last ACK sequence number
int32_t m_iAckJournal; // Last ACK sequence number
sync::atomic<int32_t> m_iRcvCurrSeqNo; // (RCV) Largest received sequence number. RcvQTh, TSBPDTh.
int32_t m_iRcvCurrPhySeqNo; // Same as m_iRcvCurrSeqNo, but physical only (disregarding a filter)
bool m_bBufferWasFull; // Indicate that RX buffer was full last time a ack was sent
Expand Down
Loading
Loading