A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ism-spectrum-value-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 CTTC
3 * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari
4 * Copyright (c) 2017 Orange Labs
5 *
6 * SPDX-License-Identifier: GPL-2.0-only
7 *
8 * Authors: Nicola Baldo <nbaldo@cttc.es>
9 * Giuseppe Piro <g.piro@poliba.it>
10 */
11
13
14#include "ns3/assert.h"
15#include "ns3/log.h"
16
17namespace ns3
18{
19
20NS_LOG_COMPONENT_DEFINE("IsmSpectrumValueHelper");
21
22static Ptr<SpectrumModel> g_WifiSpectrumModel5Mhz; ///< static initializer for the class
23
24/**
25 * Static class to initialize the values for the 2.4 GHz Wi-Fi spectrum model
26 */
28{
29 public:
31 {
32 Bands bands;
33 for (int i = -4; i < 13 + 7; i++)
34 {
35 BandInfo bi;
36 bi.fl = 2407.0e6 + i * 5.0e6;
37 bi.fh = 2407.0e6 + (i + 1) * 5.0e6;
38 bi.fc = (bi.fl + bi.fh) / 2;
39 bands.push_back(bi);
40 }
42 }
43} g_WifiSpectrumModel5MhzInitializerInstance; //!< initialization instance for WifiSpectrumModel5Mhz
44
45Ptr<SpectrumValue>
52
55{
57
58 // since the spectrum model has a resolution of 5 MHz, we model
59 // the transmitted signal with a constant density over a 20MHz
60 // bandwidth centered on the center frequency of the channel. The
61 // transmission power outside the transmission power density is
62 // calculated considering the transmit spectrum mask, see IEEE
63 // Std. 802.11-2007, Annex I
64
65 double txPowerDensity = txPower / 20e6;
66
67 NS_ASSERT(channel >= 1);
68 NS_ASSERT(channel <= 13);
69
70 (*txPsd)[channel - 1] = txPowerDensity * 1e-4; // -40dB
71 (*txPsd)[channel] = txPowerDensity * 1e-4; // -40dB
72 (*txPsd)[channel + 1] = txPowerDensity * 0.0015849; // -28dB
73 (*txPsd)[channel + 2] = txPowerDensity * 0.0015849; // -28dB
74 (*txPsd)[channel + 3] = txPowerDensity;
75 (*txPsd)[channel + 4] = txPowerDensity;
76 (*txPsd)[channel + 5] = txPowerDensity;
77 (*txPsd)[channel + 6] = txPowerDensity;
78 (*txPsd)[channel + 7] = txPowerDensity * 0.0015849; // -28dB
79 (*txPsd)[channel + 8] = txPowerDensity * 0.0015849; // -28dB
80 (*txPsd)[channel + 9] = txPowerDensity * 1e-4; // -40dB
81 (*txPsd)[channel + 10] = txPowerDensity * 1e-4; // -40dB
82
83 return txPsd;
84}
85
86} // namespace ns3
Smart pointer class similar to boost::intrusive_ptr.
virtual Ptr< SpectrumValue > CreateConstant(double psd)
Creates a SpectrumValue instance with a constant value for all frequencies.
virtual Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double txPower, uint8_t channel)
Creates a SpectrumValue instance that represents the TX Power Spectral Density of a wifi device corre...
Static class to initialize the values for the 2.4 GHz Wi-Fi spectrum model.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Ptr< SpectrumModel > g_WifiSpectrumModel5Mhz
static initializer for the class
std::vector< BandInfo > Bands
Container of BandInfo.
static class ns3::WifiSpectrumModel5MhzInitializer g_WifiSpectrumModel5MhzInitializerInstance
initialization instance for WifiSpectrumModel5Mhz
The building block of a SpectrumModel.
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband