|
|
| 103 |
return ret; |
103 |
return ret; |
| 104 |
} |
104 |
} |
| 105 |
|
105 |
|
|
|
106 |
// Power allocated to 71 center subbands out of 135 total subbands in the band |
| 107 |
Ptr<SpectrumValue> |
| 108 |
WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (uint32_t centerFrequency, double txPowerW) |
| 109 |
{ |
| 110 |
NS_LOG_FUNCTION (centerFrequency << txPowerW); |
| 111 |
uint32_t channelWidth = 22; // DSSS channels are 22 MHz wide |
| 112 |
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, 312500)); |
| 113 |
Values::iterator vit = c->ValuesBegin (); |
| 114 |
Bands::const_iterator bit = c->ConstBandsBegin (); |
| 115 |
double txPowerPerBand; |
| 116 |
// Evenly spread power across 22 MHz (71 bands) |
| 117 |
NS_ASSERT (c->GetSpectrumModel ()->GetNumBands () == 135); |
| 118 |
txPowerPerBand = txPowerW / 71; |
| 119 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
| 120 |
{ |
| 121 |
if (i >= 32 && i <= 102) |
| 122 |
{ |
| 123 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
| 124 |
} |
| 125 |
} |
| 126 |
return c; |
| 127 |
} |
| 128 |
|
| 129 |
Ptr<SpectrumValue> |
| 130 |
WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW) |
| 131 |
{ |
| 132 |
NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW); |
| 133 |
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, 312500)); |
| 134 |
Values::iterator vit = c->ValuesBegin (); |
| 135 |
Bands::const_iterator bit = c->ConstBandsBegin (); |
| 136 |
double txPowerPerBand; |
| 137 |
switch (channelWidth) |
| 138 |
{ |
| 139 |
case 20: |
| 140 |
// 52 subcarriers (48 data + 4 pilot) |
| 141 |
// skip 38 subbands, then place power in 26 subbands, then |
| 142 |
// skip the center subband, then place power in 26 subbands, then skip |
| 143 |
// the final 38 subbands. |
| 144 |
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 129, "Unexpected number of bands"); |
| 145 |
txPowerPerBand = txPowerW / 52; |
| 146 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
| 147 |
{ |
| 148 |
if ((i >= 38 && i <= 63) || (i >= 65 && i <= 90)) |
| 149 |
{ |
| 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; |
| 161 |
case 10: |
| 162 |
// 28 subcarriers (24 data + 4 pilot) |
| 163 |
// skip 34 subbands, then place power in 14 subbands, then |
| 164 |
// skip the center subband, then place power in 14 subbands, then skip |
| 165 |
// the final 34 subbands. |
| 166 |
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 97, "Unexpected number of bands"); |
| 167 |
txPowerPerBand = txPowerW / 28; |
| 168 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
| 169 |
{ |
| 170 |
if ((i >= 34 && i <= 47) || (i >= 49 && i <= 62)) |
| 171 |
{ |
| 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; |
| 183 |
case 5: |
| 184 |
// 16 subcarriers (12 data + 4 pilot) |
| 185 |
// skip 34 subbands, then place power in 14 subbands, then |
| 186 |
// skip the center subband, then place power in 14 subbands, then skip |
| 187 |
// the final 34 subbands. |
| 188 |
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 81, "Unexpected number of bands"); |
| 189 |
txPowerPerBand = txPowerW / 16; |
| 190 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
| 191 |
{ |
| 192 |
if ((i >= 32 && i <= 39) || (i >= 41 && i <= 48)) |
| 193 |
{ |
| 194 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
| 195 |
} |
| 196 |
else |
| 197 |
{ |
| 198 |
*vit = 0; |
| 199 |
} |
| 200 |
} |
| 201 |
NS_LOG_DEBUG ("Added signal power to subbands 32-39 and 41-48"); |
| 202 |
NS_LOG_DEBUG ("Integrated power " << Integral (*c)); |
| 203 |
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); |
| 204 |
break; |
| 205 |
default: |
| 206 |
NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported"); |
| 207 |
break; |
| 208 |
} |
| 209 |
return c; |
| 210 |
} |
| 211 |
|
| 106 |
Ptr<SpectrumValue> |
212 |
Ptr<SpectrumValue> |
| 107 |
WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW) |
213 |
WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW) |
| 108 |
{ |
214 |
{ |
|
|
| 122 |
txPowerPerBand = txPowerW / 56; |
228 |
txPowerPerBand = txPowerW / 56; |
| 123 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
229 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
| 124 |
{ |
230 |
{ |
| 125 |
if ((i >=36 && i <=63) || (i >=65 && i <=92)) |
231 |
if ((i >= 36 && i <= 63) || (i >= 65 && i <= 92)) |
| 126 |
{ |
232 |
{ |
| 127 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
233 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
| 128 |
} |
234 |
} |
|
|
| 138 |
txPowerPerBand = txPowerW / 112; |
244 |
txPowerPerBand = txPowerW / 112; |
| 139 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
245 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
| 140 |
{ |
246 |
{ |
| 141 |
if ((i >=36 && i <=63) || (i >=65 && i <=92) || (i >=100 && i<=127) || (i >=129 && i<= 156)) |
247 |
if ((i >= 36 && i <= 63) || (i >= 65 && i <= 92) || |
|
|
248 |
(i >= 100 && i<= 127) || (i >= 129 && i <= 156)) |
| 142 |
{ |
249 |
{ |
| 143 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
250 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
| 144 |
} |
251 |
} |
|
|
| 167 |
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); |
274 |
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); |
| 168 |
break; |
275 |
break; |
| 169 |
case 160: |
276 |
case 160: |
| 170 |
// 448 subcarriers (416 data + 32 pilot) VHT |
277 |
// 448 subcarriers (416 data + 32 pilot) |
| 171 |
// possible alternative: 484 subcarriers (468 data + 16 pilot) |
278 |
// possible alternative: 484 subcarriers (468 data + 16 pilot) |
| 172 |
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 577, "Unexpected number of bands"); |
279 |
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 577, "Unexpected number of bands"); |
| 173 |
txPowerPerBand = txPowerW / 448; |
280 |
txPowerPerBand = txPowerW / 448; |
|
|
| 197 |
} |
304 |
} |
| 198 |
|
305 |
|
| 199 |
Ptr<SpectrumValue> |
306 |
Ptr<SpectrumValue> |
| 200 |
WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW) |
307 |
WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW) |
| 201 |
{ |
308 |
{ |
| 202 |
NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW); |
309 |
NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW); |
| 203 |
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, 312500)); |
310 |
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, 78125)); |
| 204 |
Values::iterator vit = c->ValuesBegin (); |
311 |
Values::iterator vit = c->ValuesBegin (); |
| 205 |
Bands::const_iterator bit = c->ConstBandsBegin (); |
312 |
Bands::const_iterator bit = c->ConstBandsBegin (); |
| 206 |
double txPowerPerBand; |
313 |
double txPowerPerBand; |
| 207 |
switch (channelWidth) |
314 |
switch (channelWidth) |
| 208 |
{ |
315 |
{ |
| 209 |
case 20: |
316 |
case 20: |
| 210 |
// 52 subcarriers (48 data + 4 pilot) |
317 |
// 242 subcarriers (234 data + 8 pilot) |
| 211 |
// skip 38 subbands, then place power in 26 subbands, then |
318 |
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 513, "Unexpected number of bands"); |
| 212 |
// skip the center subband, then place power in 26 subbands, then skip |
319 |
// skip 133 subbands, then place power in 121 subbands, then |
| 213 |
// the final 38 subbands. |
320 |
// skip 3 DC, then place power in 121 subbands, then skip |
| 214 |
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 129, "Unexpected number of bands"); |
321 |
// the final 133 subbands. |
| 215 |
txPowerPerBand = txPowerW / 52; |
322 |
txPowerPerBand = txPowerW / 242; |
| 216 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
323 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
| 217 |
{ |
324 |
{ |
| 218 |
if ((i >=38 && i <=63) || (i >=65 && i <=90)) |
325 |
if ((i >= 134 && i <= 254) || (i >= 258 && i <= 378)) |
| 219 |
{ |
326 |
{ |
| 220 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
327 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
| 221 |
} |
328 |
} |
| 222 |
else |
|
|
| 223 |
{ |
| 224 |
*vit = 0; |
| 225 |
} |
| 226 |
} |
329 |
} |
| 227 |
NS_LOG_DEBUG ("Added signal power to subbands 38-63 and 65-90"); |
330 |
NS_LOG_DEBUG ("Added signal power to subbands 134-254 and 258-378"); |
| 228 |
NS_LOG_DEBUG ("Integrated power " << Integral (*c)); |
331 |
NS_LOG_DEBUG ("Integrated power " << Integral (*c)); |
| 229 |
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); |
332 |
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); |
| 230 |
break; |
333 |
break; |
| 231 |
case 10: |
334 |
case 40: |
| 232 |
// 28 subcarriers (24 data + 4 pilot) |
335 |
// 484 subcarriers (468 data + 16 pilot) |
| 233 |
// skip 34 subbands, then place power in 14 subbands, then |
336 |
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 769, "Unexpected number of bands"); |
| 234 |
// skip the center subband, then place power in 14 subbands, then skip |
337 |
// skip 139 subbands, then place power in 242 subbands, then |
| 235 |
// the final 34 subbands. |
338 |
// skip 5 DC, then place power in 242 subbands, then skip |
| 236 |
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 97, "Unexpected number of bands"); |
339 |
// the final 139 subbands. |
| 237 |
txPowerPerBand = txPowerW / 28; |
340 |
txPowerPerBand = txPowerW / 484; |
| 238 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
341 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
| 239 |
{ |
342 |
{ |
| 240 |
if ((i >=34 && i <=47) || (i >=49 && i <=62)) |
343 |
if ((i >= 140 && i <= 381) || (i >= 387 && i <= 628)) |
| 241 |
{ |
344 |
{ |
| 242 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
345 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
| 243 |
} |
346 |
} |
| 244 |
else |
|
|
| 245 |
{ |
| 246 |
*vit = 0; |
| 247 |
} |
| 248 |
} |
347 |
} |
| 249 |
NS_LOG_DEBUG ("Added signal power to subbands 34-47 and 49-62"); |
348 |
NS_LOG_DEBUG ("Added signal power to subbands 140-381 and 387-628"); |
| 250 |
NS_LOG_DEBUG ("Integrated power " << Integral (*c)); |
349 |
NS_LOG_DEBUG ("Integrated power " << Integral (*c)); |
| 251 |
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); |
350 |
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); |
| 252 |
break; |
351 |
break; |
| 253 |
case 5: |
352 |
case 80: |
| 254 |
// 16 subcarriers (12 data + 4 pilot) |
353 |
// 996 subcarriers (980 data + 16 pilot) |
| 255 |
// skip 34 subbands, then place power in 14 subbands, then |
354 |
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 1281, "Unexpected number of bands"); |
| 256 |
// skip the center subband, then place power in 14 subbands, then skip |
355 |
// skip 139 subbands, then place power in 498 subbands, then |
| 257 |
// the final 34 subbands. |
356 |
// skip 5 DC, then place power in 498 subbands, then skip |
| 258 |
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == 81, "Unexpected number of bands"); |
357 |
// the final 139 subbands. |
| 259 |
txPowerPerBand = txPowerW / 16; |
358 |
txPowerPerBand = txPowerW / 996; |
| 260 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
359 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
| 261 |
{ |
360 |
{ |
| 262 |
if ((i >=32 && i <=39) || (i >=41 && i <=48)) |
361 |
if ((i >= 140 && i <= 637) || (i >= 643 && i <= 1140)) |
| 263 |
{ |
362 |
{ |
| 264 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
363 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
| 265 |
} |
364 |
} |
| 266 |
else |
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)) |
| 267 |
{ |
378 |
{ |
| 268 |
*vit = 0; |
379 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
| 269 |
} |
380 |
} |
| 270 |
} |
381 |
} |
| 271 |
NS_LOG_DEBUG ("Added signal power to subbands 32-39 and 41-48"); |
382 |
NS_LOG_DEBUG ("Added signal power to subbands 140-637, 643-1140, 1164-1661 and 1667-2164"); |
| 272 |
NS_LOG_DEBUG ("Integrated power " << Integral (*c)); |
383 |
NS_LOG_DEBUG ("Integrated power " << Integral (*c)); |
| 273 |
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); |
384 |
NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed"); |
| 274 |
break; |
385 |
break; |
|
|
| 279 |
return c; |
390 |
return c; |
| 280 |
} |
391 |
} |
| 281 |
|
392 |
|
| 282 |
// Power allocated to 71 center subbands out of 135 total subbands in the band |
|
|
| 283 |
Ptr<SpectrumValue> |
| 284 |
WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (uint32_t centerFrequency, double txPowerW) |
| 285 |
{ |
| 286 |
NS_LOG_FUNCTION (centerFrequency << txPowerW); |
| 287 |
uint32_t channelWidth = 22; // DSSS channels are 22 MHz wide |
| 288 |
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, 312500)); |
| 289 |
Values::iterator vit = c->ValuesBegin (); |
| 290 |
Bands::const_iterator bit = c->ConstBandsBegin (); |
| 291 |
double txPowerPerBand; |
| 292 |
// Evenly spread power across 22 MHz (71 bands) |
| 293 |
NS_ASSERT (c->GetSpectrumModel ()->GetNumBands () == 135); |
| 294 |
txPowerPerBand = txPowerW / 71; |
| 295 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
| 296 |
{ |
| 297 |
if (i >=32 && i <=102) |
| 298 |
{ |
| 299 |
*vit = txPowerPerBand / (bit->fh - bit->fl); |
| 300 |
} |
| 301 |
} |
| 302 |
return c; |
| 303 |
} |
| 304 |
|
| 305 |
Ptr<SpectrumValue> |
393 |
Ptr<SpectrumValue> |
| 306 |
WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth, double noiseFigure) |
394 |
WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth, double noiseFigure) |
| 307 |
{ |
395 |
{ |