wifi: Add functions to retrieve the segment that contains the primary or secondary channel
This commit is contained in:
@@ -553,6 +553,34 @@ WifiPhyOperatingChannel::SetPrimary20Index(uint8_t index)
|
||||
m_primary20Index = index;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
WifiPhyOperatingChannel::GetPrimarySegmentIndex(ChannelWidthMhz primaryChannelWidth) const
|
||||
{
|
||||
if (m_channelIts.size() < 2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// Note: this function assumes no more than 2 segments are used
|
||||
const auto numIndices = GetTotalWidth() / primaryChannelWidth;
|
||||
const auto primaryIndex = GetPrimaryChannelIndex(primaryChannelWidth);
|
||||
return (primaryIndex >= (numIndices / 2)) ? 1 : 0;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
WifiPhyOperatingChannel::GetSecondarySegmentIndex(ChannelWidthMhz primaryChannelWidth) const
|
||||
{
|
||||
NS_ABORT_MSG_IF(primaryChannelWidth > GetWidth(),
|
||||
"Primary channel width cannot be larger than the width of a frequency segment");
|
||||
if (m_channelIts.size() < 2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
// Note: this function assumes no more than 2 segments are used
|
||||
const auto numIndices = GetTotalWidth() / primaryChannelWidth;
|
||||
const auto secondaryIndex = GetSecondaryChannelIndex(primaryChannelWidth);
|
||||
return (secondaryIndex >= (numIndices / 2)) ? 1 : 0;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
WifiPhyOperatingChannel::GetPrimaryChannelCenterFrequency(ChannelWidthMhz primaryChannelWidth) const
|
||||
{
|
||||
|
||||
@@ -356,6 +356,22 @@ class WifiPhyOperatingChannel
|
||||
*/
|
||||
std::set<uint8_t> Get20MHzIndicesCoveringRu(HeRu::RuSpec ru, ChannelWidthMhz width) const;
|
||||
|
||||
/**
|
||||
* Get the index of the segment that contains a given primary channel (in MHz).
|
||||
*
|
||||
* \param primaryChannelWidth the width of the primary channel in MHz
|
||||
* \return the index of the segment that contains the primary channel
|
||||
*/
|
||||
uint8_t GetPrimarySegmentIndex(ChannelWidthMhz primaryChannelWidth) const;
|
||||
|
||||
/**
|
||||
* Get the index of the segment that contains a given secondary channel (in MHz).
|
||||
*
|
||||
* \param secondaryChannelWidth the width of the secondary channel in MHz
|
||||
* \return the index of the segment that contains the secondary channel
|
||||
*/
|
||||
uint8_t GetSecondarySegmentIndex(ChannelWidthMhz secondaryChannelWidth) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Sort the segments by increasing frequencies.
|
||||
|
||||
Reference in New Issue
Block a user