Left: | ||
Right: |
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) 2013 ResiliNets, ITTC, University of Kansas· | 3 * Copyright (c) 2013 ResiliNets, ITTC, University of Kansas· |
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 static TypeId tid = TypeId("ns3::TcpWestwood") | 49 static TypeId tid = TypeId("ns3::TcpWestwood") |
50 .SetParent<TcpNewReno>() | 50 .SetParent<TcpNewReno>() |
51 .SetGroupName ("Internet") | 51 .SetGroupName ("Internet") |
52 .AddConstructor<TcpWestwood>() | 52 .AddConstructor<TcpWestwood>() |
53 .AddAttribute("FilterType", "Use this to choose no filter or Tustin's approx imation filter", | 53 .AddAttribute("FilterType", "Use this to choose no filter or Tustin's approx imation filter", |
54 EnumValue(TcpWestwood::TUSTIN), MakeEnumAccessor(&TcpWestwood: :m_fType), | 54 EnumValue(TcpWestwood::TUSTIN), MakeEnumAccessor(&TcpWestwood: :m_fType), |
55 MakeEnumChecker(TcpWestwood::NONE, "None", TcpWestwood::TUSTIN , "Tustin")) | 55 MakeEnumChecker(TcpWestwood::NONE, "None", TcpWestwood::TUSTIN , "Tustin")) |
56 .AddAttribute("ProtocolType", "Use this to let the code run as Westwood or W estwoodPlus", | 56 .AddAttribute("ProtocolType", "Use this to let the code run as Westwood or W estwoodPlus", |
57 EnumValue(TcpWestwood::WESTWOOD), | 57 EnumValue(TcpWestwood::WESTWOOD), |
58 MakeEnumAccessor(&TcpWestwood::m_pType), | 58 MakeEnumAccessor(&TcpWestwood::m_pType), |
59 MakeEnumChecker(TcpWestwood::WESTWOOD, "Westwood",TcpWestwood: :WESTWOODPLUS, "WestwoodPlus",TcpWestwood::WESTWOODCRB, "WestwoodCRB")) | 59 MakeEnumChecker(TcpWestwood::WESTWOOD, "Westwood", TcpWestwood ::WESTWOODPLUS, "WestwoodPlus", TcpWestwood::WESTWOODCRB, "WestwoodCrb")) |
Mohit Tahiliani
2017/04/15 07:36:46
One space before TcpWestwood::WESTWOODCRB
and
it
| |
60 .AddTraceSource("EstimatedBW", "The estimated bandwidth", | 60 .AddTraceSource("EstimatedBW", "The estimated bandwidth", |
61 MakeTraceSourceAccessor(&TcpWestwood::m_currentBW), | 61 MakeTraceSourceAccessor(&TcpWestwood::m_currentBW), |
62 "ns3::TracedValueCallback::Double") | 62 "ns3::TracedValueCallback::Double") |
63 .AddTraceSource("EstimatedRE", "The estimated rate", | 63 .AddTraceSource("EstimatedRE", "The estimated rate", |
64 MakeTraceSourceAccessor(&TcpWestwood::m_currentRE), | 64 MakeTraceSourceAccessor(&TcpWestwood::m_currentRE), |
65 "ns3::TracedValueCallback::Double") | 65 "ns3::TracedValueCallback::Double") |
66 ; | 66 ; |
67 return tid; | 67 return tid; |
68 } | 68 } |
69 | 69 |
70 TcpWestwood::TcpWestwood (void) : | 70 TcpWestwood::TcpWestwood (void) : |
71 TcpNewReno (), | 71 TcpNewReno (), |
72 m_currentBW (0), | 72 m_currentBW (0), |
73 m_currentRE (0), | 73 m_currentRE (0), |
74 m_tvalue (Seconds (0.4)), | 74 m_tValue (Seconds (0.4)), |
Mohit Tahiliani
2017/04/15 07:36:46
m_tValue
| |
75 m_lastSampleBW (0), | 75 m_lastSampleBW (0), |
76 m_lastBW (0), | 76 m_lastBW (0), |
77 m_lastSampleRE (0), | 77 m_lastSampleRE (0), |
78 m_lastRE (0), | 78 m_lastRE (0), |
79 m_minRtt (Time (0)), | 79 m_minRtt (Time (0)), |
80 m_ackedSegments (0), | 80 m_ackedSegments (0), |
81 m_ackedSinceT (0), | 81 m_ackedSinceT (0), |
82 m_IsCount (false) | 82 m_IsCount (false) |
83 { | 83 { |
84 NS_LOG_FUNCTION (this); | 84 NS_LOG_FUNCTION (this); |
(...skipping 13 matching lines...) Expand all Loading... | |
98 m_IsCount (sock.m_IsCount) | 98 m_IsCount (sock.m_IsCount) |
99 { | 99 { |
100 NS_LOG_FUNCTION (this); | 100 NS_LOG_FUNCTION (this); |
101 NS_LOG_LOGIC ("Invoked the copy constructor"); | 101 NS_LOG_LOGIC ("Invoked the copy constructor"); |
102 } | 102 } |
103 | 103 |
104 TcpWestwood::~TcpWestwood (void) | 104 TcpWestwood::~TcpWestwood (void) |
105 { | 105 { |
106 } | 106 } |
107 | 107 |
108 | |
Mohit Tahiliani
2017/04/15 07:36:45
Remove blank line
| |
109 void | 108 void |
110 TcpWestwood::PktsAcked (Ptr<TcpSocketState> tcb, uint32_t packetsAcked, | 109 TcpWestwood::PktsAcked (Ptr<TcpSocketState> tcb, uint32_t packetsAcked, |
111 const Time& rtt) | 110 const Time& rtt) |
112 { | 111 {··· |
113 ··· | |
114 ·· | |
Mohit Tahiliani
2017/04/15 07:36:46
Remove both blank lines
| |
115 NS_LOG_FUNCTION (this << tcb << packetsAcked << rtt); | 112 NS_LOG_FUNCTION (this << tcb << packetsAcked << rtt); |
116 | 113 |
117 if (rtt.IsZero ()) | 114 if (rtt.IsZero ()) |
118 { | 115 { |
119 NS_LOG_WARN ("RTT measured is zero!"); | 116 NS_LOG_WARN ("RTT measured is zero!"); |
120 return; | 117 return; |
121 } | 118 } |
122 | 119 |
123 m_ackedSegments += packetsAcked; | 120 m_ackedSegments += packetsAcked; |
124 m_ackedSinceT += packetsAcked; | 121 m_ackedSinceT += packetsAcked; |
(...skipping 21 matching lines...) Expand all Loading... | |
146 { | 143 { |
147 if (!(rtt.IsZero () || m_IsCount)) | 144 if (!(rtt.IsZero () || m_IsCount)) |
148 { | 145 { |
149 m_IsCount = true; | 146 m_IsCount = true; |
150 m_bwEstimateEvent.Cancel (); | 147 m_bwEstimateEvent.Cancel (); |
151 m_bwEstimateEvent = Simulator::Schedule (rtt, &TcpWestwood::EstimateBW , | 148 m_bwEstimateEvent = Simulator::Schedule (rtt, &TcpWestwood::EstimateBW , |
152 this, rtt, tcb); | 149 this, rtt, tcb); |
153 } | 150 } |
154 } | 151 } |
155 else if (m_pType == TcpWestwood::WESTWOODCRB) | 152 else if (m_pType == TcpWestwood::WESTWOODCRB) |
156 { | 153 { |
Mohit Tahiliani
2017/04/15 07:36:46
Indent according to ns-3 standards
| |
157 if (!m_IsCount) | 154 if (!m_IsCount) |
158 { | 155 { |
Mohit Tahiliani
2017/04/15 07:36:46
Indent according to ns-3 standards
Follow this wh
| |
159 m_IsCount = true; | 156 m_IsCount = true; |
160 m_reEstimateEvent.Cancel (); | 157 m_reEstimateEvent.Cancel (); |
161 m_reEstimateEvent = Simulator::Schedule (m_tvalue, &TcpWestwood::Estim ateRE, | 158 m_reEstimateEvent = Simulator::Schedule (m_tValue, &TcpWestwood::Es timateRE, |
162 this, m_tvalue, tcb); | 159 this, m_tValue, tcb); |
Mohit Tahiliani
2017/04/15 07:36:45
m_tValue
reflect this change at all other places
| |
163 }· | 160 }· |
Mohit Tahiliani
2017/04/15 07:36:46
trailing white space
| |
164 EstimateBW(rtt,tcb); | 161 EstimateBW(rtt,tcb); |
Mohit Tahiliani
2017/04/15 07:36:45
trailing white spaces
| |
165 · | 162 } |
166 ··· | 163 } |
Mohit Tahiliani
2017/04/15 07:36:46
Remove both blank lines
| |
167 } | |
168 } | |
169 | |
170 | 164 |
171 void | 165 void |
172 TcpWestwood::EstimateRE (const Time &tvalue, Ptr<TcpSocketState> tcb) | 166 TcpWestwood::EstimateRE (const Time &tvalue, Ptr<TcpSocketState> tcb) |
173 { | 167 { |
174 · | 168 NS_LOG_FUNCTION (this << tvalue << tcb);· |
Mohit Tahiliani
2017/04/15 07:36:46
trailing white space
| |
175 NS_LOG_FUNCTION (this << tvalue << tcb); | |
176 · | |
Mohit Tahiliani
2017/04/15 07:36:46
remove all trailing white spaces
| |
177 NS_ASSERT (!tvalue.IsZero ());· | 169 NS_ASSERT (!tvalue.IsZero ());· |
178 | 170 |
179 m_currentRE = m_ackedSinceT * tcb->m_segmentSize / tvalue.GetSeconds (); | 171 m_currentRE = m_ackedSinceT * tcb->m_segmentSize / tvalue.GetSeconds (); |
180 ···· | |
181 m_ackedSinceT = 0; | 172 m_ackedSinceT = 0; |
182 ······ | |
183 if (m_pType == TcpWestwood::WESTWOODCRB) | 173 if (m_pType == TcpWestwood::WESTWOODCRB) |
184 { | 174 { |
185 m_IsCount = false; | 175 m_IsCount = false; |
186 } | 176 } |
187 | 177 |
188 // Filter the BW sample | 178 // Filter the BW sample |
189 double alpha = 0.9;· | 179 double alpha = 0.9;· |
Mohit Tahiliani
2017/04/15 07:36:46
Give a reference for choosing 0.9
| |
190 | |
191 if (m_fType == TcpWestwood::NONE) | 180 if (m_fType == TcpWestwood::NONE) |
192 { | 181 { |
193 ··· | |
Mohit Tahiliani
2017/04/15 07:36:46
white spaces
| |
194 } | 182 } |
195 else if (m_fType == TcpWestwood::TUSTIN) | 183 else if (m_fType == TcpWestwood::TUSTIN) |
196 { | 184 { |
197 double sample_ree = m_currentRE; | 185 double sample_re = m_currentRE; |
Mohit Tahiliani
2017/04/15 07:36:46
any reason for "ee" in "ree"?
| |
198 m_currentRE = (alpha * m_lastRE) + ((1 - alpha) * ((sample_ree + m_lastSam pleRE) / 2)); | 186 m_currentRE = (alpha * m_lastRE) + ((1 - alpha) * ((sample_re + m_lastSamp leRE) / 2)); |
199 m_lastSampleRE = sample_ree; | 187 m_lastSampleRE = sample_re; |
200 m_lastRE = m_currentRE; | 188 m_lastRE = m_currentRE; |
201 } | 189 } |
202 ··· | |
Mohit Tahiliani
2017/04/15 07:36:46
blank line
| |
203 NS_LOG_LOGIC ("Estimated RE after filtering: " << m_currentRE); | 190 NS_LOG_LOGIC ("Estimated RE after filtering: " << m_currentRE); |
204 } | 191 } |
205 | 192 |
206 void | 193 void |
207 TcpWestwood::EstimateBW (const Time &rtt, Ptr<TcpSocketState> tcb) | 194 TcpWestwood::EstimateBW (const Time &rtt, Ptr<TcpSocketState> tcb) |
208 { | 195 { |
209 | |
210 NS_LOG_FUNCTION (this); | 196 NS_LOG_FUNCTION (this); |
211 | 197 |
212 NS_ASSERT (!rtt.IsZero ()); | 198 NS_ASSERT (!rtt.IsZero ()); |
213 | 199 |
214 m_currentBW = m_ackedSegments * tcb->m_segmentSize / rtt.GetSeconds (); | 200 m_currentBW = m_ackedSegments * tcb->m_segmentSize / rtt.GetSeconds (); |
215 | 201 |
216 if (m_pType == TcpWestwood::WESTWOODPLUS) | 202 if (m_pType == TcpWestwood::WESTWOODPLUS) |
217 { | 203 { |
218 m_IsCount = false; | 204 m_IsCount = false; |
219 } | 205 } |
Mohit Tahiliani
2017/04/15 07:36:45
Avoid changing existing code
| |
220 | 206 |
221 m_ackedSegments = 0; | 207 m_ackedSegments = 0; |
222 NS_LOG_LOGIC ("Estimated BW: " << m_currentBW); | 208 NS_LOG_LOGIC ("Estimated BW: " << m_currentBW); |
223 | 209 |
224 // Filter the BW sample | 210 // Filter the BW sample |
225 double alpha = 0.9; | 211 double alpha = 0.9; |
226 | 212 |
227 if (m_fType == TcpWestwood::NONE) | 213 if (m_fType == TcpWestwood::NONE) |
228 { | 214 { |
229 } | 215 } |
(...skipping 11 matching lines...) Expand all Loading... | |
241 uint32_t | 227 uint32_t |
242 TcpWestwood::GetSsThresh (Ptr<const TcpSocketState> tcb, | 228 TcpWestwood::GetSsThresh (Ptr<const TcpSocketState> tcb, |
243 uint32_t bytesInFlight) | 229 uint32_t bytesInFlight) |
244 { | 230 { |
245 | 231 |
246 (void) bytesInFlight; | 232 (void) bytesInFlight; |
247 NS_LOG_LOGIC ("CurrentBW: " << m_currentBW << " minRtt: " << | 233 NS_LOG_LOGIC ("CurrentBW: " << m_currentBW << " minRtt: " << |
248 m_minRtt << " ssthresh: " << | 234 m_minRtt << " ssthresh: " << |
249 m_currentBW * static_cast<double> (m_minRtt.GetSeconds ())); | 235 m_currentBW * static_cast<double> (m_minRtt.GetSeconds ())); |
250 · | 236 · |
251 · | |
252 double theta = 1.4; | 237 double theta = 1.4; |
253 · | 238 · |
254 // in TCPW-CRB, if the min_RTT is zero, we return the BW estimate instead of t he RE estimate | 239 // in Westwood CRB, if the min_RTT is zero, we return the BW estimate instead of the RE estimate |
Mohit Tahiliani
2017/04/15 07:36:45
in Westwood CRB
| |
255 if(m_minRtt.GetSeconds () !=0 && m_currentRE!=0 && (tcb->m_cWnd/(uint32_t (m_c urrentRE * static_cast<double> (m_minRtt.GetSeconds ()))) < theta)) | 240 if(m_minRtt.GetSeconds () != 0 && m_currentRE != 0 && (tcb->m_cWnd/(uint32_t ( m_currentRE * static_cast<double> (m_minRtt.GetSeconds ()))) < theta)) |
Mohit Tahiliani
2017/04/15 07:36:45
Give proper spaces, for example, it should be:
if
| |
256 { | 241 { |
257 return std::max (2*tcb->m_segmentSize, | 242 return std::max (2 * tcb->m_segmentSize, |
Mohit Tahiliani
2017/04/15 07:36:45
Spaces before and after *
| |
258 uint32_t (m_currentRE * static_cast<double> (m_minRtt.GetSeco nds ()))); | 243 uint32_t (m_currentRE * static_cast<double> (m_minRtt.GetSeco nds ()))); |
259 } | 244 }· |
260 · | |
Mohit Tahiliani
2017/04/15 07:36:46
blank line
| |
261 else | 245 else |
262 {· | 246 {· |
263 return std::max (2*tcb->m_segmentSize, | 247 return std::max (2 * tcb->m_segmentSize, |
Mohit Tahiliani
2017/04/15 07:36:45
Spaces before and after *
| |
264 uint32_t (m_currentBW * static_cast<double> (m_minRtt.GetSeco nds ()))); | 248 uint32_t (m_currentBW * static_cast<double> (m_minRtt.GetSeco nds ()))); |
265 } | 249 } |
266 | |
267 ·· | |
268 } | 250 } |
269 | 251 |
270 Ptr<TcpCongestionOps> | 252 Ptr<TcpCongestionOps> |
271 TcpWestwood::Fork () | 253 TcpWestwood::Fork () |
272 { | 254 { |
273 return CreateObject<TcpWestwood> (*this); | 255 return CreateObject<TcpWestwood> (*this); |
274 } | 256 } |
275 | 257 |
276 } // namespace ns3 | 258 } // namespace ns3 |
LEFT | RIGHT |