diff --git a/src/wifi/model/phy-entity.cc b/src/wifi/model/phy-entity.cc index 3affeba8e..9fb01a89d 100644 --- a/src/wifi/model/phy-entity.cc +++ b/src/wifi/model/phy-entity.cc @@ -1042,6 +1042,13 @@ PhyEntity::GetPrimaryBand (uint16_t bandWidth) const return m_wifiPhy->GetBand (bandWidth, m_wifiPhy->m_operatingChannel.GetPrimaryChannelIndex (bandWidth)); } +WifiSpectrumBand +PhyEntity::GetSecondaryBand (uint16_t bandWidth) const +{ + NS_ASSERT (m_wifiPhy->GetChannelWidth () >= 40); + return m_wifiPhy->GetBand (bandWidth, m_wifiPhy->m_operatingChannel.GetSecondaryChannelIndex (bandWidth)); +} + uint16_t PhyEntity::GetRxChannelWidth (const WifiTxVector& txVector) const { diff --git a/src/wifi/model/phy-entity.h b/src/wifi/model/phy-entity.h index fccecf408..b94484a4e 100644 --- a/src/wifi/model/phy-entity.h +++ b/src/wifi/model/phy-entity.h @@ -805,6 +805,16 @@ protected: * \return a pair of start and stop indexes that defines the band */ WifiSpectrumBand GetPrimaryBand (uint16_t bandWidth) const; + /** + * If the channel bonding is used, return the start band index and the stop band index + * for the secondary channel of the given bandwidth (which must be a multiple of 20 MHz + * and not exceed the operating channel width). + * + * \param bandWidth the width of the band to be returned (MHz) + * + * \return a pair of start and stop indexes that defines the band + */ + WifiSpectrumBand GetSecondaryBand (uint16_t bandWidth) const; /** * Return the channel width used to measure the RSSI. diff --git a/src/wifi/model/wifi-phy-operating-channel.cc b/src/wifi/model/wifi-phy-operating-channel.cc index d930846ee..65bf6eb43 100644 --- a/src/wifi/model/wifi-phy-operating-channel.cc +++ b/src/wifi/model/wifi-phy-operating-channel.cc @@ -437,10 +437,20 @@ WifiPhyOperatingChannel::GetPrimaryChannelIndex (uint16_t primaryChannelWidth) c index /= 2; width *= 2; } - NS_LOG_LOGIC ("Return " << +index); + NS_LOG_LOGIC ("Return primary index " << +index); return index; } +uint8_t +WifiPhyOperatingChannel::GetSecondaryChannelIndex (uint16_t secondaryChannelWidth) const +{ + NS_LOG_FUNCTION (this << secondaryChannelWidth); + const uint8_t primaryIndex = GetPrimaryChannelIndex (secondaryChannelWidth); + const uint8_t secondaryIndex = (primaryIndex % 2 == 0) ? (primaryIndex + 1) : (primaryIndex - 1); + NS_LOG_LOGIC ("Return secondary index " << +secondaryIndex); + return secondaryIndex; +} + void WifiPhyOperatingChannel::SetPrimary20Index (uint8_t index) { diff --git a/src/wifi/model/wifi-phy-operating-channel.h b/src/wifi/model/wifi-phy-operating-channel.h index 108ac033c..728140999 100644 --- a/src/wifi/model/wifi-phy-operating-channel.h +++ b/src/wifi/model/wifi-phy-operating-channel.h @@ -141,6 +141,17 @@ public: * \return the index of the requested primary channel within the operating channel */ uint8_t GetPrimaryChannelIndex (uint16_t primaryChannelWidth) const; + + /** + * If the operating channel width is made of a multiple of 20 MHz, return the index of the + * secondary channel of the given width within the operating channel (0 indicates + * the 20 MHz subchannel with the lowest center frequency). Otherwise, return 0. + * + * \param secondaryChannelWidth the width of the secondary channel in MHz + * \return the index of the requested secondary channel within the operating channel + */ + uint8_t GetSecondaryChannelIndex (uint16_t secondaryChannelWidth) const; + /** * Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel * with the lowest center frequency).