From 727045ef8ed516e30e5a600efa3b6079b851d3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Tue, 8 Jul 2025 21:23:12 +0200 Subject: [PATCH] wifi: Add some sanity checks to detect use of undefined RUs --- src/wifi/model/eht/eht-ru.cc | 3 +++ src/wifi/model/he/he-phy.cc | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/wifi/model/eht/eht-ru.cc b/src/wifi/model/eht/eht-ru.cc index 4b74764b0..07b529020 100644 --- a/src/wifi/model/eht/eht-ru.cc +++ b/src/wifi/model/eht/eht-ru.cc @@ -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); } diff --git a/src/wifi/model/he/he-phy.cc b/src/wifi/model/he/he-phy.cc index b05b52afd..0006fa24c 100644 --- a/src/wifi/model/he/he-phy.cc +++ b/src/wifi/model/he/he-phy.cc @@ -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(