diff --git a/src/wifi/model/wifi-tx-vector.cc b/src/wifi/model/wifi-tx-vector.cc index ab2df79c4..7b1409d01 100644 --- a/src/wifi/model/wifi-tx-vector.cc +++ b/src/wifi/model/wifi-tx-vector.cc @@ -22,6 +22,8 @@ #include "wifi-tx-vector.h" #include "wifi-phy-common.h" #include "ns3/abort.h" +#include +#include namespace ns3 { @@ -67,7 +69,8 @@ WifiTxVector::WifiTxVector (WifiMode mode, m_ldpc (ldpc), m_bssColor (bssColor), m_length (length), - m_modeInitialized (true) + m_modeInitialized (true), + m_inactiveSubchannels () { } @@ -85,7 +88,8 @@ WifiTxVector::WifiTxVector (const WifiTxVector& txVector) m_ldpc (txVector.m_ldpc), m_bssColor (txVector.m_bssColor), m_length (txVector.m_length), - m_modeInitialized (txVector.m_modeInitialized) + m_modeInitialized (txVector.m_modeInitialized), + m_inactiveSubchannels (txVector.m_inactiveSubchannels) { m_muUserInfos.clear (); if (!txVector.m_muUserInfos.empty ()) //avoids crashing for loop @@ -498,6 +502,24 @@ WifiTxVector::GetNumRusPerHeSigBContentChannel (void) const return std::make_pair (numRusContentChannel1, numRusContentChannel2); } +void +WifiTxVector::SetInactiveSubchannels (const std::vector& inactiveSubchannels) +{ + NS_ABORT_MSG_IF (m_preamble < WIFI_PREAMBLE_HE_SU, + "Only HE (or later) authorized for preamble puncturing"); + NS_ABORT_MSG_IF (m_channelWidth < 80, + "Preamble puncturing only possible for transmission bandwidth of 80 MHz or larger"); + NS_ABORT_MSG_IF (inactiveSubchannels.size () != (m_channelWidth / 20), + "The size of the inactive subchannnels bitmap should be equal to the number of 20 MHz subchannels"); + m_inactiveSubchannels = inactiveSubchannels; +} + +const std::vector& +WifiTxVector::GetInactiveSubchannels (void) const +{ + return m_inactiveSubchannels; +} + std::ostream & operator << ( std::ostream &os, const WifiTxVector &v) { if (!v.IsValid ()) @@ -539,6 +561,13 @@ std::ostream & operator << ( std::ostream &os, const WifiTxVector &v) os << " mode: " << v.GetMode () << " Nss: " << +v.GetNss (); } + const auto& puncturedSubchannels = v.GetInactiveSubchannels (); + if (!puncturedSubchannels.empty ()) + { + os << " Punctured subchannels: "; + std::copy (puncturedSubchannels.cbegin (), puncturedSubchannels.cend(), + std::ostream_iterator(os, ", ")); + } return os; } diff --git a/src/wifi/model/wifi-tx-vector.h b/src/wifi/model/wifi-tx-vector.h index e35c0e143..9015cc8e6 100644 --- a/src/wifi/model/wifi-tx-vector.h +++ b/src/wifi/model/wifi-tx-vector.h @@ -23,6 +23,7 @@ #define WIFI_TX_VECTOR_H #include +#include #include "wifi-mode.h" #include "wifi-phy-common.h" #include "ns3/he-ru.h" @@ -388,6 +389,22 @@ public: */ std::pair GetNumRusPerHeSigBContentChannel (void) const; + /** + * Set the 20 MHz subchannels that are punctured. + * + * \param inactiveSubchannels the bitmap indexed by the 20 MHz subchannels in ascending order, + * where each bit indicates whether the corresponding 20 MHz subchannel is punctured or not + * within the transmission bandwidth + */ + void SetInactiveSubchannels (const std::vector& inactiveSubchannels); + /** + * Get the 20 MHz subchannels that are punctured. + * + * \return the bitmap indexed by the 20 MHz subchannels in ascending order, + * where each bit indicates whether the corresponding 20 MHz subchannel is punctured or not + * within the transmission bandwidth + */ + const std::vector& GetInactiveSubchannels (void) const; private: WifiMode m_mode; /**< The DATARATE parameter in Table 15-4. @@ -415,6 +432,7 @@ private: indexed by station ID (STA-ID) corresponding to the 11 LSBs of the AID of the recipient STA This list shall be used only for HE MU */ + std::vector m_inactiveSubchannels;/**< Bitmap of inactive subchannels used for preamble puncturing */ }; /**