LEFT | RIGHT |
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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com> | 18 * Author: Adrian Sai-wah Tam <adrian.sw.tam@gmail.com> |
19 */ | 19 */ |
20 | 20 |
21 #ifndef __TCP_RX_BUFFER_H__ | 21 #ifndef __TCP_RX_BUFFER_H__ |
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" |
| 26 #include "ns3/trace-source-accessor.h" |
25 #include "ns3/sequence-number.h" | 27 #include "ns3/sequence-number.h" |
26 #include "ns3/ptr.h" | 28 #include "ns3/ptr.h" |
27 #include "ns3/tcp-header.h" | 29 #include "ns3/tcp-header.h" |
28 | 30 |
29 namespace ns3 { | 31 namespace ns3 { |
30 class Packet; | 32 class Packet; |
31 | 33 |
32 /** | 34 /** |
33 * \ingroup tcp | 35 * \ingroup tcp |
34 * | 36 * |
35 * \brief class for the reordering buffer that keeps the data from lower layer,
i.e. | 37 * \brief class for the reordering buffer that keeps the data from lower layer,
i.e. |
36 * TcpL4Protocol, sent to the application | 38 * TcpL4Protocol, sent to the application |
37 */ | 39 */ |
38 class TcpRxBuffer | 40 class TcpRxBuffer : public Object |
39 { | 41 { |
40 public: | 42 public: |
| 43 static TypeId GetTypeId (void); |
41 TcpRxBuffer (uint32_t n = 0); | 44 TcpRxBuffer (uint32_t n = 0); |
42 virtual ~TcpRxBuffer (); | 45 virtual ~TcpRxBuffer (); |
43 | 46 |
44 // Accessors | 47 // Accessors |
45 SequenceNumber32 NextRxSequence (void) const; | 48 SequenceNumber32 NextRxSequence (void) const; |
46 SequenceNumber32 MaxRxSequence (void) const; | 49 SequenceNumber32 MaxRxSequence (void) const; |
47 void IncNextRxSequence (void); | 50 void IncNextRxSequence (void); |
48 void SetNextRxSequence (const SequenceNumber32& s); | 51 void SetNextRxSequence (const SequenceNumber32& s); |
49 void SetFinSequence (const SequenceNumber32& s); | 52 void SetFinSequence (const SequenceNumber32& s); |
50 uint32_t MaxBufferSize (void) const; | 53 uint32_t MaxBufferSize (void) const; |
(...skipping 13 matching lines...) Expand all Loading... |
64 */ | 67 */ |
65 bool Add (Ptr<Packet> p, TcpHeader const& tcph); | 68 bool Add (Ptr<Packet> p, TcpHeader const& tcph); |
66 | 69 |
67 /** | 70 /** |
68 * Extract data from the head of the buffer as indicated by nextRxSeq. | 71 * Extract data from the head of the buffer as indicated by nextRxSeq. |
69 * The extracted data is going to be forwarded to the application. | 72 * The extracted data is going to be forwarded to the application. |
70 */ | 73 */ |
71 Ptr<Packet> Extract (uint32_t maxSize); | 74 Ptr<Packet> Extract (uint32_t maxSize); |
72 public: | 75 public: |
73 typedef std::map<SequenceNumber32, Ptr<Packet> >::iterator BufIterator; | 76 typedef std::map<SequenceNumber32, Ptr<Packet> >::iterator BufIterator; |
74 SequenceNumber32 m_nextRxSeq; //< Seqnum of the first missing byte in data (
RCV.NXT) | 77 TracedValue<SequenceNumber32> m_nextRxSeq; //< Seqnum of the first missing byt
e in data (RCV.NXT) |
75 SequenceNumber32 m_finSeq; //< Seqnum of the FIN packet | 78 SequenceNumber32 m_finSeq; //< Seqnum of the FIN packet |
76 bool m_gotFin; //< Did I received FIN packet? | 79 bool m_gotFin; //< Did I received FIN packet? |
77 uint32_t m_size; //< Number of total data bytes in the buffer, no
t necessarily contiguous | 80 uint32_t m_size; //< Number of total data bytes in t
he buffer, not necessarily contiguous |
78 uint32_t m_maxBuffer; //< Upper bound of the number of data bytes in b
uffer (RCV.WND) | 81 uint32_t m_maxBuffer; //< Upper bound of the number of da
ta bytes in buffer (RCV.WND) |
79 uint32_t m_availBytes; //< Number of bytes available to read, i.e. cont
iguous block at head | 82 uint32_t m_availBytes; //< Number of bytes available to re
ad, i.e. contiguous block at head |
80 std::map<SequenceNumber32, Ptr<Packet> > m_data; | 83 std::map<SequenceNumber32, Ptr<Packet> > m_data; |
81 //< Corresponding data (may be null) | 84 //< Corresponding data (may be null
) |
82 }; | 85 }; |
83 | 86 |
84 }//namepsace ns3 | 87 }//namepsace ns3 |
85 | 88 |
86 #endif /* __TCP_RX_BUFFER_H__ */ | 89 #endif /* __TCP_RX_BUFFER_H__ */ |
LEFT | RIGHT |