A Discrete-Event Network Simulator
API
pending-data.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 //
3 // Copyright (c) 2006 Georgia Tech Research Corporation
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License version 2 as
7 // published by the Free Software Foundation;
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 //
18 // Author: Rajib Bhattacharjea<raj.b@gatech.edu>
19 //
20 
21 // Georgia Tech Network Simulator - Data Descriptors
22 // George F. Riley. Georgia Tech, Spring 2002
23 
24 #ifndef PENDING_DATA_H
25 #define PENDING_DATA_H
26 
27 #include "ns3/packet.h"
28 #include "pending-data.h"
29 #include "ns3/sequence-number.h"
30 
31 #include "ns3/ptr.h"
32 namespace ns3
33 {
34 class Packet;
35 
41 class PendingData {
42 public:
43  PendingData ();
51  PendingData (uint32_t s, uint8_t* d = NULL, uint32_t msg = 0, uint32_t resp = 0);
56  PendingData (const std::string& s); // Construct from string
57 
62  PendingData (const PendingData& o); // Copy constructor
63  virtual ~PendingData (); // Destructor
64 
69  uint32_t Size () const { return size; }
70 
74  virtual void Clear ();
75 
81  virtual void Add (uint32_t s, const uint8_t* d = 0); //
86  virtual void Add (Ptr<Packet> p);
106  virtual uint32_t SizeFromSeq (const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset);
107  // Inquire available data from offset
112  virtual uint32_t SizeFromOffset (uint32_t offset);
113  // Available size from sequence difference
122  virtual uint32_t OffsetFromSeq (const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset);
123 
130  virtual Ptr<Packet> CopyFromOffset (uint32_t s, uint32_t o); // Size, offset, ret packet
140  virtual Ptr<Packet> CopyFromSeq (uint32_t s, const SequenceNumber32& f, const SequenceNumber32& o);
150  virtual uint32_t RemoveToSeq (const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset);
151 
156  PendingData* Copy () const;
164  PendingData* CopyS (uint32_t s); // Copy
173  PendingData* CopySD (uint32_t s, uint8_t* d);
174 public:
175  uint32_t size;
176  std::vector<Ptr<Packet> > data;
177  // The next two fields allow simulated applications to exchange some info
178  uint32_t msgSize;
179  uint32_t responseSize;
180 };
181 
182 } //namespace ns3
183 
184 #endif /* PENDING_DATA_H */
virtual Ptr< Packet > CopyFromSeq(uint32_t s, const SequenceNumber32 &f, const SequenceNumber32 &o)
Copy data starting from a give offset.
PendingData * CopySD(uint32_t s, uint8_t *d)
Create a copy of self with new size, new data.
Definition: pending-data.cc:90
uint32_t responseSize
Size of response requested.
Definition: pending-data.h:179
virtual void Add(uint32_t s, const uint8_t *d=0)
Add some data to end.
virtual uint32_t RemoveToSeq(const SequenceNumber32 &seqFront, const SequenceNumber32 &seqOffset)
Permits object to clear any pending data between seqFront and seqOffset - 1).
virtual uint32_t SizeFromOffset(uint32_t offset)
PendingData * Copy() const
Create a copy of self.
Definition: pending-data.cc:78
PendingData * CopyS(uint32_t s)
Create a copy of self with new size.
Definition: pending-data.cc:84
virtual ~PendingData()
Definition: pending-data.cc:73
class for managing I/O between applications and TCP
Definition: pending-data.h:41
virtual void Clear()
Remove all associated data.
Definition: pending-data.cc:96
uint32_t size
Number of data bytes.
Definition: pending-data.h:175
double f(double x, void *params)
Definition: 80211b.c:70
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual Ptr< Packet > CopyFromOffset(uint32_t s, uint32_t o)
Copy data starting from a give offset.
uint32_t Size() const
Returns the size of the pending data.
Definition: pending-data.h:69
uint32_t msgSize
Total size of message.
Definition: pending-data.h:178
virtual uint32_t SizeFromSeq(const SequenceNumber32 &seqFront, const SequenceNumber32 &seqOffset)
This method returns the number of bytes in the PendingData buffer beyond the sequence number specifie...
virtual uint32_t OffsetFromSeq(const SequenceNumber32 &seqFront, const SequenceNumber32 &seqOffset)
Subtracts seqFront from seqOffset after enforcing seqFront is less than seqOffset.
std::vector< Ptr< Packet > > data
Corresponding data (may be null)
Definition: pending-data.h:176