A Discrete-Event Network Simulator
API
tcp-rx-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_RX_BUFFER_H
22 #define TCP_RX_BUFFER_H
23 
24 #include <map>
25 #include "ns3/traced-value.h"
26 #include "ns3/trace-source-accessor.h"
27 #include "ns3/sequence-number.h"
28 #include "ns3/ptr.h"
29 #include "ns3/tcp-header.h"
30 #include "ns3/tcp-option-sack.h"
31 
32 namespace ns3 {
33 class Packet;
34 
73 class TcpRxBuffer : public Object
74 {
75 public:
80  static TypeId GetTypeId (void);
85  TcpRxBuffer (uint32_t n = 0);
86  virtual ~TcpRxBuffer ();
87 
88  // Accessors
93  SequenceNumber32 NextRxSequence (void) const;
98  SequenceNumber32 MaxRxSequence (void) const;
102  void IncNextRxSequence (void);
107  void SetNextRxSequence (const SequenceNumber32& s);
112  void SetFinSequence (const SequenceNumber32& s);
117  uint32_t MaxBufferSize (void) const;
122  void SetMaxBufferSize (uint32_t s);
127  uint32_t Size (void) const;
132  uint32_t Available () const;
137  bool Finished (void);
138 
150  bool Add (Ptr<Packet> p, TcpHeader const& tcph);
151 
159  Ptr<Packet> Extract (uint32_t maxSize);
160 
170 
176  uint32_t GetSackListSize () const;
177 
182  bool GotFin () const { return m_gotFin; }
183 
184 private:
203  void UpdateSackList (const SequenceNumber32 &head, const SequenceNumber32 &tail);
204 
216  void ClearSackList (const SequenceNumber32 &seq);
217 
219 
221  typedef std::map<SequenceNumber32, Ptr<Packet> >::iterator BufIterator;
224  bool m_gotFin;
225  uint32_t m_size;
226  uint32_t m_maxBuffer;
227  uint32_t m_availBytes;
228  std::map<SequenceNumber32, Ptr<Packet> > m_data;
229 };
230 
231 } //namespace ns3
232 
233 #endif /* TCP_RX_BUFFER_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::TcpRxBuffer::IncNextRxSequence
void IncNextRxSequence(void)
Increment the Next Sequence number.
Definition: tcp-rx-buffer.cc:99
ns3::TcpRxBuffer::ClearSackList
void ClearSackList(const SequenceNumber32 &seq)
Remove old blocks from the sack list.
Definition: tcp-rx-buffer.cc:336
ns3::TcpRxBuffer::m_gotFin
bool m_gotFin
Did I received FIN packet?
Definition: tcp-rx-buffer.h:224
ns3::TcpRxBuffer::UpdateSackList
void UpdateSackList(const SequenceNumber32 &head, const SequenceNumber32 &tail)
Update the sack list, with the block seq starting at the beginning.
Definition: tcp-rx-buffer.cc:239
ns3::TcpRxBuffer::Size
uint32_t Size(void) const
Get the actual buffer occupancy.
Definition: tcp-rx-buffer.cc:87
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::TcpRxBuffer::MaxRxSequence
SequenceNumber32 MaxRxSequence(void) const
Get the lowest sequence number that this TcpRxBuffer cannot accept.
Definition: tcp-rx-buffer.cc:110
ns3::TcpRxBuffer::GetSackListSize
uint32_t GetSackListSize() const
Get the size of Sack list.
Definition: tcp-rx-buffer.cc:231
ns3::TcpRxBuffer::m_finSeq
SequenceNumber32 m_finSeq
Seqnum of the FIN packet.
Definition: tcp-rx-buffer.h:223
ns3::TcpRxBuffer::NextRxSequence
SequenceNumber32 NextRxSequence(void) const
Get Next Rx Sequence number.
Definition: tcp-rx-buffer.cc:63
ns3::TcpRxBuffer::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-rx-buffer.cc:32
ns3::TcpRxBuffer::Add
bool Add(Ptr< Packet > p, TcpHeader const &tcph)
Insert a packet into the buffer and update the availBytes counter to reflect the number of bytes read...
Definition: tcp-rx-buffer.cc:140
ns3::TcpRxBuffer
Rx reordering buffer for TCP.
Definition: tcp-rx-buffer.h:74
ns3::TcpRxBuffer::~TcpRxBuffer
virtual ~TcpRxBuffer()
Definition: tcp-rx-buffer.cc:58
ns3::TcpRxBuffer::SetMaxBufferSize
void SetMaxBufferSize(uint32_t s)
Set the Maximum buffer size.
Definition: tcp-rx-buffer.cc:81
ns3::TcpRxBuffer::MaxBufferSize
uint32_t MaxBufferSize(void) const
Get the Maximum buffer size.
Definition: tcp-rx-buffer.cc:75
ns3::Ptr< Packet >
ns3::TcpRxBuffer::m_sackList
TcpOptionSack::SackList m_sackList
Sack list (updated constantly)
Definition: tcp-rx-buffer.h:218
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::TcpRxBuffer::GotFin
bool GotFin() const
Says if a FIN bit has been received.
Definition: tcp-rx-buffer.h:182
ns3::TcpRxBuffer::Available
uint32_t Available() const
Get the actual number of bytes available to be read.
Definition: tcp-rx-buffer.cc:93
ns3::TcpRxBuffer::m_nextRxSeq
TracedValue< SequenceNumber32 > m_nextRxSeq
Seqnum of the first missing byte in data (RCV.NXT)
Definition: tcp-rx-buffer.h:222
ns3::TcpHeader
Header for the Transmission Control Protocol.
Definition: tcp-header.h:45
ns3::TcpRxBuffer::SetFinSequence
void SetFinSequence(const SequenceNumber32 &s)
Set the FIN Sequence number (i.e., the one closing the connection)
Definition: tcp-rx-buffer.cc:124
ns3::TcpRxBuffer::GetSackList
TcpOptionSack::SackList GetSackList() const
Get the sack list.
Definition: tcp-rx-buffer.cc:358
ns3::TcpRxBuffer::BufIterator
std::map< SequenceNumber32, Ptr< Packet > >::iterator BufIterator
container for data stored in the buffer
Definition: tcp-rx-buffer.h:221
ns3::TcpRxBuffer::m_availBytes
uint32_t m_availBytes
Number of bytes available to read, i.e.
Definition: tcp-rx-buffer.h:227
ns3::TcpRxBuffer::m_maxBuffer
uint32_t m_maxBuffer
Upper bound of the number of data bytes in buffer (RCV.WND)
Definition: tcp-rx-buffer.h:226
ns3::TracedValue< SequenceNumber32 >
ns3::TcpRxBuffer::m_data
std::map< SequenceNumber32, Ptr< Packet > > m_data
Corresponding data (may be null)
Definition: tcp-rx-buffer.h:228
ns3::TcpRxBuffer::Finished
bool Finished(void)
Check if the buffer did receive all the data (and the connection is closed)
Definition: tcp-rx-buffer.cc:134
ns3::TcpRxBuffer::SetNextRxSequence
void SetNextRxSequence(const SequenceNumber32 &s)
Set the Next Sequence number.
Definition: tcp-rx-buffer.cc:69
ns3::TcpRxBuffer::TcpRxBuffer
TcpRxBuffer(uint32_t n=0)
Constructor.
Definition: tcp-rx-buffer.cc:53
ns3::SequenceNumber< uint32_t, int32_t >
ns3::TcpRxBuffer::m_size
uint32_t m_size
Number of total data bytes in the buffer, not necessarily contiguous.
Definition: tcp-rx-buffer.h:225
ns3::TcpRxBuffer::Extract
Ptr< Packet > Extract(uint32_t maxSize)
Extract data from the head of the buffer as indicated by nextRxSeq.
Definition: tcp-rx-buffer.cc:364
sample-rng-plot.n
n
Definition: sample-rng-plot.py:37
ns3::TcpOptionSack::SackList
std::list< SackBlock > SackList
SACK list definition.
Definition: tcp-option-sack.h:60