00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 // 00003 // Copyright (c) 2006 Georgia Tech Research Corporation 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License version 2 as 00007 // published by the Free Software Foundation; 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 // 00018 // Author: Rajib Bhattacharjea<raj.b@gatech.edu> 00019 // 00020 00021 // Georgia Tech Network Simulator - Data Descriptors 00022 // George F. Riley. Georgia Tech, Spring 2002 00023 00024 #ifndef __datapdu_h__ 00025 #define __datapdu_h__ 00026 00027 #include "ns3/packet.h" 00028 #include "pending-data.h" 00029 #include "sequence-number.h" 00030 00031 #include "ns3/ptr.h" 00032 namespace ns3 00033 { 00034 class Packet; 00035 00036 /** 00037 * \ingroup tcp 00038 * 00039 * \brief class for managing I/O between applications and TCP 00040 */ 00041 class PendingData { 00042 public: 00043 PendingData (); 00044 PendingData (uint32_t s, uint8_t* d = NULL, uint32_t msg = 0, uint32_t resp = 0); 00045 PendingData (const std::string&); // Construct from string 00046 PendingData (uint8_t*, uint32_t&, Packet*); // Construct from serialized buffer 00047 PendingData (const PendingData&); // Copy constructor 00048 virtual ~PendingData (); // Destructor 00049 uint32_t Size () const { return size;} 00050 // Serialization 00051 uint32_t SSize (); // Size needed for serialization 00052 uint8_t* Serialize (uint8_t*, uint32_t&); // Serialize to a buffer 00053 uint8_t* Construct (uint8_t*, uint32_t&); // Construct from buffer 00054 virtual void Clear ();// Remove all associated data 00055 virtual void Add (uint32_t s, const uint8_t* d = 0);// Add some data to end 00056 virtual void Add (Ptr<Packet> p); 00057 // Inquire available data from (f,o) sequence pair 00058 virtual uint32_t SizeFromSeq (const SequenceNumber&, const SequenceNumber&); 00059 // Inquire available data from offset 00060 virtual uint32_t SizeFromOffset (uint32_t); 00061 // Available size from sequence difference 00062 virtual uint32_t OffsetFromSeq (const SequenceNumber&, const SequenceNumber&); 00063 virtual Ptr<Packet> CopyFromOffset (uint32_t, uint32_t); // Size, offset, ret packet 00064 // Copy data, size, offset specified by sequence difference 00065 virtual Ptr<Packet> CopyFromSeq (uint32_t, const SequenceNumber&, const SequenceNumber&); 00066 PendingData* Copy () const; // Create a copy of this header 00067 PendingData* CopyS (uint32_t); // Copy with new size 00068 PendingData* CopySD (uint32_t, uint8_t*); // Copy with new size, new data 00069 public: 00070 uint32_t size; // Number of data bytes 00071 std::vector<Ptr<Packet> > data; // Corresponding data (may be null) 00072 // The next two fields allow simulated applications to exchange some info 00073 uint32_t msgSize; // Total size of message 00074 uint32_t responseSize;// Size of response requested 00075 }; 00076 00077 }//namepsace ns3 00078 #endif 00079