author | Brian Swenson <bswenson3@gatech.edu> |
Tue, 22 Apr 2014 11:52:55 -0400 | |
changeset 10694 | 4af272d94cfd |
parent 10440 | 1e48ff9185f1 |
permissions | -rw-r--r-- |
6694 | 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 |
||
7353
09fccf6195ea
bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents:
7176
diff
changeset
|
21 |
#ifndef TCP_RX_BUFFER_H |
09fccf6195ea
bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents:
7176
diff
changeset
|
22 |
#define TCP_RX_BUFFER_H |
6694 | 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 |
||
34 |
/** |
|
35 |
* \ingroup tcp |
|
36 |
* |
|
37 |
* \brief class for the reordering buffer that keeps the data from lower layer, i.e. |
|
38 |
* TcpL4Protocol, sent to the application |
|
39 |
*/ |
|
40 |
class TcpRxBuffer : public Object |
|
41 |
{ |
|
42 |
public: |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
43 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
44 |
* \brief Get the type ID. |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
45 |
* \return the object TypeId |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
46 |
*/ |
6694 | 47 |
static TypeId GetTypeId (void); |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
48 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
49 |
* \brief Constructor |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
50 |
* \param n initial Sequence number to be received |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
51 |
*/ |
6694 | 52 |
TcpRxBuffer (uint32_t n = 0); |
53 |
virtual ~TcpRxBuffer (); |
|
54 |
||
55 |
// Accessors |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
56 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
57 |
* \brief Get Next Rx Sequence number |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
58 |
* \returns Next Rx Sequence number |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
59 |
*/ |
6694 | 60 |
SequenceNumber32 NextRxSequence (void) const; |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
61 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
62 |
* \brief Get the lowest sequence number that this TcpRxBuffer cannot accept |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
63 |
* \returns the lowest sequence number that this TcpRxBuffer cannot accept |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
64 |
*/ |
6694 | 65 |
SequenceNumber32 MaxRxSequence (void) const; |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
66 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
67 |
* \brief Increment the Next Sequence number |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
68 |
*/ |
6694 | 69 |
void IncNextRxSequence (void); |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
70 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
71 |
* \brief Set the Next Sequence number |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
72 |
* \param s the Sequence number |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
73 |
*/ |
6694 | 74 |
void SetNextRxSequence (const SequenceNumber32& s); |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
75 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
76 |
* \brief Set the FIN Sequence number (i.e., the one closing the connection) |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
77 |
* \param s the Sequence number |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
78 |
*/ |
6694 | 79 |
void SetFinSequence (const SequenceNumber32& s); |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
80 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
81 |
* \brief Get the Maximum buffer size |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
82 |
* \returns the Maximum buffer size |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
83 |
*/ |
6694 | 84 |
uint32_t MaxBufferSize (void) const; |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
85 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
86 |
* \brief Set the Maximum buffer size |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
87 |
* \param s the Maximum buffer size |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
88 |
*/ |
6694 | 89 |
void SetMaxBufferSize (uint32_t s); |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
90 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
91 |
* \brief Get the actual buffer occupancy |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
92 |
* \returns buffer occupancy (in bytes) |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
93 |
*/ |
6694 | 94 |
uint32_t Size (void) const; |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
95 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
96 |
* \brief Get the actual number of bytes available to be read |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
97 |
* \returns size of available data (in bytes) |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
98 |
*/ |
6694 | 99 |
uint32_t Available () const; |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
100 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
101 |
* \brief Check if the buffer did receive all the data (and the connection is closed) |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
102 |
* \returns true if all data have been received |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
103 |
*/ |
6694 | 104 |
bool Finished (void); |
105 |
||
106 |
/** |
|
107 |
* Insert a packet into the buffer and update the availBytes counter to |
|
108 |
* reflect the number of bytes ready to send to the application. This |
|
109 |
* function handles overlap by triming the head of the inputted packet and |
|
110 |
* removing data from the buffer that overlaps the tail of the inputted |
|
111 |
* packet |
|
112 |
* |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
113 |
* \param p packet |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
114 |
* \param tcph packet's TCP header |
6694 | 115 |
* \return True when success, false otherwise. |
116 |
*/ |
|
117 |
bool Add (Ptr<Packet> p, TcpHeader const& tcph); |
|
118 |
||
119 |
/** |
|
120 |
* Extract data from the head of the buffer as indicated by nextRxSeq. |
|
121 |
* The extracted data is going to be forwarded to the application. |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
122 |
* |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
123 |
* \param maxSize maximum number of bytes to extract |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
124 |
* \returns a packet |
6694 | 125 |
*/ |
126 |
Ptr<Packet> Extract (uint32_t maxSize); |
|
127 |
public: |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
128 |
/// container for data stored in the buffer |
6694 | 129 |
typedef std::map<SequenceNumber32, Ptr<Packet> >::iterator BufIterator; |
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
130 |
TracedValue<SequenceNumber32> m_nextRxSeq; //!< Seqnum of the first missing byte in data (RCV.NXT) |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
131 |
SequenceNumber32 m_finSeq; //!< Seqnum of the FIN packet |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
132 |
bool m_gotFin; //!< Did I received FIN packet? |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
133 |
uint32_t m_size; //!< Number of total data bytes in the buffer, not necessarily contiguous |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
134 |
uint32_t m_maxBuffer; //!< Upper bound of the number of data bytes in buffer (RCV.WND) |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
135 |
uint32_t m_availBytes; //!< Number of bytes available to read, i.e. contiguous block at head |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7353
diff
changeset
|
136 |
std::map<SequenceNumber32, Ptr<Packet> > m_data; //!< Corresponding data (may be null) |
6694 | 137 |
}; |
138 |
||
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
139 |
} //namepsace ns3 |
6694 | 140 |
|
7353
09fccf6195ea
bug 1203: Inconsistently named ifndef/define macros in ns-3 headers
Vedran Miletic <rivanvx@gmail.com>
parents:
7176
diff
changeset
|
141 |
#endif /* TCP_RX_BUFFER_H */ |