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) 2004,2005,2006 INRIA | 3 * Copyright (c) 2004,2005,2006 INRIA |
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: Federico Maguolo <maguolof@dei.unipd.it> | 18 * Author: Federico Maguolo <maguolof@dei.unipd.it> |
19 */ | 19 */ |
20 | 20 |
21 #include "ns3/log.h" | |
22 #include "ns3/packet.h" | |
23 #include "ns3/simulator.h" | |
21 #include "rraa-wifi-manager.h" | 24 #include "rraa-wifi-manager.h" |
25 #include "wifi-phy.h" | |
22 #include "wifi-mac.h" | 26 #include "wifi-mac.h" |
23 #include "ns3/log.h" | |
24 #include "ns3/boolean.h" | |
25 #include "ns3/double.h" | |
26 #include "ns3/uinteger.h" | |
27 #include "ns3/simulator.h" | |
28 | 27 |
29 #define Min(a,b) ((a < b) ? a : b) | 28 #define Min(a,b) ((a < b) ? a : b) |
30 | 29 |
31 namespace ns3 { | 30 namespace ns3 { |
32 | 31 |
33 NS_LOG_COMPONENT_DEFINE ("RraaWifiManager"); | 32 NS_LOG_COMPONENT_DEFINE ("RraaWifiManager"); |
34 | 33 |
35 /** | 34 /** |
36 * \brief hold per-remote-station state for RRAA Wifi manager. | 35 * \brief hold per-remote-station state for RRAA Wifi manager. |
37 * | 36 * |
38 * This struct extends from WifiRemoteStation struct to hold additional | 37 * This struct extends from WifiRemoteStation struct to hold additional |
39 * information required by the RRAA Wifi manager | 38 * information required by the RRAA Wifi manager |
40 */ | 39 */ |
41 struct RraaWifiRemoteStation : public WifiRemoteStation | 40 struct RraaWifiRemoteStation : public WifiRemoteStation |
42 { | 41 { |
43 uint32_t m_counter; //!< Counter for transmission attempts. | 42 uint32_t m_counter; //!< Counter for transmission attempts. |
44 uint32_t m_nFailed; //!< Number of failed transmission attempts. | 43 uint32_t m_nFailed; //!< Number of failed transmission attempts. |
45 uint32_t m_adaptiveRtsWnd; //!< Window size for the Adaptive RTS mechanism . | 44 uint32_t m_adaptiveRtsWnd; //!< Window size for the Adaptive RTS mechanism . |
46 uint32_t m_rtsCounter; //!< Counter for RTS transmission attempts. | 45 uint32_t m_rtsCounter; //!< Counter for RTS transmission attempts. |
47 Time m_lastReset; //!< Time of the last reset. | 46 Time m_lastReset; //!< Time of the last reset. |
48 bool m_adaptiveRtsOn; //!< Check if Adaptive RTS mechanism is on. | 47 bool m_adaptiveRtsOn; //!< Check if Adaptive RTS mechanism is on. |
49 bool m_lastFrameFail; //!< Flag if the last frame sent has failed. | 48 bool m_lastFrameFail; //!< Flag if the last frame sent has failed. |
50 bool m_initialized; //!< For initializing variables. | 49 bool m_initialized; //!< For initializing variables. |
51 | |
52 uint8_t m_nRate; //!< Number of supported rates. | 50 uint8_t m_nRate; //!< Number of supported rates. |
53 | |
54 uint8_t m_rateIndex; //!< Current rate index. | 51 uint8_t m_rateIndex; //!< Current rate index. |
55 | 52 |
56 RraaThresholdsTable m_thresholds; //!< RRAA thresholds for this station. | 53 RraaThresholdsTable m_thresholds; //!< RRAA thresholds for this station. |
57 }; | 54 }; |
58 | 55 |
59 NS_OBJECT_ENSURE_REGISTERED (RraaWifiManager); | 56 NS_OBJECT_ENSURE_REGISTERED (RraaWifiManager); |
60 | 57 |
61 TypeId | 58 TypeId |
62 RraaWifiManager::GetTypeId (void) | 59 RraaWifiManager::GetTypeId (void) |
63 { | 60 { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 "ns3::TracedValueCallback::Uint64") | 103 "ns3::TracedValueCallback::Uint64") |
107 ; | 104 ; |
108 return tid; | 105 return tid; |
109 } | 106 } |
110 | 107 |
111 | 108 |
112 RraaWifiManager::RraaWifiManager () | 109 RraaWifiManager::RraaWifiManager () |
113 : WifiRemoteStationManager (), | 110 : WifiRemoteStationManager (), |
114 m_currentRate (0) | 111 m_currentRate (0) |
115 { | 112 { |
113 NS_LOG_FUNCTION (this); | |
116 } | 114 } |
117 | 115 |
118 RraaWifiManager::~RraaWifiManager () | 116 RraaWifiManager::~RraaWifiManager () |
119 { | 117 { |
118 NS_LOG_FUNCTION (this); | |
120 } | 119 } |
121 | 120 |
122 void | 121 void |
123 RraaWifiManager::SetupPhy (const Ptr<WifiPhy> phy) | 122 RraaWifiManager::SetupPhy (const Ptr<WifiPhy> phy) |
124 { | 123 { |
125 NS_LOG_FUNCTION (this); | 124 NS_LOG_FUNCTION (this << phy); |
126 uint8_t nModes = phy->GetNModes (); | 125 uint8_t nModes = phy->GetNModes (); |
127 for (uint8_t i = 0; i < nModes; i++) | 126 for (uint8_t i = 0; i < nModes; i++) |
128 { | 127 { |
129 WifiMode mode = phy->GetMode (i); | 128 WifiMode mode = phy->GetMode (i); |
130 WifiTxVector txVector; | 129 WifiTxVector txVector; |
131 txVector.SetMode (mode); | 130 txVector.SetMode (mode); |
132 txVector.SetPreambleType (WIFI_PREAMBLE_LONG); | 131 txVector.SetPreambleType (WIFI_PREAMBLE_LONG); |
133 /* Calculate the TX Time of the data and the corresponding ACK*/ | 132 /* Calculate the TX Time of the data and the corresponding ACK*/ |
134 Time dataTxTime = phy->CalculateTxDuration (m_frameLength, txVector, phy-> GetFrequency ()); | 133 Time dataTxTime = phy->CalculateTxDuration (m_frameLength, txVector, phy-> GetFrequency ()); |
135 Time ackTxTime = phy->CalculateTxDuration (m_ackLength, txVector, phy->Get Frequency ()); | 134 Time ackTxTime = phy->CalculateTxDuration (m_ackLength, txVector, phy->Get Frequency ()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 | 199 |
201 void | 200 void |
202 RraaWifiManager::CheckInit (RraaWifiRemoteStation *station) | 201 RraaWifiManager::CheckInit (RraaWifiRemoteStation *station) |
203 { | 202 { |
204 NS_LOG_FUNCTION (this << station); | 203 NS_LOG_FUNCTION (this << station); |
205 if (!station->m_initialized) | 204 if (!station->m_initialized) |
206 { | 205 { |
207 //Note: we appear to be doing late initialization of the table | 206 //Note: we appear to be doing late initialization of the table |
208 //to make sure that the set of supported rates has been initialized | 207 //to make sure that the set of supported rates has been initialized |
209 //before we perform our own initialization. | 208 //before we perform our own initialization. |
210 station->m_nRate = static_cast<uint8_t>(GetNSupported (station)); | 209 station->m_nRate = GetNSupported (station); |
211 //Initialize at maximal rate | 210 //Initialize at maximal rate |
212 station->m_rateIndex = GetMaxRate (station); | 211 station->m_rateIndex = GetMaxRate (station); |
213 | 212 |
214 station->m_initialized = true; | 213 station->m_initialized = true; |
215 | 214 |
216 station->m_thresholds = RraaThresholdsTable (station->m_nRate); | 215 station->m_thresholds = RraaThresholdsTable (station->m_nRate); |
217 InitThresholds (station); | 216 InitThresholds (station); |
218 ResetCountersBasic (station); | 217 ResetCountersBasic (station); |
219 } | 218 } |
220 } | 219 } |
(...skipping 22 matching lines...) Expand all Loading... | |
243 Time nextTotalTxTime = GetCalcTxTime (nextMode) + m_sifs + m_difs; | 242 Time nextTotalTxTime = GetCalcTxTime (nextMode) + m_sifs + m_difs; |
244 nextCritical = 1 - (nextTotalTxTime.GetSeconds () / totalTxTime.GetSec onds ()); | 243 nextCritical = 1 - (nextTotalTxTime.GetSeconds () / totalTxTime.GetSec onds ()); |
245 nextMtl = m_alpha * nextCritical; | 244 nextMtl = m_alpha * nextCritical; |
246 ori = nextMtl / m_beta; | 245 ori = nextMtl / m_beta; |
247 } | 246 } |
248 if (i == 0) | 247 if (i == 0) |
249 { | 248 { |
250 mtl = 1; | 249 mtl = 1; |
251 } | 250 } |
252 WifiRraaThresholds th; | 251 WifiRraaThresholds th; |
253 th.m_ewnd = static_cast<uint32_t>(ceil (m_tau / totalTxTime.GetSeconds ()) ); | 252 th.m_ewnd = static_cast<uint32_t> (ceil (m_tau / totalTxTime.GetSeconds () )); |
S. Deronne
2018/02/17 08:13:15
change type of m_ewnd?
| |
254 th.m_ori = ori; | 253 th.m_ori = ori; |
255 th.m_mtl = mtl; | 254 th.m_mtl = mtl; |
256 station->m_thresholds.push_back (std::make_pair (th, mode)); | 255 station->m_thresholds.push_back (std::make_pair (th, mode)); |
257 mtl = nextMtl; | 256 mtl = nextMtl; |
258 NS_LOG_DEBUG (mode << " " << th.m_ewnd << " " << th.m_mtl << " " << th.m_o ri); | 257 NS_LOG_DEBUG (mode << " " << th.m_ewnd << " " << th.m_mtl << " " << th.m_o ri); |
259 } | 258 } |
260 } | 259 } |
261 | 260 |
262 void | 261 void |
263 RraaWifiManager::ResetCountersBasic (RraaWifiRemoteStation *station) | 262 RraaWifiManager::ResetCountersBasic (RraaWifiRemoteStation *station) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
297 double rxSnr, WifiMode txMode) | 296 double rxSnr, WifiMode txMode) |
298 { | 297 { |
299 NS_LOG_FUNCTION (this << st << rxSnr << txMode); | 298 NS_LOG_FUNCTION (this << st << rxSnr << txMode); |
300 } | 299 } |
301 | 300 |
302 void | 301 void |
303 RraaWifiManager::DoReportRtsOk (WifiRemoteStation *st, | 302 RraaWifiManager::DoReportRtsOk (WifiRemoteStation *st, |
304 double ctsSnr, WifiMode ctsMode, double rtsSnr) | 303 double ctsSnr, WifiMode ctsMode, double rtsSnr) |
305 { | 304 { |
306 NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr); | 305 NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr); |
307 NS_LOG_DEBUG ("self=" << st << " rts ok"); | |
308 } | 306 } |
309 | 307 |
310 void | 308 void |
311 RraaWifiManager::DoReportDataOk (WifiRemoteStation *st, | 309 RraaWifiManager::DoReportDataOk (WifiRemoteStation *st, |
312 double ackSnr, WifiMode ackMode, double dataSnr ) | 310 double ackSnr, WifiMode ackMode, double dataSnr ) |
313 { | 311 { |
314 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); | 312 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); |
315 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; | 313 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; |
316 station->m_lastFrameFail = false; | 314 station->m_lastFrameFail = false; |
317 CheckTimeout (station); | 315 CheckTimeout (station); |
(...skipping 11 matching lines...) Expand all Loading... | |
329 RraaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) | 327 RraaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) |
330 { | 328 { |
331 NS_LOG_FUNCTION (this << st); | 329 NS_LOG_FUNCTION (this << st); |
332 } | 330 } |
333 | 331 |
334 WifiTxVector | 332 WifiTxVector |
335 RraaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) | 333 RraaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) |
336 { | 334 { |
337 NS_LOG_FUNCTION (this << st); | 335 NS_LOG_FUNCTION (this << st); |
338 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; | 336 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; |
339 uint32_t channelWidth = GetChannelWidth (station); | 337 uint16_t channelWidth = GetChannelWidth (station); |
340 if (channelWidth > 20 && channelWidth != 22) | 338 if (channelWidth > 20 && channelWidth != 22) |
341 { | 339 { |
342 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 340 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
343 channelWidth = 20; | 341 channelWidth = 20; |
344 } | 342 } |
345 CheckInit (station); | 343 CheckInit (station); |
346 WifiMode mode = GetSupported (station, station->m_rateIndex); | 344 WifiMode mode = GetSupported (station, station->m_rateIndex); |
347 if (m_currentRate != mode.GetDataRate (static_cast<uint8_t>(channelWidth))) | 345 if (m_currentRate != mode.GetDataRate (channelWidth)) |
S. Deronne
2018/02/17 08:13:15
Instead, I will change the channel width to uint8_
ammo6818-vandals.uidaho.edu
2018/02/18 05:13:09
change incorporated.
| |
348 { | 346 { |
349 NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (static_cast<uint8_t>(c hannelWidth))); | 347 NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (channelWidth)); |
350 m_currentRate = mode.GetDataRate (static_cast<uint8_t>(channelWidth)); | 348 m_currentRate = mode.GetDataRate (channelWidth); |
351 } | 349 } |
352 return WifiTxVector (mode, GetDefaultTxPowerLevel (), static_cast<uint8_t>(Get LongRetryCount (station)), GetPreambleForTransmission (mode, GetAddress (station )), 800, 1, 1, 0, (uint8_t)channelWidth, GetAggregation (station), false); | 350 return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmissi on (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (sta tion), false); |
353 } | 351 } |
354 | 352 |
355 WifiTxVector | 353 WifiTxVector |
356 RraaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) | 354 RraaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) |
357 { | 355 { |
358 NS_LOG_FUNCTION (this << st); | 356 NS_LOG_FUNCTION (this << st); |
359 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; | 357 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; |
360 uint32_t channelWidth = GetChannelWidth (station); | 358 uint16_t channelWidth = GetChannelWidth (station); |
361 if (channelWidth > 20 && channelWidth != 22) | 359 if (channelWidth > 20 && channelWidth != 22) |
362 { | 360 { |
363 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 361 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
364 channelWidth = 20; | 362 channelWidth = 20; |
365 } | 363 } |
366 WifiTxVector rtsTxVector; | 364 WifiTxVector rtsTxVector; |
367 WifiMode mode; | 365 WifiMode mode; |
368 if (GetUseNonErpProtection () == false) | 366 if (GetUseNonErpProtection () == false) |
369 { | 367 { |
370 mode = GetSupported (station, 0); | 368 mode = GetSupported (station, 0); |
371 } | 369 } |
372 else | 370 else |
373 { | 371 { |
374 mode = GetNonErpSupported (station, 0); | 372 mode = GetNonErpSupported (station, 0); |
375 } | 373 } |
376 rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), static_cast<uint8 _t>(GetShortRetryCount (station)), GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1, 0, (uint8_t)channelWidth, GetAggregation (station), false ); | 374 rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTra nsmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregati on (station), false); |
377 return rtsTxVector; | 375 return rtsTxVector; |
378 } | 376 } |
379 | 377 |
380 bool | 378 bool |
381 RraaWifiManager::DoNeedRts (WifiRemoteStation *st, | 379 RraaWifiManager::DoNeedRts (WifiRemoteStation *st, |
382 Ptr<const Packet> packet, bool normally) | 380 Ptr<const Packet> packet, bool normally) |
383 { | 381 { |
384 NS_LOG_FUNCTION (this << st << packet << normally); | 382 NS_LOG_FUNCTION (this << st << packet << normally); |
385 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; | 383 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; |
386 CheckInit (station); | 384 CheckInit (station); |
(...skipping 14 matching lines...) Expand all Loading... | |
401 { | 399 { |
402 ResetCountersBasic (station); | 400 ResetCountersBasic (station); |
403 } | 401 } |
404 } | 402 } |
405 | 403 |
406 void | 404 void |
407 RraaWifiManager::RunBasicAlgorithm (RraaWifiRemoteStation *station) | 405 RraaWifiManager::RunBasicAlgorithm (RraaWifiRemoteStation *station) |
408 { | 406 { |
409 NS_LOG_FUNCTION (this << station); | 407 NS_LOG_FUNCTION (this << station); |
410 WifiRraaThresholds thresholds = GetThresholds (station, station->m_rateIndex); | 408 WifiRraaThresholds thresholds = GetThresholds (station, station->m_rateIndex); |
411 double ploss = (static_cast<double> (station->m_nFailed) / thresholds.m_ewnd); | 409 double ploss = (station->m_nFailed / thresholds.m_ewnd); |
412 if (station->m_counter == 0 | 410 if (station->m_counter == 0 |
413 || ploss > thresholds.m_mtl) | 411 || ploss > thresholds.m_mtl) |
414 { | 412 { |
415 if (ploss > thresholds.m_mtl) | 413 if (ploss > thresholds.m_mtl) |
416 { | 414 { |
417 station->m_rateIndex--; | 415 station->m_rateIndex--; |
418 } | 416 } |
419 else if (station->m_rateIndex < GetMaxRate (station) | 417 else if (station->m_rateIndex < GetMaxRate (station) |
420 && ploss < thresholds.m_ori) | 418 && ploss < thresholds.m_ori) |
421 { | 419 { |
(...skipping 23 matching lines...) Expand all Loading... | |
445 station->m_adaptiveRtsOn = true; | 443 station->m_adaptiveRtsOn = true; |
446 station->m_rtsCounter--; | 444 station->m_rtsCounter--; |
447 } | 445 } |
448 else | 446 else |
449 { | 447 { |
450 station->m_adaptiveRtsOn = false; | 448 station->m_adaptiveRtsOn = false; |
451 } | 449 } |
452 } | 450 } |
453 | 451 |
454 WifiRraaThresholds | 452 WifiRraaThresholds |
455 RraaWifiManager::GetThresholds (RraaWifiRemoteStation *station, | 453 RraaWifiManager::GetThresholds (RraaWifiRemoteStation *station, uint8_t rate) co nst |
456 uint32_t rate) const | 454 { |
457 { | 455 NS_LOG_FUNCTION (this << station << +rate); |
458 NS_LOG_FUNCTION (this << station << rate); | |
459 WifiMode mode = GetSupported (station, rate); | 456 WifiMode mode = GetSupported (station, rate); |
460 return GetThresholds (station, mode); | 457 return GetThresholds (station, mode); |
461 } | 458 } |
462 | 459 |
463 bool | 460 bool |
464 RraaWifiManager::IsLowLatency (void) const | 461 RraaWifiManager::IsLowLatency (void) const |
465 { | 462 { |
466 return true; | 463 return true; |
467 } | 464 } |
468 | 465 |
(...skipping 21 matching lines...) Expand all Loading... | |
490 RraaWifiManager::SetHeSupported (bool enable) | 487 RraaWifiManager::SetHeSupported (bool enable) |
491 { | 488 { |
492 //HE is not supported by this algorithm. | 489 //HE is not supported by this algorithm. |
493 if (enable) | 490 if (enable) |
494 { | 491 { |
495 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat es"); | 492 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat es"); |
496 } | 493 } |
497 } | 494 } |
498 | 495 |
499 } //namespace ns3 | 496 } //namespace ns3 |
LEFT | RIGHT |