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

(-)a/src/wifi/model/ideal-wifi-manager.cc (-47 / +81 lines)
 Lines 264-270   IdealWifiManager::DoGetDataTxVector (WifiRemoteStation *st) Link Here 
264
  std::vector<WifiTxVector> candidateTxVectors;
264
  std::vector<WifiTxVector> candidateTxVectors;
265
  WifiTxVector txVector;
265
  WifiTxVector txVector;
266
  WifiMode mode;
266
  WifiMode mode;
267
  uint8_t nss = 1;
267
  uint8_t selectedNss = 1;
268
  txVector.SetChannelWidth (GetPhy ()->GetChannelWidth ());
268
  txVector.SetChannelWidth (GetPhy ()->GetChannelWidth ());
269
  txVector.SetGuardInterval (GetPhy ()->GetShortGuardInterval () ? 400 : 800);
269
  txVector.SetGuardInterval (GetPhy ()->GetShortGuardInterval () ? 400 : 800);
270
  if (station->m_lastSnrObserved == station->m_lastSnrCached)
270
  if (station->m_lastSnrObserved == station->m_lastSnrCached)
 Lines 272-285   IdealWifiManager::DoGetDataTxVector (WifiRemoteStation *st) Link Here 
272
      // SNR has not changed, so skip the search and use the last
272
      // SNR has not changed, so skip the search and use the last
273
      // mode selected
273
      // mode selected
274
      maxMode = station->m_lastMode;
274
      maxMode = station->m_lastMode;
275
      nss = station->m_nss;
275
      selectedNss = station->m_nss;
276
      NS_LOG_DEBUG ("Using cached mode = " << maxMode.GetUniqueName () <<
276
      NS_LOG_DEBUG ("Using cached mode = " << maxMode.GetUniqueName () <<
277
                    " last snr observed " << station->m_lastSnrObserved <<
277
                    " last snr observed " << station->m_lastSnrObserved <<
278
                    " cached " << station->m_lastSnrCached);
278
                    " cached " << station->m_lastSnrCached);
279
    }
279
    }
280
  else
280
  else
281
    {
281
    {
282
      if (HasVhtSupported () == true || HasHtSupported () == true)
282
      if ((HasVhtSupported () == true || HasHtSupported () == true) &&
283
          (GetHtSupported (station) == true || GetVhtSupported (station) == true))
283
        {
284
        {
284
          for (uint32_t i = 0; i < GetNMcsSupported (station); i++)
285
          for (uint32_t i = 0; i < GetNMcsSupported (station); i++)
285
            {
286
            {
 Lines 287-343   IdealWifiManager::DoGetDataTxVector (WifiRemoteStation *st) Link Here 
287
              txVector.SetMode (mode);
288
              txVector.SetMode (mode);
288
              if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
289
              if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
289
                {
290
                {
290
                  //derive NSS from the Mcs index
291
                  // If the node and peer are both VHT capable, only search VHT modes
291
                  nss = (mode.GetMcsValue () / 8) + 1;
292
                  if (HasVhtSupported () && GetVhtSupported (station))
292
                }
293
                    {
294
                      continue;
295
                    }
296
                  // Derive NSS from the MCS index. There is a different mode for each possible NSS value.
297
                  uint8_t nss = (mode.GetMcsValue () / 8) + 1;
298
                  txVector.SetNss (nss);
299
                  if (WifiPhy::IsValidTxVector (txVector) == false)
300
                    {
301
                      NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () <<
302
                                    " nss " << nss << " width " <<
303
                                    (uint16_t) txVector.GetChannelWidth ());
304
                      continue;
305
                    }
306
                  double threshold = GetSnrThreshold (txVector);
307
                  NS_LOG_DEBUG ("Testing mode = " << mode.GetUniqueName () <<
308
                                " threshold " << threshold  << " maxThreshold " <<
309
                                maxThreshold << " last snr observed " <<
310
                                station->m_lastSnrObserved << " cached " <<
311
                                station->m_lastSnrCached);
312
                  if (threshold > maxThreshold && threshold < station->m_lastSnrObserved)
313
                    {
314
                      NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName () <<
315
                                    " threshold " << threshold  <<
316
                                    " last snr observed " <<
317
                                    station->m_lastSnrObserved);
318
                      maxThreshold = threshold;
319
                      maxMode = mode;
320
                      selectedNss = nss;
321
                    }
322
                 }
293
              else
323
              else
294
                {
324
                {
295
                  nss = GetPhy ()->GetMaxSupportedTxSpatialStreams ();
325
                  // If the node and peer are not both VHT capable, only search HT modes
296
                }
326
                  if (!HasVhtSupported () || !GetVhtSupported (station))
297
              txVector.SetNss (nss);
327
                    {
298
              if (WifiPhy::IsValidTxVector (txVector) == false)
328
                      continue;
299
                {
329
                    }
300
                  NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () <<
330
                  uint8_t maxNss = GetPhy ()->GetMaxSupportedTxSpatialStreams ();
301
                                " nss " << nss << " width " <<
331
                  for (uint8_t nss = 0; nss <= maxNss; nss++)
302
                                (uint16_t) txVector.GetChannelWidth ());
332
                    {
303
                  continue;
333
                      // If the peer does not support more streams, stop searching.
304
                }
334
                      if (GetNumberOfSupportedStreams (station) < nss)
305
              double threshold = GetSnrThreshold (txVector);
335
                        {
306
              // If the node and peer are both VHT capable, only search VHT modes
336
                          break;
307
              if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT && HasVhtSupported () && GetVhtSupported (st))
337
                        }
308
                {
338
                      txVector.SetNss (nss);
309
                  continue;
339
                      if (WifiPhy::IsValidTxVector (txVector) == false)
310
                }
340
                        {
311
              // If the node and peer are not both VHT capable, only search HT modes
341
                          NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () <<
312
              if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT && (!HasVhtSupported () || !GetVhtSupported (st)))
342
                                        " nss " << nss << " width " <<
313
                {
343
                                        (uint16_t) txVector.GetChannelWidth ());
314
                  continue;
344
                          continue;
315
                }
345
                        }
316
              NS_LOG_DEBUG ("Testing mode = " << mode.GetUniqueName () <<
346
                      double threshold = GetSnrThreshold (txVector);
317
                            " threshold " << threshold  << " maxThreshold " <<
347
                      NS_LOG_DEBUG ("Testing mode = " << mode.GetUniqueName () <<
318
                            maxThreshold << " last snr observed " <<
348
                                    " threshold " << threshold  << " maxThreshold " <<
319
                            station->m_lastSnrObserved << " cached " <<
349
                                    maxThreshold << " last snr observed " <<
320
                            station->m_lastSnrCached);
350
                                    station->m_lastSnrObserved << " cached " <<
321
              if (threshold > maxThreshold && threshold < station->m_lastSnrObserved)
351
                                    station->m_lastSnrCached);
322
                {
352
                      if (threshold > maxThreshold && threshold < station->m_lastSnrObserved)
323
                  NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName () <<
353
                        {
324
                                " threshold " << threshold  <<
354
                          NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName () <<
325
                                " last snr observed " <<
355
                                        " threshold " << threshold  <<
326
                                station->m_lastSnrObserved);
356
                                        " last snr observed " <<
327
                  maxThreshold = threshold;
357
                                        station->m_lastSnrObserved);
328
                  maxMode = mode;
358
                          maxThreshold = threshold;
359
                          maxMode = mode;
360
                          selectedNss = nss;
361
                        }
362
                    }
329
                }
363
                }
330
            }
364
            }
331
        }
365
        }
332
      else
366
      else
333
        {
367
        {
334
          // Non-HT selection
368
          // Non-HT selection
335
          nss = 1;
369
          selectedNss = 1;
336
          for (uint32_t i = 0; i < GetNSupported (station); i++)
370
          for (uint32_t i = 0; i < GetNSupported (station); i++)
337
            {
371
            {
338
              mode = GetSupported (station, i);
372
              mode = GetSupported (station, i);
339
              txVector.SetMode (mode);
373
              txVector.SetMode (mode);
340
              txVector.SetNss (nss);
374
              txVector.SetNss (selectedNss);
341
              txVector.SetChannelWidth (GetChannelWidthForMode (mode));
375
              txVector.SetChannelWidth (GetChannelWidthForMode (mode));
342
              double threshold = GetSnrThreshold (txVector);
376
              double threshold = GetSnrThreshold (txVector);
343
              NS_LOG_DEBUG ("mode = " << mode.GetUniqueName () <<
377
              NS_LOG_DEBUG ("mode = " << mode.GetUniqueName () <<
 Lines 358-373   IdealWifiManager::DoGetDataTxVector (WifiRemoteStation *st) Link Here 
358
      NS_LOG_DEBUG ("Updating cached values for station to " <<  maxMode.GetUniqueName () << " snr " << station->m_lastSnrObserved);
392
      NS_LOG_DEBUG ("Updating cached values for station to " <<  maxMode.GetUniqueName () << " snr " << station->m_lastSnrObserved);
359
      station->m_lastSnrCached = station->m_lastSnrObserved;
393
      station->m_lastSnrCached = station->m_lastSnrObserved;
360
      station->m_lastMode = maxMode;
394
      station->m_lastMode = maxMode;
361
      station->m_nss = nss;
395
      station->m_nss = selectedNss;
362
    }
396
    }
363
  uint8_t channelWidth = GetChannelWidth (station);
397
  uint8_t channelWidth = GetChannelWidth (station);
364
  NS_LOG_DEBUG ("Found maxMode: " << maxMode << " channelWidth: " << (uint16_t) channelWidth);
398
  NS_LOG_DEBUG ("Found maxMode: " << maxMode << " channelWidth: " << (uint16_t) channelWidth);
365
  if (m_currentRate != maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, nss))
399
  if (m_currentRate != maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, selectedNss))
366
    {
400
    {
367
      NS_LOG_DEBUG ("New datarate: " << maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, nss));
401
      NS_LOG_DEBUG ("New datarate: " << maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, selectedNss));
368
      m_currentRate = maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, nss);
402
      m_currentRate = maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, selectedNss);
369
    }
403
    }
370
  return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetPreambleForTransmission (maxMode, GetAddress (station)), 800, GetNumberOfAntennas (), nss, 0, channelWidth, GetAggregation (station), false);
404
  return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetPreambleForTransmission (maxMode, GetAddress (station)), 800, GetNumberOfAntennas (), selectedNss, 0, channelWidth, GetAggregation (station), false);
371
}
405
}
372
406
373
WifiTxVector
407
WifiTxVector

Return to bug 2647