View | Details | Raw Unified | Return to bug 2656
Collapse All | Expand All

(-)a/src/wifi/examples/wifi-manager-example.cc (+5 lines)
 Lines 43-48    Link Here 
43
#include "ns3/stats-module.h"
43
#include "ns3/stats-module.h"
44
#include "ns3/mobility-module.h"
44
#include "ns3/mobility-module.h"
45
#include "ns3/propagation-module.h"
45
#include "ns3/propagation-module.h"
46
#include "ns3/rng-seed-manager.h"
46
47
47
using namespace ns3;
48
using namespace ns3;
48
49
 Lines 332-337   int main (int argc, char *argv[]) Link Here 
332
333
333
  serverDevice = wifi.Install (wifiPhy, wifiMac, serverNode);
334
  serverDevice = wifi.Install (wifiPhy, wifiMac, serverNode);
334
  clientDevice = wifi.Install (wifiPhy, wifiMac, clientNode);
335
  clientDevice = wifi.Install (wifiPhy, wifiMac, clientNode);
336
  RngSeedManager::SetSeed (1);
337
  RngSeedManager::SetRun (2);
338
  wifi.AssignStreams(serverDevice, 100);
339
  wifi.AssignStreams(clientDevice, 100);
335
340
336
  if (wifiManager == "MinstrelHt")
341
  if (wifiManager == "MinstrelHt")
337
    {
342
    {
(-)a/src/wifi/helper/wifi-helper.cc (+7 lines)
 Lines 23-28    Link Here 
23
#include "wifi-helper.h"
23
#include "wifi-helper.h"
24
#include "ns3/wifi-net-device.h"
24
#include "ns3/wifi-net-device.h"
25
#include "ns3/minstrel-wifi-manager.h"
25
#include "ns3/minstrel-wifi-manager.h"
26
#include "ns3/minstrel-ht-wifi-manager.h"
26
#include "ns3/ap-wifi-mac.h"
27
#include "ns3/ap-wifi-mac.h"
27
#include "ns3/ampdu-subframe-header.h"
28
#include "ns3/ampdu-subframe-header.h"
28
#include "ns3/log.h"
29
#include "ns3/log.h"
 Lines 858-863   WifiHelper::AssignStreams (NetDeviceContainer c, int64_t stream) Link Here 
858
              currentStream += minstrel->AssignStreams (currentStream);
859
              currentStream += minstrel->AssignStreams (currentStream);
859
            }
860
            }
860
861
862
          Ptr<MinstrelHtWifiManager> minstrelHt = DynamicCast<MinstrelHtWifiManager> (manager);
863
          if (minstrelHt)
864
            {
865
              currentStream += minstrelHt->AssignStreams (currentStream);
866
            }
867
861
          //Handle any random numbers in the MAC objects.
868
          //Handle any random numbers in the MAC objects.
862
          Ptr<WifiMac> mac = wifi->GetMac ();
869
          Ptr<WifiMac> mac = wifi->GetMac ();
863
          Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
870
          Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
(-)a/src/wifi/model/minstrel-ht-wifi-manager.cc (-4 / +8 lines)
 Lines 476-482   MinstrelHtWifiManager::CheckInit (MinstrelHtWifiRemoteStation *station) Link Here 
476
       */
476
       */
477
      if (!GetHtSupported (station) && !GetVhtSupported (station))
477
      if (!GetHtSupported (station) && !GetVhtSupported (station))
478
        {
478
        {
479
          NS_LOG_DEBUG ("Non-HT station " << station);
479
          NS_LOG_INFO ("Non-HT station " << station);
480
          station->m_isHt = false;
480
          station->m_isHt = false;
481
          // We will use non-HT minstrel for this station. Initialize the manager.
481
          // We will use non-HT minstrel for this station. Initialize the manager.
482
          m_legacyManager->SetAttribute ("UpdateStatistics", TimeValue (m_updateStats));
482
          m_legacyManager->SetAttribute ("UpdateStatistics", TimeValue (m_updateStats));
 Lines 567-580   MinstrelHtWifiManager::DoReportDataFailed (WifiRemoteStation *st) Link Here 
567
      return;
567
      return;
568
    }
568
    }
569
569
570
  NS_LOG_DEBUG ("DoReportDataFailed " << station << "\t rate " << station->m_txrate << "\tlongRetry \t" << station->m_longRetry);
571
570
  if (!station->m_isHt)
572
  if (!station->m_isHt)
571
    {
573
    {
572
      m_legacyManager->UpdateRate (station);
574
      m_legacyManager->UpdateRate (station);
573
    }
575
    }
574
  else
576
  else
575
    {
577
    {
576
      NS_LOG_DEBUG ("DoReportDataFailed " << station << "\t rate " << station->m_txrate << "\tlongRetry \t" << station->m_longRetry);
577
578
      uint32_t rateId = GetRateId (station->m_txrate);
578
      uint32_t rateId = GetRateId (station->m_txrate);
579
      uint32_t groupId = GetGroupId (station->m_txrate);
579
      uint32_t groupId = GetGroupId (station->m_txrate);
580
      station->m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt++; // Increment the attempts counter for the rate used.
580
      station->m_groupsTable[groupId].m_ratesTable[rateId].numRateAttempt++; // Increment the attempts counter for the rate used.
 Lines 596-602   MinstrelHtWifiManager::DoReportDataOk (WifiRemoteStation *st, Link Here 
596
      return;
596
      return;
597
    }
597
    }
598
598
599
  NS_LOG_DEBUG ("Data OK - Txrate = " << station->m_txrate  );
599
  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 update).");
600
600
601
  if (!station->m_isHt)
601
  if (!station->m_isHt)
602
    {
602
    {
 Lines 605-610   MinstrelHtWifiManager::DoReportDataOk (WifiRemoteStation *st, Link Here 
605
605
606
      m_legacyManager->UpdatePacketCounters (station);
606
      m_legacyManager->UpdatePacketCounters (station);
607
607
608
      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 update).");
609
608
      UpdateRetry (station);
610
      UpdateRetry (station);
609
      m_legacyManager->UpdateStats (station);
611
      m_legacyManager->UpdateStats (station);
610
612
 Lines 622-627   MinstrelHtWifiManager::DoReportDataOk (WifiRemoteStation *st, Link Here 
622
624
623
      UpdatePacketCounters (station, 1, 0);
625
      UpdatePacketCounters (station, 1, 0);
624
626
627
      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 update).");
628
625
      station->m_isSampling = false;
629
      station->m_isSampling = false;
626
      station->m_sampleDeferred = false;
630
      station->m_sampleDeferred = false;
627
631
(-)a/src/wifi/model/minstrel-wifi-manager.cc (-5 / +14 lines)
 Lines 361-372   MinstrelWifiManager::GetDataTxVector (MinstrelWifiRemoteStation *station) Link Here 
361
  if (!station->m_initialized)
361
  if (!station->m_initialized)
362
    {
362
    {
363
      CheckInit (station);
363
      CheckInit (station);
364
365
      //start the rate at half way
366
      station->m_txrate = station->m_nModes / 2;
367
    }
364
    }
368
  WifiMode mode = GetSupported (station, station->m_txrate);
365
  WifiMode mode = GetSupported (station, station->m_txrate);
369
  if (m_currentRate != mode.GetDataRate (channelWidth))
366
  if (m_currentRate != mode.GetDataRate (channelWidth) && !station->m_isSampling)
370
    {
367
    {
371
      NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (channelWidth));
368
      NS_LOG_DEBUG ("New datarate: " << mode.GetDataRate (channelWidth));
372
      m_currentRate = mode.GetDataRate (channelWidth);
369
      m_currentRate = mode.GetDataRate (channelWidth);
 Lines 431-436   MinstrelWifiManager::FindRate (MinstrelWifiRemoteStation *station) Link Here 
431
428
432
  uint32_t idx;
429
  uint32_t idx;
433
430
431
  NS_LOG_DEBUG ("Total: " << station->m_totalPacketsCount << "  Sample: " << station->m_samplePacketsCount << "  Deferred: " << station->m_numSamplesDeferred);
432
434
  int delta = (station->m_totalPacketsCount * m_lookAroundRate / 100) - (station->m_samplePacketsCount + station->m_numSamplesDeferred / 2);
433
  int delta = (station->m_totalPacketsCount * m_lookAroundRate / 100) - (station->m_samplePacketsCount + station->m_numSamplesDeferred / 2);
435
434
436
  NS_LOG_DEBUG ("Decide sampling. Delta: " << delta << " lookAroundRatio: " <<  m_lookAroundRate);
435
  NS_LOG_DEBUG ("Decide sampling. Delta: " << delta << " lookAroundRatio: " <<  m_lookAroundRate);
 Lines 458-463   MinstrelWifiManager::FindRate (MinstrelWifiRemoteStation *station) Link Here 
458
      //now go through the table and find an index rate
457
      //now go through the table and find an index rate
459
      idx = GetNextSample (station);
458
      idx = GetNextSample (station);
460
459
460
      NS_LOG_DEBUG ("Sample rate = " << idx << "(" << GetSupported (station, idx) << ")");
461
461
      //error check
462
      //error check
462
      if (idx >= station->m_nModes)
463
      if (idx >= station->m_nModes)
463
        {
464
        {
 Lines 699-704   MinstrelWifiManager::DoReportRxOk (WifiRemoteStation *st, Link Here 
699
                                   double rxSnr, WifiMode txMode)
700
                                   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
 Lines 723-728   MinstrelWifiManager::DoReportFinalRtsFailed (WifiRemoteStation *st) Link Here 
723
{
725
{
724
  NS_LOG_FUNCTION (this << st);
726
  NS_LOG_FUNCTION (this << st);
725
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st;
727
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st;
728
  NS_LOG_DEBUG ("Final RTS failed");
726
  UpdateRetry (station);
729
  UpdateRetry (station);
727
}
730
}
728
731
 Lines 731-736   MinstrelWifiManager::DoReportDataFailed (WifiRemoteStation *st) Link Here 
731
{
734
{
732
  NS_LOG_FUNCTION (this << st);
735
  NS_LOG_FUNCTION (this << st);
733
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st;
736
  MinstrelWifiRemoteStation *station = (MinstrelWifiRemoteStation *)st;
737
  NS_LOG_DEBUG ("DoReportDataFailed " << station << "\t rate " << station->m_txrate << "\tlongRetry \t" << station->m_longRetry);
734
  CheckInit (station);
738
  CheckInit (station);
735
  if (!station->m_initialized)
739
  if (!station->m_initialized)
736
    {
740
    {
 Lines 769-774   MinstrelWifiManager::DoReportDataOk (WifiRemoteStation *st, Link Here 
769
    {
773
    {
770
      station->m_txrate = FindRate (station);
774
      station->m_txrate = FindRate (station);
771
    }
775
    }
776
  NS_LOG_DEBUG ("Next rate to use TxRate = " << station->m_txrate  );
772
}
777
}
773
778
774
void
779
void
 Lines 796-801   MinstrelWifiManager::DoReportFinalDataFailed (WifiRemoteStation *st) Link Here 
796
    {
801
    {
797
      station->m_txrate = FindRate (station);
802
      station->m_txrate = FindRate (station);
798
    }
803
    }
804
  NS_LOG_DEBUG ("Next rate to use TxRate = " << station->m_txrate  );
799
}
805
}
800
806
801
void
807
void
 Lines 861-872   MinstrelWifiManager::DoNeedDataRetransmission (WifiRemoteStation *st, Ptr<const Link Here 
861
    {
867
    {
862
      return normally;
868
      return normally;
863
    }
869
    }
864
  if (station->m_longRetry > CountRetries (station))
870
  if (station->m_longRetry >= CountRetries (station))
865
    {
871
    {
872
      NS_LOG_DEBUG ("No re-transmission allowed. Retries: " <<  station->m_longRetry << " Max retries: " << CountRetries (station));
866
      return false;
873
      return false;
867
    }
874
    }
868
  else
875
  else
869
    {
876
    {
877
      NS_LOG_DEBUG ("Re-transmit. Retries: " <<  station->m_longRetry << " Max retries: " << CountRetries (station));
870
      return true;
878
      return true;
871
    }
879
    }
872
}
880
}
 Lines 989-994   MinstrelWifiManager::InitSampleTable (MinstrelWifiRemoteStation *station) Link Here 
989
           * between 0 and the number of available rates
997
           * between 0 and the number of available rates
990
           */
998
           */
991
          int uv = m_uniformRandomVariable->GetInteger (0, numSampleRates);
999
          int uv = m_uniformRandomVariable->GetInteger (0, numSampleRates);
1000
          NS_LOG_DEBUG("InitSampleTable uv: " << uv);
992
          newIndex = (i + uv) % numSampleRates;
1001
          newIndex = (i + uv) % numSampleRates;
993
1002
994
          //this loop is used for filling in other uninitialized places
1003
          //this loop is used for filling in other uninitialized places

Return to bug 2656