A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
wifi-spectrum-value-helper.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 CTTC
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Nicola Baldo <nbaldo@cttc.es>
19
*/
20
21
22
#include "
wifi-spectrum-value-helper.h
"
23
24
namespace
ns3 {
25
26
27
Ptr<SpectrumModel>
g_WifiSpectrumModel5Mhz
;
28
29
WifiSpectrumValueHelper::~WifiSpectrumValueHelper
()
30
{
31
}
32
33
WifiSpectrumValue5MhzFactory::~WifiSpectrumValue5MhzFactory
()
34
{
35
}
36
37
class
WifiSpectrumModel5MhzInitializer
38
{
39
public
:
40
WifiSpectrumModel5MhzInitializer
()
41
{
42
Bands
bands;
43
for
(
int
i = -4; i < 13 + 7; i++)
44
{
45
BandInfo
bi;
46
bi.
fl
= 2407.0e6 + i * 5.0e6;
47
bi.
fh
= 2407.0e6 + (i + 1) * 5.0e6;
48
bi.
fc
= (bi.
fl
+ bi.
fh
) / 2;
49
bands.push_back (bi);
50
}
51
g_WifiSpectrumModel5Mhz
= Create<SpectrumModel> (bands);
52
}
53
}
g_WifiSpectrumModel5MhzInitializerInstance
;
54
55
56
57
Ptr<SpectrumValue>
58
WifiSpectrumValue5MhzFactory::CreateConstant
(
double
v)
59
{
60
Ptr<SpectrumValue>
c = Create <SpectrumValue> (
g_WifiSpectrumModel5Mhz
);
61
(*c) = v;
62
return
c;
63
}
64
65
66
Ptr<SpectrumValue>
67
WifiSpectrumValue5MhzFactory::CreateTxPowerSpectralDensity
(
double
txPower, uint32_t channel)
68
{
69
Ptr<SpectrumValue>
txPsd = Create <SpectrumValue> (
g_WifiSpectrumModel5Mhz
);
70
71
// since the spectrum model has a resolution of 5 MHz, we model
72
// the transmitted signal with a constant density over a 20MHz
73
// bandwidth centered on the center frequency of the channel. The
74
// transmission power outside the transmission power density is
75
// calculated considering the transmit spectrum mask, see IEEE
76
// Std. 802.11-2007, Annex I
77
78
double
txPowerDensity = txPower / 20e6;
79
80
NS_ASSERT
(channel >= 1);
81
NS_ASSERT
(channel <= 13);
82
83
(*txPsd)[channel - 1] = txPowerDensity * 1e-4;
// -40dB
84
(*txPsd)[channel] = txPowerDensity * 1e-4;
// -40dB
85
(*txPsd)[channel + 1] = txPowerDensity * 0.0015849;
// -28dB
86
(*txPsd)[channel + 2] = txPowerDensity * 0.0015849;
// -28dB
87
(*txPsd)[channel + 3] = txPowerDensity;
88
(*txPsd)[channel + 4] = txPowerDensity;
89
(*txPsd)[channel + 5] = txPowerDensity;
90
(*txPsd)[channel + 6] = txPowerDensity;
91
(*txPsd)[channel + 7] = txPowerDensity * 0.0015849;
// -28dB
92
(*txPsd)[channel + 8] = txPowerDensity * 0.0015849;
// -28dB
93
(*txPsd)[channel + 9] = txPowerDensity * 1e-4;
// -40dB
94
(*txPsd)[channel + 10] = txPowerDensity * 1e-4;
// -40dB
95
96
return
txPsd;
97
}
98
99
100
Ptr<SpectrumValue>
101
WifiSpectrumValue5MhzFactory::CreateRfFilter
(uint32_t channel)
102
{
103
Ptr<SpectrumValue>
rf = Create <SpectrumValue> (
g_WifiSpectrumModel5Mhz
);
104
105
NS_ASSERT
(channel >= 1);
106
NS_ASSERT
(channel <= 13);
107
108
(*rf)[channel - 1] = 1;
109
(*rf)[channel ] = 1;
110
(*rf)[channel + 1] = 1;
111
(*rf)[channel + 2] = 1;
112
113
return
rf;
114
}
115
116
117
}
// namespace ns3
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
ns3::g_WifiSpectrumModel5MhzInitializerInstance
class ns3::WifiSpectrumModel5MhzInitializer g_WifiSpectrumModel5MhzInitializerInstance
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::Bands
std::vector< BandInfo > Bands
Definition:
spectrum-model.h:53
ns3::WifiSpectrumValue5MhzFactory::CreateTxPowerSpectralDensity
virtual Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double txPower, uint32_t channel)
Definition:
wifi-spectrum-value-helper.cc:67
ns3::BandInfo::fc
double fc
center frequency
Definition:
spectrum-model.h:48
ns3::WifiSpectrumValue5MhzFactory::~WifiSpectrumValue5MhzFactory
virtual ~WifiSpectrumValue5MhzFactory()
Definition:
wifi-spectrum-value-helper.cc:33
ns3::BandInfo::fl
double fl
lower limit of subband
Definition:
spectrum-model.h:47
ns3::WifiSpectrumValue5MhzFactory::CreateConstant
virtual Ptr< SpectrumValue > CreateConstant(double psd)
Definition:
wifi-spectrum-value-helper.cc:58
wifi-spectrum-value-helper.h
ns3::WifiSpectrumValue5MhzFactory::CreateRfFilter
virtual Ptr< SpectrumValue > CreateRfFilter(uint32_t channel)
Definition:
wifi-spectrum-value-helper.cc:101
ns3::WifiSpectrumModel5MhzInitializer::WifiSpectrumModel5MhzInitializer
WifiSpectrumModel5MhzInitializer()
Definition:
wifi-spectrum-value-helper.cc:40
ns3::WifiSpectrumValueHelper::~WifiSpectrumValueHelper
virtual ~WifiSpectrumValueHelper()
Definition:
wifi-spectrum-value-helper.cc:29
ns3::WifiSpectrumModel5MhzInitializer
Definition:
wifi-spectrum-value-helper.cc:37
ns3::BandInfo::fh
double fh
upper limit of subband
Definition:
spectrum-model.h:49
ns3::g_WifiSpectrumModel5Mhz
Ptr< SpectrumModel > g_WifiSpectrumModel5Mhz
Definition:
wifi-spectrum-value-helper.cc:27
ns3::BandInfo
The building block of a SpectrumModel.
Definition:
spectrum-model.h:45
src
spectrum
model
wifi-spectrum-value-helper.cc
Generated on Sat Apr 19 2014 14:07:08 for ns-3 by
1.8.6