OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2010 Adrian Sai-wah Tam | 3 * Copyright (c) 2010 Adrian Sai-wah Tam |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 11 matching lines...) Expand all Loading... |
22 #define TCP_RX_BUFFER_H | 22 #define TCP_RX_BUFFER_H |
23 | 23 |
24 #include <map> | 24 #include <map> |
25 #include "ns3/traced-value.h" | 25 #include "ns3/traced-value.h" |
26 #include "ns3/trace-source-accessor.h" | 26 #include "ns3/trace-source-accessor.h" |
27 #include "ns3/sequence-number.h" | 27 #include "ns3/sequence-number.h" |
28 #include "ns3/ptr.h" | 28 #include "ns3/ptr.h" |
29 #include "ns3/tcp-header.h" | 29 #include "ns3/tcp-header.h" |
30 | 30 |
31 namespace ns3 { | 31 namespace ns3 { |
| 32 |
| 33 typedef std::list<std::pair<SequenceNumber32, SequenceNumber32> > List; |
| 34 |
32 class Packet; | 35 class Packet; |
33 | 36 |
34 /** | 37 /** |
35 * \ingroup tcp | 38 * \ingroup tcp |
36 * | 39 * |
37 * \brief class for the reordering buffer that keeps the data from lower layer,
i.e. | 40 * \brief class for the reordering buffer that keeps the data from lower layer,
i.e. |
38 * TcpL4Protocol, sent to the application | 41 * TcpL4Protocol, sent to the application |
39 */ | 42 */ |
40 class TcpRxBuffer : public Object | 43 class TcpRxBuffer : public Object |
41 { | 44 { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 * \returns size of available data (in bytes) | 100 * \returns size of available data (in bytes) |
98 */ | 101 */ |
99 uint32_t Available () const; | 102 uint32_t Available () const; |
100 /** | 103 /** |
101 * \brief Check if the buffer did receive all the data (and the connection is
closed) | 104 * \brief Check if the buffer did receive all the data (and the connection is
closed) |
102 * \returns true if all data have been received | 105 * \returns true if all data have been received |
103 */ | 106 */ |
104 bool Finished (void); | 107 bool Finished (void); |
105 | 108 |
106 /** | 109 /** |
107 * Insert a packet into the buffer and update the availBytes counter to | 110 * \brief 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 | 111 * 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 | 112 * 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 | 113 * removing data from the buffer that overlaps the tail of the inputted |
111 * packet | 114 * packet |
112 * | 115 * |
113 * \param p packet | 116 * \param p packet |
114 * \param tcph packet's TCP header | 117 * \param tcph packet's TCP header |
115 * \return True when success, false otherwise. | 118 * \return True when success, false otherwise. |
116 */ | 119 */ |
117 bool Add (Ptr<Packet> p, TcpHeader const& tcph); | 120 bool Add (Ptr<Packet> p, TcpHeader const& tcph); |
118 | 121 |
119 /** | 122 /** |
120 * Extract data from the head of the buffer as indicated by nextRxSeq. | 123 * \brief Extract data from the head of the buffer as indicated by nextRxSeq. |
121 * The extracted data is going to be forwarded to the application. | 124 * The extracted data is going to be forwarded to the application. |
122 * | 125 * |
123 * \param maxSize maximum number of bytes to extract | 126 * \param maxSize maximum number of bytes to extract |
124 * \returns a packet | 127 * \returns a packet |
125 */ | 128 */ |
126 Ptr<Packet> Extract (uint32_t maxSize); | 129 Ptr<Packet> Extract (uint32_t maxSize); |
| 130 |
| 131 /** |
| 132 * \brief Find all isolated blocks of data following m_nextRxSeq in the buffer
, |
| 133 * merge all consecutive blocks, and then store the blocks after merging |
| 134 * in a list |
| 135 * |
| 136 * \param list the list of isolated blocks of data in the receiver buffer |
| 137 */ |
| 138 void GetIsolatedDataChunks (List& list); |
| 139 |
127 public: | 140 public: |
128 /// container for data stored in the buffer | 141 /// container for data stored in the buffer |
129 typedef std::map<SequenceNumber32, Ptr<Packet> >::iterator BufIterator; | 142 typedef std::map<SequenceNumber32, Ptr<Packet> >::iterator BufIterator; |
130 TracedValue<SequenceNumber32> m_nextRxSeq; //!< Seqnum of the first missing by
te in data (RCV.NXT) | 143 TracedValue<SequenceNumber32> m_nextRxSeq; //!< Seqnum of the first missing by
te in data (RCV.NXT) |
131 SequenceNumber32 m_finSeq; //!< Seqnum of the FIN packet | 144 SequenceNumber32 m_finSeq; //!< Seqnum of the FIN packet |
132 bool m_gotFin; //!< Did I received FIN packet? | 145 bool m_gotFin; //!< Did I received FIN packet? |
133 uint32_t m_size; //!< Number of total data bytes in
the buffer, not necessarily contiguous | 146 uint32_t m_size; //!< Number of total data bytes in
the buffer, not necessarily contiguous |
134 uint32_t m_maxBuffer; //!< Upper bound of the number of d
ata bytes in buffer (RCV.WND) | 147 uint32_t m_maxBuffer; //!< Upper bound of the number of d
ata bytes in buffer (RCV.WND) |
135 uint32_t m_availBytes; //!< Number of bytes available to r
ead, i.e. contiguous block at head | 148 uint32_t m_availBytes; //!< Number of bytes available to r
ead, i.e. contiguous block at head |
136 std::map<SequenceNumber32, Ptr<Packet> > m_data; //!< Corresponding data (may
be null) | 149 std::map<SequenceNumber32, Ptr<Packet> > m_data; //!< Corresponding data (may
be null) |
137 }; | 150 }; |
138 | 151 |
139 } //namepsace ns3 | 152 } //namepsace ns3 |
140 | 153 |
141 #endif /* TCP_RX_BUFFER_H */ | 154 #endif /* TCP_RX_BUFFER_H */ |
OLD | NEW |