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) 2015 Natale Patriciello, <natale.patriciello@gmail.com> | 3 * Copyright (c) 2015 Natale Patriciello, <natale.patriciello@gmail.com> |
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 uint32_t ackCnt = 0; | 143 uint32_t ackCnt = 0; |
144 | 144 |
145 if (segCwnd < lowWindow.Get ()) | 145 if (segCwnd < lowWindow.Get ()) |
146 { | 146 { |
147 ackCnt = segCwnd; | 147 ackCnt = segCwnd; |
148 return ackCnt; | 148 return ackCnt; |
149 } | 149 } |
150 if (segCwnd < m_lastMaxCwnd) | 150 if (segCwnd < m_lastMaxCwnd) |
151 { | 151 { |
152 double midPt = (m_lastMaxCwnd - segCwnd) / bsCoeff.Get (); | 152 double midPt = static_cast<double> ((m_lastMaxCwnd - segCwnd) / bsCoeff.Ge
t ()); |
153 if (midPt > wMax.Get ()) | 153 if (midPt > wMax.Get ()) |
154 { | 154 { |
155 //Linear increase | 155 //Linear increase |
156 ackCnt = segCwnd / wMax.Get (); | 156 ackCnt = static_cast<uint32_t> (segCwnd / wMax.Get ()); |
157 } | 157 } |
158 else if (midPt <= 1) | 158 else if (midPt <= 1) |
159 { | 159 { |
160 ackCnt = (segCwnd * smoothPart.Get ()) / bsCoeff.Get (); | 160 ackCnt = static_cast<uint32_t> ((segCwnd * smoothPart.Get ()) / bsCoef
f.Get ()); |
161 } | 161 } |
162 else | 162 else |
163 { | 163 { |
164 //Binary search increase | 164 //Binary search increase |
165 ackCnt = segCwnd / midPt; | 165 ackCnt = static_cast<uint32_t> (segCwnd / midPt); |
166 } | 166 } |
167 } | 167 } |
168 else | 168 else |
169 { | 169 { |
170 if (segCwnd < m_lastMaxCwnd + bsCoeff.Get ()) | 170 if (segCwnd < m_lastMaxCwnd + bsCoeff.Get ()) |
171 { | 171 { |
172 /* slow start AMD linear increase */ | 172 /* slow start AMD linear increase */ |
173 ackCnt = (segCwnd * smoothPart.Get ()) / bsCoeff.Get (); | 173 ackCnt = static_cast<uint32_t> ((segCwnd * smoothPart.Get ()) / bsCoef
f.Get ()); |
174 } | 174 } |
175 else if (segCwnd < m_lastMaxCwnd + wMax.Get () * (bsCoeff.Get () - 1)) | 175 else if (segCwnd < m_lastMaxCwnd + wMax.Get () * (bsCoeff.Get () - 1)) |
176 { | 176 { |
177 /* slow start */ | 177 /* slow start */ |
178 ackCnt = (segCwnd * (bsCoeff.Get () - 1)) / (segCwnd - m_lastMaxCwnd); | 178 ackCnt = static_cast<uint32_t> ( (segCwnd * (bsCoeff.Get () - 1)) / (s
egCwnd - m_lastMaxCwnd)); |
179 } | 179 } |
180 else | 180 else |
181 { | 181 { |
182 /* linear increase */ | 182 /* linear increase */ |
183 ackCnt = segCwnd / wMax.Get (); | 183 ackCnt = static_cast<uint32_t> (segCwnd / wMax.Get ()); |
184 | 184 |
185 } | 185 } |
186 } | 186 } |
187 return ackCnt; | 187 return ackCnt; |
188 | 188 |
189 } | 189 } |
190 | 190 |
191 /** | 191 /** |
192 * \ingroup internet-test | 192 * \ingroup internet-test |
193 * \ingroup tests | 193 * \ingroup tests |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 265 |
266 DoubleValue beta; | 266 DoubleValue beta; |
267 UintegerValue lowWindow; | 267 UintegerValue lowWindow; |
268 cong->GetAttribute ("Beta", beta); | 268 cong->GetAttribute ("Beta", beta); |
269 cong->GetAttribute ("LowWnd", lowWindow); | 269 cong->GetAttribute ("LowWnd", lowWindow); |
270 | 270 |
271 uint32_t lastMaxCwnd, ssThresh; | 271 uint32_t lastMaxCwnd, ssThresh; |
272 | 272 |
273 if (segCwnd < m_lastMaxCwnd && m_fastConvergence.Get ()) | 273 if (segCwnd < m_lastMaxCwnd && m_fastConvergence.Get ()) |
274 { | 274 { |
275 lastMaxCwnd = beta.Get () * segCwnd; | 275 lastMaxCwnd = static_cast<uint32_t> (beta.Get () * segCwnd); |
276 NS_TEST_ASSERT_MSG_EQ (retLastMaxCwnd, lastMaxCwnd, | 276 NS_TEST_ASSERT_MSG_EQ (retLastMaxCwnd, lastMaxCwnd, |
277 "Bic has not updated lastMaxCwnd during fast conver
gence"); | 277 "Bic has not updated lastMaxCwnd during fast conver
gence"); |
278 } | 278 } |
279 else | 279 else |
280 { | 280 { |
281 lastMaxCwnd = segCwnd; | 281 lastMaxCwnd = segCwnd; |
282 NS_TEST_ASSERT_MSG_EQ (retLastMaxCwnd, lastMaxCwnd, | 282 NS_TEST_ASSERT_MSG_EQ (retLastMaxCwnd, lastMaxCwnd, |
283 "Bic has not reset lastMaxCwnd to current cwnd (in
segments)"); | 283 "Bic has not reset lastMaxCwnd to current cwnd (in
segments)"); |
284 } | 284 } |
285 | 285 |
286 | 286 |
287 if (segCwnd < lowWindow.Get ()) | 287 if (segCwnd < lowWindow.Get ()) |
288 { | 288 { |
289 ssThresh = std::max (2 * m_segmentSize, m_cWnd / 2); | 289 ssThresh = std::max (2 * m_segmentSize, m_cWnd / 2); |
290 NS_TEST_ASSERT_MSG_EQ (retSsThresh, ssThresh, | 290 NS_TEST_ASSERT_MSG_EQ (retSsThresh, ssThresh, |
291 "Bic has not updated ssThresh when cWnd less than l
owWindow"); | 291 "Bic has not updated ssThresh when cWnd less than l
owWindow"); |
292 } | 292 } |
293 else | 293 else |
294 { | 294 { |
295 ssThresh = std::max (segCwnd * beta.Get (), 2.0) * m_segmentSize; | 295 ssThresh = static_cast<uint32_t> (std::max (segCwnd * beta.Get (), 2.0) *
m_segmentSize); |
296 NS_TEST_ASSERT_MSG_EQ (retSsThresh, ssThresh, | 296 NS_TEST_ASSERT_MSG_EQ (retSsThresh, ssThresh, |
297 "Bic has not updated ssThresh when cWnd greater tha
n lowWindow"); | 297 "Bic has not updated ssThresh when cWnd greater tha
n lowWindow"); |
298 } | 298 } |
299 } | 299 } |
300 | 300 |
301 | 301 |
302 /** | 302 /** |
303 * \ingroup internet-test | 303 * \ingroup internet-test |
304 * \ingroup tests | 304 * \ingroup tests |
305 * | 305 * |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 AddTestCase (new TcpBicDecrementTest (5 * 1446, 1446, false, 10, | 341 AddTestCase (new TcpBicDecrementTest (5 * 1446, 1446, false, 10, |
342 "Bic decrement test: not in fast conve
rgence & cwnd less than lowWindow"), | 342 "Bic decrement test: not in fast conve
rgence & cwnd less than lowWindow"), |
343 TestCase::QUICK); | 343 TestCase::QUICK); |
344 AddTestCase (new TcpBicDecrementTest (15 * 1446, 1446, false, 10, | 344 AddTestCase (new TcpBicDecrementTest (15 * 1446, 1446, false, 10, |
345 "Bic decrement test: not in fast conve
rgence & cwnd greater than lowWindow"), | 345 "Bic decrement test: not in fast conve
rgence & cwnd greater than lowWindow"), |
346 TestCase::QUICK); | 346 TestCase::QUICK); |
347 } | 347 } |
348 }; | 348 }; |
349 | 349 |
350 static TcpBicTestSuite g_tcpBicTest; //!< Static variable for test initializatio
n | 350 static TcpBicTestSuite g_tcpBicTest; //!< Static variable for test initializatio
n |
OLD | NEW |