From 235732f6afc598979b5a8d7ce7f433af1e8d8df2 Mon Sep 17 00:00:00 2001 From: Gauri Prasad Date: Wed, 29 Sep 2021 14:06:47 -0700 Subject: [PATCH] tcp: (fixes #410) Fix TCP Westwood bandwidth estimation bug --- src/internet/model/tcp-westwood.cc | 12 ++++++++++-- src/internet/model/tcp-westwood.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/internet/model/tcp-westwood.cc b/src/internet/model/tcp-westwood.cc index 75cb6d906..1e2734e06 100644 --- a/src/internet/model/tcp-westwood.cc +++ b/src/internet/model/tcp-westwood.cc @@ -70,7 +70,8 @@ TcpWestwood::TcpWestwood (void) : m_lastSampleBW (0), m_lastBW (0), m_ackedSegments (0), - m_IsCount (false) + m_IsCount (false), + m_lastAck (0) { NS_LOG_FUNCTION (this); } @@ -131,8 +132,15 @@ TcpWestwood::EstimateBW (const Time &rtt, Ptr tcb) m_currentBW = m_ackedSegments * tcb->m_segmentSize / rtt.GetSeconds (); - if (m_pType == TcpWestwood::WESTWOODPLUS) + if (m_pType == TcpWestwood::WESTWOOD) { + Time currentAck = Simulator::Now (); + m_currentBW = m_ackedSegments * tcb->m_segmentSize / (currentAck - m_lastAck).GetSeconds (); + m_lastAck = currentAck; + } + else if (m_pType == TcpWestwood::WESTWOODPLUS) + { + m_currentBW = m_ackedSegments * tcb->m_segmentSize / rtt.GetSeconds (); m_IsCount = false; } diff --git a/src/internet/model/tcp-westwood.h b/src/internet/model/tcp-westwood.h index 154e141ca..39a5b9be6 100644 --- a/src/internet/model/tcp-westwood.h +++ b/src/internet/model/tcp-westwood.h @@ -133,6 +133,7 @@ protected: uint32_t m_ackedSegments; //!< The number of segments ACKed between RTTs bool m_IsCount; //!< Start keeping track of m_ackedSegments for Westwood+ if TRUE EventId m_bwEstimateEvent; //!< The BW estimation event for Westwood+ + Time m_lastAck; //!< The last ACK time };