From b1b9ff1ecc802f3884c1479b55b3bd09cdd84fe1 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Sun, 3 Dec 2023 18:32:06 +0100 Subject: [PATCH] wifi: Check if band is appropriate for (ERP-)OFDM modulation class --- src/wifi/model/wifi-phy.cc | 2 +- src/wifi/model/wifi-tx-vector.cc | 12 +++++++++++- src/wifi/model/wifi-tx-vector.h | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/wifi/model/wifi-phy.cc b/src/wifi/model/wifi-phy.cc index abf8138da..e1bf7f17b 100644 --- a/src/wifi/model/wifi-phy.cc +++ b/src/wifi/model/wifi-phy.cc @@ -1736,7 +1736,7 @@ WifiPhy::Send(WifiConstPsduMap psdus, const WifiTxVector& txVector) NS_ASSERT(!m_state->IsStateTx() && !m_state->IsStateSwitching()); NS_ASSERT(m_endTxEvent.IsExpired()); - if (!txVector.IsValid()) + if (!txVector.IsValid(m_band)) { NS_FATAL_ERROR("TX-VECTOR is invalid!"); } diff --git a/src/wifi/model/wifi-tx-vector.cc b/src/wifi/model/wifi-tx-vector.cc index b21be482d..25bca7b6a 100644 --- a/src/wifi/model/wifi-tx-vector.cc +++ b/src/wifi/model/wifi-tx-vector.cc @@ -446,7 +446,7 @@ WifiTxVector::GetEhtPpduType() const } bool -WifiTxVector::IsValid() const +WifiTxVector::IsValid(WifiPhyBand band) const { if (!GetModeInitialized()) { @@ -517,6 +517,16 @@ WifiTxVector::IsValid() const return false; } } + + if (band != WIFI_PHY_BAND_UNSPECIFIED) + { + NS_ABORT_MSG_IF(GetModulationClass() == WIFI_MOD_CLASS_OFDM && band == WIFI_PHY_BAND_2_4GHZ, + "Cannot use OFDM modulation class in the 2.4 GHz band"); + NS_ABORT_MSG_IF(GetModulationClass() == WIFI_MOD_CLASS_ERP_OFDM && + band != WIFI_PHY_BAND_2_4GHZ, + "ERP-OFDM modulation class can only be used in the 2.4 GHz band"); + } + return true; } diff --git a/src/wifi/model/wifi-tx-vector.h b/src/wifi/model/wifi-tx-vector.h index 1d24eeb0f..f9ec4d982 100644 --- a/src/wifi/model/wifi-tx-vector.h +++ b/src/wifi/model/wifi-tx-vector.h @@ -22,6 +22,7 @@ #define WIFI_TX_VECTOR_H #include "wifi-mode.h" +#include "wifi-phy-band.h" #include "wifi-phy-common.h" #include "ns3/he-ru.h" @@ -356,10 +357,13 @@ class WifiTxVector * The standard disallows certain combinations of WifiMode, number of * spatial streams, and channel widths. This method can be used to * check whether this WifiTxVector contains an invalid combination. + * If a PHY band is specified, it is checked that the PHY band is appropriate for + * the modulation class of the TXVECTOR, in case the latter is OFDM or ERP-OFDM. * + * \param band the PHY band * \return true if the WifiTxVector parameters are allowed by the standard */ - bool IsValid() const; + bool IsValid(WifiPhyBand band = WIFI_PHY_BAND_UNSPECIFIED) const; /** * \return true if this TX vector is used for a multi-user (OFDMA and/or MU-MIMO) transmission */