From 04015e2fd021fb430fedfb26dbaa6043fb273c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sun, 9 Jun 2019 17:24:42 +0200 Subject: [PATCH] wifi: Compute and store received power per RU if PHY supports 802.11ax --- src/wifi/model/spectrum-wifi-phy.cc | 44 ++++++++++++++++++++++--- src/wifi/model/spectrum-wifi-phy.h | 6 ++-- src/wifi/test/spectrum-wifi-phy-test.cc | 31 +++++++++++++++++ 3 files changed, 73 insertions(+), 8 deletions(-) diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index a2d052372..76404ce44 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -141,6 +141,20 @@ SpectrumWifiPhy::UpdateInterferenceHelperBands (void) } } } + if (GetPhyStandard () >= WIFI_PHY_STANDARD_80211ax) + { + for (unsigned int type = 0; type < 7; type++) + { + HeRu::RuType ruType = static_cast (type); + for (std::size_t index = 1; index <= HeRu::GetNRus (channelWidth, ruType); index++) + { + HeRu::SubcarrierGroup group = HeRu::GetSubcarrierGroup (channelWidth, ruType, index); + HeRu::SubcarrierRange range = std::make_pair (group.front ().first, group.back ().second); + WifiSpectrumBand band = ConvertHeRuSubcarriers (channelWidth, range); + m_interference.AddBand (band); + } + } + } } Ptr @@ -274,6 +288,26 @@ SpectrumWifiPhy::StartRx (Ptr rxParams) rxPowerW.insert ({filteredBand, rxPowerPerBandW}); NS_LOG_DEBUG ("Signal power received after antenna gain for 20 MHz channel band " << +i << ": " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)"); } + + if (GetPhyStandard () >= WIFI_PHY_STANDARD_80211ax) + { + for (unsigned int type = 0; type < 7; type++) + { + HeRu::RuType ruType = static_cast (type); + for (std::size_t index = 1; index <= HeRu::GetNRus (channelWidth, ruType); index++) + { + HeRu::SubcarrierGroup group = HeRu::GetSubcarrierGroup (channelWidth, ruType, index); + HeRu::SubcarrierRange range = std::make_pair (group.front ().first, group.back ().second); + WifiSpectrumBand band = ConvertHeRuSubcarriers (channelWidth, range); + Ptr filter = WifiSpectrumValueHelper::CreateRfFilter (GetFrequency (), channelWidth, GetBandBandwidth (), GetGuardBandwidth (channelWidth), band); + SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd); + NS_LOG_DEBUG ("Signal power received (watts) before antenna gain for RU with type " << ruType << " and range (" << range.first << "; " << range.second << ") -> (" << band.first << "; " << band.second << "): " << Integral (filteredSignal)); + double rxPowerPerBandW = Integral (filteredSignal) * DbToRatio (GetRxGain ()); + NS_LOG_DEBUG ("Signal power received after antenna gain for RU with type " << ruType << " and range (" << range.first << "; " << range.second << ") -> (" << band.first << "; " << band.second << "): " << rxPowerPerBandW << " W (" << WToDbm (rxPowerPerBandW) << " dBm)"); + rxPowerW.insert ({band, rxPowerPerBandW}); + } + } + } NS_LOG_DEBUG ("Total signal power received after antenna gain: " << totalRxPowerW << " W (" << WToDbm (totalRxPowerW) << " dBm)"); @@ -483,9 +517,9 @@ SpectrumWifiPhy::GetBand (uint16_t bandWidth, uint8_t bandIndex) } WifiSpectrumBand -SpectrumWifiPhy::ConvertHeRuIndices (uint16_t channelWidth, HeRu::SubcarrierRange range) const +SpectrumWifiPhy::ConvertHeRuSubcarriers (uint16_t channelWidth, HeRu::SubcarrierRange range) const { - WifiSpectrumBand convertedIndices; + WifiSpectrumBand convertedSubcarriers; uint32_t nGuardBands = static_cast (((2 * GetGuardBandwidth (channelWidth) * 1e6) / GetBandBandwidth ()) + 0.5); uint32_t centerFrequencyIndex = 0; switch (channelWidth) @@ -506,9 +540,9 @@ SpectrumWifiPhy::ConvertHeRuIndices (uint16_t channelWidth, HeRu::SubcarrierRang NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported"); break; } - convertedIndices.first = centerFrequencyIndex + range.first; - convertedIndices.second = centerFrequencyIndex + range.second; - return convertedIndices; + convertedSubcarriers.first = centerFrequencyIndex + range.first; + convertedSubcarriers.second = centerFrequencyIndex + range.second; + return convertedSubcarriers; } } //namespace ns3 diff --git a/src/wifi/model/spectrum-wifi-phy.h b/src/wifi/model/spectrum-wifi-phy.h index 7ec9a2bd2..0c4c3643b 100644 --- a/src/wifi/model/spectrum-wifi-phy.h +++ b/src/wifi/model/spectrum-wifi-phy.h @@ -192,11 +192,11 @@ private: /** * \param channelWidth the total channel width (MHz) used for the OFDMA transmission * \param range the subcarrier range of the HE RU - * \return the converted indices + * \return the converted subcarriers * - * This is a helper function to convert HE RU indices, which are relative to the center frequency subcarrier, to the indices used by the Spectrum model. + * This is a helper function to convert HE RU subcarriers, which are relative to the center frequency subcarrier, to the indexes used by the Spectrum model. */ - WifiSpectrumBand ConvertHeRuIndices (uint16_t channelWidth, HeRu::SubcarrierRange range) const; + WifiSpectrumBand ConvertHeRuSubcarriers (uint16_t channelWidth, HeRu::SubcarrierRange range) const; /** * Perform run-time spectrum model change diff --git a/src/wifi/test/spectrum-wifi-phy-test.cc b/src/wifi/test/spectrum-wifi-phy-test.cc index 322c77d41..7d0f8bb5d 100644 --- a/src/wifi/test/spectrum-wifi-phy-test.cc +++ b/src/wifi/test/spectrum-wifi-phy-test.cc @@ -407,6 +407,34 @@ SpectrumWifiPhyFilterTest::RxCallback (Ptr p, RxPowerWattPerChanne expectedNumBands += (m_rxChannelWidth / 40); expectedNumBands += (m_rxChannelWidth / 80); expectedNumBands += (m_rxChannelWidth / 160); + if (m_rxChannelWidth == 20) + { + expectedNumBands += 9; /* RU_26_TONE */ + expectedNumBands += 4; /* RU_52_TONE */ + expectedNumBands += 2; /* RU_106_TONE */ + expectedNumBands += 1; /* RU_242_TONE */ + } + else if (m_rxChannelWidth == 40) + { + expectedNumBands += 18; /* RU_26_TONE */ + expectedNumBands += 8; /* RU_52_TONE */ + expectedNumBands += 4; /* RU_106_TONE */ + expectedNumBands += 2; /* RU_242_TONE */ + expectedNumBands += 1; /* RU_484_TONE */ + } + else if (m_rxChannelWidth >= 80) + { + expectedNumBands += 37 * (m_rxChannelWidth / 80); /* RU_26_TONE */ + expectedNumBands += 16 * (m_rxChannelWidth / 80); /* RU_52_TONE */ + expectedNumBands += 8 * (m_rxChannelWidth / 80); /* RU_106_TONE */ + expectedNumBands += 4 * (m_rxChannelWidth / 80); /* RU_242_TONE */ + expectedNumBands += 2 * (m_rxChannelWidth / 80); /* RU_484_TONE */ + expectedNumBands += 1 * (m_rxChannelWidth / 80); /* RU_996_TONE */ + if (m_rxChannelWidth == 160) + { + ++expectedNumBands; /* RU_2x996_TONE */ + } + } NS_TEST_ASSERT_MSG_EQ (numBands, expectedNumBands, "Total number of bands handled by the receiver is incorrect"); uint16_t channelWidth = std::min (m_txChannelWidth, m_rxChannelWidth); @@ -441,6 +469,9 @@ SpectrumWifiPhyFilterTest::RxCallback (Ptr p, RxPowerWattPerChanne void SpectrumWifiPhyFilterTest::DoSetup (void) { + //WifiHelper::EnableLogComponents (); + //LogComponentEnable ("SpectrumWifiPhyBasicTest", LOG_LEVEL_ALL); + Ptr spectrumChannel = CreateObject (); Ptr lossModel = CreateObject (); lossModel->SetFrequency (5.180e9);