From 2873f8877ffb016ecc2b73c33ca4e03c5aa0f121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Wed, 14 Jun 2023 20:46:05 +0200 Subject: [PATCH] wifi: Extend WifiPhyOperatingChannel to retrieve the center frequency, the channel number and the width in MHz of a given segment --- src/wifi/model/wifi-phy-operating-channel.cc | 15 ++++++---- src/wifi/model/wifi-phy-operating-channel.h | 30 ++++++++++++++------ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/wifi/model/wifi-phy-operating-channel.cc b/src/wifi/model/wifi-phy-operating-channel.cc index f564b590a..2d2d6b353 100644 --- a/src/wifi/model/wifi-phy-operating-channel.cc +++ b/src/wifi/model/wifi-phy-operating-channel.cc @@ -409,23 +409,27 @@ WifiPhyOperatingChannel::FindFirst(uint8_t number, } uint8_t -WifiPhyOperatingChannel::GetNumber() const +WifiPhyOperatingChannel::GetNumber(std::size_t segment /* = 0 */) const { NS_ASSERT(IsSet()); - return m_channelIts.front()->number; + NS_ASSERT_MSG(segment == 0, "non-contiguous operating channel is not supported yet"); + return m_channelIts.at(segment)->number; } uint16_t -WifiPhyOperatingChannel::GetFrequency() const +WifiPhyOperatingChannel::GetFrequency(std::size_t segment /* = 0 */) const { NS_ASSERT(IsSet()); - return m_channelIts.front()->frequency; + NS_ASSERT_MSG(segment == 0, "non-contiguous operating channel is not supported yet"); + return m_channelIts.at(segment)->frequency; } ChannelWidthMhz -WifiPhyOperatingChannel::GetWidth() const +WifiPhyOperatingChannel::GetWidth(std::size_t segment /* = 0 */) const { NS_ASSERT(IsSet()); + NS_ASSERT_MSG(segment == 0, "non-contiguous operating channel is not supported yet"); + // Current specs only allow all segments to be the same width return m_channelIts.front()->width; } @@ -433,6 +437,7 @@ WifiPhyBand WifiPhyOperatingChannel::GetPhyBand() const { NS_ASSERT(IsSet()); + // Current specs only allow all segments to be the same band return m_channelIts.front()->band; } diff --git a/src/wifi/model/wifi-phy-operating-channel.h b/src/wifi/model/wifi-phy-operating-channel.h index 173d81132..aafe5593d 100644 --- a/src/wifi/model/wifi-phy-operating-channel.h +++ b/src/wifi/model/wifi-phy-operating-channel.h @@ -170,23 +170,35 @@ class WifiPhyOperatingChannel WifiPhyBand band); /** - * Return the channel number identifying the whole operating channel. + * Return the channel number for a given frequency segment. + * Segments are ordered by increasing frequencies, hence by default + * it returns the channel number of the segment occuping the lowest + * frequencies when a non-contiguous operating channel is used. * - * \return the channel number identifying the whole operating channel + * \param segment the index of the frequency segment (if operating channel is non-contiguous) + * \return the channel number for a given frequency segment */ - uint8_t GetNumber() const; + uint8_t GetNumber(std::size_t segment = 0) const; /** - * Return the center frequency of the operating channel (in MHz). + * Return the center frequency for a given frequency segment (in MHz). + * Segments are ordered by increasing frequencies, hence by default + * it returns the center frequency of the segment occuping the lowest + * frequencies when a non-contiguous operating channel is used. * - * \return the center frequency of the operating channel (in MHz) + * \param segment the index of the frequency segment (if operating channel is non-contiguous) + * \return the center frequency for a given frequency segment (in MHz) */ - uint16_t GetFrequency() const; + uint16_t GetFrequency(std::size_t segment = 0) const; /** - * Return the width of the whole operating channel (in MHz). + * Return the channel width for a given frequency segment (in MHz). + * Segments are ordered by increasing frequencies, hence by default + * it returns the channel width of the segment occuping the lowest + * frequencies when a non-contiguous operating channel is used. * - * \return the width of the whole operating channel (in MHz) + * \param segment the index of the frequency segment (if operating channel is non-contiguous) + * \return the channel width for a given frequency segment (in MHz) */ - ChannelWidthMhz GetWidth() const; + ChannelWidthMhz GetWidth(std::size_t segment = 0) const; /** * Return the width type of the operating channel. *