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 * |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 "ns3::TracedValueCallback::Uint64") | 103 "ns3::TracedValueCallback::Uint64") |
105 ; | 104 ; |
106 return tid; | 105 return tid; |
107 } | 106 } |
108 | 107 |
109 | 108 |
110 RraaWifiManager::RraaWifiManager () | 109 RraaWifiManager::RraaWifiManager () |
111 : WifiRemoteStationManager (), | 110 : WifiRemoteStationManager (), |
112 m_currentRate (0) | 111 m_currentRate (0) |
113 { | 112 { |
| 113 NS_LOG_FUNCTION (this); |
114 } | 114 } |
115 | 115 |
116 RraaWifiManager::~RraaWifiManager () | 116 RraaWifiManager::~RraaWifiManager () |
117 { | 117 { |
| 118 NS_LOG_FUNCTION (this); |
118 } | 119 } |
119 | 120 |
120 void | 121 void |
121 RraaWifiManager::SetupPhy (const Ptr<WifiPhy> phy) | 122 RraaWifiManager::SetupPhy (const Ptr<WifiPhy> phy) |
122 { | 123 { |
123 NS_LOG_FUNCTION (this); | 124 NS_LOG_FUNCTION (this << phy); |
124 uint8_t nModes = phy->GetNModes (); | 125 uint8_t nModes = phy->GetNModes (); |
125 for (uint8_t i = 0; i < nModes; i++) | 126 for (uint8_t i = 0; i < nModes; i++) |
126 { | 127 { |
127 WifiMode mode = phy->GetMode (i); | 128 WifiMode mode = phy->GetMode (i); |
128 WifiTxVector txVector; | 129 WifiTxVector txVector; |
129 txVector.SetMode (mode); | 130 txVector.SetMode (mode); |
130 txVector.SetPreambleType (WIFI_PREAMBLE_LONG); | 131 txVector.SetPreambleType (WIFI_PREAMBLE_LONG); |
131 /* Calculate the TX Time of the data and the corresponding ACK*/ | 132 /* Calculate the TX Time of the data and the corresponding ACK*/ |
132 Time dataTxTime = phy->CalculateTxDuration (m_frameLength, txVector, phy->
GetFrequency ()); | 133 Time dataTxTime = phy->CalculateTxDuration (m_frameLength, txVector, phy->
GetFrequency ()); |
133 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... |
198 | 199 |
199 void | 200 void |
200 RraaWifiManager::CheckInit (RraaWifiRemoteStation *station) | 201 RraaWifiManager::CheckInit (RraaWifiRemoteStation *station) |
201 { | 202 { |
202 NS_LOG_FUNCTION (this << station); | 203 NS_LOG_FUNCTION (this << station); |
203 if (!station->m_initialized) | 204 if (!station->m_initialized) |
204 { | 205 { |
205 //Note: we appear to be doing late initialization of the table | 206 //Note: we appear to be doing late initialization of the table |
206 //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 |
207 //before we perform our own initialization. | 208 //before we perform our own initialization. |
208 station->m_nRate = static_cast<uint8_t>(GetNSupported (station)); | 209 station->m_nRate = GetNSupported (station); |
209 //Initialize at maximal rate | 210 //Initialize at maximal rate |
210 station->m_rateIndex = GetMaxRate (station); | 211 station->m_rateIndex = GetMaxRate (station); |
211 | 212 |
212 station->m_initialized = true; | 213 station->m_initialized = true; |
213 | 214 |
214 station->m_thresholds = RraaThresholdsTable (station->m_nRate); | 215 station->m_thresholds = RraaThresholdsTable (station->m_nRate); |
215 InitThresholds (station); | 216 InitThresholds (station); |
216 ResetCountersBasic (station); | 217 ResetCountersBasic (station); |
217 } | 218 } |
218 } | 219 } |
(...skipping 22 matching lines...) Expand all Loading... |
241 Time nextTotalTxTime = GetCalcTxTime (nextMode) + m_sifs + m_difs; | 242 Time nextTotalTxTime = GetCalcTxTime (nextMode) + m_sifs + m_difs; |
242 nextCritical = 1 - (nextTotalTxTime.GetSeconds () / totalTxTime.GetSec
onds ()); | 243 nextCritical = 1 - (nextTotalTxTime.GetSeconds () / totalTxTime.GetSec
onds ()); |
243 nextMtl = m_alpha * nextCritical; | 244 nextMtl = m_alpha * nextCritical; |
244 ori = nextMtl / m_beta; | 245 ori = nextMtl / m_beta; |
245 } | 246 } |
246 if (i == 0) | 247 if (i == 0) |
247 { | 248 { |
248 mtl = 1; | 249 mtl = 1; |
249 } | 250 } |
250 WifiRraaThresholds th; | 251 WifiRraaThresholds th; |
251 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 ()
)); |
252 th.m_ori = ori; | 253 th.m_ori = ori; |
253 th.m_mtl = mtl; | 254 th.m_mtl = mtl; |
254 station->m_thresholds.push_back (std::make_pair (th, mode)); | 255 station->m_thresholds.push_back (std::make_pair (th, mode)); |
255 mtl = nextMtl; | 256 mtl = nextMtl; |
256 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); |
257 } | 258 } |
258 } | 259 } |
259 | 260 |
260 void | 261 void |
261 RraaWifiManager::ResetCountersBasic (RraaWifiRemoteStation *station) | 262 RraaWifiManager::ResetCountersBasic (RraaWifiRemoteStation *station) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 double rxSnr, WifiMode txMode) | 296 double rxSnr, WifiMode txMode) |
296 { | 297 { |
297 NS_LOG_FUNCTION (this << st << rxSnr << txMode); | 298 NS_LOG_FUNCTION (this << st << rxSnr << txMode); |
298 } | 299 } |
299 | 300 |
300 void | 301 void |
301 RraaWifiManager::DoReportRtsOk (WifiRemoteStation *st, | 302 RraaWifiManager::DoReportRtsOk (WifiRemoteStation *st, |
302 double ctsSnr, WifiMode ctsMode, double rtsSnr) | 303 double ctsSnr, WifiMode ctsMode, double rtsSnr) |
303 { | 304 { |
304 NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr); | 305 NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr); |
305 NS_LOG_DEBUG ("self=" << st << " rts ok"); | |
306 } | 306 } |
307 | 307 |
308 void | 308 void |
309 RraaWifiManager::DoReportDataOk (WifiRemoteStation *st, | 309 RraaWifiManager::DoReportDataOk (WifiRemoteStation *st, |
310 double ackSnr, WifiMode ackMode, double dataSnr
) | 310 double ackSnr, WifiMode ackMode, double dataSnr
) |
311 { | 311 { |
312 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); | 312 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); |
313 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; | 313 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; |
314 station->m_lastFrameFail = false; | 314 station->m_lastFrameFail = false; |
315 CheckTimeout (station); | 315 CheckTimeout (station); |
(...skipping 11 matching lines...) Expand all Loading... |
327 RraaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) | 327 RraaWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) |
328 { | 328 { |
329 NS_LOG_FUNCTION (this << st); | 329 NS_LOG_FUNCTION (this << st); |
330 } | 330 } |
331 | 331 |
332 WifiTxVector | 332 WifiTxVector |
333 RraaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) | 333 RraaWifiManager::DoGetDataTxVector (WifiRemoteStation *st) |
334 { | 334 { |
335 NS_LOG_FUNCTION (this << st); | 335 NS_LOG_FUNCTION (this << st); |
336 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; | 336 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; |
337 uint8_t channelWidth = GetChannelWidth (station); | 337 uint16_t channelWidth = GetChannelWidth (station); |
338 if (channelWidth > 20 && channelWidth != 22) | 338 if (channelWidth > 20 && channelWidth != 22) |
339 { | 339 { |
340 //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 |
341 channelWidth = 20; | 341 channelWidth = 20; |
342 } | 342 } |
343 CheckInit (station); | 343 CheckInit (station); |
344 WifiMode mode = GetSupported (station, station->m_rateIndex); | 344 WifiMode mode = GetSupported (station, station->m_rateIndex); |
345 if (m_currentRate != mode.GetDataRate (static_cast<uint8_t>(channelWidth))) | 345 if (m_currentRate != mode.GetDataRate (channelWidth)) |
346 { | 346 { |
347 NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (static_cast<uint8_t>(c
hannelWidth))); | 347 NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (channelWidth)); |
348 m_currentRate = mode.GetDataRate (static_cast<uint8_t>(channelWidth)); | 348 m_currentRate = mode.GetDataRate (channelWidth); |
349 } | 349 } |
350 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); |
351 } | 351 } |
352 | 352 |
353 WifiTxVector | 353 WifiTxVector |
354 RraaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) | 354 RraaWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) |
355 { | 355 { |
356 NS_LOG_FUNCTION (this << st); | 356 NS_LOG_FUNCTION (this << st); |
357 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; | 357 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; |
358 uint8_t channelWidth = GetChannelWidth (station); | 358 uint16_t channelWidth = GetChannelWidth (station); |
359 if (channelWidth > 20 && channelWidth != 22) | 359 if (channelWidth > 20 && channelWidth != 22) |
360 { | 360 { |
361 //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 |
362 channelWidth = 20; | 362 channelWidth = 20; |
363 } | 363 } |
364 WifiTxVector rtsTxVector; | 364 WifiTxVector rtsTxVector; |
365 WifiMode mode; | 365 WifiMode mode; |
366 if (GetUseNonErpProtection () == false) | 366 if (GetUseNonErpProtection () == false) |
367 { | 367 { |
368 mode = GetSupported (station, 0); | 368 mode = GetSupported (station, 0); |
369 } | 369 } |
370 else | 370 else |
371 { | 371 { |
372 mode = GetNonErpSupported (station, 0); | 372 mode = GetNonErpSupported (station, 0); |
373 } | 373 } |
374 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); |
375 return rtsTxVector; | 375 return rtsTxVector; |
376 } | 376 } |
377 | 377 |
378 bool | 378 bool |
379 RraaWifiManager::DoNeedRts (WifiRemoteStation *st, | 379 RraaWifiManager::DoNeedRts (WifiRemoteStation *st, |
380 Ptr<const Packet> packet, bool normally) | 380 Ptr<const Packet> packet, bool normally) |
381 { | 381 { |
382 NS_LOG_FUNCTION (this << st << packet << normally); | 382 NS_LOG_FUNCTION (this << st << packet << normally); |
383 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; | 383 RraaWifiRemoteStation *station = (RraaWifiRemoteStation *) st; |
384 CheckInit (station); | 384 CheckInit (station); |
(...skipping 14 matching lines...) Expand all Loading... |
399 { | 399 { |
400 ResetCountersBasic (station); | 400 ResetCountersBasic (station); |
401 } | 401 } |
402 } | 402 } |
403 | 403 |
404 void | 404 void |
405 RraaWifiManager::RunBasicAlgorithm (RraaWifiRemoteStation *station) | 405 RraaWifiManager::RunBasicAlgorithm (RraaWifiRemoteStation *station) |
406 { | 406 { |
407 NS_LOG_FUNCTION (this << station); | 407 NS_LOG_FUNCTION (this << station); |
408 WifiRraaThresholds thresholds = GetThresholds (station, station->m_rateIndex); | 408 WifiRraaThresholds thresholds = GetThresholds (station, station->m_rateIndex); |
409 double ploss = (static_cast<double> (station->m_nFailed) / thresholds.m_ewnd); | 409 double ploss = (station->m_nFailed / thresholds.m_ewnd); |
410 if (station->m_counter == 0 | 410 if (station->m_counter == 0 |
411 || ploss > thresholds.m_mtl) | 411 || ploss > thresholds.m_mtl) |
412 { | 412 { |
413 if (ploss > thresholds.m_mtl) | 413 if (ploss > thresholds.m_mtl) |
414 { | 414 { |
415 station->m_rateIndex--; | 415 station->m_rateIndex--; |
416 } | 416 } |
417 else if (station->m_rateIndex < GetMaxRate (station) | 417 else if (station->m_rateIndex < GetMaxRate (station) |
418 && ploss < thresholds.m_ori) | 418 && ploss < thresholds.m_ori) |
419 { | 419 { |
(...skipping 25 matching lines...) Expand all Loading... |
445 } | 445 } |
446 else | 446 else |
447 { | 447 { |
448 station->m_adaptiveRtsOn = false; | 448 station->m_adaptiveRtsOn = false; |
449 } | 449 } |
450 } | 450 } |
451 | 451 |
452 WifiRraaThresholds | 452 WifiRraaThresholds |
453 RraaWifiManager::GetThresholds (RraaWifiRemoteStation *station, uint8_t rate) co
nst | 453 RraaWifiManager::GetThresholds (RraaWifiRemoteStation *station, uint8_t rate) co
nst |
454 { | 454 { |
455 NS_LOG_FUNCTION (this << station << static_cast<uint16_t>(rate)); | 455 NS_LOG_FUNCTION (this << station << +rate); |
456 WifiMode mode = GetSupported (station, rate); | 456 WifiMode mode = GetSupported (station, rate); |
457 return GetThresholds (station, mode); | 457 return GetThresholds (station, mode); |
458 } | 458 } |
459 | 459 |
460 bool | 460 bool |
461 RraaWifiManager::IsLowLatency (void) const | 461 RraaWifiManager::IsLowLatency (void) const |
462 { | 462 { |
463 return true; | 463 return true; |
464 } | 464 } |
465 | 465 |
(...skipping 21 matching lines...) Expand all Loading... |
487 RraaWifiManager::SetHeSupported (bool enable) | 487 RraaWifiManager::SetHeSupported (bool enable) |
488 { | 488 { |
489 //HE is not supported by this algorithm. | 489 //HE is not supported by this algorithm. |
490 if (enable) | 490 if (enable) |
491 { | 491 { |
492 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); | 492 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); |
493 } | 493 } |
494 } | 494 } |
495 | 495 |
496 } //namespace ns3 | 496 } //namespace ns3 |
LEFT | RIGHT |