From 477a0344b6479fb4d7036f1640ed005cc54665bc Mon Sep 17 00:00:00 2001 From: Natale Patriciello Date: Fri, 3 Feb 2017 14:01:56 +0100 Subject: [PATCH] tcp: Added RFC6675 BytesInFlight () [Pipe()] into TcpTxBuffer --- src/internet/model/tcp-tx-buffer.cc | 35 +++++++++++++++++++++++++++++ src/internet/model/tcp-tx-buffer.h | 9 ++++++++ 2 files changed, 44 insertions(+) diff --git a/src/internet/model/tcp-tx-buffer.cc b/src/internet/model/tcp-tx-buffer.cc index 41da143f7..f21afd424 100644 --- a/src/internet/model/tcp-tx-buffer.cc +++ b/src/internet/model/tcp-tx-buffer.cc @@ -828,6 +828,41 @@ TcpTxBuffer::NextSeg (SequenceNumber32 *seq, uint32_t dupThresh, return false; } +uint32_t +TcpTxBuffer::BytesInFlight (uint32_t dupThresh, uint32_t segmentSize) const +{ + PacketList::const_iterator it; + TcpTxItem *item; + uint32_t size = 0; // "pipe" in RFC + SequenceNumber32 beginOfCurrentPkt = m_firstByteSeq; + + // After initializing pipe to zero, the following steps are taken for each + // octet 'S1' in the sequence space between HighACK and HighData that has not + // been SACKed: + for (it = m_sentList.begin (); it != m_sentList.end (); ++it) + { + item = *it; + if (!item->m_sacked) + { + // (a) If IsLost (S1) returns false: Pipe is incremented by 1 octet. + if (!IsLost (beginOfCurrentPkt, it, dupThresh, segmentSize)) + { + size += item->m_packet->GetSize (); + } + // (b) If S1 <= HighRxt: Pipe is incremented by 1 octet. + // (NOTE: we use the m_retrans flag instead of keeping and updating + // another variable). Only if the item is not marked as lost + else if (item->m_retrans && ! item->m_lost) + { + size += item->m_packet->GetSize (); + } + } + beginOfCurrentPkt += item->m_packet->GetSize (); + } + + return size; +} + std::ostream & operator<< (std::ostream & os, TcpTxBuffer const & tcpTxBuf) { diff --git a/src/internet/model/tcp-tx-buffer.h b/src/internet/model/tcp-tx-buffer.h index f70d8dd77..1c3870a40 100644 --- a/src/internet/model/tcp-tx-buffer.h +++ b/src/internet/model/tcp-tx-buffer.h @@ -235,6 +235,15 @@ public: bool NextSeg (SequenceNumber32 *seq, uint32_t dupThresh, uint32_t segmentSize, bool isRecovery) const; + /** + * \brief Return total bytes in flight + * + * The routine follows the "SetPipe" function in RFC 6675 + * + * \returns total bytes in flight + */ + uint32_t BytesInFlight (uint32_t dupThresh, uint32_t segmentSize) const; + private: friend std::ostream & operator<< (std::ostream & os, TcpTxBuffer const & tcpTxBuf);