A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
12
#include "
ism-spectrum-value-helper.h
"
13
14
#include "ns3/assert.h"
15
#include "ns3/log.h"
16
17
namespace
ns3
18
{
19
20
NS_LOG_COMPONENT_DEFINE
(
"IsmSpectrumValueHelper"
);
21
22
static
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
*/
27
static
class
WifiSpectrumModel5MhzInitializer
28
{
29
public
:
30
WifiSpectrumModel5MhzInitializer
()
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
}
41
g_WifiSpectrumModel5Mhz
=
Create<SpectrumModel>
(bands);
42
}
43
}
g_WifiSpectrumModel5MhzInitializerInstance
;
//!< initialization instance for WifiSpectrumModel5Mhz
44
45
Ptr<SpectrumValue>
46
SpectrumValue5MhzFactory::CreateConstant
(
double
v)
47
{
48
Ptr<SpectrumValue>
c =
Create<SpectrumValue>
(
g_WifiSpectrumModel5Mhz
);
49
(*c) = v;
50
return
c;
51
}
52
53
Ptr<SpectrumValue>
54
SpectrumValue5MhzFactory::CreateTxPowerSpectralDensity
(
double
txPower, uint8_t channel)
55
{
56
Ptr<SpectrumValue>
txPsd =
Create<SpectrumValue>
(
g_WifiSpectrumModel5Mhz
);
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
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
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:46
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:54
ns3::WifiSpectrumModel5MhzInitializer
Static class to initialize the values for the 2.4 GHz Wi-Fi spectrum model.
Definition
ism-spectrum-value-helper.cc:28
ns3::WifiSpectrumModel5MhzInitializer::WifiSpectrumModel5MhzInitializer
WifiSpectrumModel5MhzInitializer()
Definition
ism-spectrum-value-helper.cc:30
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:55
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
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:22
ns3::Bands
std::vector< BandInfo > Bands
Container of BandInfo.
Definition
spectrum-model.h:49
ns3::g_WifiSpectrumModel5MhzInitializerInstance
static class ns3::WifiSpectrumModel5MhzInitializer g_WifiSpectrumModel5MhzInitializerInstance
initialization instance for WifiSpectrumModel5Mhz
ns3::BandInfo
The building block of a SpectrumModel.
Definition
spectrum-model.h:42
ns3::BandInfo::fc
double fc
center frequency
Definition
spectrum-model.h:44
ns3::BandInfo::fl
double fl
lower limit of subband
Definition
spectrum-model.h:43
ns3::BandInfo::fh
double fh
upper limit of subband
Definition
spectrum-model.h:45
src
spectrum
model
ism-spectrum-value-helper.cc
Generated on Fri Nov 8 2024 13:59:06 for ns-3 by
1.11.0