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

(-)a/src/wifi/model/ideal-wifi-manager.cc (-26 / +52 lines)
 Lines 37-43    Link Here 
37
{
37
{
38
  double m_lastSnrObserved;  //!< SNR of most recently reported packet sent to the remote station
38
  double m_lastSnrObserved;  //!< SNR of most recently reported packet sent to the remote station
39
  double m_lastSnrCached;    //!< SNR most recently used to select a rate
39
  double m_lastSnrCached;    //!< SNR most recently used to select a rate
40
  double m_nss;          //!< SNR most recently used to select a rate
40
  double m_nss;              //!< spatial stream recently used to remote station
41
  WifiMode m_lastMode;       //!< Mode most recently used to the remote station
41
  WifiMode m_lastMode;       //!< Mode most recently used to the remote station
42
};
42
};
43
43
 Lines 118-124    Link Here 
118
                    " short GI " << GetPhy ()->GetGuardInterval ());
118
                    " short GI " << GetPhy ()->GetGuardInterval ());
119
      AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber));
119
      AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber));
120
    }
120
    }
121
  // Add all Ht and Vht MCSes 
121
  // Add all supported Ht and Vht MCSes 
122
  txVector.SetChannelWidth (GetPhy ()->GetChannelWidth ());
122
  txVector.SetChannelWidth (GetPhy ()->GetChannelWidth ());
123
  if (HasVhtSupported () == true || HasHtSupported () == true )
123
  if (HasVhtSupported () == true || HasHtSupported () == true )
124
    {
124
    {
 Lines 126-148    Link Here 
126
      for (uint32_t i = 0; i < nModes; i++)
126
      for (uint32_t i = 0; i < nModes; i++)
127
        {
127
        {
128
          mode = GetPhy ()->GetMcs (i);
128
          mode = GetPhy ()->GetMcs (i);
129
          if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
129
          txVector.SetMode (mode);
130
          for (uint8_t j = 1; j <= GetPhy ()->GetSupportedTxSpatialStreams (); j++)
130
            {
131
            {
131
              //derive NSS from the Mcs index
132
              if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
132
              nss = (mode.GetMcsValue () / 8) + 1;
133
                {
134
                  //derive NSS from the Mcs index
135
                  nss = (mode.GetMcsValue () / 8) + 1;
136
                  if (nss != j)
137
                    {
138
                      continue;
139
                    }
140
                }
141
              else
142
                {
143
                  nss = j;
144
                }
145
              txVector.SetNss (nss);
146
              if (IsSupportedTxVector (txVector) && WifiPhy::IsValidTxVector (txVector))
147
                {
148
                  NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniqueName () <<
149
                                " channel width " << GetPhy ()->GetChannelWidth () <<
150
                                " nss " << (uint16_t) nss << 
151
                               " short GI " << GetPhy ()->GetGuardInterval ());
152
                  AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber));
153
                }
154
              else
155
                {
156
                  NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () << " as unsupported");
157
                }
133
            }
158
            }
134
          else
135
            {
136
              nss = GetPhy ()->GetSupportedTxSpatialStreams ();
137
            }
138
          NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniqueName () <<
139
                        " channel width " << GetPhy ()->GetChannelWidth () <<
140
                        " nss " << (uint16_t) nss << 
141
                        " short GI " << GetPhy ()->GetGuardInterval ());
142
          NS_LOG_DEBUG ("In SetupPhy, adding mode = " << mode.GetUniqueName ());
143
          txVector.SetNss (nss);
144
          txVector.SetMode (mode);
145
          AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber));
146
        }
159
        }
147
    }
160
    }
148
}
161
}
 Lines 264-269    Link Here 
264
  //to ensure correct packet delivery.
277
  //to ensure correct packet delivery.
265
  double maxThreshold = 0.0;
278
  double maxThreshold = 0.0;
266
  WifiMode maxMode = GetDefaultMode ();
279
  WifiMode maxMode = GetDefaultMode ();
280
  uint8_t maxNss = 1;
267
  std::vector<WifiTxVector> candidateTxVectors;
281
  std::vector<WifiTxVector> candidateTxVectors;
268
  WifiTxVector txVector;
282
  WifiTxVector txVector;
269
  WifiMode mode;
283
  WifiMode mode;
 Lines 275-281    Link Here 
275
      // SNR has not changed, so skip the search and use the last
289
      // SNR has not changed, so skip the search and use the last
276
      // mode selected
290
      // mode selected
277
      maxMode = station->m_lastMode;      
291
      maxMode = station->m_lastMode;      
278
      nss = station->m_nss;
292
      maxNss = station->m_nss;
279
      NS_LOG_DEBUG ("Using cached mode = " << maxMode.GetUniqueName () <<
293
      NS_LOG_DEBUG ("Using cached mode = " << maxMode.GetUniqueName () <<
280
                    " last snr observed " << station->m_lastSnrObserved <<
294
                    " last snr observed " << station->m_lastSnrObserved <<
281
                    " cached " << station->m_lastSnrCached);
295
                    " cached " << station->m_lastSnrCached);
 Lines 298-307    Link Here 
298
                  nss = GetPhy ()->GetSupportedTxSpatialStreams ();
312
                  nss = GetPhy ()->GetSupportedTxSpatialStreams ();
299
                }
313
                }
300
              txVector.SetNss (nss);
314
              txVector.SetNss (nss);
301
              if (WifiPhy::IsValidTxVector (txVector) == false)
315
              if (WifiPhy::IsValidTxVector (txVector) == false || IsSupportedTxVector (txVector) == false)
302
                 {
316
                 {
303
                   NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () <<
317
                   NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () <<
304
                                 " nss " << nss << " width " << 
318
                                 " nss " << (uint16_t) nss << " width " << 
305
                                 txVector.GetChannelWidth());
319
                                 txVector.GetChannelWidth());
306
                   continue;       
320
                   continue;       
307
                 }
321
                 }
 Lines 329-334    Link Here 
329
                                station->m_lastSnrObserved);
343
                                station->m_lastSnrObserved);
330
                  maxThreshold = threshold;
344
                  maxThreshold = threshold;
331
                  maxMode = mode;
345
                  maxMode = mode;
346
                  maxNss = nss;
332
                }
347
                }
333
            }
348
            }
334
        }
349
        }
 Lines 355-376    Link Here 
355
                                station->m_lastSnrObserved);
370
                                station->m_lastSnrObserved);
356
                  maxThreshold = threshold;
371
                  maxThreshold = threshold;
357
                  maxMode = mode;
372
                  maxMode = mode;
373
                  maxNss = nss;
358
                }
374
                }
359
            }
375
            }
360
        }
376
        }
361
      NS_LOG_DEBUG ("Updating cached values for station to " <<  maxMode.GetUniqueName () << " snr " << station->m_lastSnrObserved);
377
      NS_LOG_DEBUG ("Updating cached values for station to " <<  maxMode.GetUniqueName () << " snr " << station->m_lastSnrObserved << " nss " << uint16_t (maxNss));
362
      station->m_lastSnrCached = station->m_lastSnrObserved;
378
      station->m_lastSnrCached = station->m_lastSnrObserved;
363
      station->m_lastMode = maxMode;
379
      station->m_lastMode = maxMode;
364
      station->m_nss = nss;
380
      station->m_nss = maxNss;
365
    }
381
    }
366
  uint32_t channelWidth = GetChannelWidth (station);
382
  uint32_t channelWidth = GetChannelWidth (station);
367
  NS_LOG_DEBUG ("Found maxMode: " << maxMode << " channelWidth: " << channelWidth);
383
  NS_LOG_DEBUG ("Found maxMode: " << maxMode << " channelWidth: " << channelWidth);
368
  if (m_currentRate != maxMode.GetDataRate (channelWidth, GetPhy ()->GetGuardInterval (), nss))
384
  if (m_currentRate != maxMode.GetDataRate (channelWidth, GetPhy ()->GetGuardInterval (), maxNss))
369
    {
385
    {
370
      NS_LOG_DEBUG ("New datarate: " << maxMode.GetDataRate (channelWidth, GetPhy ()->GetGuardInterval (), nss));
386
      NS_LOG_DEBUG ("New datarate: " << maxMode.GetDataRate (channelWidth, GetPhy ()->GetGuardInterval (), maxNss));
371
      m_currentRate = maxMode.GetDataRate (channelWidth, GetPhy ()->GetGuardInterval (), nss);
387
      m_currentRate = maxMode.GetDataRate (channelWidth, GetPhy ()->GetGuardInterval (), maxNss);
372
    }
388
    }
373
  return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), false, nss, 0, channelWidth, GetAggregation (station), false);
389
  return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), false, maxNss, 0, channelWidth, GetAggregation (station), false);
374
}
390
}
375
391
376
WifiTxVector
392
WifiTxVector
 Lines 411-414    Link Here 
411
  return true;
427
  return true;
412
}
428
}
413
429
430
bool 
431
IdealWifiManager::IsSupportedTxVector (const WifiTxVector txVector) const
432
{
433
  if (txVector.GetNss () > GetPhy ()->GetSupportedTxSpatialStreams ())
434
    {
435
      return false;
436
    } 
437
  return true;
438
}
439
414
} //namespace ns3
440
} //namespace ns3
(-)a/src/wifi/model/ideal-wifi-manager.h (+15 lines)
 Lines 74-79    Link Here 
74
  virtual bool IsLowLatency (void) const;
74
  virtual bool IsLowLatency (void) const;
75
75
76
  /**
76
  /**
77
   * Return true or false depending on whether the txVector is supported 
78
   * for transmitting.  The list of supported modes stored in the 
79
   * WifiPhy may be larger than the list of usable modes for sending data 
80
   * because the number of transmit antennas and receive antennas may 
81
   * be unequal.
82
   *
83
   * Note that WifiPhy has a similar IsValidTxVector() that may be used
84
   * to check whether the standard allows the combination of channel width,
85
   * NSS, and MCS.
86
   *
87
   * \param txVector the txVector to check
88
   * \return true if the station can transmit using this txVector
89
   */
90
  bool IsSupportedTxVector (const WifiTxVector txVector) const;
91
  /**
77
   * Return the minimum SNR needed to successfully transmit
92
   * Return the minimum SNR needed to successfully transmit
78
   * data with this WifiTxVector at the specified BER.
93
   * data with this WifiTxVector at the specified BER.
79
   *
94
   *

Return to bug 2385