|
|
| 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 |
|
|
|
| 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 |
{ |
|
|
| 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 |
} |
|
|
| 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; |
|
|
| 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); |
|
|
| 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 |
} |
|
|
| 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 |
} |
|
|
| 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 |
|
|
| 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 |