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 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Authors: Nicola Baldo <nbaldo@cttc.es>
20 * Giuseppe Piro <g.piro@poliba.it>
21 */
22
24
25#include "ns3/assert.h"
26#include "ns3/log.h"
27
28namespace ns3
29{
30
31NS_LOG_COMPONENT_DEFINE("IsmSpectrumValueHelper");
32
33static Ptr<SpectrumModel> g_WifiSpectrumModel5Mhz; ///< static initializer for the class
34
35/**
36 * Static class to initialize the values for the 2.4 GHz Wi-Fi spectrum model
37 */
39{
40 public:
42 {
43 Bands bands;
44 for (int i = -4; i < 13 + 7; i++)
45 {
46 BandInfo bi;
47 bi.fl = 2407.0e6 + i * 5.0e6;
48 bi.fh = 2407.0e6 + (i + 1) * 5.0e6;
49 bi.fc = (bi.fl + bi.fh) / 2;
50 bands.push_back(bi);
51 }
52 g_WifiSpectrumModel5Mhz = Create<SpectrumModel>(bands);
53 }
54} g_WifiSpectrumModel5MhzInitializerInstance; //!< initialization instance for WifiSpectrumModel5Mhz
55
56Ptr<SpectrumValue>
58{
59 Ptr<SpectrumValue> c = Create<SpectrumValue>(g_WifiSpectrumModel5Mhz);
60 (*c) = v;
61 return c;
62}
63
66{
67 Ptr<SpectrumValue> txPsd = Create<SpectrumValue>(g_WifiSpectrumModel5Mhz);
68
69 // since the spectrum model has a resolution of 5 MHz, we model
70 // the transmitted signal with a constant density over a 20MHz
71 // bandwidth centered on the center frequency of the channel. The
72 // transmission power outside the transmission power density is
73 // calculated considering the transmit spectrum mask, see IEEE
74 // Std. 802.11-2007, Annex I
75
76 double txPowerDensity = txPower / 20e6;
77
78 NS_ASSERT(channel >= 1);
79 NS_ASSERT(channel <= 13);
80
81 (*txPsd)[channel - 1] = txPowerDensity * 1e-4; // -40dB
82 (*txPsd)[channel] = txPowerDensity * 1e-4; // -40dB
83 (*txPsd)[channel + 1] = txPowerDensity * 0.0015849; // -28dB
84 (*txPsd)[channel + 2] = txPowerDensity * 0.0015849; // -28dB
85 (*txPsd)[channel + 3] = txPowerDensity;
86 (*txPsd)[channel + 4] = txPowerDensity;
87 (*txPsd)[channel + 5] = txPowerDensity;
88 (*txPsd)[channel + 6] = txPowerDensity;
89 (*txPsd)[channel + 7] = txPowerDensity * 0.0015849; // -28dB
90 (*txPsd)[channel + 8] = txPowerDensity * 0.0015849; // -28dB
91 (*txPsd)[channel + 9] = txPowerDensity * 1e-4; // -40dB
92 (*txPsd)[channel + 10] = txPowerDensity * 1e-4; // -40dB
93
94 return txPsd;
95}
96
97} // namespace ns3
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
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:66
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
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