spectrum: Split out WifiSpectrumValue5MhzFactory since it is not used by wifi
This commit is contained in:
committed by
Sébastien Deronne
parent
e00523cf59
commit
5ed4fe74c7
@@ -10,6 +10,7 @@ set(source_files
|
||||
model/friis-spectrum-propagation-loss.cc
|
||||
model/half-duplex-ideal-phy-signal-parameters.cc
|
||||
model/half-duplex-ideal-phy.cc
|
||||
model/ism-spectrum-value-helper.cc
|
||||
model/matrix-based-channel-model.cc
|
||||
model/microwave-oven-spectrum-value-helper.cc
|
||||
model/two-ray-spectrum-propagation-loss-model.cc
|
||||
@@ -50,6 +51,7 @@ set(header_files
|
||||
model/friis-spectrum-propagation-loss.h
|
||||
model/half-duplex-ideal-phy-signal-parameters.h
|
||||
model/half-duplex-ideal-phy.h
|
||||
model/ism-spectrum-value-helper.h
|
||||
model/matrix-based-channel-model.h
|
||||
model/microwave-oven-spectrum-value-helper.h
|
||||
model/two-ray-spectrum-propagation-loss-model.h
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <ns3/applications-module.h>
|
||||
#include <ns3/core-module.h>
|
||||
#include <ns3/friis-spectrum-propagation-loss.h>
|
||||
#include <ns3/ism-spectrum-value-helper.h>
|
||||
#include <ns3/log.h>
|
||||
#include <ns3/mobility-module.h>
|
||||
#include <ns3/network-module.h>
|
||||
@@ -31,7 +32,6 @@
|
||||
#include <ns3/spectrum-model-300kHz-300GHz-log.h>
|
||||
#include <ns3/spectrum-model-ism2400MHz-res1MHz.h>
|
||||
#include <ns3/waveform-generator.h>
|
||||
#include <ns3/wifi-spectrum-value-helper.h>
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
@@ -163,7 +163,7 @@ main(int argc, char** argv)
|
||||
channelHelper.AddPropagationLoss(propLoss);
|
||||
Ptr<SpectrumChannel> channel = channelHelper.Create();
|
||||
|
||||
WifiSpectrumValue5MhzFactory sf;
|
||||
SpectrumValue5MhzFactory sf;
|
||||
|
||||
uint32_t channelNumber = 1;
|
||||
Ptr<SpectrumValue> txPsd = sf.CreateTxPowerSpectralDensity(txPowerW, channelNumber);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <ns3/applications-module.h>
|
||||
#include <ns3/core-module.h>
|
||||
#include <ns3/friis-spectrum-propagation-loss.h>
|
||||
#include <ns3/ism-spectrum-value-helper.h>
|
||||
#include <ns3/log.h>
|
||||
#include <ns3/microwave-oven-spectrum-value-helper.h>
|
||||
#include <ns3/mobility-module.h>
|
||||
@@ -35,7 +36,6 @@
|
||||
#include <ns3/spectrum-model-ism2400MHz-res1MHz.h>
|
||||
#include <ns3/waveform-generator-helper.h>
|
||||
#include <ns3/waveform-generator.h>
|
||||
#include <ns3/wifi-spectrum-value-helper.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@@ -196,7 +196,7 @@ main(int argc, char** argv)
|
||||
// Configure ofdm nodes
|
||||
////////////////////////
|
||||
|
||||
WifiSpectrumValue5MhzFactory sf;
|
||||
SpectrumValue5MhzFactory sf;
|
||||
|
||||
double txPower = 0.1; // Watts
|
||||
uint32_t channelNumber = 4;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <ns3/applications-module.h>
|
||||
#include <ns3/core-module.h>
|
||||
#include <ns3/friis-spectrum-propagation-loss.h>
|
||||
#include <ns3/ism-spectrum-value-helper.h>
|
||||
#include <ns3/log.h>
|
||||
#include <ns3/mobility-module.h>
|
||||
#include <ns3/network-module.h>
|
||||
@@ -31,7 +32,6 @@
|
||||
#include <ns3/spectrum-model-300kHz-300GHz-log.h>
|
||||
#include <ns3/spectrum-model-ism2400MHz-res1MHz.h>
|
||||
#include <ns3/waveform-generator.h>
|
||||
#include <ns3/wifi-spectrum-value-helper.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@@ -176,7 +176,7 @@ main(int argc, char** argv)
|
||||
SpectrumChannelHelper channelHelper = SpectrumChannelHelper::Default();
|
||||
Ptr<SpectrumChannel> channel = channelHelper.Create();
|
||||
|
||||
WifiSpectrumValue5MhzFactory sf;
|
||||
SpectrumValue5MhzFactory sf;
|
||||
|
||||
double txPower = 0.1; // Watts
|
||||
uint32_t channelNumber = 1;
|
||||
|
||||
97
src/spectrum/model/ism-spectrum-value-helper.cc
Normal file
97
src/spectrum/model/ism-spectrum-value-helper.cc
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2009 CTTC
|
||||
* Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
|
||||
* Copyright (c) 2017 Orange Labs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Authors: Nicola Baldo <nbaldo@cttc.es>
|
||||
* Giuseppe Piro <g.piro@poliba.it>
|
||||
*/
|
||||
|
||||
#include "ism-spectrum-value-helper.h"
|
||||
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/log.h"
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE("IsmSpectrumValueHelper");
|
||||
|
||||
static Ptr<SpectrumModel> g_WifiSpectrumModel5Mhz; ///< static initializer for the class
|
||||
|
||||
/**
|
||||
* Static class to initialize the values for the 2.4 GHz Wi-Fi spectrum model
|
||||
*/
|
||||
static class WifiSpectrumModel5MhzInitializer
|
||||
{
|
||||
public:
|
||||
WifiSpectrumModel5MhzInitializer()
|
||||
{
|
||||
Bands bands;
|
||||
for (int i = -4; i < 13 + 7; i++)
|
||||
{
|
||||
BandInfo bi;
|
||||
bi.fl = 2407.0e6 + i * 5.0e6;
|
||||
bi.fh = 2407.0e6 + (i + 1) * 5.0e6;
|
||||
bi.fc = (bi.fl + bi.fh) / 2;
|
||||
bands.push_back(bi);
|
||||
}
|
||||
g_WifiSpectrumModel5Mhz = Create<SpectrumModel>(bands);
|
||||
}
|
||||
} g_WifiSpectrumModel5MhzInitializerInstance; //!< initialization instance for WifiSpectrumModel5Mhz
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
SpectrumValue5MhzFactory::CreateConstant(double v)
|
||||
{
|
||||
Ptr<SpectrumValue> c = Create<SpectrumValue>(g_WifiSpectrumModel5Mhz);
|
||||
(*c) = v;
|
||||
return c;
|
||||
}
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
SpectrumValue5MhzFactory::CreateTxPowerSpectralDensity(double txPower, uint8_t channel)
|
||||
{
|
||||
Ptr<SpectrumValue> txPsd = Create<SpectrumValue>(g_WifiSpectrumModel5Mhz);
|
||||
|
||||
// since the spectrum model has a resolution of 5 MHz, we model
|
||||
// the transmitted signal with a constant density over a 20MHz
|
||||
// bandwidth centered on the center frequency of the channel. The
|
||||
// transmission power outside the transmission power density is
|
||||
// calculated considering the transmit spectrum mask, see IEEE
|
||||
// Std. 802.11-2007, Annex I
|
||||
|
||||
double txPowerDensity = txPower / 20e6;
|
||||
|
||||
NS_ASSERT(channel >= 1);
|
||||
NS_ASSERT(channel <= 13);
|
||||
|
||||
(*txPsd)[channel - 1] = txPowerDensity * 1e-4; // -40dB
|
||||
(*txPsd)[channel] = txPowerDensity * 1e-4; // -40dB
|
||||
(*txPsd)[channel + 1] = txPowerDensity * 0.0015849; // -28dB
|
||||
(*txPsd)[channel + 2] = txPowerDensity * 0.0015849; // -28dB
|
||||
(*txPsd)[channel + 3] = txPowerDensity;
|
||||
(*txPsd)[channel + 4] = txPowerDensity;
|
||||
(*txPsd)[channel + 5] = txPowerDensity;
|
||||
(*txPsd)[channel + 6] = txPowerDensity;
|
||||
(*txPsd)[channel + 7] = txPowerDensity * 0.0015849; // -28dB
|
||||
(*txPsd)[channel + 8] = txPowerDensity * 0.0015849; // -28dB
|
||||
(*txPsd)[channel + 9] = txPowerDensity * 1e-4; // -40dB
|
||||
(*txPsd)[channel + 10] = txPowerDensity * 1e-4; // -40dB
|
||||
|
||||
return txPsd;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
76
src/spectrum/model/ism-spectrum-value-helper.h
Normal file
76
src/spectrum/model/ism-spectrum-value-helper.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2009 CTTC
|
||||
* Copyright (c) 2017 Orange Labs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Authors: Nicola Baldo <nbaldo@cttc.es>
|
||||
* Giuseppe Piro <g.piro@poliba.it>
|
||||
*/
|
||||
|
||||
#ifndef ISM_SPECTRUM_VALUE_HELPER_H
|
||||
#define ISM_SPECTRUM_VALUE_HELPER_H
|
||||
|
||||
#include <ns3/spectrum-value.h>
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
/**
|
||||
* \ingroup spectrum
|
||||
*
|
||||
* Implements Wifi SpectrumValue for the 2.4 GHz ISM band only, with a
|
||||
* 5 MHz spectrum resolution.
|
||||
*
|
||||
*/
|
||||
class SpectrumValue5MhzFactory
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~SpectrumValue5MhzFactory() = default;
|
||||
/**
|
||||
* Creates a SpectrumValue instance with a constant value for all frequencies
|
||||
*
|
||||
* @param psd the constant value
|
||||
*
|
||||
* @return a Ptr to a newly created SpectrumValue
|
||||
*/
|
||||
virtual Ptr<SpectrumValue> CreateConstant(double psd);
|
||||
/**
|
||||
* Creates a SpectrumValue instance that represents the TX Power Spectral
|
||||
* Density of a wifi device corresponding to the provided parameters
|
||||
*
|
||||
* Since the spectrum model has a resolution of 5 MHz, we model
|
||||
* the transmitted signal with a constant density over a 20MHz
|
||||
* bandwidth centered on the center frequency of the channel. The
|
||||
* transmission power outside the transmission power density is
|
||||
* calculated considering the transmit spectrum mask, see IEEE
|
||||
* Std. 802.11-2007, Annex I. The two bands just outside of the main
|
||||
* 20 MHz are allocated power at -28 dB down from the center 20 MHz,
|
||||
* and the two bands outside of this are allocated power at -40 dB down
|
||||
* (with a total bandwidth of 60 MHz containing non-zero power allocation).
|
||||
*
|
||||
* @param txPower the total TX power in W
|
||||
* @param channel the number of the channel (1 <= channel <= 13)
|
||||
*
|
||||
* @return a Ptr to a newly created SpectrumValue
|
||||
*/
|
||||
virtual Ptr<SpectrumValue> CreateTxPowerSpectralDensity(double txPower, uint8_t channel);
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* ISM_SPECTRUM_VALUE_HELPER_H */
|
||||
@@ -819,78 +819,6 @@ WifiSpectrumValueHelper::GetBandPowerW(Ptr<SpectrumValue> psd, const WifiSpectru
|
||||
return powerWattPerHertz * (bandIt->fh - bandIt->fl);
|
||||
}
|
||||
|
||||
static Ptr<SpectrumModel> g_WifiSpectrumModel5Mhz; ///< static initializer for the class
|
||||
|
||||
WifiSpectrumValueHelper::~WifiSpectrumValueHelper()
|
||||
{
|
||||
}
|
||||
|
||||
WifiSpectrumValue5MhzFactory::~WifiSpectrumValue5MhzFactory()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Static class to initialize the values for the 2.4 GHz Wi-Fi spectrum model
|
||||
*/
|
||||
static class WifiSpectrumModel5MhzInitializer
|
||||
{
|
||||
public:
|
||||
WifiSpectrumModel5MhzInitializer()
|
||||
{
|
||||
Bands bands;
|
||||
for (int i = -4; i < 13 + 7; i++)
|
||||
{
|
||||
BandInfo bi;
|
||||
bi.fl = 2407.0e6 + i * 5.0e6;
|
||||
bi.fh = 2407.0e6 + (i + 1) * 5.0e6;
|
||||
bi.fc = (bi.fl + bi.fh) / 2;
|
||||
bands.push_back(bi);
|
||||
}
|
||||
g_WifiSpectrumModel5Mhz = Create<SpectrumModel>(bands);
|
||||
}
|
||||
} g_WifiSpectrumModel5MhzInitializerInstance; //!< initialization instance for WifiSpectrumModel5Mhz
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
WifiSpectrumValue5MhzFactory::CreateConstant(double v)
|
||||
{
|
||||
Ptr<SpectrumValue> c = Create<SpectrumValue>(g_WifiSpectrumModel5Mhz);
|
||||
(*c) = v;
|
||||
return c;
|
||||
}
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
WifiSpectrumValue5MhzFactory::CreateTxPowerSpectralDensity(double txPower, uint8_t channel)
|
||||
{
|
||||
Ptr<SpectrumValue> txPsd = Create<SpectrumValue>(g_WifiSpectrumModel5Mhz);
|
||||
|
||||
// since the spectrum model has a resolution of 5 MHz, we model
|
||||
// the transmitted signal with a constant density over a 20MHz
|
||||
// bandwidth centered on the center frequency of the channel. The
|
||||
// transmission power outside the transmission power density is
|
||||
// calculated considering the transmit spectrum mask, see IEEE
|
||||
// Std. 802.11-2007, Annex I
|
||||
|
||||
double txPowerDensity = txPower / 20e6;
|
||||
|
||||
NS_ASSERT(channel >= 1);
|
||||
NS_ASSERT(channel <= 13);
|
||||
|
||||
(*txPsd)[channel - 1] = txPowerDensity * 1e-4; // -40dB
|
||||
(*txPsd)[channel] = txPowerDensity * 1e-4; // -40dB
|
||||
(*txPsd)[channel + 1] = txPowerDensity * 0.0015849; // -28dB
|
||||
(*txPsd)[channel + 2] = txPowerDensity * 0.0015849; // -28dB
|
||||
(*txPsd)[channel + 3] = txPowerDensity;
|
||||
(*txPsd)[channel + 4] = txPowerDensity;
|
||||
(*txPsd)[channel + 5] = txPowerDensity;
|
||||
(*txPsd)[channel + 6] = txPowerDensity;
|
||||
(*txPsd)[channel + 7] = txPowerDensity * 0.0015849; // -28dB
|
||||
(*txPsd)[channel + 8] = txPowerDensity * 0.0015849; // -28dB
|
||||
(*txPsd)[channel + 9] = txPowerDensity * 1e-4; // -40dB
|
||||
(*txPsd)[channel + 10] = txPowerDensity * 1e-4; // -40dB
|
||||
|
||||
return txPsd;
|
||||
}
|
||||
|
||||
bool
|
||||
operator<(const FrequencyRange& left, const FrequencyRange& right)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ class WifiSpectrumValueHelper
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~WifiSpectrumValueHelper();
|
||||
virtual ~WifiSpectrumValueHelper() = default;
|
||||
|
||||
/**
|
||||
* Return a SpectrumModel instance corresponding to the center frequency
|
||||
@@ -323,50 +323,6 @@ class WifiSpectrumValueHelper
|
||||
static double GetBandPowerW(Ptr<SpectrumValue> psd, const WifiSpectrumBand& band);
|
||||
};
|
||||
|
||||
/**
|
||||
* \ingroup spectrum
|
||||
*
|
||||
* Implements Wifi SpectrumValue for the 2.4 GHz ISM band only, with a
|
||||
* 5 MHz spectrum resolution.
|
||||
*
|
||||
*/
|
||||
class WifiSpectrumValue5MhzFactory
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~WifiSpectrumValue5MhzFactory();
|
||||
/**
|
||||
* Creates a SpectrumValue instance with a constant value for all frequencies
|
||||
*
|
||||
* @param psd the constant value
|
||||
*
|
||||
* @return a Ptr to a newly created SpectrumValue
|
||||
*/
|
||||
virtual Ptr<SpectrumValue> CreateConstant(double psd);
|
||||
/**
|
||||
* Creates a SpectrumValue instance that represents the TX Power Spectral
|
||||
* Density of a wifi device corresponding to the provided parameters
|
||||
*
|
||||
* Since the spectrum model has a resolution of 5 MHz, we model
|
||||
* the transmitted signal with a constant density over a 20MHz
|
||||
* bandwidth centered on the center frequency of the channel. The
|
||||
* transmission power outside the transmission power density is
|
||||
* calculated considering the transmit spectrum mask, see IEEE
|
||||
* Std. 802.11-2007, Annex I. The two bands just outside of the main
|
||||
* 20 MHz are allocated power at -28 dB down from the center 20 MHz,
|
||||
* and the two bands outside of this are allocated power at -40 dB down
|
||||
* (with a total bandwidth of 60 MHz containing non-zero power allocation).
|
||||
*
|
||||
* @param txPower the total TX power in W
|
||||
* @param channel the number of the channel (1 <= channel <= 13)
|
||||
*
|
||||
* @return a Ptr to a newly created SpectrumValue
|
||||
*/
|
||||
virtual Ptr<SpectrumValue> CreateTxPowerSpectralDensity(double txPower, uint8_t channel);
|
||||
};
|
||||
|
||||
/**
|
||||
* \ingroup spectrum
|
||||
* Struct defining a frequency range between minFrequency (MHz) and maxFrequency (MHz).
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <ns3/config.h>
|
||||
#include <ns3/data-rate.h>
|
||||
#include <ns3/friis-spectrum-propagation-loss.h>
|
||||
#include <ns3/ism-spectrum-value-helper.h>
|
||||
#include <ns3/log.h>
|
||||
#include <ns3/math.h>
|
||||
#include <ns3/mobility-helper.h>
|
||||
@@ -43,7 +44,6 @@
|
||||
#include <ns3/test.h>
|
||||
#include <ns3/uinteger.h>
|
||||
#include <ns3/waveform-generator.h>
|
||||
#include <ns3/wifi-spectrum-value-helper.h>
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
@@ -170,7 +170,7 @@ SpectrumIdealPhyTestCase::DoRun()
|
||||
channelHelper.AddPropagationLoss(propLoss);
|
||||
Ptr<SpectrumChannel> channel = channelHelper.Create();
|
||||
|
||||
WifiSpectrumValue5MhzFactory sf;
|
||||
SpectrumValue5MhzFactory sf;
|
||||
|
||||
uint32_t channelNumber = 1;
|
||||
Ptr<SpectrumValue> txPsd = sf.CreateTxPowerSpectralDensity(txPowerW, channelNumber);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "ns3/config.h"
|
||||
#include "ns3/constant-position-mobility-model.h"
|
||||
#include "ns3/double.h"
|
||||
#include "ns3/ism-spectrum-value-helper.h"
|
||||
#include "ns3/isotropic-antenna-model.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/node-container.h"
|
||||
@@ -34,7 +35,6 @@
|
||||
#include "ns3/three-gpp-spectrum-propagation-loss-model.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "ns3/uniform-planar-array.h"
|
||||
#include "ns3/wifi-spectrum-value-helper.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
@@ -636,7 +636,7 @@ ThreeGppSpectrumPropagationLossModelTest::DoRun()
|
||||
DoBeamforming(rxDev, rxAntenna, txDev, txAntenna);
|
||||
|
||||
// create the tx psd
|
||||
WifiSpectrumValue5MhzFactory sf;
|
||||
SpectrumValue5MhzFactory sf;
|
||||
double txPower = 0.1; // Watts
|
||||
uint32_t channelNumber = 1;
|
||||
Ptr<SpectrumValue> txPsd = sf.CreateTxPowerSpectralDensity(txPower, channelNumber);
|
||||
|
||||
Reference in New Issue
Block a user