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