|
|
| 74 |
static std::map<WifiSpectrumModelId, Ptr<SpectrumModel> > g_wifiSpectrumModelMap; ///< static initializer for the class |
74 |
static std::map<WifiSpectrumModelId, Ptr<SpectrumModel> > g_wifiSpectrumModelMap; ///< static initializer for the class |
| 75 |
|
75 |
|
| 76 |
Ptr<SpectrumModel> |
76 |
Ptr<SpectrumModel> |
| 77 |
WifiSpectrumValueHelper::GetSpectrumModel (uint32_t centerFrequency, uint8_t channelWidth, double bandBandwidth, uint8_t guardBandwidth) |
77 |
WifiSpectrumValueHelper::GetSpectrumModel (uint32_t centerFrequency, uint8_t channelWidth, double bandBandwidth, double guardBandwidth) |
| 78 |
{ |
78 |
{ |
| 79 |
NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << bandBandwidth << (uint16_t)guardBandwidth); |
79 |
NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << bandBandwidth << guardBandwidth); |
| 80 |
Ptr<SpectrumModel> ret; |
80 |
Ptr<SpectrumModel> ret; |
| 81 |
WifiSpectrumModelId key (centerFrequency, channelWidth, bandBandwidth); |
81 |
WifiSpectrumModelId key (centerFrequency, channelWidth, bandBandwidth); |
| 82 |
std::map<WifiSpectrumModelId, Ptr<SpectrumModel> >::iterator it = g_wifiSpectrumModelMap.find (key); |
82 |
std::map<WifiSpectrumModelId, Ptr<SpectrumModel> >::iterator it = g_wifiSpectrumModelMap.find (key); |
|
|
| 96 |
{ |
96 |
{ |
| 97 |
// round up to the nearest odd number of subbands so that bands |
97 |
// round up to the nearest odd number of subbands so that bands |
| 98 |
// are symmetric around center frequency |
98 |
// are symmetric around center frequency |
| 99 |
NS_LOG_DEBUG ("Total bandwidth evenly divided by 312.5 KHz"); |
|
|
| 100 |
numBands += 1; |
99 |
numBands += 1; |
| 101 |
} |
100 |
} |
| 102 |
NS_ASSERT_MSG (numBands % 2 == 1, "Number of bands should be odd"); |
101 |
NS_ASSERT_MSG (numBands % 2 == 1, "Number of bands should be odd"); |
|
|
102 |
NS_LOG_DEBUG ("Num bands " << numBands << " band bandwidth " << bandBandwidth); |
| 103 |
// lay down numBands/2 bands symmetrically around center frequency |
103 |
// lay down numBands/2 bands symmetrically around center frequency |
| 104 |
// and place an additional band at center frequency |
104 |
// and place an additional band at center frequency |
| 105 |
double startingFrequencyHz = centerFrequencyHz - (numBands/2 * bandBandwidth) - bandBandwidth/2; |
105 |
double startingFrequencyHz = centerFrequencyHz - (numBands/2 * bandBandwidth) - bandBandwidth/2; |
|
|
| 124 |
|
124 |
|
| 125 |
// Power allocated to 71 center subbands out of 135 total subbands in the band |
125 |
// Power allocated to 71 center subbands out of 135 total subbands in the band |
| 126 |
Ptr<SpectrumValue> |
126 |
Ptr<SpectrumValue> |
| 127 |
WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (uint32_t centerFrequency, double txPowerW, uint8_t guardBandwidth) |
127 |
WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (uint32_t centerFrequency, double txPowerW, double guardBandwidth) |
| 128 |
{ |
128 |
{ |
| 129 |
NS_LOG_FUNCTION (centerFrequency << txPowerW << (uint16_t)guardBandwidth); |
129 |
NS_LOG_FUNCTION (centerFrequency << txPowerW << guardBandwidth); |
| 130 |
uint8_t channelWidth = 22; // DSSS channels are 22 MHz wide |
130 |
uint8_t channelWidth = 22; // DSSS channels are 22 MHz wide |
| 131 |
double bandBandwidth = 312500; |
131 |
double bandBandwidth = 312500; |
| 132 |
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth)); |
132 |
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth)); |
|
|
| 148 |
} |
148 |
} |
| 149 |
|
149 |
|
| 150 |
Ptr<SpectrumValue> |
150 |
Ptr<SpectrumValue> |
| 151 |
WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth) |
151 |
WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint8_t channelWidth, double txPowerW, double guardBandwidth) |
| 152 |
{ |
152 |
{ |
| 153 |
NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW << (uint16_t)guardBandwidth); |
153 |
NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW << guardBandwidth); |
| 154 |
double bandBandwidth = 312500; |
154 |
double bandBandwidth = 0; |
|
|
155 |
switch (channelWidth) |
| 156 |
{ |
| 157 |
case 20: |
| 158 |
bandBandwidth = 312500; |
| 159 |
break; |
| 160 |
case 10: |
| 161 |
bandBandwidth = 156250; |
| 162 |
break; |
| 163 |
case 5: |
| 164 |
bandBandwidth = 78125; |
| 165 |
break; |
| 166 |
default: |
| 167 |
NS_FATAL_ERROR ("Channel width " << (uint16_t) channelWidth << " should be correctly set."); |
| 168 |
return 0; |
| 169 |
} |
| 170 |
|
| 155 |
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth)); |
171 |
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth)); |
| 156 |
uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5); |
172 |
uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5); |
| 157 |
uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5); |
173 |
uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5); |
| 158 |
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumBands ()); |
174 |
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumBands ()); |
| 159 |
double txPowerPerBand = 0; |
175 |
// 52 subcarriers (48 data + 4 pilot) |
| 160 |
uint32_t start1 = 0; |
176 |
// skip guard band and 6 subbands, then place power in 26 subbands, then |
| 161 |
uint32_t stop1 = 0; |
177 |
// skip the center subband, then place power in 26 subbands, then skip |
| 162 |
uint32_t start2 = 0; |
178 |
// the final 6 subbands and the guard band. |
| 163 |
uint32_t stop2 = 0; |
179 |
double txPowerPerBand = txPowerW / 52; |
| 164 |
switch (channelWidth) |
|
|
| 165 |
{ |
| 166 |
case 20: |
| 167 |
// 52 subcarriers (48 data + 4 pilot) |
| 168 |
// skip guard band and 6 subbands, then place power in 26 subbands, then |
| 169 |
// skip the center subband, then place power in 26 subbands, then skip |
| 170 |
// the final 6 subbands and the guard band. |
| 171 |
txPowerPerBand = txPowerW / 52; |
| 172 |
start1 = (nGuardBands / 2) + 6; |
| 173 |
stop1 = start1 + 26 - 1; |
| 174 |
start2 = stop1 + 2; |
| 175 |
stop2 = start2 + 26 - 1; |
| 176 |
break; |
| 177 |
case 10: |
| 178 |
// 28 subcarriers (24 data + 4 pilot) |
| 179 |
// skip guard band and 2 subbands, then place power in 14 subbands, then |
| 180 |
// skip the center subband, then place power in 14 subbands, then skip |
| 181 |
// the final 2 subbands and the guard band. |
| 182 |
txPowerPerBand = txPowerW / 28; |
| 183 |
start1 = (nGuardBands / 2) + 2; |
| 184 |
stop1 = start1 + 14 - 1; |
| 185 |
start2 = stop1 + 2; |
| 186 |
stop2 = start2 + 14 - 1; |
| 187 |
break; |
| 188 |
case 5: |
| 189 |
// 16 subcarriers (12 data + 4 pilot) |
| 190 |
// skip guard band and 2 subbands, then place power in 8 subbands, then |
| 191 |
// skip the center subband, then place power in 8 subbands, then skip |
| 192 |
// the final 2 subbands and the guard. |
| 193 |
txPowerPerBand = txPowerW / 16; |
| 194 |
start1 = (nGuardBands / 2) + 2; |
| 195 |
stop1 = start1 + 8 - 1; |
| 196 |
start2 = stop1 + 2; |
| 197 |
stop2 = start2 + 8 - 1; |
| 198 |
break; |
| 199 |
default: |
| 200 |
NS_FATAL_ERROR ("Channel width should be correctly set."); |
| 201 |
return 0; |
| 202 |
} |
| 203 |
NS_LOG_DEBUG ("Power per band " << txPowerPerBand); |
180 |
NS_LOG_DEBUG ("Power per band " << txPowerPerBand); |
|
|
181 |
uint32_t start1 = (nGuardBands / 2) + 6; |
| 182 |
uint32_t stop1 = start1 + 26 - 1; |
| 183 |
uint32_t start2 = stop1 + 2; |
| 184 |
uint32_t stop2 = start2 + 26 - 1; |
| 204 |
Values::iterator vit = c->ValuesBegin (); |
185 |
Values::iterator vit = c->ValuesBegin (); |
| 205 |
Bands::const_iterator bit = c->ConstBandsBegin (); |
186 |
Bands::const_iterator bit = c->ConstBandsBegin (); |
| 206 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
187 |
for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) |
|
|
| 221 |
} |
202 |
} |
| 222 |
|
203 |
|
| 223 |
Ptr<SpectrumValue> |
204 |
Ptr<SpectrumValue> |
| 224 |
WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth) |
205 |
WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint8_t channelWidth, double txPowerW, double guardBandwidth) |
| 225 |
{ |
206 |
{ |
| 226 |
NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW << (uint16_t)guardBandwidth); |
207 |
NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW << guardBandwidth); |
| 227 |
double bandBandwidth = 312500; |
208 |
double bandBandwidth = 312500; |
| 228 |
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth)); |
209 |
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth)); |
| 229 |
Values::iterator vit = c->ValuesBegin (); |
210 |
Values::iterator vit = c->ValuesBegin (); |
|
|
| 389 |
} |
370 |
} |
| 390 |
|
371 |
|
| 391 |
Ptr<SpectrumValue> |
372 |
Ptr<SpectrumValue> |
| 392 |
WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth) |
373 |
WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint8_t channelWidth, double txPowerW, double guardBandwidth) |
| 393 |
{ |
374 |
{ |
| 394 |
NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW << (uint16_t)guardBandwidth); |
375 |
NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW << guardBandwidth); |
| 395 |
double bandBandwidth = 78125; |
376 |
double bandBandwidth = 78125; |
| 396 |
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth)); |
377 |
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth)); |
| 397 |
Values::iterator vit = c->ValuesBegin (); |
378 |
Values::iterator vit = c->ValuesBegin (); |
|
|
| 524 |
} |
505 |
} |
| 525 |
|
506 |
|
| 526 |
Ptr<SpectrumValue> |
507 |
Ptr<SpectrumValue> |
| 527 |
WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint8_t channelWidth, double bandBandwidth, double noiseFigure, uint8_t guardBandwidth) |
508 |
WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint8_t channelWidth, double bandBandwidth, double noiseFigure, double guardBandwidth) |
| 528 |
{ |
509 |
{ |
| 529 |
Ptr<SpectrumModel> model = GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth); |
510 |
Ptr<SpectrumModel> model = GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth); |
| 530 |
return CreateNoisePowerSpectralDensity (noiseFigure, model); |
511 |
return CreateNoisePowerSpectralDensity (noiseFigure, model); |
|
|
| 549 |
} |
530 |
} |
| 550 |
|
531 |
|
| 551 |
Ptr<SpectrumValue> |
532 |
Ptr<SpectrumValue> |
| 552 |
WifiSpectrumValueHelper::CreateRfFilter (uint32_t centerFrequency, uint8_t channelWidth, double bandGranularity, uint8_t guardBandwidth) |
533 |
WifiSpectrumValueHelper::CreateRfFilter (uint32_t centerFrequency, uint8_t channelWidth, double bandGranularity, double guardBandwidth) |
| 553 |
{ |
534 |
{ |
| 554 |
NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << bandGranularity << (uint16_t)guardBandwidth); |
535 |
NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << bandGranularity << guardBandwidth); |
| 555 |
Ptr<SpectrumValue> c = Create <SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandGranularity, guardBandwidth)); |
536 |
Ptr<SpectrumValue> c = Create <SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandGranularity, guardBandwidth)); |
| 556 |
size_t numBands = c->GetSpectrumModel ()->GetNumBands (); |
537 |
size_t numBands = c->GetSpectrumModel ()->GetNumBands (); |
| 557 |
Bands::const_iterator bit = c->ConstBandsBegin (); |
538 |
Bands::const_iterator bit = c->ConstBandsBegin (); |