Skip to content

Commit

Permalink
tcp: (fixes #1126) Fix bytesAcked calculation in ProcessAck
Browse files Browse the repository at this point in the history
* Updated the `bytesAcked` assignment to use `currentDelivered` instead
of calculating it from `ackNumber` and `oldHeadSequence` for better
accuracy in acknowledgment handling.
* Added `currentDelivered` and `oldHeadSequence` to the NS_LOG_FUNCTION
call for improved logging and debugging.
  • Loading branch information
Vivek-anand-jain committed Sep 25, 2024
1 parent c3d3d81 commit b5d00ca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/internet/model/tcp-socket-base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,7 @@ TcpSocketBase::ProcessAck(const SequenceNumber32& ackNumber,
uint32_t currentDelivered,
const SequenceNumber32& oldHeadSequence)
{
NS_LOG_FUNCTION(this << ackNumber << scoreboardUpdated);
NS_LOG_FUNCTION(this << ackNumber << scoreboardUpdated << currentDelivered << oldHeadSequence);
// RFC 6675, Section 5, 2nd paragraph:
// If the incoming ACK is a cumulative acknowledgment, the TCP MUST
// reset DupAcks to zero.
Expand Down Expand Up @@ -2030,7 +2030,7 @@ TcpSocketBase::ProcessAck(const SequenceNumber32& ackNumber,
{
// Please remember that, with SACK, we can enter here even if we
// received a dupack.
bytesAcked = ackNumber - oldHeadSequence;
bytesAcked = currentDelivered;
uint32_t segsAcked = bytesAcked / m_tcb->m_segmentSize;
m_bytesAckedNotProcessed += bytesAcked % m_tcb->m_segmentSize;
bytesAcked -= bytesAcked % m_tcb->m_segmentSize;
Expand All @@ -2041,6 +2041,8 @@ TcpSocketBase::ProcessAck(const SequenceNumber32& ackNumber,
bytesAcked += m_tcb->m_segmentSize;
m_bytesAckedNotProcessed -= m_tcb->m_segmentSize;
}
NS_LOG_DEBUG("Set segsAcked: " << segsAcked
<< " based on currentDelivered: " << currentDelivered);

// Dupack count is reset to eventually fast-retransmit after 3 dupacks.
// Any SACK-ed segment will be cleaned up by DiscardUpTo.
Expand Down

0 comments on commit b5d00ca

Please sign in to comment.