A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
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  */
21 #ifndef TCP_RX_BUFFER_H
22 #define TCP_RX_BUFFER_H
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"
31 namespace ns3 {
32 class Packet;
40 class TcpRxBuffer : public Object
41 {
42 public:
47  static TypeId GetTypeId (void);
52  TcpRxBuffer (uint32_t n = 0);
53  virtual ~TcpRxBuffer ();
55  // Accessors
60  SequenceNumber32 NextRxSequence (void) const;
65  SequenceNumber32 MaxRxSequence (void) const;
69  void IncNextRxSequence (void);
74  void SetNextRxSequence (const SequenceNumber32& s);
79  void SetFinSequence (const SequenceNumber32& s);
84  uint32_t MaxBufferSize (void) const;
89  void SetMaxBufferSize (uint32_t s);
94  uint32_t Size (void) const;
99  uint32_t Available () const;
104  bool Finished (void);
117  bool Add (Ptr<Packet> p, TcpHeader const& tcph);
126  Ptr<Packet> Extract (uint32_t maxSize);
127 public:
129  typedef std::map<SequenceNumber32, Ptr<Packet> >::iterator BufIterator;
132  bool m_gotFin;
133  uint32_t m_size;
134  uint32_t m_maxBuffer;
135  uint32_t m_availBytes;
136  std::map<SequenceNumber32, Ptr<Packet> > m_data;
137 };
139 } //namepsace ns3
141 #endif /* TCP_RX_BUFFER_H */
uint32_t m_availBytes
Number of bytes available to read, i.e.
uint32_t m_maxBuffer
Upper bound of the number of data bytes in buffer (RCV.WND)
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...
TracedValue< SequenceNumber32 > m_nextRxSeq
Seqnum of the first missing byte in data (RCV.NXT)
uint32_t Available() const
Get the actual number of bytes available to be read.
void SetFinSequence(const SequenceNumber32 &s)
Set the FIN Sequence number (i.e., the one closing the connection)
SequenceNumber32 NextRxSequence(void) const
Get Next Rx Sequence number.
SequenceNumber32 MaxRxSequence(void) const
Get the lowest sequence number that this TcpRxBuffer cannot accept.
Ptr< SampleEmitter > s
void IncNextRxSequence(void)
Increment the Next Sequence number.
bool m_gotFin
Did I received FIN packet?
class for the reordering buffer that keeps the data from lower layer, i.e.
Definition: tcp-rx-buffer.h:40
void SetNextRxSequence(const SequenceNumber32 &s)
Set the Next Sequence number.
void SetMaxBufferSize(uint32_t s)
Set the Maximum buffer size.
TcpRxBuffer(uint32_t n=0)
SequenceNumber32 m_finSeq
Seqnum of the FIN packet.
Ptr< Packet > Extract(uint32_t maxSize)
Extract data from the head of the buffer as indicated by nextRxSeq.
Header for the Transmission Control Protocol.
Definition: tcp-header.h:43
std::map< SequenceNumber32, Ptr< Packet > > m_data
Corresponding data (may be null)
uint32_t MaxBufferSize(void) const
Get the Maximum buffer size.
uint32_t m_size
Number of total data bytes in the buffer, not necessarily contiguous.
static TypeId GetTypeId(void)
Get the type ID.
a base class which provides memory management and object aggregation
Definition: object.h:64
uint32_t Size(void) const
Get the actual buffer occupancy.
a unique identifier for an interface.
Definition: type-id.h:49
virtual ~TcpRxBuffer()
bool Finished(void)
Check if the buffer did receive all the data (and the connection is closed)
std::map< SequenceNumber32, Ptr< Packet > >::iterator BufIterator
container for data stored in the buffer