wifi: Use uint32_t instead of double for band bandwidth expressed in Hz
This commit is contained in:
committed by
Sebastien Deronne
parent
7309a96f37
commit
a0df8a6a0b
@@ -83,7 +83,7 @@ operator < (const WifiSpectrumModelId& a, const WifiSpectrumModelId& b)
|
||||
static std::map<WifiSpectrumModelId, Ptr<SpectrumModel> > g_wifiSpectrumModelMap; ///< static initializer for the class
|
||||
|
||||
Ptr<SpectrumModel>
|
||||
WifiSpectrumValueHelper::GetSpectrumModel (uint32_t centerFrequency, uint16_t channelWidth, double bandBandwidth, uint16_t guardBandwidth)
|
||||
WifiSpectrumValueHelper::GetSpectrumModel (uint32_t centerFrequency, uint16_t channelWidth, uint32_t bandBandwidth, uint16_t guardBandwidth)
|
||||
{
|
||||
NS_LOG_FUNCTION (centerFrequency << channelWidth << bandBandwidth << guardBandwidth);
|
||||
Ptr<SpectrumModel> ret;
|
||||
@@ -137,7 +137,7 @@ WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (uint32_t centerFreque
|
||||
{
|
||||
NS_LOG_FUNCTION (centerFrequency << txPowerW << +guardBandwidth);
|
||||
uint16_t channelWidth = 22; // DSSS channels are 22 MHz wide
|
||||
double bandBandwidth = 312500;
|
||||
uint32_t bandBandwidth = 312500;
|
||||
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth));
|
||||
Values::iterator vit = c->ValuesBegin ();
|
||||
Bands::const_iterator bit = c->ConstBandsBegin ();
|
||||
@@ -160,7 +160,7 @@ Ptr<SpectrumValue>
|
||||
WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth)
|
||||
{
|
||||
NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW << guardBandwidth);
|
||||
double bandBandwidth = 0;
|
||||
uint32_t bandBandwidth = 0;
|
||||
uint32_t innerSlopeWidth = 0;
|
||||
switch (channelWidth)
|
||||
{
|
||||
@@ -213,7 +213,7 @@ Ptr<SpectrumValue>
|
||||
WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth)
|
||||
{
|
||||
NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW << guardBandwidth);
|
||||
double bandBandwidth = 312500;
|
||||
uint32_t bandBandwidth = 312500;
|
||||
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);
|
||||
@@ -330,7 +330,7 @@ Ptr<SpectrumValue>
|
||||
WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth)
|
||||
{
|
||||
NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW << guardBandwidth);
|
||||
double bandBandwidth = 78125;
|
||||
uint32_t bandBandwidth = 78125;
|
||||
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);
|
||||
@@ -359,7 +359,7 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFreq
|
||||
innerSlopeWidth = static_cast<uint32_t> ((5e5 / bandBandwidth) + 0.5); // [-10.25;-9.75] & [9.75;10.25]
|
||||
// skip the guard band and 6 subbands, then place power in 121 subbands, then
|
||||
// skip 3 DC, then place power in 121 subbands, then skip
|
||||
// the final 6 subbands and the guard band.
|
||||
// the final 5 subbands and the guard band.
|
||||
start1 = (nGuardBands / 2) + 6;
|
||||
stop1 = start1 + 121 - 1;
|
||||
start2 = stop1 + 4;
|
||||
@@ -372,7 +372,7 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFreq
|
||||
txPowerPerBandW = txPowerW / 484;
|
||||
// skip the guard band and 12 subbands, then place power in 242 subbands, then
|
||||
// skip 5 DC, then place power in 242 subbands, then skip
|
||||
// the final 12 subbands and the guard band.
|
||||
// the final 11 subbands and the guard band.
|
||||
start1 = (nGuardBands / 2) + 12;
|
||||
stop1 = start1 + 242 - 1;
|
||||
start2 = stop1 + 6;
|
||||
@@ -385,7 +385,7 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFreq
|
||||
txPowerPerBandW = txPowerW / 996;
|
||||
// skip the guard band and 12 subbands, then place power in 498 subbands, then
|
||||
// skip 5 DC, then place power in 498 subbands, then skip
|
||||
// the final 12 subbands and the guard band.
|
||||
// the final 11 subbands and the guard band.
|
||||
start1 = (nGuardBands / 2) + 12;
|
||||
stop1 = start1 + 498 - 1;
|
||||
start2 = stop1 + 6;
|
||||
@@ -424,7 +424,7 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFreq
|
||||
}
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint16_t channelWidth, double bandBandwidth, double noiseFigure, uint16_t guardBandwidth)
|
||||
WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint16_t channelWidth, uint32_t bandBandwidth, double noiseFigure, uint16_t guardBandwidth)
|
||||
{
|
||||
Ptr<SpectrumModel> model = GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth);
|
||||
return CreateNoisePowerSpectralDensity (noiseFigure, model);
|
||||
@@ -449,14 +449,13 @@ WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (double noiseFigureDb,
|
||||
}
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
WifiSpectrumValueHelper::CreateRfFilter (uint32_t centerFrequency, uint16_t channelWidth, double bandGranularity, uint16_t guardBandwidth)
|
||||
WifiSpectrumValueHelper::CreateRfFilter (uint32_t centerFrequency, uint16_t channelWidth, uint32_t bandBandwidth, uint16_t guardBandwidth)
|
||||
{
|
||||
NS_LOG_FUNCTION (centerFrequency << channelWidth << bandGranularity << guardBandwidth);
|
||||
Ptr<SpectrumValue> c = Create <SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandGranularity, guardBandwidth));
|
||||
NS_LOG_FUNCTION (centerFrequency << channelWidth << bandBandwidth << guardBandwidth);
|
||||
Ptr<SpectrumValue> c = Create <SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth));
|
||||
size_t numBands = c->GetSpectrumModel ()->GetNumBands ();
|
||||
Bands::const_iterator bit = c->ConstBandsBegin ();
|
||||
Values::iterator vit = c->ValuesBegin ();
|
||||
uint32_t bandBandwidth = static_cast<uint32_t> (bandGranularity);
|
||||
size_t numBandsInFilter = static_cast<size_t> (channelWidth * 1e6 / bandBandwidth);
|
||||
if (channelWidth % bandBandwidth != 0)
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
* \return the static SpectrumModel instance corresponding to the
|
||||
* given carrier frequency and channel width configuration.
|
||||
*/
|
||||
static Ptr<SpectrumModel> GetSpectrumModel (uint32_t centerFrequency, uint16_t channelWidth, double bandBandwidth, uint16_t guardBandwidth);
|
||||
static Ptr<SpectrumModel> GetSpectrumModel (uint32_t centerFrequency, uint16_t channelWidth, uint32_t bandBandwidth, uint16_t guardBandwidth);
|
||||
|
||||
/**
|
||||
* Create a transmit power spectral density corresponding to DSSS
|
||||
@@ -123,7 +123,7 @@ public:
|
||||
* \param guardBandwidth width of the guard band (MHz)
|
||||
* \return a pointer to a newly allocated SpectrumValue representing the noise Power Spectral Density in W/Hz for each Band
|
||||
*/
|
||||
static Ptr<SpectrumValue> CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint16_t channelWidth, double bandBandwidth, double noiseFigure, uint16_t guardBandwidth);
|
||||
static Ptr<SpectrumValue> CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint16_t channelWidth, uint32_t bandBandwidth, double noiseFigure, uint16_t guardBandwidth);
|
||||
|
||||
/**
|
||||
* Create a thermal noise power spectral density
|
||||
@@ -145,7 +145,7 @@ public:
|
||||
* \return a pointer to a SpectrumValue representing the RF filter applied
|
||||
* to an received power spectral density
|
||||
*/
|
||||
static Ptr<SpectrumValue> CreateRfFilter (uint32_t centerFrequency, uint16_t channelWidth, double bandBandwidth, uint16_t guardBandwidth);
|
||||
static Ptr<SpectrumValue> CreateRfFilter (uint32_t centerFrequency, uint16_t channelWidth, uint32_t bandBandwidth, uint16_t guardBandwidth);
|
||||
|
||||
/**
|
||||
* typedef for a pair of start and stop sub-band indexes
|
||||
|
||||
@@ -329,10 +329,10 @@ SpectrumWifiPhy::StartTx (Ptr<Packet> packet, WifiTxVector txVector, Time txDura
|
||||
m_channel->StartTx (txParams);
|
||||
}
|
||||
|
||||
double
|
||||
uint32_t
|
||||
SpectrumWifiPhy::GetBandBandwidth (void) const
|
||||
{
|
||||
double bandBandwidth = 0;
|
||||
uint32_t bandBandwidth = 0;
|
||||
switch (GetStandard ())
|
||||
{
|
||||
case WIFI_PHY_STANDARD_80211a:
|
||||
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
/**
|
||||
* \return the width of each band (Hz)
|
||||
*/
|
||||
double GetBandBandwidth (void) const;
|
||||
uint32_t GetBandBandwidth (void) const;
|
||||
|
||||
/**
|
||||
* \param currentChannelWidth channel width of the current transmission (MHz)
|
||||
|
||||
Reference in New Issue
Block a user