|
Lines 127-145
IdealWifiManager::DoInitialize ()
|
Link Here
|
|---|
|
| 127 |
{ |
127 |
{ |
| 128 |
//derive NSS from the Mcs index |
128 |
//derive NSS from the Mcs index |
| 129 |
nss = (mode.GetMcsValue () / 8) + 1; |
129 |
nss = (mode.GetMcsValue () / 8) + 1; |
|
|
130 |
NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniqueName () << |
| 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)); |
| 130 |
} |
138 |
} |
| 131 |
else |
139 |
else |
| 132 |
{ |
140 |
{ |
| 133 |
nss = GetPhy ()->GetMaxSupportedTxSpatialStreams (); |
141 |
uint8_t maxNss = GetPhy ()->GetMaxSupportedTxSpatialStreams (); |
|
|
142 |
for (uint8_t i = 1; i <= maxNss; i++) |
| 143 |
{ |
| 144 |
NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniqueName () << |
| 145 |
" channel width " << (uint16_t) GetPhy ()->GetChannelWidth () << |
| 146 |
" nss " << (uint16_t) i << |
| 147 |
" short GI " << GetPhy ()->GetShortGuardInterval ()); |
| 148 |
NS_LOG_DEBUG ("In SetupPhy, adding mode = " << mode.GetUniqueName ()); |
| 149 |
txVector.SetNss (i); |
| 150 |
txVector.SetMode (mode); |
| 151 |
AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber)); |
| 152 |
} |
| 134 |
} |
153 |
} |
| 135 |
NS_LOG_DEBUG ("Initialize, adding mode = " << mode.GetUniqueName () << |
|
|
| 136 |
" channel width " << (uint16_t) GetPhy ()->GetChannelWidth () << |
| 137 |
" nss " << (uint16_t) nss << |
| 138 |
" short GI " << GetPhy ()->GetShortGuardInterval ()); |
| 139 |
NS_LOG_DEBUG ("In SetupPhy, adding mode = " << mode.GetUniqueName ()); |
| 140 |
txVector.SetNss (nss); |
| 141 |
txVector.SetMode (mode); |
| 142 |
AddSnrThreshold (txVector, GetPhy ()->CalculateSnr (txVector, m_ber)); |
| 143 |
} |
154 |
} |
| 144 |
} |
155 |
} |
| 145 |
} |
156 |
} |
|
Lines 264-270
IdealWifiManager::DoGetDataTxVector (WifiRemoteStation *st)
|
Link Here
|
|---|
|
| 264 |
std::vector<WifiTxVector> candidateTxVectors; |
275 |
std::vector<WifiTxVector> candidateTxVectors; |
| 265 |
WifiTxVector txVector; |
276 |
WifiTxVector txVector; |
| 266 |
WifiMode mode; |
277 |
WifiMode mode; |
| 267 |
uint8_t nss = 1; |
278 |
uint8_t selectedNss = 1; |
| 268 |
txVector.SetChannelWidth (GetPhy ()->GetChannelWidth ()); |
279 |
txVector.SetChannelWidth (GetPhy ()->GetChannelWidth ()); |
| 269 |
txVector.SetGuardInterval (GetPhy ()->GetShortGuardInterval () ? 400 : 800); |
280 |
txVector.SetGuardInterval (GetPhy ()->GetShortGuardInterval () ? 400 : 800); |
| 270 |
if (station->m_lastSnrObserved == station->m_lastSnrCached) |
281 |
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 |
283 |
// SNR has not changed, so skip the search and use the last |
| 273 |
// mode selected |
284 |
// mode selected |
| 274 |
maxMode = station->m_lastMode; |
285 |
maxMode = station->m_lastMode; |
| 275 |
nss = station->m_nss; |
286 |
selectedNss = station->m_nss; |
| 276 |
NS_LOG_DEBUG ("Using cached mode = " << maxMode.GetUniqueName () << |
287 |
NS_LOG_DEBUG ("Using cached mode = " << maxMode.GetUniqueName () << |
| 277 |
" last snr observed " << station->m_lastSnrObserved << |
288 |
" last snr observed " << station->m_lastSnrObserved << |
| 278 |
" cached " << station->m_lastSnrCached); |
289 |
" cached " << station->m_lastSnrCached); |
| 279 |
} |
290 |
} |
| 280 |
else |
291 |
else |
| 281 |
{ |
292 |
{ |
| 282 |
if (HasVhtSupported () == true || HasHtSupported () == true) |
293 |
if ((HasVhtSupported () == true || HasHtSupported () == true) && |
|
|
294 |
(GetHtSupported (station) == true || GetVhtSupported (station) == true)) |
| 283 |
{ |
295 |
{ |
| 284 |
for (uint32_t i = 0; i < GetNMcsSupported (station); i++) |
296 |
for (uint32_t i = 0; i < GetNMcsSupported (station); i++) |
| 285 |
{ |
297 |
{ |
|
Lines 287-343
IdealWifiManager::DoGetDataTxVector (WifiRemoteStation *st)
|
Link Here
|
|---|
|
| 287 |
txVector.SetMode (mode); |
299 |
txVector.SetMode (mode); |
| 288 |
if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
300 |
if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
| 289 |
{ |
301 |
{ |
| 290 |
//derive NSS from the Mcs index |
302 |
// If the node and peer are both VHT capable, only search VHT modes |
| 291 |
nss = (mode.GetMcsValue () / 8) + 1; |
303 |
if (HasVhtSupported () && GetVhtSupported (station)) |
| 292 |
} |
304 |
{ |
|
|
305 |
continue; |
| 306 |
} |
| 307 |
// Derive NSS from the MCS index. There is a different mode for each possible NSS value. |
| 308 |
uint8_t nss = (mode.GetMcsValue () / 8) + 1; |
| 309 |
txVector.SetNss (nss); |
| 310 |
if (WifiPhy::IsValidTxVector (txVector) == false) |
| 311 |
{ |
| 312 |
NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () << |
| 313 |
" nss " << (uint16_t) nss << " width " << |
| 314 |
(uint16_t) txVector.GetChannelWidth ()); |
| 315 |
continue; |
| 316 |
} |
| 317 |
double threshold = GetSnrThreshold (txVector); |
| 318 |
NS_LOG_DEBUG ("Testing mode = " << mode.GetUniqueName () << |
| 319 |
" threshold " << threshold << " maxThreshold " << |
| 320 |
maxThreshold << " last snr observed " << |
| 321 |
station->m_lastSnrObserved << " cached " << |
| 322 |
station->m_lastSnrCached); |
| 323 |
if (threshold > maxThreshold && threshold < station->m_lastSnrObserved) |
| 324 |
{ |
| 325 |
NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName () << |
| 326 |
" threshold " << threshold << |
| 327 |
" last snr observed " << |
| 328 |
station->m_lastSnrObserved); |
| 329 |
maxThreshold = threshold; |
| 330 |
maxMode = mode; |
| 331 |
selectedNss = nss; |
| 332 |
} |
| 333 |
} |
| 293 |
else |
334 |
else |
| 294 |
{ |
335 |
{ |
| 295 |
nss = GetPhy ()->GetMaxSupportedTxSpatialStreams (); |
336 |
// If the node and peer are not both VHT capable, only search HT modes |
| 296 |
} |
337 |
if (!HasVhtSupported () || !GetVhtSupported (station)) |
| 297 |
txVector.SetNss (nss); |
338 |
{ |
| 298 |
if (WifiPhy::IsValidTxVector (txVector) == false) |
339 |
continue; |
| 299 |
{ |
340 |
} |
| 300 |
NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () << |
341 |
uint8_t maxNss = GetPhy ()->GetMaxSupportedTxSpatialStreams (); |
| 301 |
" nss " << nss << " width " << |
342 |
for (uint8_t nss = 1; nss <= maxNss; nss++) |
| 302 |
(uint16_t) txVector.GetChannelWidth ()); |
343 |
{ |
| 303 |
continue; |
344 |
// If the peer does not support more streams, stop searching. |
| 304 |
} |
345 |
if (GetNumberOfSupportedStreams (station) < nss) |
| 305 |
double threshold = GetSnrThreshold (txVector); |
346 |
{ |
| 306 |
// If the node and peer are both VHT capable, only search VHT modes |
347 |
break; |
| 307 |
if (mode.GetModulationClass () == WIFI_MOD_CLASS_HT && HasVhtSupported () && GetVhtSupported (st)) |
348 |
} |
| 308 |
{ |
349 |
txVector.SetNss (nss); |
| 309 |
continue; |
350 |
if (WifiPhy::IsValidTxVector (txVector) == false) |
| 310 |
} |
351 |
{ |
| 311 |
// If the node and peer are not both VHT capable, only search HT modes |
352 |
NS_LOG_DEBUG ("Skipping mode " << mode.GetUniqueName () << |
| 312 |
if (mode.GetModulationClass () == WIFI_MOD_CLASS_VHT && (!HasVhtSupported () || !GetVhtSupported (st))) |
353 |
" nss " << (uint16_t) nss << " width " << |
| 313 |
{ |
354 |
(uint16_t) txVector.GetChannelWidth ()); |
| 314 |
continue; |
355 |
continue; |
| 315 |
} |
356 |
} |
| 316 |
NS_LOG_DEBUG ("Testing mode = " << mode.GetUniqueName () << |
357 |
double threshold = GetSnrThreshold (txVector); |
| 317 |
" threshold " << threshold << " maxThreshold " << |
358 |
NS_LOG_DEBUG ("Testing mode = " << mode.GetUniqueName () << |
| 318 |
maxThreshold << " last snr observed " << |
359 |
" threshold " << threshold << " maxThreshold " << |
| 319 |
station->m_lastSnrObserved << " cached " << |
360 |
maxThreshold << " last snr observed " << |
| 320 |
station->m_lastSnrCached); |
361 |
station->m_lastSnrObserved << " cached " << |
| 321 |
if (threshold > maxThreshold && threshold < station->m_lastSnrObserved) |
362 |
station->m_lastSnrCached); |
| 322 |
{ |
363 |
if (threshold > maxThreshold && threshold < station->m_lastSnrObserved) |
| 323 |
NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName () << |
364 |
{ |
| 324 |
" threshold " << threshold << |
365 |
NS_LOG_DEBUG ("Candidate mode = " << mode.GetUniqueName () << |
| 325 |
" last snr observed " << |
366 |
" threshold " << threshold << |
| 326 |
station->m_lastSnrObserved); |
367 |
" last snr observed " << |
| 327 |
maxThreshold = threshold; |
368 |
station->m_lastSnrObserved); |
| 328 |
maxMode = mode; |
369 |
maxThreshold = threshold; |
|
|
370 |
maxMode = mode; |
| 371 |
selectedNss = nss; |
| 372 |
} |
| 373 |
} |
| 329 |
} |
374 |
} |
| 330 |
} |
375 |
} |
| 331 |
} |
376 |
} |
| 332 |
else |
377 |
else |
| 333 |
{ |
378 |
{ |
| 334 |
// Non-HT selection |
379 |
// Non-HT selection |
| 335 |
nss = 1; |
380 |
selectedNss = 1; |
| 336 |
for (uint32_t i = 0; i < GetNSupported (station); i++) |
381 |
for (uint32_t i = 0; i < GetNSupported (station); i++) |
| 337 |
{ |
382 |
{ |
| 338 |
mode = GetSupported (station, i); |
383 |
mode = GetSupported (station, i); |
| 339 |
txVector.SetMode (mode); |
384 |
txVector.SetMode (mode); |
| 340 |
txVector.SetNss (nss); |
385 |
txVector.SetNss (selectedNss); |
| 341 |
txVector.SetChannelWidth (GetChannelWidthForMode (mode)); |
386 |
txVector.SetChannelWidth (GetChannelWidthForMode (mode)); |
| 342 |
double threshold = GetSnrThreshold (txVector); |
387 |
double threshold = GetSnrThreshold (txVector); |
| 343 |
NS_LOG_DEBUG ("mode = " << mode.GetUniqueName () << |
388 |
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); |
403 |
NS_LOG_DEBUG ("Updating cached values for station to " << maxMode.GetUniqueName () << " snr " << station->m_lastSnrObserved); |
| 359 |
station->m_lastSnrCached = station->m_lastSnrObserved; |
404 |
station->m_lastSnrCached = station->m_lastSnrObserved; |
| 360 |
station->m_lastMode = maxMode; |
405 |
station->m_lastMode = maxMode; |
| 361 |
station->m_nss = nss; |
406 |
station->m_nss = selectedNss; |
| 362 |
} |
407 |
} |
| 363 |
uint8_t channelWidth = GetChannelWidth (station); |
408 |
uint8_t channelWidth = GetChannelWidth (station); |
| 364 |
NS_LOG_DEBUG ("Found maxMode: " << maxMode << " channelWidth: " << (uint16_t) channelWidth); |
409 |
NS_LOG_DEBUG ("Found maxMode: " << maxMode << " channelWidth: " << (uint16_t) channelWidth); |
| 365 |
if (m_currentRate != maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, nss)) |
410 |
if (m_currentRate != maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, selectedNss)) |
| 366 |
{ |
411 |
{ |
| 367 |
NS_LOG_DEBUG ("New datarate: " << maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, nss)); |
412 |
NS_LOG_DEBUG ("New datarate: " << maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, selectedNss)); |
| 368 |
m_currentRate = maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, nss); |
413 |
m_currentRate = maxMode.GetDataRate (channelWidth, GetPhy ()->GetShortGuardInterval () ? 400 : 800, selectedNss); |
| 369 |
} |
414 |
} |
| 370 |
return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetPreambleForTransmission (maxMode, GetAddress (station)), 800, GetNumberOfAntennas (), nss, 0, channelWidth, GetAggregation (station), false); |
415 |
return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetPreambleForTransmission (maxMode, GetAddress (station)), 800, GetNumberOfAntennas (), selectedNss, 0, channelWidth, GetAggregation (station), false); |
| 371 |
} |
416 |
} |
| 372 |
|
417 |
|
| 373 |
WifiTxVector |
418 |
WifiTxVector |