A Discrete-Event Network Simulator
API
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 
23 
24 namespace ns3 {
25 
28 
30 {
31 }
32 
34 {
35 }
36 
41 {
42 public:
44  {
45  Bands bands;
46  for (int i = -4; i < 13 + 7; i++)
47  {
48  BandInfo bi;
49  bi.fl = 2407.0e6 + i * 5.0e6;
50  bi.fh = 2407.0e6 + (i + 1) * 5.0e6;
51  bi.fc = (bi.fl + bi.fh) / 2;
52  bands.push_back (bi);
53  }
54  g_WifiSpectrumModel5Mhz = Create<SpectrumModel> (bands);
55  }
57 
58 
59 
60 Ptr<SpectrumValue>
62 {
63  Ptr<SpectrumValue> c = Create <SpectrumValue> (g_WifiSpectrumModel5Mhz);
64  (*c) = v;
65  return c;
66 }
67 
68 
71 {
72  Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (g_WifiSpectrumModel5Mhz);
73 
74  // since the spectrum model has a resolution of 5 MHz, we model
75  // the transmitted signal with a constant density over a 20MHz
76  // bandwidth centered on the center frequency of the channel. The
77  // transmission power outside the transmission power density is
78  // calculated considering the transmit spectrum mask, see IEEE
79  // Std. 802.11-2007, Annex I
80 
81  double txPowerDensity = txPower / 20e6;
82 
83  NS_ASSERT (channel >= 1);
84  NS_ASSERT (channel <= 13);
85 
86  (*txPsd)[channel - 1] = txPowerDensity * 1e-4; // -40dB
87  (*txPsd)[channel] = txPowerDensity * 1e-4; // -40dB
88  (*txPsd)[channel + 1] = txPowerDensity * 0.0015849; // -28dB
89  (*txPsd)[channel + 2] = txPowerDensity * 0.0015849; // -28dB
90  (*txPsd)[channel + 3] = txPowerDensity;
91  (*txPsd)[channel + 4] = txPowerDensity;
92  (*txPsd)[channel + 5] = txPowerDensity;
93  (*txPsd)[channel + 6] = txPowerDensity;
94  (*txPsd)[channel + 7] = txPowerDensity * 0.0015849; // -28dB
95  (*txPsd)[channel + 8] = txPowerDensity * 0.0015849; // -28dB
96  (*txPsd)[channel + 9] = txPowerDensity * 1e-4; // -40dB
97  (*txPsd)[channel + 10] = txPowerDensity * 1e-4; // -40dB
98 
99  return txPsd;
100 }
101 
102 
105 {
106  Ptr<SpectrumValue> rf = Create <SpectrumValue> (g_WifiSpectrumModel5Mhz);
107 
108  NS_ASSERT (channel >= 1);
109  NS_ASSERT (channel <= 13);
110 
111  (*rf)[channel + 3] = 1;
112  (*rf)[channel + 4] = 1;
113  (*rf)[channel + 5] = 1;
114  (*rf)[channel + 6] = 1;
115 
116  return rf;
117 }
118 
119 
120 } // namespace ns3
tuple channel
Definition: third.py:85
static class ns3::WifiSpectrumModel5MhzInitializer g_WifiSpectrumModel5MhzInitializerInstance
initialization instance for WifiSpectrumModel5Mhz
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
std::vector< BandInfo > Bands
Container of BandInfo.
virtual Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double txPower, uint32_t channel)
Creates a SpectrumValue instance which represents the TX Power Spectral Density of a wifi device corr...
double fc
center frequency
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double fl
lower limit of subband
virtual Ptr< SpectrumValue > CreateConstant(double psd)
Creates a SpectrumValue instance which has a constant value for all frequencies.
virtual Ptr< SpectrumValue > CreateRfFilter(uint32_t channel)
Creates a pectrumValue instance which represents the frequency response of the RF filter which is use...
Static class to initialize the values for the Wi-Fi spectrum model.
double fh
upper limit of subband
static Ptr< SpectrumModel > g_WifiSpectrumModel5Mhz
The Wi-Fi spectrum model.
The building block of a SpectrumModel.