A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
tcp-tx-buffer.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2010 Adrian Sai-wah Tam
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: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com>
19  */
20 
21 #ifndef TCP_TX_BUFFER_H
22 #define TCP_TX_BUFFER_H
23 
24 #include <list>
25 #include "ns3/traced-value.h"
26 #include "ns3/trace-source-accessor.h"
27 #include "ns3/object.h"
28 #include "ns3/sequence-number.h"
29 #include "ns3/ptr.h"
30 
31 namespace ns3 {
32 class Packet;
33 
40 class TcpTxBuffer : public Object
41 {
42 public:
47  static TypeId GetTypeId (void);
52  TcpTxBuffer (uint32_t n = 0);
53  virtual ~TcpTxBuffer (void);
54 
55  // Accessors
56 
61  SequenceNumber32 HeadSequence (void) const;
62 
67  SequenceNumber32 TailSequence (void) const;
68 
73  uint32_t Size (void) const;
74 
79  uint32_t MaxBufferSize (void) const;
80 
85  void SetMaxBufferSize (uint32_t n);
86 
91  uint32_t Available (void) const;
92 
99  bool Add (Ptr<Packet> p);
100 
106  uint32_t SizeFromSequence (const SequenceNumber32& seq) const;
107 
114  Ptr<Packet> CopyFromSequence (uint32_t numBytes, const SequenceNumber32& seq);
115 
121  void SetHeadSequence (const SequenceNumber32& seq);
122 
128  void DiscardUpTo (const SequenceNumber32& seq);
129 
130 private:
132  typedef std::list<Ptr<Packet> >::iterator BufIterator;
133 
135  uint32_t m_size;
136  uint32_t m_maxBuffer;
137  std::list<Ptr<Packet> > m_data;
138 };
139 
140 } // namepsace ns3
141 
142 #endif /* TCP_TX_BUFFER_H */
uint32_t Size(void) const
Returns total number of bytes in this Tx buffer.
void DiscardUpTo(const SequenceNumber32 &seq)
Discard data up to but not including this sequence number.
uint32_t SizeFromSequence(const SequenceNumber32 &seq) const
Returns the number of bytes from the buffer in the range [seq, tailSequence)
SequenceNumber32 HeadSequence(void) const
Returns the first byte's sequence number.
uint32_t MaxBufferSize(void) const
Returns the Tx window size.
TracedValue< SequenceNumber32 > m_firstByteSeq
Sequence number of the first byte in data (SND.UNA)
uint32_t m_size
Number of data bytes.
class for keeping the data sent by the application to the TCP socket, i.e.
Definition: tcp-tx-buffer.h:40
void SetMaxBufferSize(uint32_t n)
Set the Tx window size.
uint32_t Available(void) const
Returns the available capacity in this Tx window.
Generic "sequence number" class.
bool Add(Ptr< Packet > p)
Append a data packet to the end of the buffer.
static TypeId GetTypeId(void)
Get the type ID.
uint32_t m_maxBuffer
Max number of data bytes in buffer (SND.WND)
a base class which provides memory management and object aggregation
Definition: object.h:63
TcpTxBuffer(uint32_t n=0)
Constructor.
virtual ~TcpTxBuffer(void)
a unique identifier for an interface.
Definition: type-id.h:49
std::list< Ptr< Packet > >::iterator BufIterator
container for data stored in the buffer
SequenceNumber32 TailSequence(void) const
Returns the last byte's sequence number + 1.
std::list< Ptr< Packet > > m_data
Corresponding data (may be null)
void SetHeadSequence(const SequenceNumber32 &seq)
Set the m_firstByteSeq to seq.
Ptr< Packet > CopyFromSequence(uint32_t numBytes, const SequenceNumber32 &seq)
Copy data of size numBytes into a packet, data from the range [seq, seq+numBytes) ...