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) 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 uint16_t channelWidth = GetChannelWidth (station); | 354 uint16_t channelWidth = GetChannelWidth (station); |
355 if (channelWidth > 20 && channelWidth != 22) | 355 if (channelWidth > 20 && channelWidth != 22) |
356 { | 356 { |
357 //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 |
358 channelWidth = 20; | 358 channelWidth = 20; |
359 } | 359 } |
360 if (!station->m_initialized) | 360 if (!station->m_initialized) |
361 { | 361 { |
362 CheckInit (station); | 362 CheckInit (station); |
363 } | 363 } |
364 WifiMode mode = GetSupported (station, station->m_txrate); | 364 WifiMode mode = GetSupported (station, static_cast<uint8_t> (station->m_txrate
)); |
365 if (m_currentRate != mode.GetDataRate (channelWidth) && !station->m_isSampling
) | 365 if (m_currentRate != mode.GetDataRate (channelWidth) && !station->m_isSampling
) |
366 { | 366 { |
367 NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (channelWidth)); | 367 NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (channelWidth)); |
368 m_currentRate = mode.GetDataRate (channelWidth); | 368 m_currentRate = mode.GetDataRate (channelWidth); |
369 } | 369 } |
370 return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmissi
on (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (sta
tion), false); | 370 return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetPreambleForTransmissi
on (mode, GetAddress (station)), 800, 1, 1, 0, channelWidth, GetAggregation (sta
tion), false); |
371 } | 371 } |
372 | 372 |
373 WifiTxVector | 373 WifiTxVector |
374 MinstrelWifiManager::GetRtsTxVector (MinstrelWifiRemoteStation *station) | 374 MinstrelWifiManager::GetRtsTxVector (MinstrelWifiRemoteStation *station) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 NS_LOG_FUNCTION (this << station); | 420 NS_LOG_FUNCTION (this << station); |
421 | 421 |
422 if (station->m_totalPacketsCount == 0) | 422 if (station->m_totalPacketsCount == 0) |
423 { | 423 { |
424 return 0; | 424 return 0; |
425 } | 425 } |
426 | 426 |
427 uint32_t idx = 0; | 427 uint32_t idx = 0; |
428 NS_LOG_DEBUG ("Total: " << station->m_totalPacketsCount << " Sample: " << sta
tion->m_samplePacketsCount << " Deferred: " << station->m_numSamplesDeferred); | 428 NS_LOG_DEBUG ("Total: " << station->m_totalPacketsCount << " Sample: " << sta
tion->m_samplePacketsCount << " Deferred: " << station->m_numSamplesDeferred); |
429 | 429 |
430 int delta = (station->m_totalPacketsCount * m_lookAroundRate / 100) - (station
->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); |
431 | 431 |
432 NS_LOG_DEBUG ("Decide sampling. Delta: " << delta << " lookAroundRatio: " <<
m_lookAroundRate); | 432 NS_LOG_DEBUG ("Decide sampling. Delta: " << delta << " lookAroundRatio: " <<
m_lookAroundRate); |
433 | 433 |
434 /* delta < 0: no sampling required */ | 434 /* delta < 0: no sampling required */ |
435 if (delta >= 0) | 435 if (delta >= 0) |
436 { | 436 { |
437 NS_LOG_DEBUG ("Search next sampling rate"); | 437 NS_LOG_DEBUG ("Search next sampling rate"); |
438 uint8_t ratesSupported = station->m_nModes; | 438 uint8_t ratesSupported = station->m_nModes; |
439 if (delta > ratesSupported * 2) | 439 if (delta > ratesSupported * 2) |
440 { | 440 { |
441 /* From Linux implementation: | 441 /* From Linux implementation: |
442 * With multi-rate retry, not every planned sample | 442 * With multi-rate retry, not every planned sample |
443 * attempt actually gets used, due to the way the retry | 443 * attempt actually gets used, due to the way the retry |
444 * chain is set up - [max_tp,sample,prob,lowest] for | 444 * chain is set up - [max_tp,sample,prob,lowest] for |
445 * sample_rate < max_tp. | 445 * sample_rate < max_tp. |
446 * | 446 * |
447 * If there's too much sampling backlog and the link | 447 * If there's too much sampling backlog and the link |
448 * starts getting worse, minstrel would start bursting | 448 * starts getting worse, minstrel would start bursting |
449 * out lots of sampling frames, which would result | 449 * out lots of sampling frames, which would result |
450 * in a large throughput loss. */ | 450 * in a large throughput loss. */ |
451 station->m_samplePacketsCount += (delta - ratesSupported * 2); | 451 station->m_samplePacketsCount += (delta - ratesSupported * 2); |
452 } | 452 } |
453 | 453 |
454 //now go through the table and find an index rate | 454 //now go through the table and find an index rate |
455 idx = GetNextSample (station); | 455 idx = GetNextSample (station); |
456 | 456 |
457 NS_LOG_DEBUG ("Sample rate = " << idx << "(" << GetSupported (station, idx
) << ")"); | 457 NS_LOG_DEBUG ("Sample rate = " << idx << "(" << GetSupported (station, sta
tic_cast<uint8_t> (idx)) << ")"); |
458 | 458 |
459 //error check | 459 //error check |
460 if (idx >= station->m_nModes) | 460 if (idx >= station->m_nModes) |
461 { | 461 { |
462 NS_LOG_DEBUG ("ALERT!!! ERROR"); | 462 NS_LOG_DEBUG ("ALERT!!! ERROR"); |
463 } | 463 } |
464 | 464 |
465 //set the rate that we're currently sampling | 465 //set the rate that we're currently sampling |
466 station->m_sampleRate = idx; | 466 station->m_sampleRate = idx; |
467 | 467 |
(...skipping 27 matching lines...) Expand all Loading... |
495 if (station->m_minstrelTable[idx].sampleLimit > 0) | 495 if (station->m_minstrelTable[idx].sampleLimit > 0) |
496 { | 496 { |
497 station->m_minstrelTable[idx].sampleLimit--; | 497 station->m_minstrelTable[idx].sampleLimit--; |
498 } | 498 } |
499 } | 499 } |
500 } | 500 } |
501 | 501 |
502 //using the best rate instead | 502 //using the best rate instead |
503 if (station->m_sampleDeferred) | 503 if (station->m_sampleDeferred) |
504 { | 504 { |
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, 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)
) << ")"); |
506 idx = station->m_maxTpRate; | 506 idx = station->m_maxTpRate; |
507 } | 507 } |
508 } | 508 } |
509 //continue using the best rate | 509 //continue using the best rate |
510 else | 510 else |
511 { | 511 { |
512 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)) << ")"); |
513 idx = station->m_maxTpRate; | 513 idx = station->m_maxTpRate; |
514 } | 514 } |
515 | 515 |
516 NS_LOG_DEBUG ("Rate = " << idx << "(" << GetSupported (station, idx) << ")"); | 516 NS_LOG_DEBUG ("Rate = " << idx << "(" << GetSupported (station, static_cast<ui
nt8_t> (idx)) << ")"); |
517 | 517 |
518 return idx; | 518 return idx; |
519 } | 519 } |
520 | 520 |
521 void | 521 void |
522 MinstrelWifiManager::UpdateStats (MinstrelWifiRemoteStation *station) | 522 MinstrelWifiManager::UpdateStats (MinstrelWifiRemoteStation *station) |
523 { | 523 { |
524 NS_LOG_FUNCTION (this << station); | 524 NS_LOG_FUNCTION (this << station); |
525 if (Simulator::Now () < station->m_nextStatsUpdate) | 525 if (Simulator::Now () < station->m_nextStatsUpdate) |
526 { | 526 { |
527 return; | 527 return; |
528 } | 528 } |
529 | 529 |
530 if (!station->m_initialized) | 530 if (!station->m_initialized) |
531 { | 531 { |
532 return; | 532 return; |
533 } | 533 } |
534 NS_LOG_FUNCTION (this); | 534 NS_LOG_FUNCTION (this); |
535 station->m_nextStatsUpdate = Simulator::Now () + m_updateStats; | 535 station->m_nextStatsUpdate = Simulator::Now () + m_updateStats; |
536 NS_LOG_DEBUG ("Next update at " << station->m_nextStatsUpdate); | 536 NS_LOG_DEBUG ("Next update at " << station->m_nextStatsUpdate); |
537 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)) << ")"); |
538 | 538 |
539 Time txTime; | 539 Time txTime; |
540 uint32_t tempProb; | 540 uint32_t tempProb; |
541 | 541 |
542 NS_LOG_DEBUG ("Index-Rate\t\tAttempt\tSuccess"); | 542 NS_LOG_DEBUG ("Index-Rate\t\tAttempt\tSuccess"); |
543 for (uint8_t i = 0; i < station->m_nModes; i++) | 543 for (uint8_t i = 0; i < station->m_nModes; i++) |
544 { | 544 { |
545 | 545 |
546 //calculate the perfect tx time for this rate | 546 //calculate the perfect tx time for this rate |
547 txTime = station->m_minstrelTable[i].perfectTxTime; | 547 txTime = station->m_minstrelTable[i].perfectTxTime; |
(...skipping 27 matching lines...) Expand all Loading... |
575 } | 575 } |
576 else | 576 else |
577 { | 577 { |
578 //ewma probability (cast for gcc 3.4 compatibility) | 578 //ewma probability (cast for gcc 3.4 compatibility) |
579 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); |
580 | 580 |
581 station->m_minstrelTable[i].ewmaProb = tempProb; | 581 station->m_minstrelTable[i].ewmaProb = tempProb; |
582 } | 582 } |
583 | 583 |
584 //calculating throughput | 584 //calculating throughput |
585 station->m_minstrelTable[i].throughput = tempProb * (1000000 / txTime.
GetMicroSeconds ()); | 585 station->m_minstrelTable[i].throughput = tempProb * static_cast<uint32
_t> ((1000000 / txTime.GetMicroSeconds ())); |
586 | 586 |
587 } | 587 } |
588 else | 588 else |
589 { | 589 { |
590 station->m_minstrelTable[i].numSamplesSkipped++; | 590 station->m_minstrelTable[i].numSamplesSkipped++; |
591 } | 591 } |
592 | 592 |
593 //bookeeping | 593 //bookeeping |
594 station->m_minstrelTable[i].successHist += station->m_minstrelTable[i].num
RateSuccess; | 594 station->m_minstrelTable[i].successHist += station->m_minstrelTable[i].num
RateSuccess; |
595 station->m_minstrelTable[i].attemptHist += station->m_minstrelTable[i].num
RateAttempt; | 595 station->m_minstrelTable[i].attemptHist += station->m_minstrelTable[i].num
RateAttempt; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 | 676 |
677 station->m_maxTpRate = index_max_tp; | 677 station->m_maxTpRate = index_max_tp; |
678 station->m_maxTpRate2 = index_max_tp2; | 678 station->m_maxTpRate2 = index_max_tp2; |
679 station->m_maxProbRate = index_max_prob; | 679 station->m_maxProbRate = index_max_prob; |
680 | 680 |
681 if (index_max_tp > station->m_txrate) | 681 if (index_max_tp > station->m_txrate) |
682 { | 682 { |
683 station->m_txrate = index_max_tp; | 683 station->m_txrate = index_max_tp; |
684 } | 684 } |
685 | 685 |
686 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)) << |
687 ")\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)) << |
688 ")\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)) << ")"); |
689 if (m_printStats) | 689 if (m_printStats) |
690 { | 690 { |
691 PrintTable (station); | 691 PrintTable (station); |
692 } | 692 } |
693 if (m_printSamples) | 693 if (m_printSamples) |
694 { | 694 { |
695 PrintSampleTable (station); | 695 PrintSampleTable (station); |
696 } | 696 } |
697 } | 697 } |
698 | 698 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 MinstrelWifiManager::SetHeSupported (bool enable) | 1106 MinstrelWifiManager::SetHeSupported (bool enable) |
1107 { | 1107 { |
1108 //HE is not supported by this algorithm. | 1108 //HE is not supported by this algorithm. |
1109 if (enable) | 1109 if (enable) |
1110 { | 1110 { |
1111 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); | 1111 NS_FATAL_ERROR ("WifiRemoteStationManager selected does not support HE rat
es"); |
1112 } | 1112 } |
1113 } | 1113 } |
1114 | 1114 |
1115 } //namespace ns3 | 1115 } //namespace ns3 |
OLD | NEW |