A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tcp-tx-buffer.h
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:
43  static TypeId GetTypeId (void);
44  TcpTxBuffer (uint32_t n = 0);
45  virtual ~TcpTxBuffer (void);
46 
47  // Accessors
48 
52  SequenceNumber32 HeadSequence (void) const;
53 
57  SequenceNumber32 TailSequence (void) const;
58 
62  uint32_t Size (void) const;
63 
67  uint32_t MaxBufferSize (void) const;
68 
72  void SetMaxBufferSize (uint32_t n);
73 
77  uint32_t Available (void) const;
78 
85  bool Add (Ptr<Packet> p);
86 
90  uint32_t SizeFromSequence (const SequenceNumber32& seq) const;
91 
95  Ptr<Packet> CopyFromSequence (uint32_t numBytes, const SequenceNumber32& seq);
96 
101  void SetHeadSequence (const SequenceNumber32& seq);
102 
108  void DiscardUpTo (const SequenceNumber32& seq);
109 
110 private:
111  typedef std::list<Ptr<Packet> >::iterator BufIterator;
112 
113  TracedValue<SequenceNumber32> m_firstByteSeq; //< Sequence number of the first byte in data (SND.UNA)
114  uint32_t m_size; //< Number of data bytes
115  uint32_t m_maxBuffer; //< Max number of data bytes in buffer (SND.WND)
116  std::list<Ptr<Packet> > m_data; //< Corresponding data (may be null)
117 };
118 
119 } // namepsace ns3
120 
121 #endif /* TCP_TX_BUFFER_H */
uint32_t Size(void) const
void DiscardUpTo(const SequenceNumber32 &seq)
uint32_t SizeFromSequence(const SequenceNumber32 &seq) const
SequenceNumber32 HeadSequence(void) const
uint32_t MaxBufferSize(void) const
class for keeping the data sent by the application to the TCP socket, i.e. the sending buffer...
Definition: tcp-tx-buffer.h:40
void SetMaxBufferSize(uint32_t n)
uint32_t Available(void) const
Generic "sequence number" class.
bool Add(Ptr< Packet > p)
a base class which provides memory management and object aggregation
Definition: object.h:63
a unique identifier for an interface.
Definition: type-id.h:44
SequenceNumber32 TailSequence(void) const
void SetHeadSequence(const SequenceNumber32 &seq)
Ptr< Packet > CopyFromSequence(uint32_t numBytes, const SequenceNumber32 &seq)