wifi: Add some sanity checks to detect use of undefined RUs

This commit is contained in:
Sébastien Deronne
2025-07-08 21:23:12 +02:00
parent 2b0526ec9d
commit 727045ef8e
2 changed files with 5 additions and 0 deletions

View File

@@ -1064,6 +1064,9 @@ EhtRu::GetSubcarrierGroup(MHz_u bw, RuType ruType, std::size_t phyIndex)
{
const auto it = m_ruSubcarrierGroups.find({bw, ruType});
NS_ABORT_MSG_IF(it == m_ruSubcarrierGroups.cend(), "RU not found");
NS_ABORT_MSG_IF(phyIndex == 0 || phyIndex > it->second.size(),
"Invalid PHY index " << phyIndex << " for RU type " << ruType
<< " and bandwidth " << bw);
return it->second.at(phyIndex - 1);
}

View File

@@ -992,6 +992,7 @@ HePhy::GetRuBandForTx(const WifiTxVector& txVector, uint16_t staId) const
channelWidth,
m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(MHz_u{20})),
mc);
NS_ABORT_MSG_IF(group.empty(), "No subcarrier group found");
// for a TX spectrum, the guard bandwidth is a function of the transmission channel width
// and the spectrum width equals the transmission channel width (hence bandIndex equals 0)
const auto indices = ConvertRuSubcarriers({channelWidth,
@@ -1027,6 +1028,7 @@ HePhy::GetRuBandForRx(const WifiTxVector& txVector, uint16_t staId) const
channelWidth,
m_wifiPhy->GetOperatingChannel().GetPrimaryChannelIndex(MHz_u{20})),
mc);
NS_ABORT_MSG_IF(group.empty(), "No subcarrier group found");
// for an RX spectrum, the guard bandwidth is a function of the operating channel width
// and the spectrum width equals the operating channel width
const auto indices = ConvertRuSubcarriers(