|
|
| 1127 |
NS_LOG_FUNCTION (this << address << reqMode); |
1127 |
NS_LOG_FUNCTION (this << address << reqMode); |
| 1128 |
WifiMode mode = GetDefaultMode (); |
1128 |
WifiMode mode = GetDefaultMode (); |
| 1129 |
bool found = false; |
1129 |
bool found = false; |
| 1130 |
uint8_t nss = 1; // Use one spatial stream for control response |
|
|
| 1131 |
//First, search the BSS Basic Rate set |
1130 |
//First, search the BSS Basic Rate set |
| 1132 |
for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++) |
1131 |
for (WifiModeListIterator i = m_bssBasicRateSet.begin (); i != m_bssBasicRateSet.end (); i++) |
| 1133 |
{ |
1132 |
{ |
| 1134 |
if ((!found || i->GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss) > mode.GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss)) |
1133 |
bool isOfdm = true; |
| 1135 |
&& (i->GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss) <= reqMode.GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss)) |
1134 |
if (reqMode.GetModulationClass () == WIFI_MOD_CLASS_DSSS || reqMode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS |
| 1136 |
&& (i->GetConstellationSize (nss) <= reqMode.GetConstellationSize (nss)) |
1135 |
|| i->GetModulationClass () == WIFI_MOD_CLASS_DSSS || i->GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS |
| 1137 |
&& ((i->GetModulationClass () == reqMode.GetModulationClass ()) |
1136 |
|| mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS || mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS) |
|
|
1137 |
{ |
| 1138 |
isOfdm = false; |
| 1139 |
} |
| 1140 |
if ((!found |
| 1141 |
|| (isOfdm && (i->IsHigherCodeRate (mode) || (mode.GetConstellationSize () < i->GetConstellationSize ()))) |
| 1142 |
|| (!isOfdm && ((mode.GetConstellationSize () < i->GetConstellationSize ()) |
| 1143 |
|| (mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && i->GetModulationClass () == WIFI_MOD_CLASS_DSSS) |
| 1144 |
|| (mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS && i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM) |
| 1145 |
|| (mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM) |
| 1146 |
|| (mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS && i->GetModulationClass () == WIFI_MOD_CLASS_HT) |
| 1147 |
|| (mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && i->GetModulationClass () == WIFI_MOD_CLASS_HT)))) |
| 1148 |
&& ((isOfdm && !i->IsHigherCodeRate (reqMode) && (i->GetConstellationSize () <= reqMode.GetConstellationSize ())) |
| 1149 |
|| (!isOfdm && (i->GetConstellationSize () <= reqMode.GetConstellationSize ()))) |
| 1150 |
&& ((!isOfdm && ((i->GetModulationClass () == WIFI_MOD_CLASS_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_DSSS) |
| 1151 |
|| (i->GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS) |
| 1152 |
|| (i->GetModulationClass () == WIFI_MOD_CLASS_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS) |
| 1153 |
|| (i->GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_DSSS) |
| 1154 |
|| (i->GetModulationClass () == WIFI_MOD_CLASS_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM) |
| 1155 |
|| (i->GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM) |
| 1156 |
|| (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM && reqMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM) |
| 1157 |
|| (i->GetModulationClass () == WIFI_MOD_CLASS_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
| 1158 |
|| (i->GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
| 1159 |
|| (i->GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM && reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT))) |
| 1160 |
|| (isOfdm && ((i->GetModulationClass () == reqMode.GetModulationClass ()) |
| 1138 |
|| (reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
1161 |
|| (reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
| 1139 |
|| (reqMode.GetModulationClass () == WIFI_MOD_CLASS_VHT))) |
1162 |
|| (reqMode.GetModulationClass () == WIFI_MOD_CLASS_VHT))))) |
| 1140 |
|
|
|
| 1141 |
{ |
1163 |
{ |
| 1142 |
mode = *i; |
1164 |
mode = *i; |
| 1143 |
//We've found a potentially-suitable transmit rate, but we |
1165 |
//We've found a potentially-suitable transmit rate, but we |
|
|
| 1146 |
found = true; |
1168 |
found = true; |
| 1147 |
} |
1169 |
} |
| 1148 |
} |
1170 |
} |
| 1149 |
nss = 1; // Continue the assumption that MIMO not used for control response |
|
|
| 1150 |
if (HasHtSupported () || HasVhtSupported ()) |
1171 |
if (HasHtSupported () || HasVhtSupported ()) |
| 1151 |
{ |
1172 |
{ |
| 1152 |
if (!found) |
1173 |
if (!found) |
|
|
| 1154 |
mode = GetDefaultMcs (); |
1175 |
mode = GetDefaultMcs (); |
| 1155 |
for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++) |
1176 |
for (WifiModeListIterator i = m_bssBasicMcsSet.begin (); i != m_bssBasicMcsSet.end (); i++) |
| 1156 |
{ |
1177 |
{ |
| 1157 |
if ((!found || i->GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss) > mode.GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss)) |
1178 |
if ((!found || i->IsHigherCodeRate(mode)) |
| 1158 |
&& i->GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss) <= reqMode.GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss)) |
1179 |
&& !i->IsHigherCodeRate(reqMode)) |
| 1159 |
//&& thismode.GetModulationClass () == reqMode.GetModulationClass ()) //TODO: check standard |
1180 |
//&& thismode.GetModulationClass () == reqMode.GetModulationClass ()) //TODO: check standard |
| 1160 |
{ |
1181 |
{ |
| 1161 |
mode = *i; |
1182 |
mode = *i; |
|
|
| 1192 |
* \todo Note that we're ignoring the last sentence for now, because |
1213 |
* \todo Note that we're ignoring the last sentence for now, because |
| 1193 |
* there is not yet any manipulation here of PHY options. |
1214 |
* there is not yet any manipulation here of PHY options. |
| 1194 |
*/ |
1215 |
*/ |
| 1195 |
nss = 1; // Continue the assumption that MIMO not used for control response |
|
|
| 1196 |
for (uint32_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++) |
1216 |
for (uint32_t idx = 0; idx < m_wifiPhy->GetNModes (); idx++) |
| 1197 |
{ |
1217 |
{ |
| 1198 |
WifiMode thismode = m_wifiPhy->GetMode (idx); |
1218 |
WifiMode thismode = m_wifiPhy->GetMode (idx); |
| 1199 |
|
1219 |
bool isOfdm = true; |
|
|
1220 |
if (reqMode.GetModulationClass () == WIFI_MOD_CLASS_DSSS || reqMode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS |
| 1221 |
|| thismode.GetModulationClass () == WIFI_MOD_CLASS_DSSS || thismode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS |
| 1222 |
|| mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS || mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS) |
| 1223 |
{ |
| 1224 |
isOfdm = false; |
| 1225 |
} |
| 1200 |
/* If the rate: |
1226 |
/* If the rate: |
| 1201 |
* |
1227 |
* |
| 1202 |
* - is a mandatory rate for the PHY, and |
1228 |
* - is a mandatory rate for the PHY, and |
|
|
| 1207 |
* ...then it's our best choice so far. |
1233 |
* ...then it's our best choice so far. |
| 1208 |
*/ |
1234 |
*/ |
| 1209 |
if (thismode.IsMandatory () |
1235 |
if (thismode.IsMandatory () |
| 1210 |
&& (!found || thismode.GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss) > mode.GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss)) |
1236 |
&& (!found |
| 1211 |
&& (thismode.GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss) <= reqMode.GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss)) |
1237 |
|| (isOfdm && (thismode.IsHigherCodeRate (mode) || (mode.GetConstellationSize () < thismode.GetConstellationSize ()))) |
| 1212 |
&& (thismode.GetConstellationSize (nss) <= reqMode.GetConstellationSize (nss)) |
1238 |
|| (!isOfdm && ((mode.GetConstellationSize () < thismode.GetConstellationSize ()) |
| 1213 |
&& ((thismode.GetModulationClass () == reqMode.GetModulationClass ()) |
1239 |
|| (mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && thismode.GetModulationClass () == WIFI_MOD_CLASS_DSSS) |
| 1214 |
|| (reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
1240 |
|| (mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS && thismode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM) |
| 1215 |
|| (reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT))) |
1241 |
|| (mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && thismode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM) |
| 1216 |
|
1242 |
|| (mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS && thismode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
|
|
1243 |
|| (mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && thismode.GetModulationClass () == WIFI_MOD_CLASS_HT)))) |
| 1244 |
&& ((isOfdm && !thismode.IsHigherCodeRate (reqMode) && (thismode.GetConstellationSize () <= reqMode.GetConstellationSize ())) |
| 1245 |
|| (!isOfdm && (thismode.GetConstellationSize () <= reqMode.GetConstellationSize ()))) |
| 1246 |
&& ((!isOfdm && ((thismode.GetModulationClass () == WIFI_MOD_CLASS_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_DSSS) |
| 1247 |
|| (thismode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS) |
| 1248 |
|| (thismode.GetModulationClass () == WIFI_MOD_CLASS_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS) |
| 1249 |
|| (thismode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_DSSS) |
| 1250 |
|| (thismode.GetModulationClass () == WIFI_MOD_CLASS_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM) |
| 1251 |
|| (thismode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM) |
| 1252 |
|| (thismode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM && reqMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM) |
| 1253 |
|| (thismode.GetModulationClass () == WIFI_MOD_CLASS_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
| 1254 |
|| (thismode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS && reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
| 1255 |
|| (thismode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM && reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT))) |
| 1256 |
|| (isOfdm && ((thismode.GetModulationClass () == reqMode.GetModulationClass ()) |
| 1257 |
|| (reqMode.GetModulationClass () == WIFI_MOD_CLASS_HT) |
| 1258 |
|| (reqMode.GetModulationClass () == WIFI_MOD_CLASS_VHT))))) |
| 1217 |
{ |
1259 |
{ |
| 1218 |
mode = thismode; |
1260 |
mode = thismode; |
| 1219 |
//As above; we've found a potentially-suitable transmit |
1261 |
//As above; we've found a potentially-suitable transmit |
|
|
| 1222 |
found = true; |
1264 |
found = true; |
| 1223 |
} |
1265 |
} |
| 1224 |
} |
1266 |
} |
| 1225 |
nss = 1; // Continue the assumption that MIMO not used for control response |
|
|
| 1226 |
if (HasHtSupported () || HasVhtSupported ()) |
1267 |
if (HasHtSupported () || HasVhtSupported ()) |
| 1227 |
{ |
1268 |
{ |
| 1228 |
for (uint32_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++) |
1269 |
for (uint32_t idx = 0; idx < m_wifiPhy->GetNMcs (); idx++) |
| 1229 |
{ |
1270 |
{ |
| 1230 |
WifiMode thismode = m_wifiPhy->GetMcs (idx); |
1271 |
WifiMode thismode = m_wifiPhy->GetMcs (idx); |
| 1231 |
if (thismode.IsMandatory () |
1272 |
if (thismode.IsMandatory () |
| 1232 |
&& (!found || thismode.GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss) > mode.GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss)) |
1273 |
&& (!found || !mode.IsHigherCodeRate(thismode)) |
| 1233 |
&& thismode.GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss) <= reqMode.GetPhyRate (m_wifiPhy->GetChannelWidth (), 0, nss)) |
1274 |
&& !reqMode.IsHigherCodeRate(thismode)) |
| 1234 |
//&& thismode.GetModulationClass () == reqMode.GetModulationClass ()) //TODO: check standard |
1275 |
//&& thismode.GetModulationClass () == reqMode.GetModulationClass ()) //TODO: check standard |
| 1235 |
{ |
1276 |
{ |
| 1236 |
mode = thismode; |
1277 |
mode = thismode; |