25#include "ns3/assert.h"
301 NS_LOG_FUNCTION(
this << +number << frequency << width << standard << band);
303 auto channelIt =
FindFirst(number, frequency, width, standard, band);
306 FindFirst(number, frequency, width, standard, band, std::next(channelIt)) ==
316 throw std::runtime_error(
317 "WifiPhyOperatingChannel: No unique channel found given the specified criteria");
333 auto channelIt =
FindFirst(0, 0, width, standard, band);
338 return std::get<0>(*channelIt);
342 throw std::runtime_error(
"WifiPhyOperatingChannel: No default channel found of the given width "
343 "and for the given PHY standard and band");
356 if (number != 0 && std::get<0>(channel) != number)
360 if (frequency != 0 && std::get<1>(channel) != frequency)
364 if (width != 0 && std::get<2>(channel) != width)
373 if (std::get<4>(channel) != band)
385 (std::find(standardIt->second.cbegin(), standardIt->second.cend(), band) ==
386 standardIt->second.cend() ||
449 if (primaryChannelWidth % 20 != 0)
451 NS_LOG_DEBUG(
"The operating channel width is not a multiple of 20 MHz; return 0");
462 while (width < primaryChannelWidth)
476 const uint8_t secondaryIndex =
477 (primaryIndex % 2 == 0) ? (primaryIndex + 1) : (primaryIndex - 1);
478 NS_LOG_LOGIC(
"Return secondary index " << +secondaryIndex);
479 return secondaryIndex;
506 return (primaryIndex % 2 == 0) ? (primaryCenterFrequency + secondaryChannelWidth)
507 : (primaryCenterFrequency - secondaryChannelWidth);
516 auto& [chanNumber, centerFreq, channelWidth, channelType, band] = *
m_channelIt;
517 auto primaryChanIt =
FindFirst(0, frequency, primaryChannelWidth, standard, band);
519 return std::get<0>(*primaryChanIt);
531 uint16_t currWidth = 20;
532 std::set<uint8_t> indices;
535 while (currWidth < width)
552 const std::set<uint8_t>& primaryIndices)
const
554 if (primaryIndices.empty() ||
GetWidth() == 20)
560 uint16_t primaryWidth = 20;
563 while (size != primaryIndices.size())
576 std::set<uint8_t> secondaryIndices;
577 for (
const auto& index : primaryIndices)
579 secondaryIndices.insert(index ^ size);
582 return secondaryIndices;
591 "No RU of type " << ruType <<
" is contained in a " << width <<
" MHz channel");
593 "The given width (" << width <<
" MHz) exceeds the operational width ("
599 return {0, 1, 2, 3, 4, 5, 6, 7};
606 "26-tone RU with index 19 is only present in channels of at least 80 MHz");
611 indices.erase(indices.begin());
612 indices.erase(std::prev(indices.end()));
637 ruIndex += nRusIn80MHz;
641 uint8_t n20MHzChannels;
661 auto nRusInCoveringChannel =
HeRu::GetNRus(n20MHzChannels * 20, ruType);
663 std::size_t indexOfCoveringChannelInGivenWidth = (ruIndex - 1) / nRusInCoveringChannel;
667 NS_ASSERT(indexOfCoveringChannelInGivenWidth < 8);
668 std::set<uint8_t> indices({
static_cast<uint8_t
>(indexOfCoveringChannelInGivenWidth)});
670 while (n20MHzChannels > 1)
672 std::set<uint8_t> updatedIndices;
673 for (
const auto& idx : indices)
675 updatedIndices.insert(idx * 2);
676 updatedIndices.insert(idx * 2 + 1);
678 indices.swap(updatedIndices);
687 std::set<uint8_t> updatedIndices;
688 for (
const auto& idx : indices)
690 updatedIndices.insert(idx + offset);
692 indices.swap(updatedIndices);
707 return !(*
this == other);
715 os <<
"channel " << +channel.GetNumber() <<
" in band " << channel.GetPhyBand()
716 <<
" frequency " << channel.GetFrequency() <<
" width " << channel.GetWidth();
720 os <<
"channel not set";
std::size_t GetIndex() const
Get the RU index.
RuType GetRuType() const
Get the RU type.
bool GetPrimary80MHz() const
Get the primary 80 MHz flag.
static uint16_t GetBandwidth(RuType ruType)
Get the approximate bandwidth occupied by a RU.
static std::size_t GetNRus(uint16_t bw, RuType ruType)
Get the number of distinct RUs of the given type (number of tones) available in a HE PPDU of the give...
Class that keeps track of all information about the current PHY operating channel.
bool IsSet() const
Return true if a valid channel has been set, false otherwise.
bool operator==(const WifiPhyOperatingChannel &other) const
Check if the given WifiPhyOperatingChannel is equivalent.
WifiPhyOperatingChannel()
Create an uninitialized PHY operating channel.
static const std::set< FrequencyChannelInfo > m_frequencyChannels
Available frequency channels.
uint16_t GetSecondaryChannelCenterFrequency(uint16_t secondaryChannelWidth) const
Get the center frequency of the secondary channel of the given width.
bool operator!=(const WifiPhyOperatingChannel &other) const
Check if the given WifiPhyOperatingChannel is different.
bool IsDsss() const
Return whether the operating channel is a DSSS channel.
uint8_t GetPrimaryChannelIndex(uint16_t primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
ConstIterator m_channelIt
const iterator pointing to the configured frequency channel
static ConstIterator FindFirst(uint8_t number, uint16_t frequency, uint16_t width, WifiStandard standard, WifiPhyBand band, ConstIterator start=m_frequencyChannels.begin())
Find the first channel matching the specified parameters.
void Set(uint8_t number, uint16_t frequency, uint16_t width, WifiStandard standard, WifiPhyBand band)
Set the channel according to the specified parameters if a unique frequency channel matches the speci...
bool Is80211p() const
Return whether the operating channel is an 802.11p channel.
uint8_t GetPrimaryChannelNumber(uint16_t primaryChannelWidth, WifiStandard standard) const
Get channel number of the primary channel.
void SetDefault(uint16_t width, WifiStandard standard, WifiPhyBand band)
Set the default channel of the given width and for the given standard and band.
bool IsOfdm() const
Return whether the operating channel is an OFDM channel.
uint16_t GetWidth() const
Return the width of the whole operating channel (in MHz).
static uint8_t GetDefaultChannelNumber(uint16_t width, WifiStandard standard, WifiPhyBand band)
Get the default channel number of the given width and for the given standard and band.
std::set< uint8_t > GetAll20MHzChannelIndicesInSecondary(uint16_t width) const
Get the channel indices of all the 20 MHz channels included in the secondary channel of the given wid...
std::set< uint8_t > Get20MHzIndicesCoveringRu(HeRu::RuSpec ru, uint16_t width) const
Get the channel indices of the minimum subset of 20 MHz channels containing the given RU.
uint8_t GetSecondaryChannelIndex(uint16_t secondaryChannelWidth) const
If the operating channel width is made of a multiple of 20 MHz, return the index of the secondary cha...
uint8_t m_primary20Index
index of the primary20 channel (0 indicates the 20 MHz subchannel with the lowest center frequency)
std::set< uint8_t > GetAll20MHzChannelIndicesInPrimary(uint16_t width) const
Get the channel indices of all the 20 MHz channels included in the primary channel of the given width...
WifiPhyBand GetPhyBand() const
Return the PHY band of the operating channel.
uint8_t GetNumber() const
Return the channel number identifying the whole operating channel.
uint16_t GetPrimaryChannelCenterFrequency(uint16_t primaryChannelWidth) const
Get the center frequency of the primary channel of the given width.
virtual ~WifiPhyOperatingChannel()
std::set< FrequencyChannelInfo >::const_iterator ConstIterator
Typedef for a const iterator pointing to a channel in the set of available channels.
uint16_t GetFrequency() const
Return the center frequency of the operating channel (in MHz).
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiPhyBand
Identifies the PHY band.
@ WIFI_STANDARD_UNSPECIFIED
@ WIFI_PHY_80211p_CHANNEL
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::tuple< uint8_t, uint16_t, uint16_t, FrequencyChannelType, WifiPhyBand > FrequencyChannelInfo
A tuple (number, frequency, width, type, band) identifying a frequency channel.
const std::map< WifiStandard, std::list< WifiPhyBand > > wifiStandards
map a given standard configured by the user to the allowed PHY bands
uint16_t GetMaximumChannelWidth(WifiModulationClass modulation)
Get the maximum channel width in MHz allowed for the given modulation class.
std::ostream & operator<<(std::ostream &os, const Angles &a)
WifiModulationClass GetModulationClassForStandard(WifiStandard standard)
Return the modulation class corresponding to a given standard.
FrequencyChannelType GetFrequencyChannelType(WifiStandard standard)
Get the type of the frequency channel for the given standard.
Declaration of the following enums: