A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tcp-rx-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_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 
31 namespace ns3 {
32 class Packet;
33 
40 class TcpRxBuffer : public Object
41 {
42 public:
43  static TypeId GetTypeId (void);
44  TcpRxBuffer (uint32_t n = 0);
45  virtual ~TcpRxBuffer ();
46 
47  // Accessors
48  SequenceNumber32 NextRxSequence (void) const;
49  SequenceNumber32 MaxRxSequence (void) const;
50  void IncNextRxSequence (void);
51  void SetNextRxSequence (const SequenceNumber32& s);
52  void SetFinSequence (const SequenceNumber32& s);
53  uint32_t MaxBufferSize (void) const;
54  void SetMaxBufferSize (uint32_t s);
55  uint32_t Size (void) const;
56  uint32_t Available () const;
57  bool Finished (void);
58 
68  bool Add (Ptr<Packet> p, TcpHeader const& tcph);
69 
74  Ptr<Packet> Extract (uint32_t maxSize);
75 public:
76  typedef std::map<SequenceNumber32, Ptr<Packet> >::iterator BufIterator;
77  TracedValue<SequenceNumber32> m_nextRxSeq; //< Seqnum of the first missing byte in data (RCV.NXT)
78  SequenceNumber32 m_finSeq; //< Seqnum of the FIN packet
79  bool m_gotFin; //< Did I received FIN packet?
80  uint32_t m_size; //< Number of total data bytes in the buffer, not necessarily contiguous
81  uint32_t m_maxBuffer; //< Upper bound of the number of data bytes in buffer (RCV.WND)
82  uint32_t m_availBytes; //< Number of bytes available to read, i.e. contiguous block at head
83  std::map<SequenceNumber32, Ptr<Packet> > m_data;
84  //< Corresponding data (may be null)
85 };
86 
87 } //namepsace ns3
88 
89 #endif /* TCP_RX_BUFFER_H */
bool Add(Ptr< Packet > p, TcpHeader const &tcph)
class for the reordering buffer that keeps the data from lower layer, i.e. TcpL4Protocol, sent to the application
Definition: tcp-rx-buffer.h:40
Ptr< Packet > Extract(uint32_t maxSize)
Header for the Transmission Control Protocol.
Definition: tcp-header.h:43
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