From fbe0786cd96bbbf6c12ea2361ea401e72248eabf Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Wed, 16 Nov 2022 17:09:48 -0800 Subject: [PATCH] internet: Remove obsolete PendingData model --- src/internet/CMakeLists.txt | 1 - src/internet/model/pending-data.cc | 270 ----------------------------- src/internet/model/pending-data.h | 194 --------------------- 3 files changed, 465 deletions(-) delete mode 100644 src/internet/model/pending-data.cc delete mode 100644 src/internet/model/pending-data.h diff --git a/src/internet/CMakeLists.txt b/src/internet/CMakeLists.txt index b4b294417..bd2840e7c 100644 --- a/src/internet/CMakeLists.txt +++ b/src/internet/CMakeLists.txt @@ -79,7 +79,6 @@ set(source_files model/ipv6.cc model/loopback-net-device.cc model/ndisc-cache.cc - model/pending-data.cc model/rip-header.cc model/rip.cc model/ripng-header.cc diff --git a/src/internet/model/pending-data.cc b/src/internet/model/pending-data.cc deleted file mode 100644 index 437414000..000000000 --- a/src/internet/model/pending-data.cc +++ /dev/null @@ -1,270 +0,0 @@ -// -// Copyright (c) 2006 Georgia Tech Research Corporation -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as -// published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// Author: Rajib Bhattacharjea -// - -// This is a port of Data PDU Headers from: -// Georgia Tech Network Simulator -// George F. Riley. Georgia Tech, Spring 2002 - -#include "pending-data.h" - -#include "ns3/fatal-error.h" -#include "ns3/log.h" - -#include -#include -#include - -namespace ns3 -{ - -NS_LOG_COMPONENT_DEFINE("PendingData"); - -PendingData::PendingData() - : size(0), - data(0), - msgSize(0), - responseSize(0) -{ - NS_LOG_FUNCTION(this); -} - -PendingData::PendingData(uint32_t s, uint8_t* d, uint32_t msg, uint32_t resp) - : size(s), - data(0), - msgSize(msg), - responseSize(resp) -{ - NS_LOG_FUNCTION(this << s); - if (d) - { - data.push_back(Create(d, size)); - } -} - -PendingData::PendingData(const std::string& s) - : size(s.length() + 1), - data(0), - msgSize(0), - responseSize(0) -{ - NS_LOG_FUNCTION(this << s.length() + 1); - data.push_back(Create((uint8_t*)s.c_str(), size)); -} - -PendingData::PendingData(const PendingData& c) - : size(c.Size()), - data(c.data), - msgSize(c.msgSize), - responseSize(c.responseSize) -{ - NS_LOG_FUNCTION(this << c.Size()); -} - -PendingData::~PendingData() -{ - NS_LOG_FUNCTION(this); -} - -PendingData* -PendingData::Copy() const -{ - NS_LOG_FUNCTION(this); - return new PendingData(*this); -}; - -PendingData* -PendingData::CopyS(uint32_t s) -{ // Copy, but with new size (assumes no associated data); - NS_LOG_FUNCTION(this << s); - return new PendingData(s, nullptr, msgSize, responseSize); -} - -PendingData* -PendingData::CopySD(uint32_t s, uint8_t* d) -{ // Copy, but with new size (assumes no associated data); - NS_LOG_FUNCTION(this << s); - return new PendingData(s, d, msgSize, responseSize); -} - -void -PendingData::Clear() -{ // Remove all pending data - NS_LOG_FUNCTION(this); - data.clear(); - size = 0; -} - -void -PendingData::Add(uint32_t s, const uint8_t* d) -{ - NS_LOG_FUNCTION(this << s); - data.push_back(Create(d, s)); - size += s; -} - -void -PendingData::Add(Ptr p) -{ - NS_LOG_FUNCTION(this); - data.push_back(p); - size += p->GetSize(); -} - -uint32_t -PendingData::SizeFromSeq(const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset) -{ - NS_LOG_FUNCTION(this << seqFront << seqOffset); - uint32_t o1 = OffsetFromSeq(seqFront, seqOffset); // Offset to start of unused data - return SizeFromOffset(o1); // Amount of data after offset -} - -uint32_t -PendingData::SizeFromOffset(uint32_t offset) -{ // Find out how much data is available from offset - NS_LOG_FUNCTION(this << offset); - /// \todo should this return zero, or error out? - if (offset > size) - { - return 0; // No data at requested offset - } - return size - offset; // Available data after offset -} - -uint32_t -PendingData::OffsetFromSeq(const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset) -{ // f is the first sequence number in this data, o is offset sequence - NS_LOG_FUNCTION(this << seqFront << seqOffset); - if (seqOffset < seqFront) - { - return 0; // HuH? Shouldn't happen - } - return seqOffset - seqFront; -} - -Ptr -PendingData::CopyFromOffset(uint32_t s, uint32_t o) -{ // Make a copy of data from starting position "o" for "s" bytes - // Return NULL if results in zero length data - NS_LOG_FUNCTION(this << s << o); - uint32_t s1 = std::min(s, SizeFromOffset(o)); // Insure not beyond end of data - if (s1 == 0) - { - return Create(); // No data requested - } - if (data.size() != 0) - { // Actual data exists, make copy and return it - uint32_t count = 0; - std::vector>::size_type begin = 0; - bool beginFound = false; - std::vector>::size_type end = 0; - Ptr outPacket; - Ptr endFragment; - for (std::vector>::size_type i = 0; i < data.size(); ++i) - { - count += data[i]->GetSize(); - if (!beginFound) - { - if (count > o) - { - if (count >= o + s1) // then just copy within this packet - { - Ptr toFragment = data[i]; - uint32_t packetStart = count - toFragment->GetSize(); - uint32_t packetOffset = o - packetStart; - outPacket = toFragment->CreateFragment(packetOffset, s1); - return outPacket; - } - begin = i; - beginFound = true; - Ptr toFragment = data[begin]; - uint32_t packetStart = count - toFragment->GetSize(); - uint32_t packetOffset = o - packetStart; - uint32_t fragmentLength = count - o; - outPacket = toFragment->CreateFragment(packetOffset, fragmentLength); - } - } - else - { - if (count >= o + s1) - { - end = i; - Ptr toFragment = data[end]; - uint32_t packetStart = count - toFragment->GetSize(); - uint32_t fragmentLength = o + s1 - packetStart; - endFragment = toFragment->CreateFragment(0, fragmentLength); - break; - } - } - } - for (std::vector>::size_type i = begin + 1; i < end; ++i) - { - outPacket->AddAtEnd(data[i]); - } - if (endFragment) - { - outPacket->AddAtEnd(endFragment); - } - NS_ASSERT(outPacket->GetSize() == s1); - return outPacket; - } - else - { // No actual data, just return dummy-data packet of correct size - return Create(s1); - } -} - -Ptr -PendingData::CopyFromSeq(uint32_t s, const SequenceNumber32& f, const SequenceNumber32& o) -{ - NS_LOG_FUNCTION(this << s << f << o); - return CopyFromOffset(s, OffsetFromSeq(f, o)); -} - -uint32_t -PendingData::RemoveToSeq(const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset) -{ - NS_LOG_FUNCTION(this << seqFront << seqOffset); - uint32_t count = OffsetFromSeq(seqFront, seqOffset); - NS_ASSERT_MSG(count <= size, "Trying to remove more data than in the buffer"); - if (count == size) - { - Clear(); - return size; - } - // Remove whole packets, if possible, from the front of the data - // Do not perform buffer manipulations within packet; if a whole packet - // cannot be removed, leave it alone - std::vector>::iterator endI = data.begin(); - uint32_t current = 0; - // Any packet whose data has been completely acked can be removed - for (std::vector>::iterator dataI = data.begin(); dataI < data.end(); dataI++) - { - if (current + (*dataI)->GetSize() > count) - { - break; - } - current += (*dataI)->GetSize(); - ++endI; - } - data.erase(data.begin(), endI); - size -= current; - return current; -} - -} // namespace ns3 diff --git a/src/internet/model/pending-data.h b/src/internet/model/pending-data.h deleted file mode 100644 index 3bdf3544c..000000000 --- a/src/internet/model/pending-data.h +++ /dev/null @@ -1,194 +0,0 @@ -// -// Copyright (c) 2006 Georgia Tech Research Corporation -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2 as -// published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// Author: Rajib Bhattacharjea -// - -// Georgia Tech Network Simulator - Data Descriptors -// George F. Riley. Georgia Tech, Spring 2002 - -#ifndef PENDING_DATA_H -#define PENDING_DATA_H - -#include "pending-data.h" - -#include "ns3/packet.h" -#include "ns3/ptr.h" -#include "ns3/sequence-number.h" - -namespace ns3 -{ -class Packet; - -/** - * \ingroup tcp - * - * \brief class for managing I/O between applications and TCP - */ -class PendingData -{ - public: - PendingData(); - /** - * Constructor - * \param s size - * \param d data - * \param msg message size - * \param resp response size - */ - PendingData(uint32_t s, uint8_t* d = nullptr, uint32_t msg = 0, uint32_t resp = 0); - /** - * Constructor from string - * \param s string - */ - PendingData(const std::string& s); // Construct from string - - /** - * Copy constructor - * \param o object to copy - */ - PendingData(const PendingData& o); // Copy constructor - virtual ~PendingData(); // Destructor - - /** - * Returns the size of the pending data - * \returns size of pending data - */ - uint32_t Size() const - { - return size; - } - - /** - * \brief Remove all associated data - */ - virtual void Clear(); - - /** - * \brief Add some data to end - * \param s the data size. - * \param d the data to store. - */ - virtual void Add(uint32_t s, const uint8_t* d = nullptr); // - /** - * \brief Add some data to end - * \param p packet containing the data. - */ - virtual void Add(Ptr p); - /** - * This method returns the number of bytes in the PendingData buffer - * beyond the sequence number specified by seqOffset. - * - * The variables seqFront and seqOffset correspond to a sequence number - * space in use by the user. What is significant in this method is the - * difference between them; i.e. the quantity (seqOffset - seqFront). - * This difference is subtracted from Size(), yielding the number of - * bytes beyond seqOffset, from the user perspective, in the PendingData - * buffer. - * - * If the first number specified is not a sequence number that corresponds - * to the first data byte in the PendingData buffer, the computation - * returned will be in error. - * - * \return number of bytes - * \param seqFront sequence number of assumed first byte in the PendingData - * \param seqOffset sequence number of offset - */ - virtual uint32_t SizeFromSeq(const SequenceNumber32& seqFront, - const SequenceNumber32& seqOffset); - // Inquire available data from offset - /** - * \return number of bytes in the data buffer beyond the offset specified - * \param offset offset (from zero) - */ - virtual uint32_t SizeFromOffset(uint32_t offset); - // Available size from sequence difference - /** - * Subtracts seqFront from seqOffset after enforcing seqFront is less - * than seqOffset - * - * \param seqFront sequence number to be subtracted from seqOffset - * \param seqOffset higher sequence number - * \return seqOffset-seqFront - */ - virtual uint32_t OffsetFromSeq(const SequenceNumber32& seqFront, - const SequenceNumber32& seqOffset); - - /** - * \brief Copy data starting from a give offset - * \param s size of data to copy - * \param o offset - * \returns a packet containing the requested data - */ - virtual Ptr CopyFromOffset(uint32_t s, uint32_t o); // Size, offset, ret packet - /** - * \brief Copy data starting from a give offset - * \param s size of data to copy - * \param f Front sequence - * \param o Offset sequence - * - * \see PendingData::OffsetFromSeq() - * \returns a packet containing the requested data - */ - virtual Ptr CopyFromSeq(uint32_t s, - const SequenceNumber32& f, - const SequenceNumber32& o); - /** - * Permits object to clear any pending data between seqFront and - * seqOffset - 1). Callers should check the return value to determine - * whether any data was removed from the front. - * - * \param seqFront sequence number to start to try to remove from - * \param seqOffset first sequence number in buffer that should be retained - * \return number of bytes from the front that were removed from the buffer - */ - virtual uint32_t RemoveToSeq(const SequenceNumber32& seqFront, - const SequenceNumber32& seqOffset); - - /** - * \brief Create a copy of self - * \returns copy of pending data - */ - PendingData* Copy() const; - /** - * \brief Create a copy of self with new size - * - * Assumes no associated data - * \param s new size - * \returns copy of pending data - */ - PendingData* CopyS(uint32_t s); // Copy - /** - * \brief Create a copy of self with new size, new data - * - * Assumes no associated data - * \param s new size - * \param d new data - * \returns copy of pending data - */ - PendingData* CopySD(uint32_t s, uint8_t* d); - - public: - uint32_t size; //!< Number of data bytes - std::vector> data; //!< Corresponding data (may be null) - // The next two fields allow simulated applications to exchange some info - uint32_t msgSize; //!< Total size of message - uint32_t responseSize; //!< Size of response requested -}; - -} // namespace ns3 - -#endif /* PENDING_DATA_H */