From 41ff743383d954f2347fb54a6794059b6aa49ec4 Mon Sep 17 00:00:00 2001 From: Xiuchao Wu Date: Thu, 13 Aug 2020 15:12:00 +0100 Subject: [PATCH] tcp: (merges !368) Fix assert in tx-buffer when loss rate high and w/o SACK --- src/internet/model/tcp-socket-base.cc | 1 + src/internet/model/tcp-tx-buffer.cc | 22 +++++++++++++++++++++- src/internet/model/tcp-tx-buffer.h | 13 +++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/internet/model/tcp-socket-base.cc b/src/internet/model/tcp-socket-base.cc index ceae971e2..be2fdda72 100644 --- a/src/internet/model/tcp-socket-base.cc +++ b/src/internet/model/tcp-socket-base.cc @@ -1315,6 +1315,7 @@ TcpSocketBase::DoForwardUp (Ptr packet, const Address &fromAddress, else { m_sackEnabled = false; + m_txBuffer->SetSackEnabled (false); } // When receiving a or we should adapt TS to the other end diff --git a/src/internet/model/tcp-tx-buffer.cc b/src/internet/model/tcp-tx-buffer.cc index 7e897b656..8d0f9925f 100644 --- a/src/internet/model/tcp-tx-buffer.cc +++ b/src/internet/model/tcp-tx-buffer.cc @@ -112,6 +112,18 @@ TcpTxBuffer::SetMaxBufferSize (uint32_t n) m_maxBuffer = n; } +bool +TcpTxBuffer::IsSackEnabled (void) const +{ + return m_sackEnabled; +} + +void +TcpTxBuffer::SetSackEnabled (bool enabled) +{ + m_sackEnabled = enabled; +} + uint32_t TcpTxBuffer::Available (void) const { @@ -1379,7 +1391,15 @@ void TcpTxBuffer::AddRenoSack (void) { NS_LOG_FUNCTION (this); - NS_ASSERT (m_sentList.size () > 1); + + if (m_sackEnabled) + { + NS_ASSERT (m_sentList.size () > 1); + } + else + { + NS_ASSERT (m_sentList.size () > 0); + } m_renoSack = true; diff --git a/src/internet/model/tcp-tx-buffer.h b/src/internet/model/tcp-tx-buffer.h index e92c272e6..e4e6144d8 100644 --- a/src/internet/model/tcp-tx-buffer.h +++ b/src/internet/model/tcp-tx-buffer.h @@ -166,6 +166,18 @@ public: */ void SetMaxBufferSize (uint32_t n); + /** + * \brief check whether SACK is used on the corresponding TCP socket + */ + bool IsSackEnabled (void) const; + + /** + * \brief tell tx-buffer whether SACK is used on this TCP socket + * + * \param enabled whether sack is used + */ + void SetSackEnabled (bool enabled); + /** * \brief Returns the available capacity of this buffer * \returns available capacity in this Tx window @@ -606,6 +618,7 @@ private: uint32_t m_dupAckThresh {0}; //!< Duplicate Ack threshold from TcpSocketBase uint32_t m_segmentSize {0}; //!< Segment size from TcpSocketBase bool m_renoSack {false}; //!< Indicates if AddRenoSack was called + bool m_sackEnabled {true}; //!< Indicates if SACK is enabled on this connection static Callback m_nullCb; //!< Null callback for an item };