A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
wifi-spectrum-value-helper.cc
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 
38 {
39 public:
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 
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
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_ASSERT(condition)
Definition: assert.h:64
double fc
center frequency
double fl
lower limit of subband
double fh
upper limit of subband