wifi, spectrum: (fixes #2722) Create spectral density based on WifiModulationClass iso the current standard

This commit is contained in:
Sébastien Deronne
2017-04-18 20:50:10 +02:00
parent 1aa06a90eb
commit 1e9758b406
4 changed files with 18 additions and 25 deletions

View File

@@ -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
------------

View File

@@ -135,7 +135,7 @@ WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFreque
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth));
uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nAllocatedBands = static_cast<uint32_t>(((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<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nAllocatedBands = static_cast<uint32_t>(((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<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nAllocatedBands = static_cast<uint32_t>(((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;

View File

@@ -228,33 +228,29 @@ SpectrumWifiPhy::CreateWifiSpectrumPhyInterface (Ptr<NetDevice> device)
}
Ptr<SpectrumValue>
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<SpectrumValue> 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> 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<SpectrumValue> txPowerSpectrum = GetTxPowerSpectralDensity (GetFrequency (), GetChannelWidth (), txPowerWatts);
Ptr<SpectrumValue> txPowerSpectrum = GetTxPowerSpectralDensity (GetFrequency (), GetChannelWidth (), txPowerWatts, txVector.GetMode ().GetModulationClass ());
Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
txParams->duration = txDuration;
txParams->psd = txPowerSpectrum;

View File

@@ -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<SpectrumValue> GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t channelWidth, double txPowerW) const;
Ptr<SpectrumValue> GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t channelWidth, double txPowerW, WifiModulationClass modulationClass) const;
Ptr<SpectrumChannel> m_channel; //!< SpectrumChannel that this SpectrumWifiPhy is connected to
std::vector<uint8_t> m_operationalChannelList; //!< List of possible channels