author | Natale Patriciello <natale.patriciello@gmail.com> |
Mon, 13 Jul 2015 17:57:09 -0700 | |
changeset 11513 | 99af6df16387 |
parent 11512 | c0e78011217c |
permissions | -rw-r--r-- |
9696 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2013 ResiliNets, ITTC, University of Kansas |
|
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 |
* Authors: Siddharth Gangadhar <siddharth@ittc.ku.edu>, Truc Anh N. Nguyen <annguyen@ittc.ku.edu>, |
|
19 |
* and Greeshma Umapathi |
|
20 |
* |
|
21 |
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director |
|
22 |
* ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets |
|
23 |
* Information and Telecommunication Technology Center (ITTC) |
|
24 |
* and Department of Electrical Engineering and Computer Science |
|
25 |
* The University of Kansas Lawrence, KS USA. |
|
26 |
* |
|
27 |
* Work supported in part by NSF FIND (Future Internet Design) Program |
|
28 |
* under grant CNS-0626918 (Postmodern Internet Architecture), |
|
29 |
* NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI), |
|
30 |
* US Department of Defense (DoD), and ITTC at The University of Kansas. |
|
31 |
*/ |
|
32 |
||
33 |
#ifndef TCP_WESTWOOD_H |
|
34 |
#define TCP_WESTWOOD_H |
|
35 |
||
36 |
#include "tcp-socket-base.h" |
|
37 |
#include "ns3/packet.h" |
|
38 |
||
39 |
namespace ns3 { |
|
40 |
||
41 |
/** |
|
42 |
* \ingroup socket |
|
43 |
* \ingroup tcp |
|
44 |
* |
|
45 |
* \brief An implementation of a stream socket using TCP. |
|
46 |
* |
|
47 |
* This class contains the implementation of TCP Westwood and Westwood+. |
|
48 |
* |
|
49 |
* Westwood and Westwood+ employ the AIAD (Additive Increase/Adaptive Decrease) |
|
50 |
* congestion control paradigm. When a congestion episode happens, |
|
51 |
* instead of halving the cwnd, these protocols try to estimate the network's |
|
52 |
* bandwidth and use the estimated value to adjust the cwnd. |
|
53 |
* While Westwood performs the bandwidth sampling every ACK reception, |
|
54 |
* Westwood+ samples the bandwidth every RTT. |
|
55 |
* |
|
56 |
* The two main methods in the implementation are the CountAck (const TCPHeader&) |
|
57 |
* and the EstimateBW (int, const, Time). The CountAck method calculates |
|
58 |
* the number of acknowledged segments on the receipt of an ACK. |
|
59 |
* The EstimateBW estimates the bandwidth based on the value returned by CountAck |
|
60 |
* and the sampling interval (last ACK inter-arrival time for Westwood and last RTT for Westwood+). |
|
61 |
*/ |
|
62 |
class TcpWestwood : public TcpSocketBase |
|
63 |
{ |
|
64 |
public: |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
65 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
66 |
* \brief Get the type ID. |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
67 |
* \return the object TypeId |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
68 |
*/ |
9696 | 69 |
static TypeId GetTypeId (void); |
70 |
||
71 |
TcpWestwood (void); |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
72 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
73 |
* \brief Copy constructor |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
74 |
* \param sock the object to copy |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
75 |
*/ |
9696 | 76 |
TcpWestwood (const TcpWestwood& sock); |
77 |
virtual ~TcpWestwood (void); |
|
78 |
||
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
79 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
80 |
* \brief Protocol variant (Westwood or Westwood+) |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
81 |
*/ |
9696 | 82 |
enum ProtocolType |
83 |
{ |
|
84 |
WESTWOOD, |
|
85 |
WESTWOODPLUS |
|
86 |
}; |
|
87 |
||
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
88 |
/** |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
89 |
* \brief Filter type (None or Tustin) |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
90 |
*/ |
9696 | 91 |
enum FilterType |
92 |
{ |
|
93 |
NONE, |
|
94 |
TUSTIN |
|
95 |
}; |
|
96 |
||
97 |
protected: |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
98 |
virtual Ptr<TcpSocketBase> Fork (void); // Call CopyObject<TcpTahoe> to clone me |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
99 |
virtual void NewAck (SequenceNumber32 const& seq); // Inc cwnd and call NewAck() of parent |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
100 |
virtual void DupAck (const TcpHeader& t, uint32_t count); // Treat 3 dupack as timeout |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
101 |
virtual void Retransmit (void); // Retransmit time out |
9696 | 102 |
|
103 |
/** |
|
104 |
* Process the newly received ACK |
|
105 |
* |
|
106 |
* \param packet the received ACK packet |
|
107 |
* \param tcpHeader the header attached to the ACK packet |
|
108 |
*/ |
|
109 |
virtual void ReceivedAck (Ptr<Packet> packet, const TcpHeader& tcpHeader); |
|
110 |
||
111 |
/** |
|
112 |
* Estimate the RTT, record the minimum value, |
|
113 |
* and run a clock on the RTT to trigger Westwood+ bandwidth sampling |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
114 |
* \param header the packet header |
9696 | 115 |
*/ |
116 |
virtual void EstimateRtt (const TcpHeader& header); |
|
117 |
||
118 |
private: |
|
119 |
/** |
|
120 |
* Calculate the number of acknowledged packets upon the receipt of an ACK packet |
|
121 |
* |
|
122 |
* \param tcpHeader the header of the received ACK packet |
|
123 |
* \return the number of ACKed packets |
|
124 |
*/ |
|
125 |
int CountAck (const TcpHeader& tcpHeader); |
|
126 |
||
127 |
/** |
|
128 |
* Update the total number of acknowledged packets during the current RTT |
|
129 |
* |
|
130 |
* \param acked the number of packets the currently received ACK acknowledges |
|
131 |
*/ |
|
132 |
void UpdateAckedSegments (int acked); |
|
133 |
||
134 |
/** |
|
135 |
* Estimate the network's bandwidth |
|
136 |
* |
|
137 |
* \param acked the number of acknowledged packets returned by CountAck |
|
138 |
* \param tcpHeader the header of the packet |
|
139 |
* \param rtt the RTT estimation |
|
140 |
*/ |
|
141 |
void EstimateBW (int acked, const TcpHeader& tcpHeader, Time rtt); |
|
142 |
||
143 |
/** |
|
144 |
* Tustin filter |
|
145 |
*/ |
|
146 |
void Filtering (void); |
|
147 |
||
148 |
protected: |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
149 |
bool m_inFastRec; //!< Currently in fast recovery if TRUE |
9696 | 150 |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
151 |
TracedValue<double> m_currentBW; //!< Current value of the estimated BW |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
152 |
double m_lastSampleBW; //!< Last bandwidth sample |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
153 |
double m_lastBW; //!< Last bandwidth sample after being filtered |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
154 |
Time m_minRtt; //!< Minimum RTT |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
155 |
double m_lastAck; //!< The time last ACK was received |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
156 |
SequenceNumber32 m_prevAckNo; //!< Previously received ACK number |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
157 |
int m_accountedFor; //!< The number of received DUPACKs |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
158 |
enum ProtocolType m_pType; //!< 0 for Westwood, 1 for Westwood+ |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
159 |
enum FilterType m_fType; //!< 0 for none, 1 for Tustin |
9696 | 160 |
|
10440
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
161 |
int m_ackedSegments; //!< The number of segments ACKed between RTTs |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
162 |
bool m_IsCount; //!< Start keeping track of m_ackedSegments for Westwood+ if TRUE |
1e48ff9185f1
Bug 938 - missing Doxygen in ns-3 (internet model + helper)
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9696
diff
changeset
|
163 |
EventId m_bwEstimateEvent; //!< The BW estimation event for Westwood+ |
9696 | 164 |
|
165 |
}; |
|
166 |
||
167 |
} // namespace ns3 |
|
168 |
||
169 |
#endif /* TCP_WESTWOOD_H */ |