Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 CTTC | 3 * Copyright (c) 2009 CTTC |
4 * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari | 4 * Copyright (c) 2010 TELEMATICS LAB, DEE - Politecnico di Bari |
5 * Copyright (c) 2017 Orange Labs | 5 * Copyright (c) 2017 Orange Labs |
6 * | 6 * |
7 * This program is free software; you can redistribute it and/or modify | 7 * This program is free software; you can redistribute it and/or modify |
8 * it under the terms of the GNU General Public License version 2 as | 8 * it under the terms of the GNU General Public License version 2 as |
9 * published by the Free Software Foundation; | 9 * published by the Free Software Foundation; |
10 * | 10 * |
(...skipping 29 matching lines...) Expand all Loading... | |
40 * Constructor | 40 * Constructor |
41 * \param f the frequency (in MHz) | 41 * \param f the frequency (in MHz) |
42 * \param w the channel width (in MHz) | 42 * \param w the channel width (in MHz) |
43 * \param b the width of each band (in Hz) | 43 * \param b the width of each band (in Hz) |
44 * \param g the guard band width (in MHz) | 44 * \param g the guard band width (in MHz) |
45 */· | 45 */· |
46 WifiSpectrumModelId (uint32_t f, uint8_t w, double b, uint8_t g); | 46 WifiSpectrumModelId (uint32_t f, uint8_t w, double b, uint8_t g); |
47 uint32_t m_centerFrequency; ///< center frequency (in MHz) | 47 uint32_t m_centerFrequency; ///< center frequency (in MHz) |
48 uint8_t m_channelWidth; ///< channel width (in MHz) | 48 uint8_t m_channelWidth; ///< channel width (in MHz) |
49 double m_bandBandwidth; ///< width of each band (in Hz) | 49 double m_bandBandwidth; ///< width of each band (in Hz) |
50 uint8_t m_guardBandwidth; ///< guard band width (in MHz) | 50 uint8_t m_guardBandwidth; ///< guard band width (in MHz) |
51 }; | 51 }; |
52 | 52 |
53 WifiSpectrumModelId::WifiSpectrumModelId (uint32_t f, uint8_t w, double b, uint8 _t g) | 53 WifiSpectrumModelId::WifiSpectrumModelId (uint32_t f, uint8_t w, double b, uint8 _t g) |
54 : m_centerFrequency (f), | 54 : m_centerFrequency (f), |
55 m_channelWidth (w), | 55 m_channelWidth (w), |
56 m_bandBandwidth (b), | 56 m_bandBandwidth (b), |
57 m_guardBandwidth (g) | 57 m_guardBandwidth (g) |
58 { | 58 { |
59 NS_LOG_FUNCTION (this << f << static_cast<uint16_t> (w) << b << static_cast<ui nt16_t> (g)); | 59 NS_LOG_FUNCTION (this << f << +w << b << +g); |
60 } | 60 } |
61 | 61 |
62 /** | 62 /** |
63 * Less than operator | 63 * Less than operator |
64 * \param a the first wifi spectrum to compare | 64 * \param a the first wifi spectrum to compare |
65 * \param b the second wifi spectrum to compare | 65 * \param b the second wifi spectrum to compare |
66 * \returns true if the first spectrum is less than the second spectrum | 66 * \returns true if the first spectrum is less than the second spectrum |
67 */· | 67 */· |
68 bool | 68 bool |
69 operator < (const WifiSpectrumModelId& a, const WifiSpectrumModelId& b) | 69 operator < (const WifiSpectrumModelId& a, const WifiSpectrumModelId& b) |
70 { | 70 { |
71 return ( (a.m_centerFrequency < b.m_centerFrequency) | 71 return ( (a.m_centerFrequency < b.m_centerFrequency) |
72 || ((a.m_centerFrequency == b.m_centerFrequency) && | 72 || ((a.m_centerFrequency == b.m_centerFrequency) && |
73 (a.m_channelWidth < b.m_channelWidth)) | 73 (a.m_channelWidth < b.m_channelWidth)) |
74 || ((a.m_centerFrequency == b.m_centerFrequency) && | 74 || ((a.m_centerFrequency == b.m_centerFrequency) && |
75 (a.m_channelWidth == b.m_channelWidth) && | 75 (a.m_channelWidth == b.m_channelWidth) && |
76 (a.m_bandBandwidth < b.m_bandBandwidth)) // to cover coexistence o f 11ax with legacy case | 76 (a.m_bandBandwidth < b.m_bandBandwidth)) // to cover coexistence o f 11ax with legacy case |
77 || ((a.m_centerFrequency == b.m_centerFrequency) && | 77 || ((a.m_centerFrequency == b.m_centerFrequency) && |
78 (a.m_channelWidth == b.m_channelWidth) && | 78 (a.m_channelWidth == b.m_channelWidth) && |
79 (a.m_bandBandwidth == b.m_bandBandwidth) && | 79 (a.m_bandBandwidth == b.m_bandBandwidth) && |
80 (a.m_guardBandwidth < b.m_guardBandwidth))); // to cover 2.4 GHz c ase, where DSSS coexists with OFDM | 80 (a.m_guardBandwidth < b.m_guardBandwidth))); // to cover 2.4 GHz c ase, where DSSS coexists with OFDM |
81 } | 81 } |
82 | 82 |
83 static std::map<WifiSpectrumModelId, Ptr<SpectrumModel> > g_wifiSpectrumModelMap ; ///< static initializer for the class | 83 static std::map<WifiSpectrumModelId, Ptr<SpectrumModel> > g_wifiSpectrumModelMap ; ///< static initializer for the class |
84 | 84 |
85 Ptr<SpectrumModel> | 85 Ptr<SpectrumModel> |
86 WifiSpectrumValueHelper::GetSpectrumModel (uint32_t centerFrequency, uint8_t cha nnelWidth, double bandBandwidth, uint8_t guardBandwidth) | 86 WifiSpectrumValueHelper::GetSpectrumModel (uint32_t centerFrequency, uint8_t cha nnelWidth, double bandBandwidth, uint8_t guardBandwidth) |
87 { | 87 { |
88 NS_LOG_FUNCTION (centerFrequency << static_cast<uint16_t> (channelWidth) << ba ndBandwidth << static_cast<uint16_t> (guardBandwidth)); | 88 NS_LOG_FUNCTION (centerFrequency << +channelWidth << bandBandwidth << +guardBa ndwidth); |
89 Ptr<SpectrumModel> ret; | 89 Ptr<SpectrumModel> ret; |
90 WifiSpectrumModelId key (centerFrequency, channelWidth, bandBandwidth, guardBa ndwidth); | 90 WifiSpectrumModelId key (centerFrequency, channelWidth, bandBandwidth, guardBa ndwidth); |
91 std::map<WifiSpectrumModelId, Ptr<SpectrumModel> >::iterator it = g_wifiSpectr umModelMap.find (key); | 91 std::map<WifiSpectrumModelId, Ptr<SpectrumModel> >::iterator it = g_wifiSpectr umModelMap.find (key); |
92 if (it != g_wifiSpectrumModelMap.end ()) | 92 if (it != g_wifiSpectrumModelMap.end ()) |
93 { | 93 { |
94 ret = it->second; | 94 ret = it->second; |
95 } | 95 } |
96 else | 96 else |
97 { | 97 { |
98 Bands bands; | 98 Bands bands; |
(...skipping 29 matching lines...) Expand all Loading... | |
128 g_wifiSpectrumModelMap.insert (std::pair<WifiSpectrumModelId, Ptr<Spectrum Model> > (key, ret)); | 128 g_wifiSpectrumModelMap.insert (std::pair<WifiSpectrumModelId, Ptr<Spectrum Model> > (key, ret)); |
129 } | 129 } |
130 NS_LOG_LOGIC ("returning SpectrumModel::GetUid () == " << ret->GetUid ()); | 130 NS_LOG_LOGIC ("returning SpectrumModel::GetUid () == " << ret->GetUid ()); |
131 return ret; | 131 return ret; |
132 } | 132 } |
133 | 133 |
134 // Power allocated to 71 center subbands out of 135 total subbands in the band· | 134 // Power allocated to 71 center subbands out of 135 total subbands in the band· |
135 Ptr<SpectrumValue> | 135 Ptr<SpectrumValue> |
136 WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (uint32_t centerFreque ncy, double txPowerW, uint8_t guardBandwidth) | 136 WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (uint32_t centerFreque ncy, double txPowerW, uint8_t guardBandwidth) |
137 { | 137 { |
138 NS_LOG_FUNCTION (centerFrequency << txPowerW << static_cast<uint16_t> (guardBa ndwidth)); | 138 NS_LOG_FUNCTION (centerFrequency << txPowerW << +guardBandwidth); |
139 uint8_t channelWidth = 22; // DSSS channels are 22 MHz wide | 139 uint8_t channelWidth = 22; // DSSS channels are 22 MHz wide |
140 double bandBandwidth = 312500; | 140 double bandBandwidth = 312500; |
141 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); | 141 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); |
142 Values::iterator vit = c->ValuesBegin (); | 142 Values::iterator vit = c->ValuesBegin (); |
143 Bands::const_iterator bit = c->ConstBandsBegin (); | 143 Bands::const_iterator bit = c->ConstBandsBegin (); |
144 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); | 144 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); |
145 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); | 145 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); |
146 NS_ASSERT (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuard Bands + 1)); | 146 NS_ASSERT (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuard Bands + 1)); |
147 // Evenly spread power across 22 MHz | 147 // Evenly spread power across 22 MHz |
148 double txPowerPerBand = txPowerW / nAllocatedBands; | 148 double txPowerPerBand = txPowerW / nAllocatedBands; |
149 for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit ++) | 149 for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit ++) |
150 { | 150 { |
151 if ((i >= (nGuardBands / 2)) && (i <= ((nGuardBands / 2) + nAllocatedBands - 1))) | 151 if ((i >= (nGuardBands / 2)) && (i <= ((nGuardBands / 2) + nAllocatedBands - 1))) |
152 { | 152 { |
153 *vit = txPowerPerBand / (bit->fh - bit->fl); | 153 *vit = txPowerPerBand / (bit->fh - bit->fl); |
154 } | 154 } |
155 } | 155 } |
156 return c; | 156 return c; |
157 } | 157 } |
158 | 158 |
159 Ptr<SpectrumValue> | 159 Ptr<SpectrumValue> |
160 WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFreque ncy, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth) | 160 WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFreque ncy, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth) |
161 { | 161 { |
162 NS_LOG_FUNCTION (centerFrequency << static_cast<uint16_t> (channelWidth) << tx PowerW << static_cast<uint16_t> (guardBandwidth)); | 162 NS_LOG_FUNCTION (centerFrequency << +channelWidth << txPowerW << +guardBandwid th); |
163 double bandBandwidth = 0; | 163 double bandBandwidth = 0; |
164 uint32_t innerSlopeWidth = 0; | 164 uint32_t innerSlopeWidth = 0; |
165 switch (channelWidth) | 165 switch (channelWidth) |
166 { | 166 { |
167 case 20: | 167 case 20: |
168 bandBandwidth = 312500; | 168 bandBandwidth = 312500; |
169 innerSlopeWidth = static_cast<uint32_t>((2e6 / bandBandwidth) + 0.5); // [ -11;-9] & [9;11] | 169 innerSlopeWidth = static_cast<uint32_t>((2e6 / bandBandwidth) + 0.5); // [ -11;-9] & [9;11] |
170 break; | 170 break; |
171 case 10: | 171 case 10: |
172 bandBandwidth = 156250; | 172 bandBandwidth = 156250; |
173 innerSlopeWidth = static_cast<uint32_t>((1e6 / bandBandwidth) + 0.5); // [ -5.5;-4.5] & [4.5;5.5] | 173 innerSlopeWidth = static_cast<uint32_t>((1e6 / bandBandwidth) + 0.5); // [ -5.5;-4.5] & [4.5;5.5] |
174 break; | 174 break; |
175 case 5: | 175 case 5: |
176 bandBandwidth = 78125; | 176 bandBandwidth = 78125; |
177 innerSlopeWidth = static_cast<uint32_t>((5e5 / bandBandwidth) + 0.5); // [ -2.75;-2.5] & [2.5;2.75] | 177 innerSlopeWidth = static_cast<uint32_t>((5e5 / bandBandwidth) + 0.5); // [ -2.75;-2.5] & [2.5;2.75] |
178 break; | 178 break; |
179 default: | 179 default: |
180 NS_FATAL_ERROR ("Channel width " << static_cast<uint16_t> (channelWidth) < < " should be correctly set."); | 180 NS_FATAL_ERROR ("Channel width " << +channelWidth << " should be correctly set."); |
181 return 0; | 181 return 0; |
182 } | 182 } |
183 | 183 |
184 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); | 184 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); |
185 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); | 185 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); |
186 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); | 186 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); |
187 NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nG uardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumB ands ()); | 187 NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nG uardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumB ands ()); |
188 // 52 subcarriers (48 data + 4 pilot) | 188 // 52 subcarriers (48 data + 4 pilot) |
189 // skip guard band and 6 subbands, then place power in 26 subbands, then | 189 // skip guard band and 6 subbands, then place power in 26 subbands, then |
190 // skip the center subband, then place power in 26 subbands, then skip | 190 // skip the center subband, then place power in 26 subbands, then skip |
(...skipping 14 matching lines...) Expand all Loading... | |
205 txPowerPerBandW, nGuardBands, | 205 txPowerPerBandW, nGuardBands, |
206 innerSlopeWidth, -40.0); // -40 dBr for the outermo st points of the standard defined mask for 11a, 11g and downclocked versions of 11a for 11p | 206 innerSlopeWidth, -40.0); // -40 dBr for the outermo st points of the standard defined mask for 11a, 11g and downclocked versions of 11a for 11p |
207 NormalizeSpectrumMask (c, txPowerW); | 207 NormalizeSpectrumMask (c, txPowerW); |
208 NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation f ailed"); | 208 NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation f ailed"); |
209 return c; | 209 return c; |
210 } | 210 } |
211 | 211 |
212 Ptr<SpectrumValue> | 212 Ptr<SpectrumValue> |
213 WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq uency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth) | 213 WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq uency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth) |
214 { | 214 { |
215 NS_LOG_FUNCTION (centerFrequency << static_cast<uint16_t> (channelWidth) << tx PowerW << static_cast<uint16_t> (guardBandwidth)); | 215 NS_LOG_FUNCTION (centerFrequency << +channelWidth << txPowerW << +guardBandwid th); |
216 double bandBandwidth = 312500; | 216 double bandBandwidth = 312500; |
217 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); | 217 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); |
218 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); | 218 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); |
219 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); | 219 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); |
220 NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nG uardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumB ands ()); | 220 NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nG uardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumB ands ()); |
221 double txPowerPerBandW = 0.0; | 221 double txPowerPerBandW = 0.0; |
222 // skip the guard band and 4 subbands, then place power in 28 subbands, then | 222 // skip the guard band and 4 subbands, then place power in 28 subbands, then |
223 // skip the center subband, then place power in 28 subbands, then skip | 223 // skip the center subband, then place power in 28 subbands, then skip |
224 // the final 4 subbands and the guard band. | 224 // the final 4 subbands and the guard band. |
225 // Repeat for each 20 MHz band. | 225 // Repeat for each 20 MHz band. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
322 txPowerPerBandW, nGuardBands, | 322 txPowerPerBandW, nGuardBands, |
323 innerSlopeWidth, lowestPointDbr); | 323 innerSlopeWidth, lowestPointDbr); |
324 NormalizeSpectrumMask (c, txPowerW); | 324 NormalizeSpectrumMask (c, txPowerW); |
325 NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation f ailed"); | 325 NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation f ailed"); |
326 return c; | 326 return c; |
327 } | 327 } |
328 | 328 |
329 Ptr<SpectrumValue> | 329 Ptr<SpectrumValue> |
330 WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFreq uency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth) | 330 WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFreq uency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth) |
331 { | 331 { |
332 NS_LOG_FUNCTION (centerFrequency << static_cast<uint16_t> (channelWidth) << tx PowerW << static_cast<uint16_t> (guardBandwidth)); | 332 NS_LOG_FUNCTION (centerFrequency << +channelWidth << txPowerW << +guardBandwid th); |
333 double bandBandwidth = 78125; | 333 double bandBandwidth = 78125; |
334 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); | 334 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); |
335 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); | 335 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); |
336 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); | 336 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); |
337 NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nG uardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumB ands ()); | 337 NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nG uardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumB ands ()); |
338 double txPowerPerBandW = 0.0; | 338 double txPowerPerBandW = 0.0; |
339 uint32_t start1; | 339 uint32_t start1; |
340 uint32_t stop1; | 340 uint32_t stop1; |
341 uint32_t start2; | 341 uint32_t start2; |
342 uint32_t stop2; | 342 uint32_t stop2; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 txPowerPerBandW, nGuardBands, | 419 txPowerPerBandW, nGuardBands, |
420 innerSlopeWidth, lowestPointDbr); | 420 innerSlopeWidth, lowestPointDbr); |
421 NormalizeSpectrumMask (c, txPowerW); | 421 NormalizeSpectrumMask (c, txPowerW); |
422 NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation f ailed"); | 422 NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation f ailed"); |
423 return c; | 423 return c; |
424 } | 424 } |
425 | 425 |
426 Ptr<SpectrumValue> | 426 Ptr<SpectrumValue> |
427 WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequen cy, uint8_t channelWidth, double bandBandwidth, double noiseFigure, uint8_t guar dBandwidth) | 427 WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequen cy, uint8_t channelWidth, double bandBandwidth, double noiseFigure, uint8_t guar dBandwidth) |
428 { | 428 { |
429 Ptr<SpectrumModel> model = GetSpectrumModel (centerFrequency, channelWidth, ba ndBandwidth, static_cast<uint16_t> (guardBandwidth)); | 429 Ptr<SpectrumModel> model = GetSpectrumModel (centerFrequency, channelWidth, ba ndBandwidth, guardBandwidth); |
Tom Henderson
2018/03/01 21:43:05
why is a cast to uint16_t needed here?
Rediet
2018/03/02 10:25:42
Sorry had mistaken it for a logging function. Will
| |
430 return CreateNoisePowerSpectralDensity (noiseFigure, model); | 430 return CreateNoisePowerSpectralDensity (noiseFigure, model); |
431 } | 431 } |
432 | 432 |
433 Ptr<SpectrumValue> | 433 Ptr<SpectrumValue> |
434 WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (double noiseFigureDb, Ptr<SpectrumModel> spectrumModel) | 434 WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (double noiseFigureDb, Ptr<SpectrumModel> spectrumModel) |
435 { | 435 { |
436 NS_LOG_FUNCTION (noiseFigureDb << spectrumModel); | 436 NS_LOG_FUNCTION (noiseFigureDb << spectrumModel); |
437 | 437 |
438 // see "LTE - From theory to practice" | 438 // see "LTE - From theory to practice" |
439 // Section 22.4.4.2 Thermal Noise and Receiver Noise Figure | 439 // Section 22.4.4.2 Thermal Noise and Receiver Noise Figure |
440 const double kT_dBm_Hz = -174.0; // dBm/Hz | 440 const double kT_dBm_Hz = -174.0; // dBm/Hz |
441 double kT_W_Hz = std::pow (10.0, (kT_dBm_Hz - 30) / 10.0); | 441 double kT_W_Hz = std::pow (10.0, (kT_dBm_Hz - 30) / 10.0); |
442 double noiseFigureLinear = std::pow (10.0, noiseFigureDb / 10.0); | 442 double noiseFigureLinear = std::pow (10.0, noiseFigureDb / 10.0); |
443 double noisePowerSpectralDensity = kT_W_Hz * noiseFigureLinear; | 443 double noisePowerSpectralDensity = kT_W_Hz * noiseFigureLinear; |
444 | 444 |
445 Ptr<SpectrumValue> noisePsd = Create <SpectrumValue> (spectrumModel); | 445 Ptr<SpectrumValue> noisePsd = Create <SpectrumValue> (spectrumModel); |
446 (*noisePsd) = noisePowerSpectralDensity; | 446 (*noisePsd) = noisePowerSpectralDensity; |
447 NS_LOG_INFO ("NoisePowerSpectralDensity has integrated power of " << Integral (*noisePsd)); | 447 NS_LOG_INFO ("NoisePowerSpectralDensity has integrated power of " << Integral (*noisePsd)); |
448 return noisePsd; | 448 return noisePsd; |
449 } | 449 } |
450 | 450 |
451 Ptr<SpectrumValue> | 451 Ptr<SpectrumValue> |
452 WifiSpectrumValueHelper::CreateRfFilter (uint32_t centerFrequency, uint8_t chann elWidth, double bandGranularity, uint8_t guardBandwidth) | 452 WifiSpectrumValueHelper::CreateRfFilter (uint32_t centerFrequency, uint8_t chann elWidth, double bandGranularity, uint8_t guardBandwidth) |
453 { | 453 { |
454 NS_LOG_FUNCTION (centerFrequency << static_cast<uint16_t> (channelWidth) << ba ndGranularity << static_cast<uint16_t> (guardBandwidth)); | 454 NS_LOG_FUNCTION (centerFrequency << +channelWidth << bandGranularity << +guard Bandwidth); |
Tom Henderson
2018/03/01 21:43:05
same comment as above
Rediet
2018/03/02 10:25:41
Here it's a normal logging function. By the way, w
| |
455 Ptr<SpectrumValue> c = Create <SpectrumValue> (GetSpectrumModel (centerFrequen cy, channelWidth, bandGranularity, guardBandwidth)); | 455 Ptr<SpectrumValue> c = Create <SpectrumValue> (GetSpectrumModel (centerFrequen cy, channelWidth, bandGranularity, guardBandwidth)); |
456 size_t numBands = c->GetSpectrumModel ()->GetNumBands (); | 456 size_t numBands = c->GetSpectrumModel ()->GetNumBands (); |
457 Bands::const_iterator bit = c->ConstBandsBegin (); | 457 Bands::const_iterator bit = c->ConstBandsBegin (); |
458 Values::iterator vit = c->ValuesBegin (); | 458 Values::iterator vit = c->ValuesBegin (); |
459 uint32_t bandBandwidth = static_cast<uint32_t> (bandGranularity); | 459 uint32_t bandBandwidth = static_cast<uint32_t> (bandGranularity); |
460 size_t numBandsInFilter = static_cast<size_t> (channelWidth * 1e6 / bandBandwi dth);· | 460 size_t numBandsInFilter = static_cast<size_t> (channelWidth * 1e6 / bandBandwi dth);· |
461 if (channelWidth % bandBandwidth != 0) | 461 if (channelWidth % bandBandwidth != 0) |
462 { | 462 { |
463 numBandsInFilter += 1; | 463 numBandsInFilter += 1; |
464 } | 464 } |
(...skipping 22 matching lines...) Expand all Loading... | |
487 uint32_t numMaskBands = maskBand.second - maskBand.first + 1; | 487 uint32_t numMaskBands = maskBand.second - maskBand.first + 1; |
488 NS_ASSERT (numSubBands && numBands && numMaskBands); | 488 NS_ASSERT (numSubBands && numBands && numMaskBands); |
489 NS_LOG_LOGIC ("Power per band " << txPowerPerBandW << "W"); | 489 NS_LOG_LOGIC ("Power per band " << txPowerPerBandW << "W"); |
490 | 490 |
491 //Different power levels | 491 //Different power levels |
492 double txPowerRefDbm = (10.0 * std::log10 (txPowerPerBandW * 1000.0)); | 492 double txPowerRefDbm = (10.0 * std::log10 (txPowerPerBandW * 1000.0)); |
493 double txPowerInnerBandMinDbm = txPowerRefDbm - 20; | 493 double txPowerInnerBandMinDbm = txPowerRefDbm - 20; |
494 double txPowerMiddleBandMinDbm = txPowerRefDbm - 28; | 494 double txPowerMiddleBandMinDbm = txPowerRefDbm - 28; |
495 double txPowerOuterBandMinDbm = txPowerRefDbm + lowestPointDbr; //TODO also ta ke into account dBm/MHz constraints | 495 double txPowerOuterBandMinDbm = txPowerRefDbm + lowestPointDbr; //TODO also ta ke into account dBm/MHz constraints |
496 | 496 |
497 //Determine parameters that will be used to compute non-truncated global spect rum mask | |
498 uint32_t nInbandChannelBands = numMaskBands - (nGuardBands + 1); | |
499 NS_ASSERT (nInbandChannelBands >= (allocatedSubBands.back ().second - allocate dSubBands.front ().first)); | |
500 uint32_t nIdealGuardBands = nInbandChannelBands * 2; //should ideally have as much band on left and right to fully model out of band transmission constraints | |
501 NS_ASSERT (nIdealGuardBands >= nGuardBands && (nIdealGuardBands - nGuardBands) % 2 == 0); | |
502 uint32_t numIdealMaskBands = nInbandChannelBands + nIdealGuardBands + 1; | |
503 NS_ASSERT (numIdealMaskBands >= numMaskBands); | |
504 uint32_t truncationShift = (nIdealGuardBands - nGuardBands) / 2; //shift to ap ply when allocating power to truncated spectrum mask | |
505 | |
497 //Different widths (in number of bands) | 506 //Different widths (in number of bands) |
498 uint32_t outerSlopeWidth = nGuardBands / 4; // nGuardBands is the total left+r ight guard band. The left/right outer part is half of the left/right guard band. | 507 uint32_t outerSlopeWidth = nIdealGuardBands / 4; //nIdealGuardBands is the tot al left+right ideal guard band (wrt to in-band channel width). The left/right ou ter part is half of the left/right guard band. |
499 uint32_t middleSlopeWidth = outerSlopeWidth - (innerSlopeWidth / 2); | 508 uint32_t middleSlopeWidth = outerSlopeWidth - (innerSlopeWidth / 2); |
500 StartStop outerBandLeft (maskBand.first, //to handle cases where allocated cha nnel is under WifiPhy configured channel width. | 509 StartStop outerBandLeft (maskBand.first, //to handle cases where allocated cha nnel is under WifiPhy configured channel width (especially true for mask.second) |
501 maskBand.first + outerSlopeWidth - 1); | 510 maskBand.first + outerSlopeWidth - 1); |
502 StartStop middleBandLeft (outerBandLeft.second + 1, | 511 StartStop middleBandLeft (outerBandLeft.second + 1, |
503 outerBandLeft.second + middleSlopeWidth); | 512 outerBandLeft.second + middleSlopeWidth); |
504 StartStop innerBandLeft (allocatedSubBands.front ().first - innerSlopeWidth, | 513 StartStop innerBandLeft (allocatedSubBands.front ().first + truncationShift - innerSlopeWidth, |
505 allocatedSubBands.front ().first - 1); //better to pl ace slope based on allocated subcarriers | 514 allocatedSubBands.front ().first + truncationShift - 1); //better to place slope based on (shifted) allocated subcarriers |
506 StartStop flatJunctionLeft (middleBandLeft.second + 1, | 515 StartStop flatJunctionLeft (middleBandLeft.second + 1, |
507 innerBandLeft.first - 1); //in order to handle shi ft due to guard subcarriers | 516 innerBandLeft.first - 1); //in order to handle shi ft due to guard subcarriers |
508 StartStop outerBandRight (maskBand.second - outerSlopeWidth + 1, | 517 StartStop outerBandRight (maskBand.second + 2 * truncationShift - outerSlopeWi dth + 1, |
509 maskBand.second); //start from outer edge to be able to compute flat junction width | 518 maskBand.second + 2 * truncationShift); //start from outer edge (of ideal mask) to be able to compute flat junction width |
510 StartStop middleBandRight (outerBandRight.first - middleSlopeWidth, | 519 StartStop middleBandRight (outerBandRight.first - middleSlopeWidth, |
511 outerBandRight.first - 1); | 520 outerBandRight.first - 1); |
512 StartStop innerBandRight (allocatedSubBands.back ().second + 1, | 521 StartStop innerBandRight (allocatedSubBands.back ().second + truncationShift + 1, |
513 allocatedSubBands.back ().second + innerSlopeWidth); | 522 allocatedSubBands.back ().second + truncationShift + innerSlopeWidth); |
514 StartStop flatJunctionRight (innerBandRight.second + 1, | 523 StartStop flatJunctionRight (innerBandRight.second + 1, |
515 middleBandRight.first - 1); | 524 middleBandRight.first - 1); |
516 NS_LOG_DEBUG ("outerBandLeft=[" << outerBandLeft.first << ";" << outerBandLeft .second << "] " << | 525 NS_LOG_DEBUG ("outerBandLeft=[" << outerBandLeft.first << ";" << outerBandLeft .second << "] " << |
517 "middleBandLeft=[" << middleBandLeft.first << ";" << middleBandL eft.second << "] " << | 526 "middleBandLeft=[" << middleBandLeft.first << ";" << middleBandL eft.second << "] " << |
518 "flatJunctionLeft=[" << flatJunctionLeft.first << ";" << flatJun ctionLeft.second << "] " << | 527 "flatJunctionLeft=[" << flatJunctionLeft.first << ";" << flatJun ctionLeft.second << "] " << |
519 "innerBandLeft=[" << innerBandLeft.first << ";" << innerBandLeft .second << "] " << | 528 "innerBandLeft=[" << innerBandLeft.first << ";" << innerBandLeft .second << "] " << |
520 "subBands=[" << allocatedSubBands.front ().first << ";" << alloc atedSubBands.back ().second << "] " << | 529 "subBands=[" << allocatedSubBands.front ().first + truncationShi ft << ";" << allocatedSubBands.back ().second + truncationShift << "] " << |
521 "innerBandRight=[" << innerBandRight.first << ";" << innerBandRi ght.second << "] " << | 530 "innerBandRight=[" << innerBandRight.first << ";" << innerBandRi ght.second << "] " << |
522 "flatJunctionRight=[" << flatJunctionRight.first << ";" << flatJ unctionRight.second << "] " << | 531 "flatJunctionRight=[" << flatJunctionRight.first << ";" << flatJ unctionRight.second << "] " << |
523 "middleBandRight=[" << middleBandRight.first << ";" << middleBan dRight.second << "] " << | 532 "middleBandRight=[" << middleBandRight.first << ";" << middleBan dRight.second << "] " << |
524 "outerBandRight=[" << outerBandRight.first << ";" << outerBandRi ght.second << "] "); | 533 "outerBandRight=[" << outerBandRight.first << ";" << outerBandRi ght.second << "] "); |
525 NS_ASSERT (numMaskBands == ((allocatedSubBands.back ().second - allocatedSubBa nds.front ().first + 1) //equivalent to allocatedBand (includes notches and DC) | 534 NS_ASSERT (numIdealMaskBands == ((allocatedSubBands.back ().second - allocated SubBands.front ().first + 1) //equivalent to allocatedBand (includes notches an d DC) |
526 + 2 * (innerSlopeWidth + middleSlopeWidth + outerSl opeWidth) | 535 + 2 * (innerSlopeWidth + middleSlopeWidth + ou terSlopeWidth) |
527 + (flatJunctionLeft.second - flatJunctionLeft.first + 1) //flat junctions | 536 + (flatJunctionLeft.second - flatJunctionLeft. first + 1) //flat junctions |
528 + (flatJunctionRight.second - flatJunctionRight.fir st + 1))); | 537 + (flatJunctionRight.second - flatJunctionRigh t.first + 1))); |
529 | 538 |
530 //Different slopes | 539 //Different slopes |
531 double innerSlope = 20.0 / innerSlopeWidth; //0 to 20dBr | 540 double innerSlope = 20.0 / innerSlopeWidth; //0 to 20dBr |
532 double middleSlope = 8.0 / middleSlopeWidth; //20 to 28dBr | 541 double middleSlope = 8.0 / middleSlopeWidth; //20 to 28dBr |
533 double outerSlope = (txPowerMiddleBandMinDbm - txPowerOuterBandMinDbm) / outer SlopeWidth; | 542 double outerSlope = (txPowerMiddleBandMinDbm - txPowerOuterBandMinDbm) / outer SlopeWidth; |
534 | 543 |
535 //Build spectrum mask | 544 //Build spectrum mask |
536 Values::iterator vit = c->ValuesBegin (); | 545 Values::iterator vit = c->ValuesBegin (); |
537 Bands::const_iterator bit = c->ConstBandsBegin (); | 546 Bands::const_iterator bit = c->ConstBandsBegin (); |
538 double txPowerW = 0.0; | 547 double txPowerW = 0.0; |
539 for (size_t i = 0; i < numBands; i++, vit++, bit++) | 548 for (size_t i = 0; i < numBands; i++, vit++, bit++) |
540 { | 549 { |
550 uint32_t iShift = i + truncationShift; | |
541 if (i < maskBand.first || i > maskBand.second) //outside the spectrum mask | 551 if (i < maskBand.first || i > maskBand.second) //outside the spectrum mask |
542 { | 552 { |
543 txPowerW = 0.0; | 553 txPowerW = 0.0; |
544 } | 554 } |
545 else if (i <= outerBandLeft.second && i >= outerBandLeft.first) //better t o put greater first (less computation) | 555 else if (iShift <= outerBandLeft.second && iShift >= outerBandLeft.first) //better to put greater first (less computation) |
546 { | 556 { |
547 txPowerW = DbmToW (txPowerOuterBandMinDbm + ((i - outerBandLeft.first) * outerSlope)); | 557 txPowerW = DbmToW (txPowerOuterBandMinDbm + ((iShift - outerBandLeft.f irst) * outerSlope)); |
548 } | 558 } |
549 else if (i <= middleBandLeft.second && i >= middleBandLeft.first) | 559 else if (iShift <= middleBandLeft.second && iShift >= middleBandLeft.first ) |
550 { | 560 { |
551 txPowerW = DbmToW (txPowerMiddleBandMinDbm + ((i - middleBandLeft.firs t) * middleSlope)); | 561 txPowerW = DbmToW (txPowerMiddleBandMinDbm + ((iShift - middleBandLeft .first) * middleSlope)); |
552 } | 562 } |
553 else if (i <= flatJunctionLeft.second && i >= flatJunctionLeft.first) | 563 else if (iShift <= flatJunctionLeft.second && iShift >= flatJunctionLeft.f irst) |
554 { | 564 { |
555 txPowerW = DbmToW (txPowerInnerBandMinDbm); | 565 txPowerW = DbmToW (txPowerInnerBandMinDbm); |
556 } | 566 } |
557 else if (i <= innerBandLeft.second && i >= innerBandLeft.first) | 567 else if (iShift <= innerBandLeft.second && iShift >= innerBandLeft.first) |
558 { | 568 { |
559 txPowerW = DbmToW (txPowerInnerBandMinDbm + ((i - innerBandLeft.first) * innerSlope)); | 569 txPowerW = DbmToW (txPowerInnerBandMinDbm + ((iShift - innerBandLeft.f irst) * innerSlope)); |
560 } | 570 } |
561 else if (i <= allocatedSubBands.back ().second && i >= allocatedSubBands.f ront ().first) //roughly in allocated band | 571 else if (i <= allocatedSubBands.back ().second && i >= allocatedSubBands.f ront ().first) //roughly in allocated band |
562 { | 572 { |
563 bool insideSubBand = false; | 573 bool insideSubBand = false; |
564 for (uint32_t j = 0; !insideSubBand && j < numSubBands; j++) //continu e until inside a sub-band | 574 for (uint32_t j = 0; !insideSubBand && j < numSubBands; j++) //continu e until inside a sub-band |
565 { | 575 { |
566 insideSubBand = (i <= allocatedSubBands[j].second) && (i >= alloca tedSubBands[j].first); | 576 insideSubBand = (i <= allocatedSubBands[j].second) && (i >= alloca tedSubBands[j].first); |
567 } | 577 } |
568 if (insideSubBand) | 578 if (insideSubBand) |
569 { | 579 { |
570 txPowerW = txPowerPerBandW; | 580 txPowerW = txPowerPerBandW; |
571 } | 581 } |
572 else | 582 else |
573 { | 583 { |
574 txPowerW = DbmToW (txPowerInnerBandMinDbm); //consider that nulled as much as possible inband but power leakage -> -20dBr | 584 txPowerW = DbmToW (txPowerInnerBandMinDbm); //consider that nulled as much as possible inband but power leakage -> -20dBr |
575 } | 585 } |
576 } | 586 } |
577 else if (i <= innerBandRight.second && i >= innerBandRight.first) | 587 else if (iShift <= innerBandRight.second && iShift >= innerBandRight.first ) |
578 { | 588 { |
579 txPowerW = DbmToW (txPowerRefDbm - ((i - innerBandRight.first + 1) * i nnerSlope)); // +1 so as to be symmetric with left slope | 589 txPowerW = DbmToW (txPowerRefDbm - ((iShift - innerBandRight.first + 1 ) * innerSlope)); // +1 so as to be symmetric with left slope |
580 } | 590 } |
581 else if (i <= flatJunctionRight.second && i >= flatJunctionRight.first) | 591 else if (iShift <= flatJunctionRight.second && iShift >= flatJunctionRight .first) |
582 { | 592 { |
583 txPowerW = DbmToW (txPowerInnerBandMinDbm); | 593 txPowerW = DbmToW (txPowerInnerBandMinDbm); |
584 } | 594 } |
585 else if (i <= middleBandRight.second && i >= middleBandRight.first) | 595 else if (iShift <= middleBandRight.second && iShift >= middleBandRight.fir st) |
586 { | 596 { |
587 txPowerW = DbmToW (txPowerInnerBandMinDbm - ((i - middleBandRight.firs t + 1) * middleSlope)); // +1 so as to be symmetric with left slope | 597 txPowerW = DbmToW (txPowerInnerBandMinDbm - ((iShift - middleBandRight .first + 1) * middleSlope)); // +1 so as to be symmetric with left slope |
588 } | 598 } |
589 else if (i <= outerBandRight.second && i >= outerBandRight.first) | 599 else if (iShift <= outerBandRight.second && iShift >= outerBandRight.first ) |
590 { | 600 { |
591 txPowerW = DbmToW (txPowerMiddleBandMinDbm - ((i - outerBandRight.firs t + 1) * outerSlope)); // +1 so as to be symmetric with left slope | 601 txPowerW = DbmToW (txPowerMiddleBandMinDbm - ((i - outerBandRight.firs t + 1) * outerSlope)); // +1 so as to be symmetric with left slope |
592 } | 602 } |
593 else | 603 else |
594 { | 604 { |
595 NS_FATAL_ERROR ("Should have handled all cases"); | 605 NS_FATAL_ERROR ("Should have handled all cases"); |
596 } | 606 } |
597 double txPowerDbr = 10 * std::log10 (txPowerW / txPowerPerBandW); | 607 double txPowerDbr = 10 * std::log10 (txPowerW / txPowerPerBandW); |
598 NS_LOG_LOGIC (uint32_t(i) << " -> " << txPowerDbr); | 608 NS_LOG_LOGIC (uint32_t(i) << " -> " << txPowerDbr); |
599 *vit = txPowerW / (bit->fh - bit->fl); | 609 *vit = txPowerW / (bit->fh - bit->fl); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
711 (*rf)[channel + 3] = 1; | 721 (*rf)[channel + 3] = 1; |
712 (*rf)[channel + 4] = 1; | 722 (*rf)[channel + 4] = 1; |
713 (*rf)[channel + 5] = 1; | 723 (*rf)[channel + 5] = 1; |
714 (*rf)[channel + 6] = 1; | 724 (*rf)[channel + 6] = 1; |
715 | 725 |
716 return rf; | 726 return rf; |
717 } | 727 } |
718 | 728 |
719 | 729 |
720 } // namespace ns3 | 730 } // namespace ns3 |
LEFT | RIGHT |