From 1e9758b406313432a36ab0ff7fab968dffbcf10f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Tue, 18 Apr 2017 20:50:10 +0200 Subject: [PATCH] wifi, spectrum: (fixes #2722) Create spectral density based on WifiModulationClass iso the current standard --- RELEASE_NOTES | 1 + .../model/wifi-spectrum-value-helper.cc | 13 +++------- src/wifi/model/spectrum-wifi-phy.cc | 26 ++++++++----------- src/wifi/model/spectrum-wifi-phy.h | 3 ++- 4 files changed, 18 insertions(+), 25 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index a3d1eae06..39cd67fab 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -101,6 +101,7 @@ Bugs fixed - Bug 2665 - Ipv4RawSocket can not send packets to broadcast or multicast - Bug 2671 - ArpCache::Entry::SetMacAddress is misspelled - Bug 2717 - Fix mask generation for Ipv4RoutingTableEntry::CreateDefaultRoute +- Bug 2722 - 802.11g sends DSSS spectrum signals using CreateOfdmTxPowerSpectralDensity Known issues ------------ diff --git a/src/spectrum/model/wifi-spectrum-value-helper.cc b/src/spectrum/model/wifi-spectrum-value-helper.cc index 1ea96ebd0..836236735 100644 --- a/src/spectrum/model/wifi-spectrum-value-helper.cc +++ b/src/spectrum/model/wifi-spectrum-value-helper.cc @@ -135,7 +135,7 @@ WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFreque Ptr c = Create (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth)); uint32_t nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5); uint32_t nAllocatedBands = static_cast(((channelWidth * 1e6) / bandBandwidth) + 0.5); - NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands"); + NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumBands ()); double txPowerPerBand = 0; uint32_t start1 = 0; uint32_t stop1 = 0; @@ -144,6 +144,7 @@ WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFreque switch (channelWidth) { case 20: + default: // 52 subcarriers (48 data + 4 pilot) // skip guard band and 6 subbands, then place power in 26 subbands, then // skip the center subband, then place power in 26 subbands, then skip @@ -176,9 +177,6 @@ WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFreque start2 = stop1 + 2; stop2 = start2 + 8 - 1; break; - default: - NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported"); - break; } NS_LOG_DEBUG ("Power per band " << txPowerPerBand); Values::iterator vit = c->ValuesBegin (); @@ -210,7 +208,7 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq Bands::const_iterator bit = c->ConstBandsBegin (); uint32_t nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5); uint32_t nAllocatedBands = static_cast(((channelWidth * 1e6) / bandBandwidth) + 0.5); - NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands"); + NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumBands ()); double txPowerPerBand; // skip the guard band and 4 subbands, then place power in 28 subbands, then // skip the center subband, then place power in 28 subbands, then skip @@ -362,9 +360,6 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq ", " << start15 << "-" << stop15 << ", " << start16 << "-" << stop16); break; - default: - NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported"); - break; } NS_LOG_DEBUG ("Integrated power " << Integral (*c)); NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); @@ -381,7 +376,7 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFreq Bands::const_iterator bit = c->ConstBandsBegin (); uint32_t nGuardBands = static_cast(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5); uint32_t nAllocatedBands = static_cast(((channelWidth * 1e6) / bandBandwidth) + 0.5); - NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands"); + NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumBands ()); double txPowerPerBand; uint32_t start1; uint32_t stop1; diff --git a/src/wifi/model/spectrum-wifi-phy.cc b/src/wifi/model/spectrum-wifi-phy.cc index cf2426368..f9023bb7f 100644 --- a/src/wifi/model/spectrum-wifi-phy.cc +++ b/src/wifi/model/spectrum-wifi-phy.cc @@ -228,33 +228,29 @@ SpectrumWifiPhy::CreateWifiSpectrumPhyInterface (Ptr device) } Ptr -SpectrumWifiPhy::GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t channelWidth, double txPowerW) const +SpectrumWifiPhy::GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t channelWidth, double txPowerW, WifiModulationClass modulationClass) const { NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW); Ptr v; - switch (GetStandard ()) + switch (modulationClass) { - case WIFI_PHY_STANDARD_80211a: - case WIFI_PHY_STANDARD_80211g: - case WIFI_PHY_STANDARD_holland: - case WIFI_PHY_STANDARD_80211_10MHZ: - case WIFI_PHY_STANDARD_80211_5MHZ: + case WIFI_MOD_CLASS_OFDM: + case WIFI_MOD_CLASS_ERP_OFDM: v = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth ()); break; - case WIFI_PHY_STANDARD_80211b: + case WIFI_MOD_CLASS_DSSS: + case WIFI_MOD_CLASS_HR_DSSS: v = WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (centerFrequency, txPowerW, GetGuardBandwidth ()); break; - case WIFI_PHY_STANDARD_80211n_2_4GHZ: - case WIFI_PHY_STANDARD_80211n_5GHZ: - case WIFI_PHY_STANDARD_80211ac: + case WIFI_MOD_CLASS_HT: + case WIFI_MOD_CLASS_VHT: v = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth ()); break; - case WIFI_PHY_STANDARD_80211ax_2_4GHZ: - case WIFI_PHY_STANDARD_80211ax_5GHZ: + case WIFI_MOD_CLASS_HE: v = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth ()); break; default: - NS_FATAL_ERROR ("Standard unknown: " << GetStandard ()); + NS_FATAL_ERROR ("modulation class unknown: " << modulationClass); break; } return v; @@ -265,7 +261,7 @@ SpectrumWifiPhy::StartTx (Ptr packet, WifiTxVector txVector, Time txDura { NS_LOG_DEBUG ("Start transmission: signal power before antenna gain=" << GetPowerDbm (txVector.GetTxPowerLevel ()) << "dBm"); double txPowerWatts = DbmToW (GetPowerDbm (txVector.GetTxPowerLevel ()) + GetTxGain ()); - Ptr txPowerSpectrum = GetTxPowerSpectralDensity (GetFrequency (), GetChannelWidth (), txPowerWatts); + Ptr txPowerSpectrum = GetTxPowerSpectralDensity (GetFrequency (), GetChannelWidth (), txPowerWatts, txVector.GetMode ().GetModulationClass ()); Ptr txParams = Create (); txParams->duration = txDuration; txParams->psd = txPowerSpectrum; diff --git a/src/wifi/model/spectrum-wifi-phy.h b/src/wifi/model/spectrum-wifi-phy.h index 4e614a4f0..fc5cda7e1 100644 --- a/src/wifi/model/spectrum-wifi-phy.h +++ b/src/wifi/model/spectrum-wifi-phy.h @@ -172,12 +172,13 @@ private: * \param centerFrequency center frequency (MHz) * \param channelWidth channel width (MHz) of the channel * \param txPowerW power in W to spread across the bands + * \param modulationClass the modulation class * \return Ptr to SpectrumValue * * This is a helper function to create the right Tx PSD corresponding * to the standard in use. */ - Ptr GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t channelWidth, double txPowerW) const; + Ptr GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t channelWidth, double txPowerW, WifiModulationClass modulationClass) const; Ptr m_channel; //!< SpectrumChannel that this SpectrumWifiPhy is connected to std::vector m_operationalChannelList; //!< List of possible channels