From d233286bb99d0f3e05899bc3ce4ebae91e88e2bc Mon Sep 17 00:00:00 2001 From: Sebastien Deronne Date: Sun, 15 May 2022 15:59:44 +0200 Subject: [PATCH] wifi: Add function to WifiPpdu to determine whether it overlaps with a given channel --- src/wifi/model/wifi-ppdu.cc | 19 ++++++++++++++----- src/wifi/model/wifi-ppdu.h | 9 +++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/wifi/model/wifi-ppdu.cc b/src/wifi/model/wifi-ppdu.cc index 516b1feaf..2cbc4a5ea 100644 --- a/src/wifi/model/wifi-ppdu.cc +++ b/src/wifi/model/wifi-ppdu.cc @@ -109,15 +109,25 @@ WifiPpdu::GetTransmissionChannelWidth (void) const } bool -WifiPpdu::CanBeReceived (uint16_t p20MinFreq, uint16_t p20MaxFreq) const +WifiPpdu::DoesOverlapChannel (uint16_t minFreq, uint16_t maxFreq) const { - NS_LOG_FUNCTION (this << m_txCenterFreq << p20MinFreq << p20MaxFreq); - + NS_LOG_FUNCTION (this << m_txCenterFreq << minFreq << maxFreq); uint16_t txChannelWidth = GetTxVector ().GetChannelWidth (); uint16_t minTxFreq = m_txCenterFreq - txChannelWidth / 2; uint16_t maxTxFreq = m_txCenterFreq + txChannelWidth / 2; + if (minTxFreq > minFreq || maxTxFreq < maxFreq) + { + return false; + } + return true; +} - if (minTxFreq > p20MinFreq || maxTxFreq < p20MaxFreq) +bool +WifiPpdu::CanBeReceived (uint16_t p20MinFreq, uint16_t p20MaxFreq) const +{ + NS_LOG_FUNCTION (this << p20MinFreq << p20MaxFreq); + const bool overlap = DoesOverlapChannel (p20MinFreq, p20MaxFreq); + if (!overlap) { NS_LOG_INFO ("Received PPDU does not overlap with the primary20 channel"); return false; @@ -125,7 +135,6 @@ WifiPpdu::CanBeReceived (uint16_t p20MinFreq, uint16_t p20MaxFreq) const return true; } - uint64_t WifiPpdu::GetUid (void) const { diff --git a/src/wifi/model/wifi-ppdu.h b/src/wifi/model/wifi-ppdu.h index a57f8f3d3..0e16c0f17 100644 --- a/src/wifi/model/wifi-ppdu.h +++ b/src/wifi/model/wifi-ppdu.h @@ -113,6 +113,15 @@ public: */ virtual uint16_t GetTransmissionChannelWidth (void) const; + /** + * Check whether the given PPDU overlaps a given channel. + * + * \param minFreq the minimum frequency (MHz) of the channel + * \param maxFreq the maximum frequency (MHz) of the channel + * \return true if this PPDU overlaps the channel, false otherwise + */ + bool DoesOverlapChannel (uint16_t minFreq, uint16_t maxFreq) const; + /** * Check whether the given PPDU can be received on the specified primary * channel. Normally, a PPDU can be received if it is transmitted over a