View | Details | Raw Unified | Return to bug 2720
Collapse All | Expand All

(-)a/src/spectrum/model/wifi-spectrum-value-helper.cc (-211 / +327 lines)
 Lines 54-62    Link Here 
54
static std::map<WifiSpectrumModelId, Ptr<SpectrumModel> > g_wifiSpectrumModelMap;
54
static std::map<WifiSpectrumModelId, Ptr<SpectrumModel> > g_wifiSpectrumModelMap;
55
55
56
Ptr<SpectrumModel>
56
Ptr<SpectrumModel>
57
WifiSpectrumValueHelper::GetSpectrumModel (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth)
57
WifiSpectrumValueHelper::GetSpectrumModel (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth, uint32_t guardBandwidth)
58
{
58
{
59
  NS_LOG_FUNCTION (centerFrequency << channelWidth << bandBandwidth);
59
  NS_LOG_FUNCTION (centerFrequency << channelWidth << bandBandwidth << guardBandwidth);
60
  Ptr<SpectrumModel> ret;
60
  Ptr<SpectrumModel> ret;
61
  WifiSpectrumModelId key (centerFrequency, channelWidth);
61
  WifiSpectrumModelId key (centerFrequency, channelWidth);
62
  std::map<WifiSpectrumModelId, Ptr<SpectrumModel> >::iterator it = g_wifiSpectrumModelMap.find (key);
62
  std::map<WifiSpectrumModelId, Ptr<SpectrumModel> >::iterator it = g_wifiSpectrumModelMap.find (key);
 Lines 68-77    Link Here 
68
    {
68
    {
69
      Bands bands;
69
      Bands bands;
70
      double centerFrequencyHz = centerFrequency * 1e6;
70
      double centerFrequencyHz = centerFrequency * 1e6;
71
      // Overall bandwidth will be channelWidth plus 10 MHz guards on each side
71
      double bandwidth = (channelWidth + (2 * guardBandwidth)) * 1e6;
72
      double bandwidth = (channelWidth + 20) * 1e6;
73
      // For OFDM, the center subcarrier is null (at center frequency)
72
      // For OFDM, the center subcarrier is null (at center frequency)
74
      uint32_t numBands = static_cast<uint32_t> (bandwidth / bandBandwidth + 0.5);
73
      uint32_t numBands = static_cast<uint32_t> ((bandwidth / bandBandwidth) + 0.5);
75
      NS_ASSERT (numBands > 0);
74
      NS_ASSERT (numBands > 0);
76
      if (numBands % 2 == 0)
75
      if (numBands % 2 == 0)
77
        {
76
        {
 Lines 105-124    Link Here 
105
104
106
// Power allocated to 71 center subbands out of 135 total subbands in the band 
105
// Power allocated to 71 center subbands out of 135 total subbands in the band 
107
Ptr<SpectrumValue>
106
Ptr<SpectrumValue>
108
WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (uint32_t centerFrequency, double txPowerW)
107
WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (uint32_t centerFrequency, double txPowerW, uint32_t guardBandwidth)
109
{
108
{
110
  NS_LOG_FUNCTION (centerFrequency << txPowerW);
109
  NS_LOG_FUNCTION (centerFrequency << txPowerW << guardBandwidth);
111
  uint32_t channelWidth = 22;  // DSSS channels are 22 MHz wide
110
  uint32_t channelWidth = 22;  // DSSS channels are 22 MHz wide
112
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, 312500));
111
  double bandBandwidth = 312500;
112
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth));
113
  Values::iterator vit = c->ValuesBegin ();
113
  Values::iterator vit = c->ValuesBegin ();
114
  Bands::const_iterator bit = c->ConstBandsBegin ();
114
  Bands::const_iterator bit = c->ConstBandsBegin ();
115
  double txPowerPerBand;
115
  uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
116
  // Evenly spread power across 22 MHz (71 bands)
116
  uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
117
  NS_ASSERT (c->GetSpectrumModel ()->GetNumBands () == 135);
117
  NS_ASSERT (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1));
118
  txPowerPerBand = txPowerW / 71;
118
  // Evenly spread power across 22 MHz
119
  double txPowerPerBand = txPowerW / nAllocatedBands;
119
  for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
120
  for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
120
    {
121
    {
121
      if (i >= 32 && i <= 102)
122
      if ((i >= (nGuardBands / 2)) && (i <= ((nGuardBands / 2) + nAllocatedBands - 1)))
122
        {
123
        {
123
          *vit = txPowerPerBand / (bit->fh - bit->fl);
124
          *vit = txPowerPerBand / (bit->fh - bit->fl);
124
        }
125
        }
 Lines 127-195    Link Here 
127
}
128
}
128
129
129
Ptr<SpectrumValue>
130
Ptr<SpectrumValue>
130
WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW)
131
WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW, uint32_t guardBandwidth)
131
{
132
{
132
  NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW);
133
  NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW << guardBandwidth);
133
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, 312500));
134
  double bandBandwidth = 312500;
134
  Values::iterator vit = c->ValuesBegin ();
135
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth));
135
  Bands::const_iterator bit = c->ConstBandsBegin ();
136
  uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
136
  double txPowerPerBand;
137
  uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
138
  NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands");
139
  double txPowerPerBand = 0;
140
  uint32_t start1 = 0;
141
  uint32_t stop1 = 0;
142
  uint32_t start2 = 0;
143
  uint32_t stop2 = 0;
137
  switch (channelWidth)
144
  switch (channelWidth)
138
    {
145
    {
139
    case 20:
146
    case 20:
140
      // 52 subcarriers (48 data + 4 pilot)
147
      // 52 subcarriers (48 data + 4 pilot)
141
      // skip 38 subbands, then place power in 26 subbands, then
148
      // skip guard band and 6 subbands, then place power in 26 subbands, then
142
      // skip the center subband, then place power in 26 subbands, then skip
149
      // skip the center subband, then place power in 26 subbands, then skip
143
      // the final 38 subbands.  
150
      // the final 6 subbands and the guard band.
144
      NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 129, "Unexpected number of bands");
145
      txPowerPerBand = txPowerW / 52;
151
      txPowerPerBand = txPowerW / 52;
146
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
152
      start1 = (nGuardBands / 2) + 6;
147
        {
153
      stop1 = start1 + 26 - 1;
148
          if ((i >= 38 && i <= 63) || (i >= 65 && i <= 90))
154
      start2 = stop1 + 2;
149
            {
155
      stop2 = start2 + 26 - 1;
150
              *vit = txPowerPerBand / (bit->fh - bit->fl);
151
            }
152
          else
153
            {
154
              *vit = 0;
155
            }
156
        }
157
      NS_LOG_DEBUG ("Added signal power to subbands 38-63 and 65-90");
158
      NS_LOG_DEBUG ("Integrated power " << Integral (*c));
159
      NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); 
160
      break;
156
      break;
161
    case 10:
157
    case 10:
162
      // 28 subcarriers (24 data + 4 pilot)
158
      // 28 subcarriers (24 data + 4 pilot)
163
      // skip 34 subbands, then place power in 14 subbands, then
159
      // skip guard band and 2 subbands, then place power in 14 subbands, then
164
      // skip the center subband, then place power in 14 subbands, then skip
160
      // skip the center subband, then place power in 14 subbands, then skip
165
      // the final 34 subbands.  
161
      // the final 2 subbands and the guard band.
166
      NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 97, "Unexpected number of bands");
167
      txPowerPerBand = txPowerW / 28;
162
      txPowerPerBand = txPowerW / 28;
168
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
163
      start1 = (nGuardBands / 2) + 2;
169
        {
164
      stop1 = start1 + 14 - 1;
170
          if ((i >= 34 && i <= 47) || (i >= 49 && i <= 62))
165
      start2 = stop1 + 2;
171
            {
166
      stop2 = start2 + 14 - 1;
172
              *vit = txPowerPerBand / (bit->fh - bit->fl);
173
            }
174
          else
175
            {
176
              *vit = 0;
177
            }
178
        }
179
      NS_LOG_DEBUG ("Added signal power to subbands 34-47 and 49-62");
180
      NS_LOG_DEBUG ("Integrated power " << Integral (*c));
181
      NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); 
182
      break;
167
      break;
183
    case 5:
168
    case 5:
184
      // 16 subcarriers (12 data + 4 pilot)
169
      // 16 subcarriers (12 data + 4 pilot)
185
      // skip 34 subbands, then place power in 14 subbands, then
170
      // skip guard band and 2 subbands, then place power in 8 subbands, then
186
      // skip the center subband, then place power in 14 subbands, then skip
171
      // skip the center subband, then place power in 8 subbands, then skip
187
      // the final 34 subbands.  
172
      // the final 2 subbands and the guard.
188
      NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 81, "Unexpected number of bands");
189
      txPowerPerBand = txPowerW / 16;
173
      txPowerPerBand = txPowerW / 16;
174
      start1 = (nGuardBands / 2) + 2;
175
      stop1 = start1 + 8 - 1;
176
      start2 = stop1 + 2;
177
      stop2 = start2 + 8 - 1;
178
      break;
179
    default:
180
      NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported");
181
      break;
182
    }
183
  NS_LOG_DEBUG ("Power per band " << txPowerPerBand);
184
  Values::iterator vit = c->ValuesBegin ();
185
  Bands::const_iterator bit = c->ConstBandsBegin ();
186
  for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
187
    {
188
      if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2))
189
        {
190
          *vit = txPowerPerBand / (bit->fh - bit->fl);
191
        }
192
      else
193
        {
194
          *vit = 0;
195
        }
196
    }
197
  NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 << " and " << start2 << "-" << stop2);
198
  NS_LOG_DEBUG ("Integrated power " << Integral (*c));
199
  NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed");
200
  return c;
201
}
202
203
Ptr<SpectrumValue>
204
WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW, uint32_t guardBandwidth)
205
{
206
  NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW << guardBandwidth);
207
  double bandBandwidth = 312500;
208
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth));
209
  Values::iterator vit = c->ValuesBegin ();
210
  Bands::const_iterator bit = c->ConstBandsBegin ();
211
  uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
212
  uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
213
  NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands");
214
  double txPowerPerBand;
215
  // skip the guard band and 4 subbands, then place power in 28 subbands, then
216
  // skip the center subband, then place power in 28 subbands, then skip
217
  // the final 4 subbands and the guard band.
218
  // Repeat for each 20 MHz band.
219
  uint32_t start1 = (nGuardBands / 2) + 4;
220
  uint32_t stop1 = start1 + 28 - 1;
221
  uint32_t start2 = stop1 + 2;
222
  uint32_t stop2 = start2 + 28 - 1;
223
  uint32_t start3 = stop2 + (2 * 4);
224
  uint32_t stop3 = start3 + 28 - 1;
225
  uint32_t start4 = stop3 + 2;
226
  uint32_t stop4 = start4 + 28 - 1;
227
  uint32_t start5 = stop4 + (2 * 4);
228
  uint32_t stop5 = start5 + 28 - 1;
229
  uint32_t start6 = stop5 + 2;
230
  uint32_t stop6 = start6 + 28 - 1;
231
  uint32_t start7 = stop6 + (2 * 4);
232
  uint32_t stop7 = start7 + 28 - 1;
233
  uint32_t start8 = stop7 + 2;
234
  uint32_t stop8 = start8 + 28 - 1;
235
  uint32_t start9 = stop8 + (2 * 4);
236
  uint32_t stop9 = start9 + 28 - 1;
237
  uint32_t start10 = stop9 + 2;
238
  uint32_t stop10 = start10 + 28 - 1;
239
  uint32_t start11 = stop10 + (2 * 4);
240
  uint32_t stop11 = start11 + 28 - 1;
241
  uint32_t start12 = stop11 + 2;
242
  uint32_t stop12 = start12 + 28 - 1;
243
  uint32_t start13 = stop12 + (2 * 4);
244
  uint32_t stop13 = start13 + 28 - 1;
245
  uint32_t start14 = stop13 + 2;
246
  uint32_t stop14 = start14 + 28 - 1;
247
  uint32_t start15 = stop14 + (2 * 4);
248
  uint32_t stop15 = start15 + 28 - 1;
249
  uint32_t start16 = stop15 + 2;
250
  uint32_t stop16 = start16 + 28 - 1;
251
  switch (channelWidth)
252
    {
253
    case 20:
254
      // 56 subcarriers (52 data + 4 pilot)
255
      txPowerPerBand = txPowerW / 56;
256
      NS_LOG_DEBUG ("Power per band " << txPowerPerBand);
257
      start1 = (nGuardBands / 2) + 4;
258
      stop1 = start1 + 28 - 1;
259
      start2 = stop1 + 2;
260
      stop2 = start2 + 28 - 1;
190
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
261
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
191
        {
262
        {
192
          if ((i >= 32 && i <= 39) || (i >= 41 && i <= 48))
263
          if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2))
193
            {
264
            {
194
              *vit = txPowerPerBand / (bit->fh - bit->fl);
265
              *vit = txPowerPerBand / (bit->fh - bit->fl);
195
            }
266
            }
 Lines 198-399    Link Here 
198
              *vit = 0;
269
              *vit = 0;
199
            }
270
            }
200
        }
271
        }
201
      NS_LOG_DEBUG ("Added signal power to subbands 32-39 and 41-48");
272
      NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 <<
202
      NS_LOG_DEBUG ("Integrated power " << Integral (*c));
273
                    " and " << start2 << "-" << stop2);
203
      NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); 
274
      break;
275
    case 40:
276
      // 112 subcarriers (104 data + 8 pilot) 
277
      // possible alternative:  114 subcarriers (108 data + 6 pilot)
278
      txPowerPerBand = txPowerW / 112;
279
      NS_LOG_DEBUG ("Power per band " << txPowerPerBand);
280
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
281
        {
282
          if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2) ||
283
              (i >= start3 && i <= stop3) || (i >= start4 && i <= stop4))
284
            {
285
              *vit = txPowerPerBand / (bit->fh - bit->fl);
286
            }
287
          else
288
            {
289
              *vit = 0;
290
            }
291
        }
292
      NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 <<
293
                    ", " << start2 << "-" << stop2 <<
294
                    ", " << start3 << "-" << stop3 <<
295
                    ", " << start4 << "-" << stop4);
296
      break;
297
    case 80:
298
      // 224 subcarriers (208 data + 16 pilot) 
299
      // possible alternative:  242 subcarriers (234 data + 8 pilot)
300
      txPowerPerBand = txPowerW / 224;
301
      NS_LOG_DEBUG ("Power per band " << txPowerPerBand);
302
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
303
        {
304
          if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2) ||
305
              (i >= start3 && i <= stop3) || (i >= start4 && i <= stop4) ||
306
              (i >= start5 && i <= stop5) || (i >= start6 && i <= stop6) ||
307
              (i >= start7 && i <= stop7) || (i >= start8 && i <= stop8))
308
            {
309
              *vit = txPowerPerBand / (bit->fh - bit->fl);
310
            }
311
          else
312
            {
313
              *vit = 0;
314
            }
315
        }
316
      NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 <<
317
                    ", " << start2 << "-" << stop2 <<
318
                    ", " << start3 << "-" << stop3 <<
319
                    ", " << start4 << "-" << stop4 <<
320
                    ", " << start5 << "-" << stop5 <<
321
                    ", " << start6 << "-" << stop6 <<
322
                    ", " << start7 << "-" << stop7 <<
323
                    ", " << start8 << "-" << stop8);
324
      break;
325
    case 160:
326
      // 448 subcarriers (416 data + 32 pilot)
327
      // possible alternative:  484 subcarriers (468 data + 16 pilot)
328
      txPowerPerBand = txPowerW / 448;
329
      NS_LOG_DEBUG ("Power per band " << txPowerPerBand);
330
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
331
        {
332
          if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2) ||
333
              (i >= start3 && i <= stop3) || (i >= start4 && i <= stop4) ||
334
              (i >= start5 && i <= stop5) || (i >= start6 && i <= stop6) ||
335
              (i >= start7 && i <= stop7) || (i >= start8 && i <= stop8) ||
336
              (i >= start9 && i <= stop9) || (i >= start10 && i <= stop10) ||
337
              (i >= start11 && i <= stop11) || (i >= start12 && i <= stop12) ||
338
              (i >= start13 && i <= stop13) || (i >= start14 && i <= stop14) ||
339
              (i >= start15 && i <= stop15) || (i >= start16 && i <= stop16))
340
            {
341
              *vit = txPowerPerBand / (bit->fh - bit->fl);
342
            }
343
          else
344
            {
345
              *vit = 0;
346
            }
347
        }
348
      NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 <<
349
                    ", " << start2 << "-" << stop2 <<
350
                    ", " << start3 << "-" << stop3 <<
351
                    ", " << start4 << "-" << stop4 <<
352
                    ", " << start5 << "-" << stop5 <<
353
                    ", " << start6 << "-" << stop6 <<
354
                    ", " << start7 << "-" << stop7 <<
355
                    ", " << start8 << "-" << stop8 <<
356
                    ", " << start9 << "-" << stop9 <<
357
                    ", " << start10 << "-" << stop10 <<
358
                    ", " << start11 << "-" << stop11 <<
359
                    ", " << start12 << "-" << stop12 <<
360
                    ", " << start13 << "-" << stop13 <<
361
                    ", " << start14 << "-" << stop14 <<
362
                    ", " << start15 << "-" << stop15 <<
363
                    ", " << start16 << "-" << stop16);
204
      break;
364
      break;
205
    default:
365
    default:
206
      NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported");
366
      NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported");
207
      break;
367
      break;
208
    }
368
    }
369
  NS_LOG_DEBUG ("Integrated power " << Integral (*c));
370
  NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed");
209
  return c;
371
  return c;
210
}
372
}
211
373
212
Ptr<SpectrumValue>
374
Ptr<SpectrumValue>
213
WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW)
375
WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW, uint32_t guardBandwidth)
214
{
376
{
215
  NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW);
377
  NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW << guardBandwidth);
216
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, 312500));
378
  double bandBandwidth = 78125;
379
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth));
217
  Values::iterator vit = c->ValuesBegin ();
380
  Values::iterator vit = c->ValuesBegin ();
218
  Bands::const_iterator bit = c->ConstBandsBegin ();
381
  Bands::const_iterator bit = c->ConstBandsBegin ();
382
  uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
383
  uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
384
  NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands");
219
  double txPowerPerBand;
385
  double txPowerPerBand;
386
  uint32_t start1;
387
  uint32_t stop1;
388
  uint32_t start2;
389
  uint32_t stop2;
390
  uint32_t start3;
391
  uint32_t stop3;
392
  uint32_t start4;
393
  uint32_t stop4;
220
  switch (channelWidth)
394
  switch (channelWidth)
221
    {
395
    {
222
    case 20:
396
    case 20:
223
      // 56 subcarriers (52 data + 4 pilot) 
397
      // 242 subcarriers (234 data + 8 pilot)
224
      NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 129, "Unexpected number of bands");
398
      txPowerPerBand = txPowerW / 242;
225
      // skip 32 subbands, then place power in 28 of the next 32 subbands, then
399
      NS_LOG_DEBUG ("Power per band " << txPowerPerBand);
226
      // skip the center subband, then place power in 28 of the next 32
400
      // skip the guard band and 11 subbands, then place power in 121 subbands, then
227
      // subbands, then skip the final 32 subbands.  
401
      // skip 3 DC, then place power in 121 subbands, then skip
228
      txPowerPerBand = txPowerW / 56;
402
      // the final 11 subbands and the guard band.
403
      start1 = (nGuardBands / 2) + 12;
404
      stop1 = start1 + 121 - 1;
405
      start2 = stop1 + 4;
406
      stop2 = start2 + 121 - 1;
229
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
407
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
230
        {
408
        {
231
          if ((i >= 36 && i <= 63) || (i >= 65 && i <= 92))
409
          if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2))
232
            {
233
              *vit = txPowerPerBand / (bit->fh - bit->fl);
234
            }
235
        }
236
      NS_LOG_DEBUG ("Added signal power to subbands 36-63 and 65-92");
237
      NS_LOG_DEBUG ("Integrated power " << Integral (*c));
238
      NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); 
239
      break;
240
    case 40:
241
      // 112 subcarriers (104 data + 8 pilot) 
242
      // possible alternative:  114 subcarriers (108 data + 6 pilot)
243
      NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 193, "Unexpected number of bands");
244
      txPowerPerBand = txPowerW / 112;
245
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
246
        {
247
          if ((i >= 36 && i <= 63) || (i >= 65 && i <= 92) ||
248
              (i >= 100 && i<= 127) || (i >= 129 && i <= 156))
249
            {
410
            {
250
              *vit = txPowerPerBand / (bit->fh - bit->fl);
411
              *vit = txPowerPerBand / (bit->fh - bit->fl);
251
            }
412
            }
413
          else
414
            {
415
              *vit = 0;
416
            }
252
        }
417
        }
253
      NS_LOG_DEBUG ("Added signal power to subbands 36-63, 65-92, 100-127, and 129-156");
418
      NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 <<
254
      NS_LOG_DEBUG ("Integrated power " << Integral (*c));
419
                    " and " << start2 << "-" << stop2);
255
      NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); 
256
      break;
420
      break;
257
    case 80:
421
    case 40:
258
      // 224 subcarriers (208 data + 16 pilot) 
422
      // 484 subcarriers (468 data + 16 pilot)
259
      // possible alternative:  242 subcarriers (234 data + 8 pilot)
423
      txPowerPerBand = txPowerW / 484;
260
      NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 321, "Unexpected number of bands");
424
      NS_LOG_DEBUG ("Power per band " << txPowerPerBand);
261
      txPowerPerBand = txPowerW / 224;
425
      // skip the guard band and 11 subbands, then place power in 242 subbands, then
426
      // skip 5 DC, then place power in 242 subbands, then skip
427
      // the final 11 subbands and the guard band.
428
      start1 = (nGuardBands / 2) + 12;
429
      stop1 = start1 + 242 - 1;
430
      start2 = stop1 + 6;
431
      stop2 = start2 + 242 - 1;
262
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
432
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
263
        {
433
        {
264
          if ((i >= 36 && i <= 63) || (i >= 65 && i <= 92) || 
434
          if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2))
265
              (i >= 100 && i <= 127) || (i >= 129 && i <= 156) ||
266
              (i >= 164 && i <= 191) || (i >= 193 && i <= 220) ||
267
              (i >= 228 && i <= 255) || (i >= 257 && i <= 284))
268
            {
435
            {
269
              *vit = txPowerPerBand / (bit->fh - bit->fl);
436
              *vit = txPowerPerBand / (bit->fh - bit->fl);
270
            }
437
            }
438
          else
439
            {
440
              *vit = 0;
441
            }
271
        }
442
        }
272
      NS_LOG_DEBUG ("Added signal power to subbands 36-63, 65-92, 100-127, 129-156, 164-191, 193-220, 228-255, 257-284");
443
      NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 <<
273
      NS_LOG_DEBUG ("Integrated power " << Integral (*c));
444
                    " and " << start2 << "-" << stop2);
274
      NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); 
275
      break;
445
      break;
276
    case 160:
446
    case 80:
277
      // 448 subcarriers (416 data + 32 pilot)
447
      // 996 subcarriers (980 data + 16 pilot)
278
      // possible alternative:  484 subcarriers (468 data + 16 pilot)
448
      txPowerPerBand = txPowerW / 996;
279
      NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 577, "Unexpected number of bands");
449
      NS_LOG_DEBUG ("Power per band " << txPowerPerBand);
280
      txPowerPerBand = txPowerW / 448;
450
      // skip the guard band and 11 subbands, then place power in 498 subbands, then
451
      // skip 5 DC, then place power in 498 subbands, then skip
452
      // the final 11 subbands and the guard band.
453
      start1 = (nGuardBands / 2) + 12;
454
      stop1 = start1 + 498 - 1;
455
      start2 = stop1 + 6;
456
      stop2 = start2 + 498 - 1;
281
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
457
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
282
        {
458
        {
283
          if ((i >= 36 && i <= 63) || (i >= 65 && i <= 92) || 
459
          if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2))
284
              (i >= 100 && i <= 127) || (i >= 129 && i <= 156) ||
285
              (i >= 164 && i <= 191) || (i >= 193 && i <= 220) ||
286
              (i >= 228 && i <= 255) || (i >= 257 && i <= 284) ||
287
              (i >= 292 && i <= 319) || (i >= 321 && i <= 348) ||
288
              (i >= 356 && i <= 383) || (i >= 385 && i <= 412) ||
289
              (i >= 420 && i <= 447) || (i >= 449 && i <= 476) ||
290
              (i >= 484 && i <= 511) || (i >= 513 && i <= 540))
291
            {
460
            {
292
              *vit = txPowerPerBand / (bit->fh - bit->fl);
461
              *vit = txPowerPerBand / (bit->fh - bit->fl);
293
            }
462
            }
463
          else
464
            {
465
              *vit = 0;
466
            }
294
        }
467
        }
295
      NS_LOG_DEBUG ("Added signal power to subbands 36-63, 65-92, 100-127, 129-156, 164-191, 193-220, 228-255, 257-284, 292-319, 321-348, 356-383, 385-412, 420-447, 449-476, 484-511, and 513-540");
468
      NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 <<
296
      NS_LOG_DEBUG ("Integrated power " << Integral (*c));
469
                    " and " << start2 << "-" << stop2);
297
      NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); 
470
      break;
471
    case 160:
472
      // 2 x 996 subcarriers (2 x 80 MHZ bands)
473
      txPowerPerBand = txPowerW / (2 * 996);
474
      NS_LOG_DEBUG ("Power per band " << txPowerPerBand);
475
      start1 = (nGuardBands / 2) + 12;
476
      stop1 = start1 + 498 - 1;
477
      start2 = stop1 + 6;
478
      stop2 = start2 + 498 - 1;
479
      start3 = stop2 + (2 * 12);
480
      stop3 = start3 + 498 - 1;
481
      start4 = stop3 + 6;
482
      stop4 = start4 + 498 - 1;
483
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
484
        {
485
          if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2) ||
486
              (i >= start3 && i <= stop3) || (i >= start4 && i <= stop4))
487
            {
488
              *vit = txPowerPerBand / (bit->fh - bit->fl);
489
            }
490
          else
491
            {
492
              *vit = 0;
493
            }
494
        }
495
      NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 <<
496
                    ", " << start2 << "-" << stop2 <<
497
                    ", " << start3 << "-" << stop3 <<
498
                    ", " << start4 << "-" << stop4);
298
      break;
499
      break;
299
    default:
500
    default:
300
      NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported");
501
      NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported");
301
      break;
502
      break;
302
    }
503
    }
504
  NS_LOG_DEBUG ("Integrated power " << Integral (*c));
505
  NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed");
303
  return c;
506
  return c;
304
}
507
}
305
508
306
Ptr<SpectrumValue>
509
Ptr<SpectrumValue>
307
WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW)
510
WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth, double noiseFigure, uint32_t guardBandwidth)
308
{
511
{
309
  NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW);
512
  Ptr<SpectrumModel> model = GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth);
310
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, 78125));
311
  Values::iterator vit = c->ValuesBegin ();
312
  Bands::const_iterator bit = c->ConstBandsBegin ();
313
  double txPowerPerBand;
314
  switch (channelWidth)
315
    {
316
    case 20:
317
      // 242 subcarriers (234 data + 8 pilot)
318
      NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 513, "Unexpected number of bands");
319
      // skip 133 subbands, then place power in 121 subbands, then
320
      // skip 3 DC, then place power in 121 subbands, then skip
321
      // the final 133 subbands.
322
      txPowerPerBand = txPowerW / 242;
323
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
324
        {
325
          if ((i >= 134 && i <= 254) || (i >= 258 && i <= 378))
326
            {
327
              *vit = txPowerPerBand / (bit->fh - bit->fl);
328
            }
329
        }
330
      NS_LOG_DEBUG ("Added signal power to subbands 134-254 and 258-378");
331
      NS_LOG_DEBUG ("Integrated power " << Integral (*c));
332
      NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); 
333
      break;
334
    case 40:
335
      // 484 subcarriers (468 data + 16 pilot)
336
      NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 769, "Unexpected number of bands");
337
      // skip 139 subbands, then place power in 242 subbands, then
338
      // skip 5 DC, then place power in 242 subbands, then skip
339
      // the final 139 subbands.
340
      txPowerPerBand = txPowerW / 484;
341
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
342
        {
343
          if ((i >= 140 && i <= 381) || (i >= 387 && i <= 628))
344
            {
345
              *vit = txPowerPerBand / (bit->fh - bit->fl);
346
            }
347
        }
348
      NS_LOG_DEBUG ("Added signal power to subbands 140-381 and 387-628");
349
      NS_LOG_DEBUG ("Integrated power " << Integral (*c));
350
      NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); 
351
      break;
352
    case 80:
353
      // 996 subcarriers (980 data + 16 pilot)
354
      NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 1281, "Unexpected number of bands");
355
      // skip 139 subbands, then place power in 498 subbands, then
356
      // skip 5 DC, then place power in 498 subbands, then skip
357
      // the final 139 subbands.
358
      txPowerPerBand = txPowerW / 996;
359
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
360
        {
361
          if ((i >= 140 && i <= 637) || (i >= 643 && i <= 1140))
362
            {
363
              *vit = txPowerPerBand / (bit->fh - bit->fl);
364
            }
365
        }
366
      NS_LOG_DEBUG ("Added signal power to subbands 140-637 and 643-1140");
367
      NS_LOG_DEBUG ("Integrated power " << Integral (*c));
368
      NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); 
369
      break;
370
    case 160:
371
      // 2 x 996 subcarriers (2 x 80 MHZ bands)
372
      NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 2305, "Unexpected number of bands");
373
      txPowerPerBand = txPowerW / (2 * 996);
374
      for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++)
375
        {
376
          if ((i >= 140 && i <= 637) || (i >= 643 && i <= 1140) ||
377
              (i >= 1164 && i <= 1661) || (i >= 1667 && i <= 2164))
378
            {
379
              *vit = txPowerPerBand / (bit->fh - bit->fl);
380
            }
381
        }
382
      NS_LOG_DEBUG ("Added signal power to subbands 140-637, 643-1140, 1164-1661 and 1667-2164");
383
      NS_LOG_DEBUG ("Integrated power " << Integral (*c));
384
      NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); 
385
      break;
386
    default:
387
      NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported");
388
      break;
389
    }
390
  return c;
391
}
392
393
Ptr<SpectrumValue>
394
WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth, double noiseFigure)
395
{
396
  Ptr<SpectrumModel> model = GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth);
397
  return CreateNoisePowerSpectralDensity (noiseFigure, model);
513
  return CreateNoisePowerSpectralDensity (noiseFigure, model);
398
}
514
}
399
515
 Lines 416-425    Link Here 
416
}
532
}
417
533
418
Ptr<SpectrumValue>
534
Ptr<SpectrumValue>
419
WifiSpectrumValueHelper::CreateRfFilter (uint32_t centerFrequency, uint32_t channelWidth, double bandGranularity)
535
WifiSpectrumValueHelper::CreateRfFilter (uint32_t centerFrequency, uint32_t channelWidth, double bandGranularity, uint32_t guardBandwidth)
420
{
536
{
421
  NS_LOG_FUNCTION (centerFrequency << channelWidth << bandGranularity);
537
  NS_LOG_FUNCTION (centerFrequency << channelWidth << bandGranularity << guardBandwidth);
422
  Ptr<SpectrumValue> c = Create <SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandGranularity));
538
  Ptr<SpectrumValue> c = Create <SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandGranularity, guardBandwidth));
423
  size_t numBands = c->GetSpectrumModel ()->GetNumBands ();
539
  size_t numBands = c->GetSpectrumModel ()->GetNumBands ();
424
  Bands::const_iterator bit = c->ConstBandsBegin ();
540
  Bands::const_iterator bit = c->ConstBandsBegin ();
425
  Values::iterator vit = c->ValuesBegin ();
541
  Values::iterator vit = c->ValuesBegin ();
(-)a/src/spectrum/model/wifi-spectrum-value-helper.h (-20 / +30 lines)
 Lines 49-69    Link Here 
49
   * \param centerFrequency center frequency (MHz)
49
   * \param centerFrequency center frequency (MHz)
50
   * \param channelWidth channel width (MHz)
50
   * \param channelWidth channel width (MHz)
51
   * \param bandBandwidth width of each band (Hz)
51
   * \param bandBandwidth width of each band (Hz)
52
   * \param guardBandwidth width of the guard band (MHz)
53
   *
52
   * \return the static SpectrumModel instance corresponding to the
54
   * \return the static SpectrumModel instance corresponding to the
53
   * given carrier frequency and channel width configuration. 
55
   * given carrier frequency and channel width configuration. 
54
   */
56
   */
55
  static Ptr<SpectrumModel> GetSpectrumModel (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth);
57
  static Ptr<SpectrumModel> GetSpectrumModel (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth, uint32_t guardBandwidth);
58
59
  /**
60
   * Create a transmit power spectral density corresponding to DSSS 
61
   *
62
   * The center frequency typically corresponds to 802.11b channel 
63
   * center frequencies but is not restricted to those frequencies.
64
   *
65
   * \param centerFrequency center frequency (MHz)
66
   * \param txPowerW  transmit power (W) to allocate
67
   * \param guardBandwidth width of the guard band (MHz)
68
   */
69
  static Ptr<SpectrumValue> CreateDsssTxPowerSpectralDensity (uint32_t centerFrequency, double txPowerW, uint32_t guardBandwidth);
56
70
57
  /**
71
  /**
58
   * Create a transmit power spectral density corresponding to OFDM 
72
   * Create a transmit power spectral density corresponding to OFDM 
59
   * High Efficiency (HE) (802.11ax).  Channel width may vary between 
73
   * (802.11a/g).  Channel width may vary between 20, 10, and 5 MHz.
60
   * 20, 40, 80, and 160 MHz.
61
   *
74
   *
62
   * \param centerFrequency center frequency (MHz)
75
   * \param centerFrequency center frequency (MHz)
63
   * \param channelWidth channel width (MHz)
76
   * \param channelWidth channel width (MHz)
64
   * \param txPowerW  transmit power (W) to allocate
77
   * \param txPowerW  transmit power (W) to allocate
78
   * \param guardBandwidth width of the guard band (MHz)
65
   */
79
   */
66
  static Ptr<SpectrumValue> CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW);
80
  static Ptr<SpectrumValue> CreateOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW, uint32_t guardBandwidth);
67
81
68
  /**
82
  /**
69
   * Create a transmit power spectral density corresponding to OFDM 
83
   * Create a transmit power spectral density corresponding to OFDM 
 Lines 73-101    Link Here 
73
   * \param centerFrequency center frequency (MHz)
87
   * \param centerFrequency center frequency (MHz)
74
   * \param channelWidth channel width (MHz)
88
   * \param channelWidth channel width (MHz)
75
   * \param txPowerW  transmit power (W) to allocate
89
   * \param txPowerW  transmit power (W) to allocate
90
   * \param guardBandwidth width of the guard band (MHz)
76
   */
91
   */
77
  static Ptr<SpectrumValue> CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW);
92
  static Ptr<SpectrumValue> CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW, uint32_t guardBandwidth);
78
93
79
  /**
94
  /**
80
   * Create a transmit power spectral density corresponding to OFDM 
95
   * Create a transmit power spectral density corresponding to OFDM 
81
   * (802.11a/g).  Channel width may vary between 20, 10, and 5 MHz.
96
   * High Efficiency (HE) (802.11ax).  Channel width may vary between 
97
   * 20, 40, 80, and 160 MHz.
82
   *
98
   *
83
   * \param centerFrequency center frequency (MHz)
99
   * \param centerFrequency center frequency (MHz)
84
   * \param channelWidth channel width (MHz)
100
   * \param channelWidth channel width (MHz)
85
   * \param txPowerW  transmit power (W) to allocate
101
   * \param txPowerW  transmit power (W) to allocate
102
   * \param guardBandwidth width of the guard band (MHz)
86
   */
103
   */
87
  static Ptr<SpectrumValue> CreateOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW);
104
  static Ptr<SpectrumValue> CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW, uint32_t guardBandwidth);
88
89
  /**
90
   * Create a transmit power spectral density corresponding to DSSS 
91
   *
92
   * The center frequency typically corresponds to 802.11b channel 
93
   * center frequencies but is not restricted to those frequencies.
94
   *
95
   * \param centerFrequency center frequency (MHz)
96
   * \param txPowerW  transmit power (W) to allocate
97
   */
98
  static Ptr<SpectrumValue> CreateDsssTxPowerSpectralDensity (uint32_t centerFrequency, double txPowerW);
99
105
100
  /**
106
  /**
101
   *
107
   *
 Lines 103-111    Link Here 
103
   * \param channelWidth channel width (MHz)
109
   * \param channelWidth channel width (MHz)
104
   * \param bandBandwidth width of each band (Hz)
110
   * \param bandBandwidth width of each band (Hz)
105
   * \param noiseFigure the noise figure in dB w.r.t. a reference temperature of 290K
111
   * \param noiseFigure the noise figure in dB w.r.t. a reference temperature of 290K
112
   * \param guardBandwidth width of the guard band (MHz)
113
   *
106
   * \return a pointer to a newly allocated SpectrumValue representing the noise Power Spectral Density in W/Hz for each Band
114
   * \return a pointer to a newly allocated SpectrumValue representing the noise Power Spectral Density in W/Hz for each Band
107
   */
115
   */
108
  static Ptr<SpectrumValue> CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth, double noiseFigure);
116
  static Ptr<SpectrumValue> CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth, double noiseFigure, uint32_t guardBandwidth);
109
117
110
  /**
118
  /**
111
   * \param centerFrequency center frequency (MHz)
119
   * \param centerFrequency center frequency (MHz)
 Lines 118-127    Link Here 
118
   * \param centerFrequency center frequency (MHz)
126
   * \param centerFrequency center frequency (MHz)
119
   * \param channelWidth channel width (MHz)
127
   * \param channelWidth channel width (MHz)
120
   * \param bandGranularity band granularity (Hz)
128
   * \param bandGranularity band granularity (Hz)
129
   * \param guardBandwidth width of the guard band (MHz)
130
   *
121
   * \return a pointer to a SpectrumValue representing the RF filter applied
131
   * \return a pointer to a SpectrumValue representing the RF filter applied
122
   * to an received power spectral density
132
   * to an received power spectral density
123
   */
133
   */
124
  static Ptr<SpectrumValue> CreateRfFilter (uint32_t centerFrequency, uint32_t channelWidth, double bandGranularity);
134
  static Ptr<SpectrumValue> CreateRfFilter (uint32_t centerFrequency, uint32_t channelWidth, double bandGranularity, uint32_t guardBandwidth);
125
};
135
};
126
136
127
/**
137
/**
(-)a/src/wifi/model/spectrum-wifi-phy.cc (-7 / +34 lines)
 Lines 107-113    Link Here 
107
      else
107
      else
108
        {
108
        {
109
          NS_LOG_DEBUG ("Creating spectrum model from frequency/width pair of (" << GetFrequency () << ", " << (uint16_t)GetChannelWidth () << ")");
109
          NS_LOG_DEBUG ("Creating spectrum model from frequency/width pair of (" << GetFrequency () << ", " << (uint16_t)GetChannelWidth () << ")");
110
          m_rxSpectrumModel = WifiSpectrumValueHelper::GetSpectrumModel (GetFrequency (), GetChannelWidth (), GetBandBandwidth ());
110
          m_rxSpectrumModel = WifiSpectrumValueHelper::GetSpectrumModel (GetFrequency (), GetChannelWidth (), GetBandBandwidth (), GetGuardBandwidth ());
111
        }
111
        }
112
    }
112
    }
113
  return m_rxSpectrumModel;
113
  return m_rxSpectrumModel;
 Lines 168-174    Link Here 
168
  // Integrate over our receive bandwidth (i.e., all that the receive
168
  // Integrate over our receive bandwidth (i.e., all that the receive
169
  // spectral mask representing our filtering allows) to find the
169
  // spectral mask representing our filtering allows) to find the
170
  // total energy apparent to the "demodulator".
170
  // total energy apparent to the "demodulator".
171
  Ptr<SpectrumValue> filter = WifiSpectrumValueHelper::CreateRfFilter (GetFrequency (), GetChannelWidth (), GetBandBandwidth ());
171
  Ptr<SpectrumValue> filter = WifiSpectrumValueHelper::CreateRfFilter (GetFrequency (), GetChannelWidth (), GetBandBandwidth (), GetGuardBandwidth ());
172
  SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
172
  SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
173
  // Add receiver antenna gain
173
  // Add receiver antenna gain
174
  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain: " << Integral (filteredSignal));
174
  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain: " << Integral (filteredSignal));
 Lines 239-257    Link Here 
239
    case WIFI_PHY_STANDARD_holland:
239
    case WIFI_PHY_STANDARD_holland:
240
    case WIFI_PHY_STANDARD_80211_10MHZ:
240
    case WIFI_PHY_STANDARD_80211_10MHZ:
241
    case WIFI_PHY_STANDARD_80211_5MHZ:
241
    case WIFI_PHY_STANDARD_80211_5MHZ:
242
      v = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW);
242
      v = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth ());
243
      break;
243
      break;
244
    case WIFI_PHY_STANDARD_80211b:
244
    case WIFI_PHY_STANDARD_80211b:
245
      v = WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (centerFrequency, txPowerW);
245
      v = WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (centerFrequency, txPowerW, GetGuardBandwidth ());
246
      break;
246
      break;
247
    case WIFI_PHY_STANDARD_80211n_2_4GHZ:
247
    case WIFI_PHY_STANDARD_80211n_2_4GHZ:
248
    case WIFI_PHY_STANDARD_80211n_5GHZ:
248
    case WIFI_PHY_STANDARD_80211n_5GHZ:
249
    case WIFI_PHY_STANDARD_80211ac:
249
    case WIFI_PHY_STANDARD_80211ac:
250
      v = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW);
250
      v = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth ());
251
      break;
251
      break;
252
    case WIFI_PHY_STANDARD_80211ax_2_4GHZ:
252
    case WIFI_PHY_STANDARD_80211ax_2_4GHZ:
253
    case WIFI_PHY_STANDARD_80211ax_5GHZ:
253
    case WIFI_PHY_STANDARD_80211ax_5GHZ:
254
      v = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW);
254
      v = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth ());
255
      break;
255
      break;
256
    default:
256
    default:
257
      NS_FATAL_ERROR ("Standard unknown: " << GetStandard ());
257
      NS_FATAL_ERROR ("Standard unknown: " << GetStandard ());
 Lines 305-311    Link Here 
305
      NS_FATAL_ERROR ("Standard unknown: " << GetStandard ());
305
      NS_FATAL_ERROR ("Standard unknown: " << GetStandard ());
306
      break;
306
      break;
307
    }
307
    }
308
  return bandBandwidth ;
308
  return bandBandwidth;
309
}
310
311
uint32_t
312
SpectrumWifiPhy::GetGuardBandwidth (void) const
313
{
314
  double guardBandwidth = 0;
315
  switch (GetStandard ())
316
    {
317
    case WIFI_PHY_STANDARD_80211a:
318
    case WIFI_PHY_STANDARD_80211g:
319
    case WIFI_PHY_STANDARD_holland:
320
    case WIFI_PHY_STANDARD_80211_10MHZ:
321
    case WIFI_PHY_STANDARD_80211_5MHZ:
322
    case WIFI_PHY_STANDARD_80211b:
323
    case WIFI_PHY_STANDARD_80211n_2_4GHZ:
324
    case WIFI_PHY_STANDARD_80211n_5GHZ:
325
    case WIFI_PHY_STANDARD_80211ac:
326
    case WIFI_PHY_STANDARD_80211ax_2_4GHZ:
327
    case WIFI_PHY_STANDARD_80211ax_5GHZ:
328
      // Use 10 MHZ
329
      guardBandwidth = 10;
330
      break;
331
    default:
332
      NS_FATAL_ERROR ("Standard unknown: " << GetStandard ());
333
      break;
334
    }
335
  return guardBandwidth;
309
}
336
}
310
337
311
} //namespace ns3
338
} //namespace ns3
(-)a/src/wifi/model/spectrum-wifi-phy.h (+5 lines)
 Lines 144-149    Link Here 
144
  double GetBandBandwidth (void) const;
144
  double GetBandBandwidth (void) const;
145
145
146
  /**
146
  /**
147
   * \return the width of the guard band (MHz)
148
   */
149
  uint32_t GetGuardBandwidth (void) const;
150
151
  /**
147
   * Callback invoked when the Phy model starts to process a signal
152
   * Callback invoked when the Phy model starts to process a signal
148
   *
153
   *
149
   * \param signalType Whether signal is WiFi (true) or foreign (false)
154
   * \param signalType Whether signal is WiFi (true) or foreign (false)
(-)a/src/wifi/test/spectrum-wifi-phy-test.cc (-1 / +2 lines)
 Lines 31-36    Link Here 
31
static const uint16_t CHANNEL_NUMBER = 36;
31
static const uint16_t CHANNEL_NUMBER = 36;
32
static const uint32_t FREQUENCY = 5180; // MHz
32
static const uint32_t FREQUENCY = 5180; // MHz
33
static const uint32_t CHANNEL_WIDTH = 20; // MHz
33
static const uint32_t CHANNEL_WIDTH = 20; // MHz
34
static const uint32_t GUARD_WIDTH = 10; // MHz
34
35
35
/**
36
/**
36
 * \ingroup wifi-test
37
 * \ingroup wifi-test
 Lines 114-120    Link Here 
114
  pkt->AddTrailer (trailer);
115
  pkt->AddTrailer (trailer);
115
  WifiPhyTag tag (txVector, mpdutype);
116
  WifiPhyTag tag (txVector, mpdutype);
116
  pkt->AddPacketTag (tag);
117
  pkt->AddPacketTag (tag);
117
  Ptr<SpectrumValue> txPowerSpectrum = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (FREQUENCY, CHANNEL_WIDTH, txPowerWatts);
118
  Ptr<SpectrumValue> txPowerSpectrum = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (FREQUENCY, CHANNEL_WIDTH, txPowerWatts, GUARD_WIDTH);
118
  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
119
  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
119
  txParams->psd = txPowerSpectrum;
120
  txParams->psd = txPowerSpectrum;
120
  txParams->txPhy = 0;
121
  txParams->txPhy = 0;

Return to bug 2720