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

(-)a/src/wifi/examples/wifi-manager-example.cc (-6 / +21 lines)
 Lines 164-169    Link Here 
164
  std::string standard ("802.11a");
164
  std::string standard ("802.11a");
165
  StandardInfo serverSelectedStandard;
165
  StandardInfo serverSelectedStandard;
166
  StandardInfo clientSelectedStandard;
166
  StandardInfo clientSelectedStandard;
167
  bool infrastructure = false;
167
168
168
  CommandLine cmd;
169
  CommandLine cmd;
169
  cmd.AddValue ("rtsThreshold", "RTS threshold", rtsThreshold);
170
  cmd.AddValue ("rtsThreshold", "RTS threshold", rtsThreshold);
 Lines 179-184    Link Here 
179
  cmd.AddValue ("clientShortGuardInterval", "Set short guard interval of the client (802.11n/ac)", clientShortGuardInterval);
180
  cmd.AddValue ("clientShortGuardInterval", "Set short guard interval of the client (802.11n/ac)", clientShortGuardInterval);
180
  cmd.AddValue ("standard", "Set standard (802.11a, 802.11b, 802.11g, 802.11n-5GHz, 802.11n-2.4GHz, 802.11ac, 802.11-holland, 802.11-10MHz, 802.11-5MHz)", standard);
181
  cmd.AddValue ("standard", "Set standard (802.11a, 802.11b, 802.11g, 802.11n-5GHz, 802.11n-2.4GHz, 802.11ac, 802.11-holland, 802.11-10MHz, 802.11-5MHz)", standard);
181
  cmd.AddValue ("wifiManager", "Set wifi rate manager (Aarf, Aarfcd, Amrr, Arf, Cara, Ideal, Minstrel, MinstrelHt, Onoe, Rraa)", wifiManager);
182
  cmd.AddValue ("wifiManager", "Set wifi rate manager (Aarf, Aarfcd, Amrr, Arf, Cara, Ideal, Minstrel, MinstrelHt, Onoe, Rraa)", wifiManager);
183
  cmd.AddValue ("infrastructure", "Use infrastructure instead of adhoc", infrastructure);
182
  cmd.Parse (argc,argv);
184
  cmd.Parse (argc,argv);
183
185
184
  if (standard == "802.11b")
186
  if (standard == "802.11b")
 Lines 326-337    Link Here 
326
  NetDeviceContainer clientDevice;
328
  NetDeviceContainer clientDevice;
327
329
328
  WifiMacHelper wifiMac;
330
  WifiMacHelper wifiMac;
329
  // Use Adhoc so we don't get into association issues
331
  if (infrastructure)
330
  wifiMac.SetType ("ns3::AdhocWifiMac",
332
    {
331
                   "BE_MaxAmpduSize", UintegerValue (maxAmpduSize));
333
      Ssid ssid = Ssid ("ns-3-ssid");
332
334
      wifiMac.SetType ("ns3::StaWifiMac",
333
  serverDevice = wifi.Install (wifiPhy, wifiMac, serverNode);
335
                       "Ssid", SsidValue (ssid),
334
  clientDevice = wifi.Install (wifiPhy, wifiMac, clientNode);
336
                       "ActiveProbing", BooleanValue (false));
337
      serverDevice = wifi.Install (wifiPhy, wifiMac, serverNode);
338
      wifiMac.SetType ("ns3::ApWifiMac",
339
                       "Ssid", SsidValue (ssid),
340
                       "BeaconGeneration", BooleanValue (true));
341
      clientDevice = wifi.Install (wifiPhy, wifiMac, clientNode);
342
    }
343
  else
344
    {
345
      wifiMac.SetType ("ns3::AdhocWifiMac",
346
                       "BE_MaxAmpduSize", UintegerValue (maxAmpduSize));
347
      serverDevice = wifi.Install (wifiPhy, wifiMac, serverNode);
348
      clientDevice = wifi.Install (wifiPhy, wifiMac, clientNode);
349
    }
335
350
336
  if (wifiManager == "MinstrelHt")
351
  if (wifiManager == "MinstrelHt")
337
    {
352
    {
(-)a/src/wifi/model/ideal-wifi-manager.cc (-31 / +35 lines)
 Lines 116-155    Link Here 
116
      AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber));
116
      AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber));
117
    }
117
    }
118
  // Add all Ht and Vht MCSes
118
  // Add all Ht and Vht MCSes
119
  txVector.SetChannelWidth (GetPhy ()->GetChannelWidth ());
119
  if (HasVhtSupported () == true || HasHtSupported () == true)
120
  if (HasVhtSupported () == true || HasHtSupported () == true )
121
    {
120
    {
122
      nModes = GetPhy ()->GetNMcs ();
121
      nModes = GetPhy ()->GetNMcs ();
123
      for (uint32_t i = 0; i < nModes; i++)
122
      for (uint32_t i = 0; i < nModes; i++)
124
        {
123
        {
125
          mode = GetPhy ()->GetMcs (i);
124
          for (uint16_t j = 20; j <= GetPhy ()->GetChannelWidth (); j*=2)
126
          if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
127
            {
125
            {
128
              //derive NSS from the Mcs index
126
              txVector.SetChannelWidth (j);
129
              nss = (mode.GetMcsValue () / 8) + 1;
127
              mode = GetPhy ()->GetMcs (i);
130
              NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniqueName () <<
128
              if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
131
                            " channel width " << (uint16_t) GetPhy ()->GetChannelWidth () <<
132
                            " nss " << (uint16_t) nss <<
133
                            " short GI " << GetPhy ()->GetShortGuardInterval ());
134
              NS_LOG_DEBUG ("In SetupPhy, adding mode = " << mode.GetUniqueName ());
135
              txVector.SetNss (nss);
136
              txVector.SetMode (mode);
137
              AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber));
138
            }
139
          else
140
            {
141
              uint8_t maxNss = GetPhy ()->GetMaxSupportedTxSpatialStreams ();
142
              for (uint8_t i = 1; i <= maxNss; i++)
143
                {
129
                {
130
                  //derive NSS from the Mcs index
131
                  nss = (mode.GetMcsValue () / 8) + 1;
144
                  NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniqueName () <<
132
                  NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniqueName () <<
145
                                " channel width " << (uint16_t) GetPhy ()->GetChannelWidth () <<
133
                                " channel width " << (uint16_t) GetPhy ()->GetChannelWidth () <<
146
                                " nss " << (uint16_t) i <<
134
                                " nss " << (uint16_t) nss <<
147
                                " short GI " << GetPhy ()->GetShortGuardInterval ());
135
                                " short GI " << j);
148
                  NS_LOG_DEBUG ("In SetupPhy, adding mode = " << mode.GetUniqueName ());
136
                  NS_LOG_DEBUG ("In SetupPhy, adding mode = " << mode.GetUniqueName ());
149
                  txVector.SetNss (i);
137
                  txVector.SetNss (nss);
150
                  txVector.SetMode (mode);
138
                  txVector.SetMode (mode);
151
                  AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber));
139
                  AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber));
152
                }
140
                }
141
              else //VHT
142
                {
143
                  uint8_t maxNss = GetPhy ()->GetMaxSupportedTxSpatialStreams ();
144
                  for (uint8_t i = 1; i <= maxNss; i++)
145
                    {
146
                      NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniqueName () <<
147
                                    " channel width " << (uint16_t) GetPhy ()->GetChannelWidth () <<
148
                                    " nss " << (uint16_t) i <<
149
                                    " short GI " << j);
150
                      NS_LOG_DEBUG ("In SetupPhy, adding mode = " << mode.GetUniqueName ());
151
                      txVector.SetNss (i);
152
                      txVector.SetMode (mode);
153
                      AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber));
154
                    }
155
                }
153
            }
156
            }
154
        }
157
        }
155
    }
158
    }
 Lines 163-175    Link Here 
163
    {
166
    {
164
      NS_LOG_DEBUG ("Checking " << i->second.GetMode ().GetUniqueName () <<
167
      NS_LOG_DEBUG ("Checking " << i->second.GetMode ().GetUniqueName () <<
165
                    " nss " << (uint16_t) i->second.GetNss () <<
168
                    " nss " << (uint16_t) i->second.GetNss () <<
169
                    " GI " << i->second.GetGuardInterval () <<
166
                    " width " << (uint16_t) i->second.GetChannelWidth ());
170
                    " width " << (uint16_t) i->second.GetChannelWidth ());
167
      NS_LOG_DEBUG ("against TxVector " << txVector.GetMode ().GetUniqueName () <<
171
      NS_LOG_DEBUG ("against TxVector " << txVector.GetMode ().GetUniqueName () <<
168
                    " nss " << (uint16_t) txVector.GetNss () <<
172
                    " nss " << (uint16_t) txVector.GetNss () <<
173
                    " GI " << txVector.GetGuardInterval () <<
169
                    " width " << (uint16_t) txVector.GetChannelWidth ());
174
                    " width " << (uint16_t) txVector.GetChannelWidth ());
170
      if (txVector.GetMode () == i->second.GetMode ()
175
      if (txVector.GetMode () == i->second.GetMode ()
171
          && txVector.GetNss () == i->second.GetNss ()
176
          && txVector.GetNss () == i->second.GetNss ()
172
          && txVector.GetGuardInterval () == i->second.GetGuardInterval ()
173
          && txVector.GetChannelWidth () == i->second.GetChannelWidth ())
177
          && txVector.GetChannelWidth () == i->second.GetChannelWidth ())
174
        {
178
        {
175
          return i->first;
179
          return i->first;
 Lines 272-283    Link Here 
272
  //to ensure correct packet delivery.
276
  //to ensure correct packet delivery.
273
  double maxThreshold = 0.0;
277
  double maxThreshold = 0.0;
274
  WifiMode maxMode = GetDefaultMode ();
278
  WifiMode maxMode = GetDefaultMode ();
275
  std::vector<WifiTxVector> candidateTxVectors;
276
  WifiTxVector txVector;
279
  WifiTxVector txVector;
277
  WifiMode mode;
280
  WifiMode mode;
278
  uint8_t selectedNss = 1;
281
  uint8_t selectedNss = 1;
279
  txVector.SetChannelWidth (GetPhy ()->GetChannelWidth ());
282
  uint8_t channelWidth = std::min (GetChannelWidth (station), GetPhy ()->GetChannelWidth ());
280
  txVector.SetGuardInterval (GetPhy ()->GetShortGuardInterval () ? 400 : 800);
283
  uint16_t guardInterval = std::max (GetShortGuardInterval (station) ? 400 : 800, GetPhy ()->GetShortGuardInterval () ? 400 : 800);
284
  txVector.SetChannelWidth (channelWidth);
285
  txVector.SetGuardInterval (guardInterval);
281
  if (station->m_lastSnrObserved == station->m_lastSnrCached)
286
  if (station->m_lastSnrObserved == station->m_lastSnrCached)
282
    {
287
    {
283
      // SNR has not changed, so skip the search and use the last
288
      // SNR has not changed, so skip the search and use the last
 Lines 405-418    Link Here 
405
      station->m_lastMode = maxMode;
410
      station->m_lastMode = maxMode;
406
      station->m_nss = selectedNss;
411
      station->m_nss = selectedNss;
407
    }
412
    }
408
  uint8_t channelWidth = GetChannelWidth (station);
409
  NS_LOG_DEBUG ("Found maxMode: " << maxMode << " channelWidth: " << (uint16_t) channelWidth);
413
  NS_LOG_DEBUG ("Found maxMode: " << maxMode << " channelWidth: " << (uint16_t) channelWidth);
410
  if (m_currentRate != maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, selectedNss))
414
  if (m_currentRate != maxMode.GetDataRate (channelWidth, guardInterval, selectedNss))
411
    {
415
    {
412
      NS_LOG_DEBUG ("New datarate: " << maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, selectedNss));
416
      NS_LOG_DEBUG ("New datarate: " << maxMode.GetDataRate (channelWidth, guardInterval, selectedNss));
413
      m_currentRate = maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, selectedNss);
417
      m_currentRate = maxMode.GetDataRate (channelWidth, guardInterval, selectedNss);
414
    }
418
    }
415
  return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetPreambleForTransmission (maxMode, GetAddress (station)), 800, GetNumberOfAntennas (), selectedNss, 0, channelWidth, GetAggregation (station), false);
419
  return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetPreambleForTransmission (maxMode, GetAddress (station)), guardInterval, GetNumberOfAntennas (), selectedNss, 0, channelWidth, GetAggregation (station), false);
416
}
420
}
417
421
418
WifiTxVector
422
WifiTxVector

Return to bug 2721