A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
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
23
#include "
ism-spectrum-value-helper.h
"
24
25
#include "ns3/assert.h"
26
#include "ns3/log.h"
27
28
namespace
ns3
29
{
30
31
NS_LOG_COMPONENT_DEFINE
(
"IsmSpectrumValueHelper"
);
32
33
static
Ptr<SpectrumModel>
g_WifiSpectrumModel5Mhz
;
34
38
static
class
WifiSpectrumModel5MhzInitializer
39
{
40
public
:
41
WifiSpectrumModel5MhzInitializer
()
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
;
55
56
Ptr<SpectrumValue>
57
SpectrumValue5MhzFactory::CreateConstant
(
double
v)
58
{
59
Ptr<SpectrumValue>
c = Create<SpectrumValue>(
g_WifiSpectrumModel5Mhz
);
60
(*c) = v;
61
return
c;
62
}
63
64
Ptr<SpectrumValue>
65
SpectrumValue5MhzFactory::CreateTxPowerSpectralDensity
(
double
txPower, uint8_t
channel
)
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
ns3::Ptr< SpectrumModel >
ns3::SpectrumValue5MhzFactory::CreateConstant
virtual Ptr< SpectrumValue > CreateConstant(double psd)
Creates a SpectrumValue instance with a constant value for all frequencies.
Definition:
ism-spectrum-value-helper.cc:57
ns3::SpectrumValue5MhzFactory::CreateTxPowerSpectralDensity
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...
Definition:
ism-spectrum-value-helper.cc:65
ns3::WifiSpectrumModel5MhzInitializer
Static class to initialize the values for the 2.4 GHz Wi-Fi spectrum model.
Definition:
ism-spectrum-value-helper.cc:39
ns3::WifiSpectrumModel5MhzInitializer::WifiSpectrumModel5MhzInitializer
WifiSpectrumModel5MhzInitializer()
Definition:
ism-spectrum-value-helper.cc:41
NS_ASSERT
#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
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
ism-spectrum-value-helper.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::g_WifiSpectrumModel5Mhz
static Ptr< SpectrumModel > g_WifiSpectrumModel5Mhz
static initializer for the class
Definition:
ism-spectrum-value-helper.cc:31
ns3::Bands
std::vector< BandInfo > Bands
Container of BandInfo.
Definition:
spectrum-model.h:60
ns3::g_WifiSpectrumModel5MhzInitializerInstance
static class ns3::WifiSpectrumModel5MhzInitializer g_WifiSpectrumModel5MhzInitializerInstance
initialization instance for WifiSpectrumModel5Mhz
third.channel
channel
Definition:
third.py:88
ns3::BandInfo
The building block of a SpectrumModel.
Definition:
spectrum-model.h:53
ns3::BandInfo::fc
double fc
center frequency
Definition:
spectrum-model.h:55
ns3::BandInfo::fl
double fl
lower limit of subband
Definition:
spectrum-model.h:54
ns3::BandInfo::fh
double fh
upper limit of subband
Definition:
spectrum-model.h:56
src
spectrum
model
ism-spectrum-value-helper.cc
Generated on Sun Mar 3 2024 17:11:08 for ns-3 by
1.9.1