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) 2009 Duy Nguyen | 3 * Copyright (c) 2009 Duy Nguyen |
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 11 matching lines...) Expand all Loading... |
22 * | 22 * |
23 * 1) Segment Size is declared for completeness but not used because it has | 23 * 1) Segment Size is declared for completeness but not used because it has |
24 * to do more with the requirement of the specific hardware. | 24 * to do more with the requirement of the specific hardware. |
25 * | 25 * |
26 * 2) By default, Minstrel applies the multi-rate retry (the core of Minstrel | 26 * 2) By default, Minstrel applies the multi-rate retry (the core of Minstrel |
27 * algorithm). Otherwise, please use ConstantRateWifiManager instead. | 27 * algorithm). Otherwise, please use ConstantRateWifiManager instead. |
28 * | 28 * |
29 * http://linuxwireless.org/en/developers/Documentation/mac80211/RateControl/min
strel | 29 * http://linuxwireless.org/en/developers/Documentation/mac80211/RateControl/min
strel |
30 */ | 30 */ |
31 | 31 |
32 #include "minstrel-wifi-manager.h" | 32 #include <iomanip> |
| 33 #include "ns3/packet.h" |
| 34 #include "ns3/random-variable-stream.h" |
33 #include "ns3/simulator.h" | 35 #include "ns3/simulator.h" |
34 #include "ns3/log.h" | 36 #include "ns3/log.h" |
35 #include "ns3/double.h" | 37 #include "minstrel-wifi-manager.h" |
36 #include "ns3/boolean.h" | |
37 #include "wifi-mac.h" | 38 #include "wifi-mac.h" |
38 #include "wifi-phy.h" | 39 #include "wifi-phy.h" |
39 #include <iomanip> | |
40 | 40 |
41 #define Min(a,b) ((a < b) ? a : b) | 41 #define Min(a,b) ((a < b) ? a : b) |
42 | 42 |
43 namespace ns3 { | 43 namespace ns3 { |
44 | 44 |
45 NS_LOG_COMPONENT_DEFINE ("MinstrelWifiManager"); | 45 NS_LOG_COMPONENT_DEFINE ("MinstrelWifiManager"); |
46 | 46 |
47 NS_OBJECT_ENSURE_REGISTERED (MinstrelWifiManager); | 47 NS_OBJECT_ENSURE_REGISTERED (MinstrelWifiManager); |
48 | 48 |
49 TypeId | 49 TypeId |
(...skipping 26 matching lines...) Expand all Loading... |
76 .AddAttribute ("PacketLength", | 76 .AddAttribute ("PacketLength", |
77 "The packet length used for calculating mode TxTime", | 77 "The packet length used for calculating mode TxTime", |
78 UintegerValue (1200), | 78 UintegerValue (1200), |
79 MakeUintegerAccessor (&MinstrelWifiManager::m_pktLen), | 79 MakeUintegerAccessor (&MinstrelWifiManager::m_pktLen), |
80 MakeUintegerChecker <uint32_t> ()) | 80 MakeUintegerChecker <uint32_t> ()) |
81 .AddAttribute ("PrintStats", | 81 .AddAttribute ("PrintStats", |
82 "Print statistics table", | 82 "Print statistics table", |
83 BooleanValue (false), | 83 BooleanValue (false), |
84 MakeBooleanAccessor (&MinstrelWifiManager::m_printStats), | 84 MakeBooleanAccessor (&MinstrelWifiManager::m_printStats), |
85 MakeBooleanChecker ()) | 85 MakeBooleanChecker ()) |
| 86 .AddAttribute ("PrintSamples", |
| 87 "Print samples table", |
| 88 BooleanValue (false), |
| 89 MakeBooleanAccessor (&MinstrelWifiManager::m_printSamples), |
| 90 MakeBooleanChecker ()) |
86 .AddTraceSource ("Rate", | 91 .AddTraceSource ("Rate", |
87 "Traced value for rate changes (b/s)", | 92 "Traced value for rate changes (b/s)", |
88 MakeTraceSourceAccessor (&MinstrelWifiManager::m_currentRat
e), | 93 MakeTraceSourceAccessor (&MinstrelWifiManager::m_currentRat
e), |
89 "ns3::TracedValueCallback::Uint64") | 94 "ns3::TracedValueCallback::Uint64") |
90 ; | 95 ; |
91 return tid; | 96 return tid; |
92 } | 97 } |
93 | 98 |
94 MinstrelWifiManager::MinstrelWifiManager () | 99 MinstrelWifiManager::MinstrelWifiManager () |
95 : WifiRemoteStationManager (), | 100 : WifiRemoteStationManager (), |
96 m_currentRate (0) | 101 m_currentRate (0) |
97 { | 102 { |
98 NS_LOG_FUNCTION (this); | 103 NS_LOG_FUNCTION (this); |
99 m_uniformRandomVariable = CreateObject<UniformRandomVariable> (); | 104 m_uniformRandomVariable = CreateObject<UniformRandomVariable> (); |
100 } | 105 } |
101 | 106 |
102 MinstrelWifiManager::~MinstrelWifiManager () | 107 MinstrelWifiManager::~MinstrelWifiManager () |
103 { | 108 { |
104 NS_LOG_FUNCTION (this); | 109 NS_LOG_FUNCTION (this); |
105 } | 110 } |
106 | 111 |
107 void | 112 void |
108 MinstrelWifiManager::SetupPhy (const Ptr<WifiPhy> phy) | 113 MinstrelWifiManager::SetupPhy (const Ptr<WifiPhy> phy) |
109 { | 114 { |
110 NS_LOG_FUNCTION (this << phy); | 115 NS_LOG_FUNCTION (this << phy); |
111 uint32_t nModes = phy->GetNModes (); | 116 uint8_t nModes = phy->GetNModes (); |
112 for (uint32_t i = 0; i < nModes; i++) | 117 for (uint8_t i = 0; i < nModes; i++) |
113 { | 118 { |
114 WifiMode mode = phy->GetMode (i); | 119 WifiMode mode = phy->GetMode (i); |
115 WifiTxVector txVector; | 120 WifiTxVector txVector; |
116 txVector.SetMode (mode); | 121 txVector.SetMode (mode); |
117 txVector.SetPreambleType (WIFI_PREAMBLE_LONG); | 122 txVector.SetPreambleType (WIFI_PREAMBLE_LONG); |
118 AddCalcTxTime (mode, phy->CalculateTxDuration (m_pktLen, txVector, phy->Ge
tFrequency ())); | 123 AddCalcTxTime (mode, phy->CalculateTxDuration (m_pktLen, txVector, phy->Ge
tFrequency ())); |
119 } | 124 } |
120 WifiRemoteStationManager::SetupPhy (phy); | 125 WifiRemoteStationManager::SetupPhy (phy); |
121 } | 126 } |
122 | 127 |
123 void | 128 void |
124 MinstrelWifiManager::SetupMac (const Ptr<WifiMac> mac) | 129 MinstrelWifiManager::SetupMac (const Ptr<WifiMac> mac) |
125 { | 130 { |
126 NS_LOG_FUNCTION (this << mac); | 131 NS_LOG_FUNCTION (this << mac); |
127 WifiRemoteStationManager::SetupMac (mac); | 132 WifiRemoteStationManager::SetupMac (mac); |
128 } | 133 } |
129 | 134 |
130 int64_t | 135 int64_t |
131 MinstrelWifiManager::AssignStreams (int64_t stream) | 136 MinstrelWifiManager::AssignStreams (int64_t stream) |
132 { | 137 { |
133 NS_LOG_FUNCTION (this << stream); | 138 NS_LOG_FUNCTION (this << stream); |
134 m_uniformRandomVariable->SetStream (stream); | 139 m_uniformRandomVariable->SetStream (stream); |
135 return 1; | 140 return 1; |
136 } | 141 } |
137 | 142 |
138 Time | 143 Time |
139 MinstrelWifiManager::GetCalcTxTime (WifiMode mode) const | 144 MinstrelWifiManager::GetCalcTxTime (WifiMode mode) const |
140 { | 145 { |
141 NS_LOG_FUNCTION (this << mode); | 146 NS_LOG_FUNCTION (this << mode); |
142 for (TxTime::const_iterator i = m_calcTxTime.begin (); i != m_calcTxTime.end (
); i++) | 147 auto it = m_calcTxTime.find (mode); |
143 { | 148 NS_ASSERT (it != m_calcTxTime.end ()); |
144 if (mode == i->second) | 149 return it->second; |
145 { | |
146 return i->first; | |
147 } | |
148 } | |
149 NS_ASSERT (false); | |
150 return Seconds (0); | |
151 } | 150 } |
152 | 151 |
153 void | 152 void |
154 MinstrelWifiManager::AddCalcTxTime (WifiMode mode, Time t) | 153 MinstrelWifiManager::AddCalcTxTime (WifiMode mode, Time t) |
155 { | 154 { |
156 NS_LOG_FUNCTION (this << mode << t); | 155 NS_LOG_FUNCTION (this << mode << t); |
157 m_calcTxTime.push_back (std::make_pair (t, mode)); | 156 m_calcTxTime.insert (std::make_pair (mode, t)); |
158 } | 157 } |
159 | 158 |
160 WifiRemoteStation * | 159 WifiRemoteStation * |
161 MinstrelWifiManager::DoCreateStation (void) const | 160 MinstrelWifiManager::DoCreateStation (void) const |
162 { | 161 { |
163 NS_LOG_FUNCTION (this); | 162 NS_LOG_FUNCTION (this); |
164 MinstrelWifiRemoteStation *station = new MinstrelWifiRemoteStation (); | 163 MinstrelWifiRemoteStation *station = new MinstrelWifiRemoteStation (); |
165 | 164 |
166 station->m_nextStatsUpdate = Simulator::Now () + m_updateStats; | 165 station->m_nextStatsUpdate = Simulator::Now () + m_updateStats; |
167 station->m_col = 0; | 166 station->m_col = 0; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 station->m_txrate = 0; | 344 station->m_txrate = 0; |
346 } | 345 } |
347 } | 346 } |
348 } | 347 } |
349 } | 348 } |
350 | 349 |
351 WifiTxVector | 350 WifiTxVector |
352 MinstrelWifiManager::GetDataTxVector (MinstrelWifiRemoteStation *station) | 351 MinstrelWifiManager::GetDataTxVector (MinstrelWifiRemoteStation *station) |
353 { | 352 { |
354 NS_LOG_FUNCTION (this << station); | 353 NS_LOG_FUNCTION (this << station); |
355 uint32_t channelWidth = GetChannelWidth (station); | 354 uint16_t channelWidth = GetChannelWidth (station); |
356 if (channelWidth > 20 && channelWidth != 22) | 355 if (channelWidth > 20 && channelWidth != 22) |
357 { | 356 { |
358 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 357 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
359 channelWidth = 20; | 358 channelWidth = 20; |
360 } | 359 } |
361 if (!station->m_initialized) | 360 if (!station->m_initialized) |
362 { | 361 { |
363 CheckInit (station); | 362 CheckInit (station); |
364 | 363 } |
365 //start the rate at half way | 364 WifiMode mode = GetSupported (station, static_cast<uint8_t> (station->m_txrate
)); |
366 station->m_txrate = station->m_nModes / 2; | 365 if (m_currentRate != mode.GetDataRate (channelWidth) && !station->m_isSampling
) |
367 } | 366 { |
368 WifiMode mode = GetSupported (station, station->m_txrate); | 367 NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (channelWidth)); |
369 if (m_currentRate != mode.GetDataRate ((uint8_t)channelWidth)) | 368 m_currentRate = mode.GetDataRate (channelWidth); |
370 { | 369 } |
371 NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate ((uint8_t)channelWidth)
); | 370 return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmissi
on (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (sta
tion), false); |
372 m_currentRate = mode.GetDataRate ((uint8_t)channelWidth); | |
373 } | |
374 return WifiTxVector (mode, GetDefaultTxPowerLevel (), (uint8_t)GetLongRetryCou
nt (station), GetPreambleForTransmission (mode, GetAddress (station)), 800, 1, 1
, 0, (uint8_t)channelWidth, GetAggregation (station), false); | |
375 } | 371 } |
376 | 372 |
377 WifiTxVector | 373 WifiTxVector |
378 MinstrelWifiManager::GetRtsTxVector (MinstrelWifiRemoteStation *station) | 374 MinstrelWifiManager::GetRtsTxVector (MinstrelWifiRemoteStation *station) |
379 { | 375 { |
380 NS_LOG_FUNCTION (this << station); | 376 NS_LOG_FUNCTION (this << station); |
381 NS_LOG_DEBUG ("DoGetRtsMode m_txrate=" << station->m_txrate); | 377 NS_LOG_DEBUG ("DoGetRtsMode m_txrate=" << station->m_txrate); |
382 uint32_t channelWidth = GetChannelWidth (station); | 378 uint16_t channelWidth = GetChannelWidth (station); |
383 if (channelWidth > 20 && channelWidth != 22) | 379 if (channelWidth > 20 && channelWidth != 22) |
384 { | 380 { |
385 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac | 381 //avoid to use legacy rate adaptation algorithms for IEEE 802.11n/ac |
386 channelWidth = 20; | 382 channelWidth = 20; |
387 } | 383 } |
388 WifiTxVector rtsTxVector; | 384 WifiTxVector rtsTxVector; |
389 WifiMode mode; | 385 WifiMode mode; |
390 if (GetUseNonErpProtection () == false) | 386 if (GetUseNonErpProtection () == false) |
391 { | 387 { |
392 mode = GetSupported (station, 0); | 388 mode = GetSupported (station, 0); |
393 } | 389 } |
394 else | 390 else |
395 { | 391 { |
396 mode = GetNonErpSupported (station, 0); | 392 mode = GetNonErpSupported (station, 0); |
397 } | 393 } |
398 rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), (uint8_t)GetShort
RetryCount (station), GetPreambleForTransmission (mode, GetAddress (station)), 8
00, 1, 1, 0, (uint8_t)channelWidth, GetAggregation (station), false); | 394 rtsTxVector = WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTra
nsmission (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregati
on (station), false); |
399 return rtsTxVector; | 395 return rtsTxVector; |
400 } | 396 } |
401 | 397 |
402 uint32_t | 398 uint32_t |
403 MinstrelWifiManager::CountRetries (MinstrelWifiRemoteStation *station) | 399 MinstrelWifiManager::CountRetries (MinstrelWifiRemoteStation *station) |
404 { | 400 { |
405 if (!station->m_isSampling) | 401 if (!station->m_isSampling) |
406 { | 402 { |
407 return station->m_minstrelTable[station->m_maxTpRate].adjustedRetryCount + | 403 return station->m_minstrelTable[station->m_maxTpRate].adjustedRetryCount + |
408 station->m_minstrelTable[station->m_maxTpRate2].adjustedRetryCount
+ | 404 station->m_minstrelTable[station->m_maxTpRate2].adjustedRetryCount
+ |
(...skipping 12 matching lines...) Expand all Loading... |
421 uint32_t | 417 uint32_t |
422 MinstrelWifiManager::FindRate (MinstrelWifiRemoteStation *station) | 418 MinstrelWifiManager::FindRate (MinstrelWifiRemoteStation *station) |
423 { | 419 { |
424 NS_LOG_FUNCTION (this << station); | 420 NS_LOG_FUNCTION (this << station); |
425 | 421 |
426 if (station->m_totalPacketsCount == 0) | 422 if (station->m_totalPacketsCount == 0) |
427 { | 423 { |
428 return 0; | 424 return 0; |
429 } | 425 } |
430 | 426 |
431 | 427 uint32_t idx = 0; |
432 uint32_t idx; | 428 NS_LOG_DEBUG ("Total: " << station->m_totalPacketsCount << " Sample: " << sta
tion->m_samplePacketsCount << " Deferred: " << station->m_numSamplesDeferred); |
433 | 429 |
434 int delta = (int)((station->m_totalPacketsCount * m_lookAroundRate / 100) - (s
tation->m_samplePacketsCount + station->m_numSamplesDeferred / 2)); | 430 int delta = static_cast<int> ((station->m_totalPacketsCount * m_lookAroundRate
/ 100)) - (station->m_samplePacketsCount + station->m_numSamplesDeferred / 2); |
435 | 431 |
436 NS_LOG_DEBUG ("Decide sampling. Delta: " << delta << " lookAroundRatio: " <<
m_lookAroundRate); | 432 NS_LOG_DEBUG ("Decide sampling. Delta: " << delta << " lookAroundRatio: " <<
m_lookAroundRate); |
437 | 433 |
438 /* delta < 0: no sampling required */ | 434 /* delta < 0: no sampling required */ |
439 if (delta >= 0) | 435 if (delta >= 0) |
440 { | 436 { |
441 NS_LOG_DEBUG ("Search next sampling rate"); | 437 NS_LOG_DEBUG ("Search next sampling rate"); |
442 int ratesSupported = station->m_nModes; | 438 uint8_t ratesSupported = station->m_nModes; |
443 if (delta > ratesSupported * 2) | 439 if (delta > ratesSupported * 2) |
444 { | 440 { |
445 /* From Linux implementation: | 441 /* From Linux implementation: |
446 * With multi-rate retry, not every planned sample | 442 * With multi-rate retry, not every planned sample |
447 * attempt actually gets used, due to the way the retry | 443 * attempt actually gets used, due to the way the retry |
448 * chain is set up - [max_tp,sample,prob,lowest] for | 444 * chain is set up - [max_tp,sample,prob,lowest] for |
449 * sample_rate < max_tp. | 445 * sample_rate < max_tp. |
450 * | 446 * |
451 * If there's too much sampling backlog and the link | 447 * If there's too much sampling backlog and the link |
452 * starts getting worse, minstrel would start bursting | 448 * starts getting worse, minstrel would start bursting |
453 * out lots of sampling frames, which would result | 449 * out lots of sampling frames, which would result |
454 * in a large throughput loss. */ | 450 * in a large throughput loss. */ |
455 station->m_samplePacketsCount += (delta - ratesSupported * 2); | 451 station->m_samplePacketsCount += (delta - ratesSupported * 2); |
456 } | 452 } |
457 | 453 |
458 //now go through the table and find an index rate | 454 //now go through the table and find an index rate |
459 idx = GetNextSample (station); | 455 idx = GetNextSample (station); |
460 | 456 |
| 457 NS_LOG_DEBUG ("Sample rate = " << idx << "(" << GetSupported (station, sta
tic_cast<uint8_t> (idx)) << ")"); |
| 458 |
461 //error check | 459 //error check |
462 if (idx >= station->m_nModes) | 460 if (idx >= station->m_nModes) |
463 { | 461 { |
464 NS_LOG_DEBUG ("ALERT!!! ERROR"); | 462 NS_LOG_DEBUG ("ALERT!!! ERROR"); |
465 } | 463 } |
466 | 464 |
467 //set the rate that we're currently sampling | 465 //set the rate that we're currently sampling |
468 station->m_sampleRate = idx; | 466 station->m_sampleRate = idx; |
469 | 467 |
470 /* From Linux implementation: | 468 /* From Linux implementation: |
471 * Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage) | 469 * Decide if direct ( 1st mrr stage) or indirect (2nd mrr stage) |
472 * rate sampling method should be used. | 470 * rate sampling method should be used. |
473 * Respect such rates that are not sampled for 20 iterations. | 471 * Respect such rates that are not sampled for 20 iterations. |
474 */ | 472 */ |
475 if ((station->m_minstrelTable[idx].perfectTxTime > station->m_minstrelTabl
e[station->m_maxTpRate].perfectTxTime) | 473 if ((station->m_minstrelTable[idx].perfectTxTime > station->m_minstrelTabl
e[station->m_maxTpRate].perfectTxTime) |
476 && (station->m_minstrelTable[idx].numSamplesSkipped < 20)) | 474 && (station->m_minstrelTable[idx].numSamplesSkipped < 20)) |
477 { | 475 { |
478 // If the rate is slower and we have sample it enough, defer to second
stage | 476 // If the rate is slower and we have sample it enough, defer to second
stage |
479 station->m_sampleDeferred = true; | 477 station->m_sampleDeferred = true; |
480 station->m_numSamplesDeferred++; | 478 station->m_numSamplesDeferred++; |
481 | 479 |
482 //set flag that we are currently sampling | 480 //set flag that we are currently sampling |
483 station->m_isSampling = true; | 481 station->m_isSampling = true; |
484 } | 482 } |
485 else | 483 else |
486 { | 484 { |
487 // if samplieLimit is zero, then don't sample this rate | 485 // if samplieLimit is zero, then don't sample this rate |
488 if (!station->m_minstrelTable[idx].sampleLimit) | 486 if (!station->m_minstrelTable[idx].sampleLimit) |
489 { | 487 { |
490 idx = station->m_maxTpRate; | 488 idx = station->m_maxTpRate; |
491 station->m_isSampling = false; | 489 station->m_isSampling = false; |
492 } | 490 } |
493 else | 491 else |
494 { | 492 { |
495 //set flag that we are currently sampling | 493 //set flag that we are currently sampling |
496 station->m_isSampling = true; | 494 station->m_isSampling = true; |
497 if (station->m_minstrelTable[idx].sampleLimit > 0) | 495 if (station->m_minstrelTable[idx].sampleLimit > 0) |
498 { | 496 { |
499 station->m_minstrelTable[idx].sampleLimit--; | 497 station->m_minstrelTable[idx].sampleLimit--; |
500 } | 498 } |
501 } | 499 } |
502 } | 500 } |
503 | 501 |
504 //using the best rate instead | 502 //using the best rate instead |
505 if (station->m_sampleDeferred) | 503 if (station->m_sampleDeferred) |
506 { | 504 { |
507 NS_LOG_DEBUG ("The next look around rate is slower than the maximum th
roughput rate, continue with the maximum throughput rate: " << station->m_maxTpR
ate << "(" << GetSupported (station, station->m_maxTpRate) << ")"); | 505 NS_LOG_DEBUG ("The next look around rate is slower than the maximum th
roughput rate, continue with the maximum throughput rate: " << station->m_maxTpR
ate << "(" << GetSupported (station, static_cast<uint8_t> (station->m_maxTpRate)
) << ")"); |
508 idx = station->m_maxTpRate; | 506 idx = station->m_maxTpRate; |
509 } | 507 } |
510 } | 508 } |
511 //continue using the best rate | 509 //continue using the best rate |
512 else | 510 else |
513 { | 511 { |
514 NS_LOG_DEBUG ("Continue using the maximum throughput rate: " << station->m
_maxTpRate << "(" << GetSupported (station, station->m_maxTpRate) << ")"); | 512 NS_LOG_DEBUG ("Continue using the maximum throughput rate: " << station->m
_maxTpRate << "(" << GetSupported (station, static_cast<uint8_t> (station->m_max
TpRate)) << ")"); |
515 idx = station->m_maxTpRate; | 513 idx = station->m_maxTpRate; |
516 } | 514 } |
517 | 515 |
518 NS_LOG_DEBUG ("Rate = " << idx << "(" << GetSupported (station, idx) << ")"); | 516 NS_LOG_DEBUG ("Rate = " << idx << "(" << GetSupported (station, static_cast<ui
nt8_t> (idx)) << ")"); |
519 | 517 |
520 return idx; | 518 return idx; |
521 } | 519 } |
522 | 520 |
523 void | 521 void |
524 MinstrelWifiManager::UpdateStats (MinstrelWifiRemoteStation *station) | 522 MinstrelWifiManager::UpdateStats (MinstrelWifiRemoteStation *station) |
525 { | 523 { |
526 NS_LOG_FUNCTION (this << station); | 524 NS_LOG_FUNCTION (this << station); |
527 if (Simulator::Now () < station->m_nextStatsUpdate) | 525 if (Simulator::Now () < station->m_nextStatsUpdate) |
528 { | 526 { |
529 return; | 527 return; |
530 } | 528 } |
531 | 529 |
532 if (!station->m_initialized) | 530 if (!station->m_initialized) |
533 { | 531 { |
534 return; | 532 return; |
535 } | 533 } |
536 NS_LOG_FUNCTION (this); | 534 NS_LOG_FUNCTION (this); |
537 station->m_nextStatsUpdate = Simulator::Now () + m_updateStats; | 535 station->m_nextStatsUpdate = Simulator::Now () + m_updateStats; |
538 NS_LOG_DEBUG ("Next update at " << station->m_nextStatsUpdate); | 536 NS_LOG_DEBUG ("Next update at " << station->m_nextStatsUpdate); |
539 NS_LOG_DEBUG ("Currently using rate: " << station->m_txrate << " (" << GetSupp
orted (station, station->m_txrate) << ")"); | 537 NS_LOG_DEBUG ("Currently using rate: " << station->m_txrate << " (" << GetSupp
orted (station, static_cast<uint8_t> (station->m_txrate)) << ")"); |
540 | 538 |
541 Time txTime; | 539 Time txTime; |
542 uint32_t tempProb; | 540 uint32_t tempProb; |
543 | 541 |
544 NS_LOG_DEBUG ("Index-Rate\t\tAttempt\tSuccess"); | 542 NS_LOG_DEBUG ("Index-Rate\t\tAttempt\tSuccess"); |
545 for (uint32_t i = 0; i < station->m_nModes; i++) | 543 for (uint8_t i = 0; i < station->m_nModes; i++) |
546 { | 544 { |
547 | 545 |
548 //calculate the perfect tx time for this rate | 546 //calculate the perfect tx time for this rate |
549 txTime = station->m_minstrelTable[i].perfectTxTime; | 547 txTime = station->m_minstrelTable[i].perfectTxTime; |
550 | 548 |
551 //just for initialization | 549 //just for initialization |
552 if (txTime.GetMicroSeconds () == 0) | 550 if (txTime.GetMicroSeconds () == 0) |
553 { | 551 { |
554 txTime = Seconds (1); | 552 txTime = Seconds (1); |
555 } | 553 } |
(...skipping 21 matching lines...) Expand all Loading... |
577 } | 575 } |
578 else | 576 else |
579 { | 577 { |
580 //ewma probability (cast for gcc 3.4 compatibility) | 578 //ewma probability (cast for gcc 3.4 compatibility) |
581 tempProb = static_cast<uint32_t> (((tempProb * (100 - m_ewmaLevel)
) + (station->m_minstrelTable[i].ewmaProb * m_ewmaLevel) ) / 100); | 579 tempProb = static_cast<uint32_t> (((tempProb * (100 - m_ewmaLevel)
) + (station->m_minstrelTable[i].ewmaProb * m_ewmaLevel) ) / 100); |
582 | 580 |
583 station->m_minstrelTable[i].ewmaProb = tempProb; | 581 station->m_minstrelTable[i].ewmaProb = tempProb; |
584 } | 582 } |
585 | 583 |
586 //calculating throughput | 584 //calculating throughput |
587 station->m_minstrelTable[i].throughput = (uint32_t)(tempProb * (100000
0 / txTime.GetMicroSeconds ())); | 585 station->m_minstrelTable[i].throughput = tempProb * static_cast<uint32
_t> ((1000000 / txTime.GetMicroSeconds ())); |
588 | 586 |
589 } | 587 } |
590 else | 588 else |
591 { | 589 { |
592 station->m_minstrelTable[i].numSamplesSkipped++; | 590 station->m_minstrelTable[i].numSamplesSkipped++; |
593 } | 591 } |
594 | 592 |
595 //bookeeping | 593 //bookeeping |
596 station->m_minstrelTable[i].successHist += station->m_minstrelTable[i].num
RateSuccess; | 594 station->m_minstrelTable[i].successHist += station->m_minstrelTable[i].num
RateSuccess; |
597 station->m_minstrelTable[i].attemptHist += station->m_minstrelTable[i].num
RateAttempt; | 595 station->m_minstrelTable[i].attemptHist += station->m_minstrelTable[i].num
RateAttempt; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 } | 628 } |
631 } | 629 } |
632 | 630 |
633 NS_LOG_DEBUG ("Attempt/success resetted to 0"); | 631 NS_LOG_DEBUG ("Attempt/success resetted to 0"); |
634 | 632 |
635 uint32_t max_tp = 0, index_max_tp = 0, index_max_tp2 = 0; | 633 uint32_t max_tp = 0, index_max_tp = 0, index_max_tp2 = 0; |
636 | 634 |
637 //go find max throughput, second maximum throughput, high probability succ | 635 //go find max throughput, second maximum throughput, high probability succ |
638 NS_LOG_DEBUG ("Finding the maximum throughput, second maximum throughput, and
highest probability"); | 636 NS_LOG_DEBUG ("Finding the maximum throughput, second maximum throughput, and
highest probability"); |
639 NS_LOG_DEBUG ("Index-Rate\t\tT-put\tEWMA"); | 637 NS_LOG_DEBUG ("Index-Rate\t\tT-put\tEWMA"); |
640 for (uint32_t i = 0; i < station->m_nModes; i++) | 638 for (uint8_t i = 0; i < station->m_nModes; i++) |
641 { | 639 { |
642 NS_LOG_DEBUG (i << " " << GetSupported (station, i) << | 640 NS_LOG_DEBUG (i << " " << GetSupported (station, i) << |
643 "\t" << station->m_minstrelTable[i].throughput << | 641 "\t" << station->m_minstrelTable[i].throughput << |
644 "\t" << station->m_minstrelTable[i].ewmaProb); | 642 "\t" << station->m_minstrelTable[i].ewmaProb); |
645 | 643 |
646 if (max_tp < station->m_minstrelTable[i].throughput) | 644 if (max_tp < station->m_minstrelTable[i].throughput) |
647 { | 645 { |
648 index_max_tp = i; | 646 index_max_tp = i; |
649 max_tp = station->m_minstrelTable[i].throughput; | 647 max_tp = station->m_minstrelTable[i].throughput; |
650 } | 648 } |
651 } | 649 } |
652 | 650 |
653 max_tp = 0; | 651 max_tp = 0; |
654 //find the second highest max | 652 //find the second highest max |
655 for (uint32_t i = 0; i < station->m_nModes; i++) | 653 for (uint8_t i = 0; i < station->m_nModes; i++) |
656 { | 654 { |
657 if ((i != index_max_tp) && (max_tp < station->m_minstrelTable[i].throughpu
t)) | 655 if ((i != index_max_tp) && (max_tp < station->m_minstrelTable[i].throughpu
t)) |
658 { | 656 { |
659 index_max_tp2 = i; | 657 index_max_tp2 = i; |
660 max_tp = station->m_minstrelTable[i].throughput; | 658 max_tp = station->m_minstrelTable[i].throughput; |
661 } | 659 } |
662 } | 660 } |
663 | 661 |
664 uint32_t max_prob = 0, index_max_prob = 0; | 662 uint32_t max_prob = 0, index_max_prob = 0; |
665 for (uint32_t i = 0; i < station->m_nModes; i++) | 663 for (uint8_t i = 0; i < station->m_nModes; i++) |
666 { | 664 { |
667 if ((station->m_minstrelTable[i].ewmaProb >= 95 * 180) && (station->m_mins
trelTable[i].throughput >= station->m_minstrelTable[index_max_prob].throughput)) | 665 if ((station->m_minstrelTable[i].ewmaProb >= 95 * 180) && (station->m_mins
trelTable[i].throughput >= station->m_minstrelTable[index_max_prob].throughput)) |
668 { | 666 { |
669 index_max_prob = i; | 667 index_max_prob = i; |
670 max_prob = station->m_minstrelTable[i].ewmaProb; | 668 max_prob = station->m_minstrelTable[i].ewmaProb; |
671 } | 669 } |
672 else if (station->m_minstrelTable[i].ewmaProb >= max_prob) | 670 else if (station->m_minstrelTable[i].ewmaProb >= max_prob) |
673 { | 671 { |
674 index_max_prob = i; | 672 index_max_prob = i; |
675 max_prob = station->m_minstrelTable[i].ewmaProb; | 673 max_prob = station->m_minstrelTable[i].ewmaProb; |
676 } | 674 } |
677 } | 675 } |
678 | 676 |
679 station->m_maxTpRate = index_max_tp; | 677 station->m_maxTpRate = index_max_tp; |
680 station->m_maxTpRate2 = index_max_tp2; | 678 station->m_maxTpRate2 = index_max_tp2; |
681 station->m_maxProbRate = index_max_prob; | 679 station->m_maxProbRate = index_max_prob; |
682 | 680 |
683 if (index_max_tp > station->m_txrate) | 681 if (index_max_tp > station->m_txrate) |
684 { | 682 { |
685 station->m_txrate = index_max_tp; | 683 station->m_txrate = index_max_tp; |
686 } | 684 } |
687 | 685 |
688 NS_LOG_DEBUG ("max throughput=" << index_max_tp << "(" << GetSupported (statio
n, index_max_tp) << | 686 NS_LOG_DEBUG ("max throughput=" << index_max_tp << "(" << GetSupported (statio
n, static_cast<uint8_t> (index_max_tp)) << |
689 ")\tsecond max throughput=" << index_max_tp2 << "(" << GetSuppor
ted (station, index_max_tp2) << | 687 ")\tsecond max throughput=" << index_max_tp2 << "(" << GetSuppor
ted (station, static_cast<uint8_t> (index_max_tp2)) << |
690 ")\tmax prob=" << index_max_prob << "(" << GetSupported (station
, index_max_prob) << ")"); | 688 ")\tmax prob=" << index_max_prob << "(" << GetSupported (station
, static_cast<uint8_t> (index_max_prob)) << ")"); |
691 if (m_printStats) | 689 if (m_printStats) |
692 { | 690 { |
693 PrintTable (station); | 691 PrintTable (station); |
694 } | 692 } |
695 } | 693 if (m_printSamples) |
696 | 694 { |
697 void | 695 PrintSampleTable (station); |
698 MinstrelWifiManager::DoReportRxOk (WifiRemoteStation *st, | 696 } |
699 double rxSnr, WifiMode txMode) | 697 } |
| 698 |
| 699 void |
| 700 MinstrelWifiManager::DoReportRxOk (WifiRemoteStation *st, double rxSnr, WifiMode
txMode) |
700 { | 701 { |
701 NS_LOG_FUNCTION (this << st << rxSnr << txMode); | 702 NS_LOG_FUNCTION (this << st << rxSnr << txMode); |
| 703 NS_LOG_DEBUG ("DoReportRxOk m_txrate=" << ((MinstrelWifiRemoteStation *)st)->m
_txrate); |
702 } | 704 } |
703 | 705 |
704 void | 706 void |
705 MinstrelWifiManager::DoReportRtsFailed (WifiRemoteStation *st) | 707 MinstrelWifiManager::DoReportRtsFailed (WifiRemoteStation *st) |
706 { | 708 { |
707 NS_LOG_FUNCTION (this << st); | 709 NS_LOG_FUNCTION (this << st); |
708 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st; | 710 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st; |
709 NS_LOG_DEBUG ("DoReportRtsFailed m_txrate=" << station->m_txrate); | 711 NS_LOG_DEBUG ("DoReportRtsFailed m_txrate=" << station->m_txrate); |
710 | |
711 station->m_shortRetry++; | 712 station->m_shortRetry++; |
712 } | 713 } |
713 | 714 |
714 void | 715 void |
715 MinstrelWifiManager::DoReportRtsOk (WifiRemoteStation *st, double ctsSnr, WifiMo
de ctsMode, double rtsSnr) | 716 MinstrelWifiManager::DoReportRtsOk (WifiRemoteStation *st, double ctsSnr, WifiMo
de ctsMode, double rtsSnr) |
716 { | 717 { |
717 NS_UNUSED(ctsSnr); | 718 NS_LOG_FUNCTION (this << st << ctsSnr << ctsMode << rtsSnr); |
718 NS_UNUSED(ctsMode); | |
719 NS_UNUSED(rtsSnr); | |
720 NS_LOG_FUNCTION (this << st); | |
721 NS_LOG_DEBUG ("self=" << st << " rts ok"); | |
722 } | 719 } |
723 | 720 |
724 void | 721 void |
725 MinstrelWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st) | 722 MinstrelWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st) |
726 { | 723 { |
727 NS_LOG_FUNCTION (this << st); | 724 NS_LOG_FUNCTION (this << st); |
728 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st; | 725 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st; |
729 UpdateRetry (station); | 726 UpdateRetry (station); |
730 } | 727 } |
731 | 728 |
732 void | 729 void |
733 MinstrelWifiManager::DoReportDataFailed (WifiRemoteStation *st) | 730 MinstrelWifiManager::DoReportDataFailed (WifiRemoteStation *st) |
734 { | 731 { |
735 NS_LOG_FUNCTION (this << st); | 732 NS_LOG_FUNCTION (this << st); |
736 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st; | 733 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st; |
| 734 NS_LOG_DEBUG ("DoReportDataFailed " << station << "\t rate " << station->m_txr
ate << "\tlongRetry \t" << station->m_longRetry); |
737 CheckInit (station); | 735 CheckInit (station); |
738 if (!station->m_initialized) | 736 if (!station->m_initialized) |
739 { | 737 { |
740 return; | 738 return; |
741 } | 739 } |
742 | 740 |
743 UpdateRate (station); | 741 UpdateRate (station); |
744 } | 742 } |
745 | 743 |
746 void | 744 void |
747 MinstrelWifiManager::DoReportDataOk (WifiRemoteStation *st, | 745 MinstrelWifiManager::DoReportDataOk (WifiRemoteStation *st, |
748 double ackSnr, WifiMode ackMode, double dat
aSnr) | 746 double ackSnr, WifiMode ackMode, double dat
aSnr) |
749 { | 747 { |
750 NS_LOG_FUNCTION (st << ackSnr << ackMode << dataSnr); | 748 NS_LOG_FUNCTION (this << st << ackSnr << ackMode << dataSnr); |
751 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st; | 749 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st; |
752 | 750 |
753 CheckInit (station); | 751 CheckInit (station); |
754 if (!station->m_initialized) | 752 if (!station->m_initialized) |
755 { | 753 { |
756 return; | 754 return; |
757 } | 755 } |
758 | 756 |
759 NS_LOG_DEBUG ("DoReportDataOk m_txrate = " << station->m_txrate << ", attempt
= " << station->m_minstrelTable[station->m_txrate].numRateAttempt << ", success
= " << station->m_minstrelTable[station->m_txrate].numRateSuccess << " (before u
pdate)."); | 757 NS_LOG_DEBUG ("DoReportDataOk m_txrate = " << station->m_txrate << ", attempt
= " << station->m_minstrelTable[station->m_txrate].numRateAttempt << ", success
= " << station->m_minstrelTable[station->m_txrate].numRateSuccess << " (before u
pdate)."); |
760 | 758 |
761 station->m_minstrelTable[station->m_txrate].numRateSuccess++; | 759 station->m_minstrelTable[station->m_txrate].numRateSuccess++; |
762 station->m_minstrelTable[station->m_txrate].numRateAttempt++; | 760 station->m_minstrelTable[station->m_txrate].numRateAttempt++; |
763 | 761 |
764 UpdatePacketCounters (station); | 762 UpdatePacketCounters (station); |
765 | 763 |
766 NS_LOG_DEBUG ("DoReportDataOk m_txrate = " << station->m_txrate << ", attempt
= " << station->m_minstrelTable[station->m_txrate].numRateAttempt << ", success
= " << station->m_minstrelTable[station->m_txrate].numRateSuccess << " (after up
date)."); | 764 NS_LOG_DEBUG ("DoReportDataOk m_txrate = " << station->m_txrate << ", attempt
= " << station->m_minstrelTable[station->m_txrate].numRateAttempt << ", success
= " << station->m_minstrelTable[station->m_txrate].numRateSuccess << " (after up
date)."); |
767 | 765 |
768 UpdateRetry (station); | 766 UpdateRetry (station); |
769 UpdateStats (station); | 767 UpdateStats (station); |
770 | 768 |
771 if (station->m_nModes >= 1) | 769 if (station->m_nModes >= 1) |
772 { | 770 { |
773 station->m_txrate = FindRate (station); | 771 station->m_txrate = FindRate (station); |
774 } | 772 } |
| 773 NS_LOG_DEBUG ("Next rate to use TxRate = " << station->m_txrate ); |
775 } | 774 } |
776 | 775 |
777 void | 776 void |
778 MinstrelWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) | 777 MinstrelWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) |
779 { | 778 { |
780 NS_LOG_FUNCTION (this << st); | 779 NS_LOG_FUNCTION (this << st); |
781 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st; | 780 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *) st; |
782 | 781 |
783 CheckInit (station); | 782 CheckInit (station); |
784 if (!station->m_initialized) | 783 if (!station->m_initialized) |
785 { | 784 { |
786 return; | 785 return; |
787 } | 786 } |
788 | 787 |
789 NS_LOG_DEBUG ("DoReportFinalDataFailed m_txrate = " << station->m_txrate << ",
attempt = " << station->m_minstrelTable[station->m_txrate].numRateAttempt << ",
success = " << station->m_minstrelTable[station->m_txrate].numRateSuccess << "
(before update)."); | 788 NS_LOG_DEBUG ("DoReportFinalDataFailed m_txrate = " << station->m_txrate << ",
attempt = " << station->m_minstrelTable[station->m_txrate].numRateAttempt << ",
success = " << station->m_minstrelTable[station->m_txrate].numRateSuccess << "
(before update)."); |
790 | 789 |
791 UpdatePacketCounters (station); | 790 UpdatePacketCounters (station); |
792 | 791 |
793 UpdateRetry (station); | 792 UpdateRetry (station); |
794 UpdateStats (station); | 793 UpdateStats (station); |
795 | 794 |
796 NS_LOG_DEBUG ("DoReportFinalDataFailed m_txrate = " << station->m_txrate << ",
attempt = " << station->m_minstrelTable[station->m_txrate].numRateAttempt << ",
success = " << station->m_minstrelTable[station->m_txrate].numRateSuccess << "
(after update)."); | 795 NS_LOG_DEBUG ("DoReportFinalDataFailed m_txrate = " << station->m_txrate << ",
attempt = " << station->m_minstrelTable[station->m_txrate].numRateAttempt << ",
success = " << station->m_minstrelTable[station->m_txrate].numRateSuccess << "
(after update)."); |
797 | 796 |
798 if (station->m_nModes >= 1) | 797 if (station->m_nModes >= 1) |
799 { | 798 { |
800 station->m_txrate = FindRate (station); | 799 station->m_txrate = FindRate (station); |
801 } | 800 } |
| 801 NS_LOG_DEBUG ("Next rate to use TxRate = " << station->m_txrate ); |
802 } | 802 } |
803 | 803 |
804 void | 804 void |
805 MinstrelWifiManager::UpdatePacketCounters (MinstrelWifiRemoteStation *station) | 805 MinstrelWifiManager::UpdatePacketCounters (MinstrelWifiRemoteStation *station) |
806 { | 806 { |
807 NS_LOG_FUNCTION (this << station); | 807 NS_LOG_FUNCTION (this << station); |
808 | 808 |
809 station->m_totalPacketsCount++; | 809 station->m_totalPacketsCount++; |
810 // If it is a sampling frame and the sampleRate was used, increase counter | 810 // If it is a sampling frame and the sampleRate was used, increase counter |
811 if (station->m_isSampling && (!station->m_sampleDeferred || station->m_longRet
ry >= station->m_minstrelTable[station->m_maxTpRate].adjustedRetryCount)) | 811 if (station->m_isSampling && (!station->m_sampleDeferred || station->m_longRet
ry >= station->m_minstrelTable[station->m_maxTpRate].adjustedRetryCount)) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 MinstrelWifiManager::DoNeedDataRetransmission (WifiRemoteStation *st, Ptr<const
Packet> packet, bool normally) | 857 MinstrelWifiManager::DoNeedDataRetransmission (WifiRemoteStation *st, Ptr<const
Packet> packet, bool normally) |
858 { | 858 { |
859 NS_LOG_FUNCTION (this << st << packet << normally); | 859 NS_LOG_FUNCTION (this << st << packet << normally); |
860 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st; | 860 MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st; |
861 | 861 |
862 CheckInit (station); | 862 CheckInit (station); |
863 if (!station->m_initialized) | 863 if (!station->m_initialized) |
864 { | 864 { |
865 return normally; | 865 return normally; |
866 } | 866 } |
867 if (station->m_longRetry > CountRetries (station)) | 867 if (station->m_longRetry >= CountRetries (station)) |
868 { | 868 { |
| 869 NS_LOG_DEBUG ("No re-transmission allowed. Retries: " << station->m_longR
etry << " Max retries: " << CountRetries (station)); |
869 return false; | 870 return false; |
870 } | 871 } |
871 else | 872 else |
872 { | 873 { |
| 874 NS_LOG_DEBUG ("Re-transmit. Retries: " << station->m_longRetry << " Max r
etries: " << CountRetries (station)); |
873 return true; | 875 return true; |
874 } | 876 } |
875 } | 877 } |
876 | 878 |
877 bool | 879 bool |
878 MinstrelWifiManager::IsLowLatency (void) const | 880 MinstrelWifiManager::IsLowLatency (void) const |
879 { | 881 { |
880 NS_LOG_FUNCTION (this); | |
881 return true; | 882 return true; |
882 } | 883 } |
883 | 884 |
884 uint32_t | 885 uint32_t |
885 MinstrelWifiManager::GetNextSample (MinstrelWifiRemoteStation *station) | 886 MinstrelWifiManager::GetNextSample (MinstrelWifiRemoteStation *station) |
886 { | 887 { |
887 NS_LOG_FUNCTION (this << station); | 888 NS_LOG_FUNCTION (this << station); |
888 uint32_t bitrate; | 889 uint32_t bitrate; |
889 bitrate = station->m_sampleTable[station->m_index][station->m_col]; | 890 bitrate = station->m_sampleTable[station->m_index][station->m_col]; |
890 station->m_index++; | 891 station->m_index++; |
891 | 892 |
892 //bookeeping for m_index and m_col variables | 893 //bookeeping for m_index and m_col variables |
893 if (station->m_index > (station->m_nModes - 2)) | 894 NS_ABORT_MSG_IF (station->m_nModes < 2, "Integer overflow detected"); |
| 895 if (station->m_index > station->m_nModes - 2) |
894 { | 896 { |
895 station->m_index = 0; | 897 station->m_index = 0; |
896 station->m_col++; | 898 station->m_col++; |
897 if (station->m_col >= m_sampleCol) | 899 if (station->m_col >= m_sampleCol) |
898 { | 900 { |
899 station->m_col = 0; | 901 station->m_col = 0; |
900 } | 902 } |
901 } | 903 } |
902 return bitrate; | 904 return bitrate; |
903 } | 905 } |
904 | 906 |
905 void | 907 void |
906 MinstrelWifiManager::RateInit (MinstrelWifiRemoteStation *station) | 908 MinstrelWifiManager::RateInit (MinstrelWifiRemoteStation *station) |
907 { | 909 { |
908 NS_LOG_FUNCTION (station); | 910 NS_LOG_FUNCTION (this << station); |
909 | 911 for (uint8_t i = 0; i < station->m_nModes; i++) |
910 for (uint32_t i = 0; i < station->m_nModes; i++) | 912 { |
911 { | 913 NS_LOG_DEBUG ("Initializing rate index " << +i << " " << GetSupported (sta
tion, i)); |
912 NS_LOG_DEBUG ("Initializing rate index " << i << " " << GetSupported (stat
ion, i)); | |
913 station->m_minstrelTable[i].numRateAttempt = 0; | 914 station->m_minstrelTable[i].numRateAttempt = 0; |
914 station->m_minstrelTable[i].numRateSuccess = 0; | 915 station->m_minstrelTable[i].numRateSuccess = 0; |
915 station->m_minstrelTable[i].prevNumRateSuccess = 0; | 916 station->m_minstrelTable[i].prevNumRateSuccess = 0; |
916 station->m_minstrelTable[i].prevNumRateAttempt = 0; | 917 station->m_minstrelTable[i].prevNumRateAttempt = 0; |
917 station->m_minstrelTable[i].successHist = 0; | 918 station->m_minstrelTable[i].successHist = 0; |
918 station->m_minstrelTable[i].attemptHist = 0; | 919 station->m_minstrelTable[i].attemptHist = 0; |
919 station->m_minstrelTable[i].numSamplesSkipped = 0; | 920 station->m_minstrelTable[i].numSamplesSkipped = 0; |
920 station->m_minstrelTable[i].prob = 0; | 921 station->m_minstrelTable[i].prob = 0; |
921 station->m_minstrelTable[i].ewmaProb = 0; | 922 station->m_minstrelTable[i].ewmaProb = 0; |
922 station->m_minstrelTable[i].throughput = 0; | 923 station->m_minstrelTable[i].throughput = 0; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 //Update contention window | 969 //Update contention window |
969 cw = std::min (cwMax, (cw + 1) * 2); | 970 cw = std::min (cwMax, (cw + 1) * 2); |
970 } | 971 } |
971 | 972 |
972 return tt; | 973 return tt; |
973 } | 974 } |
974 | 975 |
975 void | 976 void |
976 MinstrelWifiManager::InitSampleTable (MinstrelWifiRemoteStation *station) | 977 MinstrelWifiManager::InitSampleTable (MinstrelWifiRemoteStation *station) |
977 { | 978 { |
978 NS_LOG_DEBUG ("InitSampleTable=" << this); | 979 NS_LOG_FUNCTION (this << station); |
979 | |
980 station->m_col = station->m_index = 0; | 980 station->m_col = station->m_index = 0; |
981 | 981 |
982 //for off-setting to make rates fall between 0 and nModes | 982 //for off-setting to make rates fall between 0 and nModes |
983 uint32_t numSampleRates = station->m_nModes; | 983 uint8_t numSampleRates = station->m_nModes; |
984 | 984 |
985 uint32_t newIndex; | 985 uint32_t newIndex; |
986 for (uint32_t col = 0; col < m_sampleCol; col++) | 986 for (uint32_t col = 0; col < m_sampleCol; col++) |
987 { | 987 { |
988 for (uint32_t i = 0; i < numSampleRates; i++ ) | 988 for (uint8_t i = 0; i < numSampleRates; i++ ) |
989 { | 989 { |
990 /** | 990 /** |
991 * The next two lines basically tries to generate a random number | 991 * The next two lines basically tries to generate a random number |
992 * between 0 and the number of available rates | 992 * between 0 and the number of available rates |
993 */ | 993 */ |
994 int uv = m_uniformRandomVariable->GetInteger (0, numSampleRates); | 994 int uv = m_uniformRandomVariable->GetInteger (0, numSampleRates); |
| 995 NS_LOG_DEBUG ("InitSampleTable uv: " << uv); |
995 newIndex = (i + uv) % numSampleRates; | 996 newIndex = (i + uv) % numSampleRates; |
996 | 997 |
997 //this loop is used for filling in other uninitialized places | 998 //this loop is used for filling in other uninitialized places |
998 while (station->m_sampleTable[newIndex][col] != 0) | 999 while (station->m_sampleTable[newIndex][col] != 0) |
999 { | 1000 { |
1000 newIndex = (newIndex + 1) % station->m_nModes; | 1001 newIndex = (newIndex + 1) % station->m_nModes; |
1001 } | 1002 } |
1002 station->m_sampleTable[newIndex][col] = i; | 1003 station->m_sampleTable[newIndex][col] = i; |
1003 } | 1004 } |
1004 } | 1005 } |
1005 } | 1006 } |
1006 | 1007 |
1007 void | 1008 void |
1008 MinstrelWifiManager::PrintSampleTable (MinstrelWifiRemoteStation *station) | 1009 MinstrelWifiManager::PrintSampleTable (MinstrelWifiRemoteStation *station) |
1009 { | 1010 { |
1010 NS_LOG_DEBUG ("PrintSampleTable=" << station); | 1011 uint8_t numSampleRates = station->m_nModes; |
1011 | |
1012 uint32_t numSampleRates = station->m_nModes; | |
1013 std::stringstream table; | 1012 std::stringstream table; |
1014 for (uint32_t i = 0; i < numSampleRates; i++) | 1013 for (uint8_t i = 0; i < numSampleRates; i++) |
1015 { | 1014 { |
1016 for (uint32_t j = 0; j < m_sampleCol; j++) | 1015 for (uint32_t j = 0; j < m_sampleCol; j++) |
1017 { | 1016 { |
1018 table << station->m_sampleTable[i][j] << "\t"; | 1017 table << station->m_sampleTable[i][j] << "\t"; |
1019 } | 1018 } |
1020 table << std::endl; | 1019 table << std::endl; |
1021 } | 1020 } |
1022 NS_LOG_DEBUG (table.str ()); | 1021 NS_LOG_DEBUG (table.str ()); |
1023 } | 1022 } |
1024 | 1023 |
1025 void | 1024 void |
1026 MinstrelWifiManager::PrintTable (MinstrelWifiRemoteStation *station) | 1025 MinstrelWifiManager::PrintTable (MinstrelWifiRemoteStation *station) |
1027 { | 1026 { |
1028 NS_LOG_FUNCTION (this << station); | |
1029 NS_LOG_DEBUG ("PrintTable=" << station); | |
1030 | |
1031 station->m_statsFile << "best _______________rate________________ _______
_statistics________ ________last_______ ______sum-of________\n" << | 1027 station->m_statsFile << "best _______________rate________________ _______
_statistics________ ________last_______ ______sum-of________\n" << |
1032 "rate [ name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)]
[prob.|retry|suc|att] [#success | #attempts]\n"; | 1028 "rate [ name idx airtime max_tp] [avg(tp) avg(prob) sd(prob)]
[prob.|retry|suc|att] [#success | #attempts]\n"; |
1033 | 1029 |
1034 uint32_t maxTpRate = station->m_maxTpRate; | 1030 uint32_t maxTpRate = station->m_maxTpRate; |
1035 uint32_t maxTpRate2 = station->m_maxTpRate2; | 1031 uint32_t maxTpRate2 = station->m_maxTpRate2; |
1036 uint32_t maxProbRate = station->m_maxProbRate; | 1032 uint32_t maxProbRate = station->m_maxProbRate; |
1037 | 1033 |
1038 for (uint32_t i = 0; i < station->m_nModes; i++) | 1034 for (uint8_t i = 0; i < station->m_nModes; i++) |
1039 { | 1035 { |
1040 RateInfo rate = station->m_minstrelTable[i]; | 1036 RateInfo rate = station->m_minstrelTable[i]; |
1041 | 1037 |
1042 if (i == maxTpRate) | 1038 if (i == maxTpRate) |
1043 { | 1039 { |
1044 station->m_statsFile << 'A'; | 1040 station->m_statsFile << 'A'; |
1045 } | 1041 } |
1046 else | 1042 else |
1047 { | 1043 { |
1048 station->m_statsFile << ' '; | 1044 station->m_statsFile << ' '; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 MinstrelWifiManager::SetHeSupported (bool enable) | 1106 MinstrelWifiManager::SetHeSupported (bool enable) |
1111 { | 1107 { |
1112 //HE is not supported by this algorithm. | 1108 //HE is not supported by this algorithm. |
1113 if (enable) | 1109 if (enable) |
1114 { | 1110 { |
1115 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); | 1111 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); |
1116 } | 1112 } |
1117 } | 1113 } |
1118 | 1114 |
1119 } //namespace ns3 | 1115 } //namespace ns3 |
LEFT | RIGHT |