Left: | ||
Right: |
OLD | NEW |
---|---|
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 * | 6 * |
6 * 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 |
7 * 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 |
8 * published by the Free Software Foundation; | 9 * published by the Free Software Foundation; |
9 * | 10 * |
10 * This program is distributed in the hope that it will be useful, | 11 * This program is distributed in the hope that it will be useful, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 * GNU General Public License for more details. | 14 * GNU General Public License for more details. |
14 * | 15 * |
15 * You should have received a copy of the GNU General Public License | 16 * You should have received a copy of the GNU General Public License |
16 * along with this program; if not, write to the Free Software | 17 * along with this program; if not, write to the Free Software |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 * | 19 * |
19 * Author: Nicola Baldo <nbaldo@cttc.es> | 20 * Authors: Nicola Baldo <nbaldo@cttc.es> |
20 * Giuseppe Piro <g.piro@poliba.it> | 21 * Giuseppe Piro <g.piro@poliba.it> |
22 * Rediet <getachew.redieteab@orange.com> | |
21 */ | 23 */ |
22 | 24 |
23 #include <map> | 25 #include <map> |
24 #include <cmath> | 26 #include <cmath> |
25 #include "wifi-spectrum-value-helper.h" | 27 #include "wifi-spectrum-value-helper.h" |
26 #include "ns3/log.h" | 28 #include "ns3/log.h" |
27 #include "ns3/fatal-error.h" | 29 #include "ns3/fatal-error.h" |
28 #include "ns3/assert.h" | 30 #include "ns3/assert.h" |
29 | 31 |
30 namespace ns3 { | 32 namespace ns3 { |
31 | 33 |
32 NS_LOG_COMPONENT_DEFINE ("WifiSpectrumValueHelper"); | 34 NS_LOG_COMPONENT_DEFINE ("WifiSpectrumValueHelper"); |
33 | 35 |
34 ///< Wifi Spectrum Model structure | 36 ///< Wifi Spectrum Model structure |
35 struct WifiSpectrumModelId | 37 struct WifiSpectrumModelId |
36 { | 38 { |
37 /** | 39 /** |
38 * Constructor | 40 * Constructor |
39 * \param f the frequency in Mhz | 41 * \param f the frequency (in MHz) |
40 * \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) | |
44 * \param g the guard band width (in MHz) | |
41 */· | 45 */· |
42 WifiSpectrumModelId (uint32_t f, uint8_t w); | 46 WifiSpectrumModelId (uint32_t f, uint8_t w, double b, uint8_t g); |
43 uint32_t m_centerFrequency; ///< center frequency | 47 uint32_t m_centerFrequency; ///< center frequency (in MHz) |
44 uint8_t m_channelWidth; ///< channel width | 48 uint8_t m_channelWidth; ///< channel width (in MHz) |
49 double m_bandBandwidth; ///< width of each band (in Hz) | |
50 uint8_t m_guardBandwidth; ///< guard band width (in MHz) | |
45 }; | 51 }; |
46 | 52 |
47 WifiSpectrumModelId::WifiSpectrumModelId (uint32_t f, uint8_t w) | 53 WifiSpectrumModelId::WifiSpectrumModelId (uint32_t f, uint8_t w, double b, uint8 _t g) |
48 : m_centerFrequency (f), | 54 : m_centerFrequency (f), |
49 m_channelWidth (w) | 55 m_channelWidth (w), |
56 m_bandBandwidth (b), | |
57 m_guardBandwidth (g) | |
50 { | 58 { |
51 NS_LOG_FUNCTION (this << f << (uint16_t)w); | 59 NS_LOG_FUNCTION (this << f << (uint16_t)w << b << (uint16_t)g); |
52 } | 60 } |
53 | 61 |
54 /** | 62 /** |
55 * Less than operator | 63 * Less than operator |
56 * \param a the first wifi spectrum to compare | 64 * \param a the first wifi spectrum to compare |
57 * \param b the second wifi spectrum to compare | 65 * \param b the second wifi spectrum to compare |
58 * \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 |
59 */· | 67 */· |
60 bool | 68 bool |
61 operator < (const WifiSpectrumModelId& a, const WifiSpectrumModelId& b) | 69 operator < (const WifiSpectrumModelId& a, const WifiSpectrumModelId& b) |
62 { | 70 { |
63 return ( (a.m_centerFrequency < b.m_centerFrequency) || ( (a.m_centerFrequency == b.m_centerFrequency) && (a.m_channelWidth < b.m_channelWidth))); | 71 return ( (a.m_centerFrequency < b.m_centerFrequency) |
72 || ((a.m_centerFrequency == b.m_centerFrequency) && | |
73 (a.m_channelWidth < b.m_channelWidth)) | |
74 || ((a.m_centerFrequency == b.m_centerFrequency) && | |
75 (a.m_channelWidth == b.m_channelWidth) && | |
76 (a.m_bandBandwidth < b.m_bandBandwidth)) // to cover coexistence o f 11ax with legacy case | |
77 || ((a.m_centerFrequency == b.m_centerFrequency) && | |
78 (a.m_channelWidth == b.m_channelWidth) && | |
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 | |
64 } | 81 } |
65 | 82 |
66 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 |
67 | 84 |
68 Ptr<SpectrumModel> | 85 Ptr<SpectrumModel> |
69 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) |
70 { | 87 { |
71 NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << bandBandwidth << (uint16_t)guardBandwidth); | 88 NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << bandBandwidth << (uint16_t)guardBandwidth); |
72 Ptr<SpectrumModel> ret; | 89 Ptr<SpectrumModel> ret; |
73 WifiSpectrumModelId key (centerFrequency, channelWidth); | 90 WifiSpectrumModelId key (centerFrequency, channelWidth, bandBandwidth, guardBa ndwidth); |
74 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); |
75 if (it != g_wifiSpectrumModelMap.end ()) | 92 if (it != g_wifiSpectrumModelMap.end ()) |
76 { | 93 { |
77 ret = it->second; | 94 ret = it->second; |
78 } | 95 } |
79 else | 96 else |
80 { | 97 { |
81 Bands bands; | 98 Bands bands; |
82 double centerFrequencyHz = centerFrequency * 1e6; | 99 double centerFrequencyHz = centerFrequency * 1e6; |
83 double bandwidth = (channelWidth + (2 * guardBandwidth)) * 1e6; | 100 double bandwidth = (channelWidth + (2 * guardBandwidth)) * 1e6; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 | 158 |
142 Ptr<SpectrumValue> | 159 Ptr<SpectrumValue> |
143 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) |
144 { | 161 { |
145 NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW << (uin t16_t)guardBandwidth); | 162 NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW << (uin t16_t)guardBandwidth); |
146 double bandBandwidth = 312500; | 163 double bandBandwidth = 312500; |
147 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); | 164 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); |
148 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); | 165 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); |
149 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); | 166 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); |
150 NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nG uardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumB ands ()); | 167 NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nG uardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumB ands ()); |
151 double txPowerPerBand = 0; | 168 double txPowerPerBand = 0.0; |
152 uint32_t start1 = 0; | 169 uint32_t start1 = 0; |
153 uint32_t stop1 = 0; | 170 uint32_t stop1 = 0; |
154 uint32_t start2 = 0; | 171 uint32_t start2 = 0; |
155 uint32_t stop2 = 0; | 172 uint32_t stop2 = 0; |
173 uint32_t innerSlopeWidth = 0; | |
174 //Spectrum mask specific variables | |
175 double lowestPointDbr = -40.0; | |
176 double lowestPointDbm = 0.0; | |
156 switch (channelWidth) | 177 switch (channelWidth) |
157 { | 178 { |
158 case 20: | 179 case 20: |
159 default: | 180 default: |
160 // 52 subcarriers (48 data + 4 pilot) | 181 // 52 subcarriers (48 data + 4 pilot) |
161 // skip guard band and 6 subbands, then place power in 26 subbands, then | 182 // skip guard band and 6 subbands, then place power in 26 subbands, then |
162 // skip the center subband, then place power in 26 subbands, then skip | 183 // skip the center subband, then place power in 26 subbands, then skip |
163 // the final 6 subbands and the guard band. | 184 // the final 6 subbands and the guard band. |
164 txPowerPerBand = txPowerW / 52; | 185 txPowerPerBand = txPowerW / 52; |
165 start1 = (nGuardBands / 2) + 6; | 186 start1 = (nGuardBands / 2) + 6; |
166 stop1 = start1 + 26 - 1; | 187 stop1 = start1 + 26 - 1; |
167 start2 = stop1 + 2; | 188 start2 = stop1 + 2; |
168 stop2 = start2 + 26 - 1; | 189 stop2 = start2 + 26 - 1; |
190 innerSlopeWidth = static_cast<uint32_t>((2e6 / bandBandwidth) + 0.5); // [ -11;-9] & [9;11] | |
191 lowestPointDbm = -53.0; //dBm/MHz | |
169 break; | 192 break; |
170 case 10: | 193 case 10: |
171 // 28 subcarriers (24 data + 4 pilot) | 194 // 28 subcarriers (24 data + 4 pilot) |
172 // skip guard band and 2 subbands, then place power in 14 subbands, then | 195 // skip guard band and 2 subbands, then place power in 14 subbands, then |
173 // skip the center subband, then place power in 14 subbands, then skip | 196 // skip the center subband, then place power in 14 subbands, then skip |
174 // the final 2 subbands and the guard band. | 197 // the final 2 subbands and the guard band. |
175 txPowerPerBand = txPowerW / 28; | 198 txPowerPerBand = txPowerW / 28; |
176 start1 = (nGuardBands / 2) + 2; | 199 start1 = (nGuardBands / 2) + 2; |
177 stop1 = start1 + 14 - 1; | 200 stop1 = start1 + 14 - 1; |
178 start2 = stop1 + 2; | 201 start2 = stop1 + 2; |
179 stop2 = start2 + 14 - 1; | 202 stop2 = start2 + 14 - 1; |
203 innerSlopeWidth = static_cast<uint32_t>((1e6 / bandBandwidth) + 0.5); // [ -5.5;-4.5] & [4.5;5.5] | |
204 lowestPointDbm = -50.0; //dBm/MHz | |
180 break; | 205 break; |
181 case 5: | 206 case 5: |
182 // 16 subcarriers (12 data + 4 pilot) | 207 // 16 subcarriers (12 data + 4 pilot) |
183 // skip guard band and 2 subbands, then place power in 8 subbands, then | 208 // skip guard band and 2 subbands, then place power in 8 subbands, then |
184 // skip the center subband, then place power in 8 subbands, then skip | 209 // skip the center subband, then place power in 8 subbands, then skip |
185 // the final 2 subbands and the guard. | 210 // the final 2 subbands and the guard. |
186 txPowerPerBand = txPowerW / 16; | 211 txPowerPerBand = txPowerW / 16; |
187 start1 = (nGuardBands / 2) + 2; | 212 start1 = (nGuardBands / 2) + 2; |
188 stop1 = start1 + 8 - 1; | 213 stop1 = start1 + 8 - 1; |
189 start2 = stop1 + 2; | 214 start2 = stop1 + 2; |
190 stop2 = start2 + 8 - 1; | 215 stop2 = start2 + 8 - 1; |
216 innerSlopeWidth = static_cast<uint32_t>((5e5 / bandBandwidth) + 0.5); // [ -2.75;-2.5] & [2.5;2.75] | |
217 lowestPointDbm = -47.0; //dBm/MHz | |
191 break; | 218 break; |
192 } | 219 } |
193 NS_LOG_DEBUG ("Power per band " << txPowerPerBand); | 220 |
194 Values::iterator vit = c->ValuesBegin (); | 221 //Build transmit spectrum mask |
195 Bands::const_iterator bit = c->ConstBandsBegin (); | 222 std::vector <StartStop> subBands; |
196 for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit ++) | 223 subBands.push_back (std::make_pair (start1, stop1)); |
224 subBands.push_back (std::make_pair (start2, stop2)); | |
225 StartStop maskBand (0, nAllocatedBands + nGuardBands); | |
226 if (channelWidth > 20) | |
197 { | 227 { |
198 if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2)) | 228 //To handle cases where legacy OFDM is used for HT/VHT/HE STAs using bandw idth of 40 MHz and above |
199 { | 229 nAllocatedBands = static_cast<uint32_t>(((20e6) / bandBandwidth) + 0.5); |
200 *vit = txPowerPerBand / (bit->fh - bit->fl); | 230 nGuardBands = nAllocatedBands * 2; |
201 } | 231 maskBand.first = start1 - 6 - (nGuardBands / 2); |
202 else | 232 maskBand.second = stop2 + 5 + (nGuardBands / 2) + 1; |
203 { | |
204 *vit = 0; | |
205 } | |
206 } | 233 } |
207 NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 << " and " << start2 << "-" << stop2); | 234 |
208 NS_LOG_DEBUG ("Integrated power " << Integral (*c)); | 235 CreateSpectrumMaskForOfdm (c, subBands, maskBand, |
236 txPowerPerBand, nGuardBands, | |
237 innerSlopeWidth, lowestPointDbr, lowestPointDbm); | |
238 NormalizeSpectrumMask (c, txPowerW); | |
209 NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation f ailed"); | 239 NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation f ailed"); |
210 return c; | 240 return c; |
211 } | 241 } |
212 | 242 |
213 Ptr<SpectrumValue> | 243 Ptr<SpectrumValue> |
214 WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq uency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth) | 244 WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq uency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth) |
215 { | 245 { |
216 NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW << (uin t16_t)guardBandwidth); | 246 NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW << (uin t16_t)guardBandwidth); |
217 double bandBandwidth = 312500; | 247 double bandBandwidth = 312500; |
218 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); | 248 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); |
219 Values::iterator vit = c->ValuesBegin (); | 249 Values::iterator vit = c->ValuesBegin (); |
micha.rademacher
2017/10/25 13:16:47
unused-but-set-variable
(looks like it is save to
Rediet
2017/10/30 15:07:56
Acknowledged.
| |
220 Bands::const_iterator bit = c->ConstBandsBegin (); | 250 Bands::const_iterator bit = c->ConstBandsBegin (); |
micha.rademacher
2017/10/25 13:16:47
unused-but-set-variable
Rediet
2017/10/30 15:07:57
Acknowledged.
| |
221 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); | 251 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); |
222 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); | 252 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); |
223 NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nG uardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumB ands ()); | 253 NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nG uardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumB ands ()); |
224 double txPowerPerBand; | 254 double txPowerPerBand = 0.0; |
225 // skip the guard band and 4 subbands, then place power in 28 subbands, then | 255 // skip the guard band and 4 subbands, then place power in 28 subbands, then |
226 // skip the center subband, then place power in 28 subbands, then skip | 256 // skip the center subband, then place power in 28 subbands, then skip |
227 // the final 4 subbands and the guard band. | 257 // the final 4 subbands and the guard band. |
228 // Repeat for each 20 MHz band. | 258 // Repeat for each 20 MHz band. |
229 uint32_t start1 = (nGuardBands / 2) + 4; | 259 uint32_t start1 = (nGuardBands / 2) + 4; |
230 uint32_t stop1 = start1 + 28 - 1; | 260 uint32_t stop1 = start1 + 28 - 1; |
231 uint32_t start2 = stop1 + 2; | 261 uint32_t start2 = stop1 + 2; |
232 uint32_t stop2 = start2 + 28 - 1; | 262 uint32_t stop2 = start2 + 28 - 1; |
233 uint32_t start3 = stop2 + (2 * 4); | 263 uint32_t start3 = stop2 + (2 * 4); |
234 uint32_t stop3 = start3 + 28 - 1; | 264 uint32_t stop3 = start3 + 28 - 1; |
(...skipping 16 matching lines...) Expand all Loading... | |
251 uint32_t start12 = stop11 + 2; | 281 uint32_t start12 = stop11 + 2; |
252 uint32_t stop12 = start12 + 28 - 1; | 282 uint32_t stop12 = start12 + 28 - 1; |
253 uint32_t start13 = stop12 + (2 * 4); | 283 uint32_t start13 = stop12 + (2 * 4); |
254 uint32_t stop13 = start13 + 28 - 1; | 284 uint32_t stop13 = start13 + 28 - 1; |
255 uint32_t start14 = stop13 + 2; | 285 uint32_t start14 = stop13 + 2; |
256 uint32_t stop14 = start14 + 28 - 1; | 286 uint32_t stop14 = start14 + 28 - 1; |
257 uint32_t start15 = stop14 + (2 * 4); | 287 uint32_t start15 = stop14 + (2 * 4); |
258 uint32_t stop15 = start15 + 28 - 1; | 288 uint32_t stop15 = start15 + 28 - 1; |
259 uint32_t start16 = stop15 + 2; | 289 uint32_t start16 = stop15 + 2; |
260 uint32_t stop16 = start16 + 28 - 1; | 290 uint32_t stop16 = start16 + 28 - 1; |
291 //Prepare spectrum mask specific variables | |
292 uint32_t innerSlopeWidth = static_cast<uint32_t>((2e6 / bandBandwidth) + 0.5); //size in number of subcarriers of the 0dBr<->20dBr slope (2MHz for HT/VHT) | |
293 double lowestPointDbr = (centerFrequency >= 5000) ? | |
294 -40.0 : //if 5 GHz band | |
295 -45.0; //if 2.4 GHz band | |
296 double lowestPointDbm = 0.0; //to be defined per channelWidth | |
297 std::vector <StartStop> subBands; //list of data/pilot-containing subBands (se nt at 0dBr) | |
298 StartStop maskBand (0, nAllocatedBands + nGuardBands); | |
261 switch (channelWidth) | 299 switch (channelWidth) |
262 { | 300 { |
263 case 20: | 301 case 20: |
264 // 56 subcarriers (52 data + 4 pilot) | 302 // 56 subcarriers (52 data + 4 pilot) |
265 txPowerPerBand = txPowerW / 56; | 303 txPowerPerBand = txPowerW / 56; |
266 NS_LOG_DEBUG ("Power per band " << txPowerPerBand); | 304 lowestPointDbm = -53.0; //dBm/MHz |
267 start1 = (nGuardBands / 2) + 4; | 305 subBands.push_back (std::make_pair (start1, stop1)); |
268 stop1 = start1 + 28 - 1; | 306 subBands.push_back (std::make_pair (start2, stop2)); |
269 start2 = stop1 + 2; | |
270 stop2 = start2 + 28 - 1; | |
271 for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) | |
272 { | |
273 if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2)) | |
274 { | |
275 *vit = txPowerPerBand / (bit->fh - bit->fl); | |
276 } | |
277 else | |
278 { | |
279 *vit = 0; | |
280 } | |
281 } | |
282 NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 << | |
283 " and " << start2 << "-" << stop2); | |
284 break; | 307 break; |
285 case 40: | 308 case 40: |
286 // 112 subcarriers (104 data + 8 pilot)· | 309 // 112 subcarriers (104 data + 8 pilot)· |
287 // possible alternative: 114 subcarriers (108 data + 6 pilot) | 310 // possible alternative: 114 subcarriers (108 data + 6 pilot) |
288 txPowerPerBand = txPowerW / 112; | 311 txPowerPerBand = txPowerW / 112; |
289 NS_LOG_DEBUG ("Power per band " << txPowerPerBand); | 312 lowestPointDbm = -56.0; //dBm/MHz |
290 for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) | 313 subBands.push_back (std::make_pair (start1, stop1)); |
291 { | 314 subBands.push_back (std::make_pair (start2, stop2)); |
292 if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2) || | 315 subBands.push_back (std::make_pair (start3, stop3)); |
293 (i >= start3 && i <= stop3) || (i >= start4 && i <= stop4)) | 316 subBands.push_back (std::make_pair (start4, stop4)); |
294 { | |
295 *vit = txPowerPerBand / (bit->fh - bit->fl); | |
296 } | |
297 else | |
298 { | |
299 *vit = 0; | |
300 } | |
301 } | |
302 NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 << | |
303 ", " << start2 << "-" << stop2 << | |
304 ", " << start3 << "-" << stop3 << | |
305 ", " << start4 << "-" << stop4); | |
306 break; | 317 break; |
307 case 80: | 318 case 80: |
308 // 224 subcarriers (208 data + 16 pilot)· | 319 // 224 subcarriers (208 data + 16 pilot)· |
309 // possible alternative: 242 subcarriers (234 data + 8 pilot) | 320 // possible alternative: 242 subcarriers (234 data + 8 pilot) |
310 txPowerPerBand = txPowerW / 224; | 321 txPowerPerBand = txPowerW / 224; |
311 NS_LOG_DEBUG ("Power per band " << txPowerPerBand); | 322 lowestPointDbm = -59.0; //dBm/MHz |
312 for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) | 323 NS_ASSERT (lowestPointDbr == -40.0); |
313 { | 324 subBands.push_back (std::make_pair (start1, stop1)); |
314 if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2) || | 325 subBands.push_back (std::make_pair (start2, stop2)); |
315 (i >= start3 && i <= stop3) || (i >= start4 && i <= stop4) || | 326 subBands.push_back (std::make_pair (start3, stop3)); |
316 (i >= start5 && i <= stop5) || (i >= start6 && i <= stop6) || | 327 subBands.push_back (std::make_pair (start4, stop4)); |
317 (i >= start7 && i <= stop7) || (i >= start8 && i <= stop8)) | 328 subBands.push_back (std::make_pair (start5, stop5)); |
318 { | 329 subBands.push_back (std::make_pair (start6, stop6)); |
319 *vit = txPowerPerBand / (bit->fh - bit->fl); | 330 subBands.push_back (std::make_pair (start7, stop7)); |
320 } | 331 subBands.push_back (std::make_pair (start8, stop8)); |
321 else | |
322 { | |
323 *vit = 0; | |
324 } | |
325 } | |
326 NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 << | |
327 ", " << start2 << "-" << stop2 << | |
328 ", " << start3 << "-" << stop3 << | |
329 ", " << start4 << "-" << stop4 << | |
330 ", " << start5 << "-" << stop5 << | |
331 ", " << start6 << "-" << stop6 << | |
332 ", " << start7 << "-" << stop7 << | |
333 ", " << start8 << "-" << stop8); | |
334 break; | 332 break; |
335 case 160: | 333 case 160: |
336 // 448 subcarriers (416 data + 32 pilot) | 334 // 448 subcarriers (416 data + 32 pilot) |
337 // possible alternative: 484 subcarriers (468 data + 16 pilot) | 335 // possible alternative: 484 subcarriers (468 data + 16 pilot) |
338 txPowerPerBand = txPowerW / 448; | 336 txPowerPerBand = txPowerW / 448; |
339 NS_LOG_DEBUG ("Power per band " << txPowerPerBand); | 337 lowestPointDbm = -59.0; //dBm/MHz |
340 for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) | 338 NS_ASSERT (lowestPointDbr == -40.0); |
341 { | 339 subBands.push_back (std::make_pair (start1, stop1)); |
342 if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2) || | 340 subBands.push_back (std::make_pair (start2, stop2)); |
343 (i >= start3 && i <= stop3) || (i >= start4 && i <= stop4) || | 341 subBands.push_back (std::make_pair (start3, stop3)); |
344 (i >= start5 && i <= stop5) || (i >= start6 && i <= stop6) || | 342 subBands.push_back (std::make_pair (start4, stop4)); |
345 (i >= start7 && i <= stop7) || (i >= start8 && i <= stop8) || | 343 subBands.push_back (std::make_pair (start5, stop5)); |
346 (i >= start9 && i <= stop9) || (i >= start10 && i <= stop10) || | 344 subBands.push_back (std::make_pair (start6, stop6)); |
347 (i >= start11 && i <= stop11) || (i >= start12 && i <= stop12) || | 345 subBands.push_back (std::make_pair (start7, stop7)); |
348 (i >= start13 && i <= stop13) || (i >= start14 && i <= stop14) || | 346 subBands.push_back (std::make_pair (start8, stop8)); |
349 (i >= start15 && i <= stop15) || (i >= start16 && i <= stop16)) | 347 subBands.push_back (std::make_pair (start9, stop9)); |
350 { | 348 subBands.push_back (std::make_pair (start10, stop10)); |
351 *vit = txPowerPerBand / (bit->fh - bit->fl); | 349 subBands.push_back (std::make_pair (start11, stop11)); |
352 } | 350 subBands.push_back (std::make_pair (start12, stop12)); |
353 else | 351 subBands.push_back (std::make_pair (start13, stop13)); |
354 { | 352 subBands.push_back (std::make_pair (start14, stop14)); |
355 *vit = 0; | 353 subBands.push_back (std::make_pair (start15, stop15)); |
356 } | 354 subBands.push_back (std::make_pair (start16, stop16)); |
357 } | |
358 NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 << | |
359 ", " << start2 << "-" << stop2 << | |
360 ", " << start3 << "-" << stop3 << | |
361 ", " << start4 << "-" << stop4 << | |
362 ", " << start5 << "-" << stop5 << | |
363 ", " << start6 << "-" << stop6 << | |
364 ", " << start7 << "-" << stop7 << | |
365 ", " << start8 << "-" << stop8 << | |
366 ", " << start9 << "-" << stop9 << | |
367 ", " << start10 << "-" << stop10 << | |
368 ", " << start11 << "-" << stop11 << | |
369 ", " << start12 << "-" << stop12 << | |
370 ", " << start13 << "-" << stop13 << | |
371 ", " << start14 << "-" << stop14 << | |
372 ", " << start15 << "-" << stop15 << | |
373 ", " << start16 << "-" << stop16); | |
374 break; | 355 break; |
375 } | 356 } |
376 NS_LOG_DEBUG ("Integrated power " << Integral (*c)); | 357 |
358 //Build transmit spectrum mask | |
359 CreateSpectrumMaskForOfdm (c, subBands, maskBand, | |
360 txPowerPerBand, nGuardBands, | |
361 innerSlopeWidth, lowestPointDbr, lowestPointDbm); | |
362 NormalizeSpectrumMask (c, txPowerW); | |
377 NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation f ailed"); | 363 NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation f ailed"); |
378 return c; | 364 return c; |
379 } | 365 } |
380 | 366 |
381 Ptr<SpectrumValue> | 367 Ptr<SpectrumValue> |
382 WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFreq uency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth) | 368 WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFreq uency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth) |
383 { | 369 { |
384 NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW << (uin t16_t)guardBandwidth); | 370 NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW << (uin t16_t)guardBandwidth); |
385 double bandBandwidth = 78125; | 371 double bandBandwidth = 78125; |
386 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); | 372 Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequenc y, channelWidth, bandBandwidth, guardBandwidth)); |
387 Values::iterator vit = c->ValuesBegin (); | 373 Values::iterator vit = c->ValuesBegin (); |
micha.rademacher
2017/10/25 13:16:47
unused-but-set-variable
Rediet
2017/10/30 15:07:57
Acknowledged.
| |
388 Bands::const_iterator bit = c->ConstBandsBegin (); | 374 Bands::const_iterator bit = c->ConstBandsBegin (); |
micha.rademacher
2017/10/25 13:16:47
unused-but-set-variable
Rediet
2017/10/30 15:07:56
Acknowledged.
| |
389 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); | 375 uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / ban dBandwidth) + 0.5); |
390 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); | 376 uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandB andwidth) + 0.5); |
391 NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nG uardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumB ands ()); | 377 NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nG uardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumB ands ()); |
392 double txPowerPerBand; | 378 double txPowerPerBand = 0.0; |
393 uint32_t start1; | 379 uint32_t start1; |
394 uint32_t stop1; | 380 uint32_t stop1; |
395 uint32_t start2; | 381 uint32_t start2; |
396 uint32_t stop2; | 382 uint32_t stop2; |
397 uint32_t start3; | 383 uint32_t start3; |
398 uint32_t stop3; | 384 uint32_t stop3; |
399 uint32_t start4; | 385 uint32_t start4; |
400 uint32_t stop4; | 386 uint32_t stop4; |
387 //Prepare spectrum mask specific variables | |
388 uint32_t innerSlopeWidth = static_cast<uint32_t>((1e6 / bandBandwidth) + 0.5); //size in number of subcarriers of the 0dBr<->20dBr slope | |
389 double lowestPointDbr = (centerFrequency >= 5000) ? | |
390 -40.0 : //if 5 GHz band | |
391 -45.0; //if 2.4 GHz band | |
392 double lowestPointDbm = 0.0; //to be defined per channel width | |
393 std::vector <StartStop> subBands; //list of data/pilot-containing subBands (se nt at 0dBr) | |
394 StartStop maskBand (0, nAllocatedBands + nGuardBands); | |
401 switch (channelWidth) | 395 switch (channelWidth) |
402 { | 396 { |
403 case 20: | 397 case 20: |
404 // 242 subcarriers (234 data + 8 pilot) | 398 // 242 subcarriers (234 data + 8 pilot) |
405 txPowerPerBand = txPowerW / 242; | 399 txPowerPerBand = txPowerW / 242; |
406 NS_LOG_DEBUG ("Power per band " << txPowerPerBand); | 400 lowestPointDbm = -53.0; //dBm/MHz |
401 innerSlopeWidth = static_cast<uint32_t>((5e5 / bandBandwidth) + 0.5); // [ -10.25;-9.75] & [9.75;10.25] | |
407 // skip the guard band and 11 subbands, then place power in 121 subbands, then | 402 // skip the guard band and 11 subbands, then place power in 121 subbands, then |
408 // skip 3 DC, then place power in 121 subbands, then skip | 403 // skip 3 DC, then place power in 121 subbands, then skip |
409 // the final 11 subbands and the guard band. | 404 // the final 11 subbands and the guard band. |
410 start1 = (nGuardBands / 2) + 12; | 405 start1 = (nGuardBands / 2) + 12; |
411 stop1 = start1 + 121 - 1; | 406 stop1 = start1 + 121 - 1; |
412 start2 = stop1 + 4; | 407 start2 = stop1 + 4; |
413 stop2 = start2 + 121 - 1; | 408 stop2 = start2 + 121 - 1; |
414 for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) | 409 subBands.push_back (std::make_pair (start1, stop1)); |
415 { | 410 subBands.push_back (std::make_pair (start2, stop2)); |
416 if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2)) | |
417 { | |
418 *vit = txPowerPerBand / (bit->fh - bit->fl); | |
419 } | |
420 else | |
421 { | |
422 *vit = 0; | |
423 } | |
424 } | |
425 NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 << | |
426 " and " << start2 << "-" << stop2); | |
427 break; | 411 break; |
428 case 40: | 412 case 40: |
429 // 484 subcarriers (468 data + 16 pilot) | 413 // 484 subcarriers (468 data + 16 pilot) |
430 txPowerPerBand = txPowerW / 484; | 414 txPowerPerBand = txPowerW / 484; |
431 NS_LOG_DEBUG ("Power per band " << txPowerPerBand); | 415 lowestPointDbm = -56.0; //dBm/MHz |
432 // skip the guard band and 11 subbands, then place power in 242 subbands, then | 416 // skip the guard band and 11 subbands, then place power in 242 subbands, then |
433 // skip 5 DC, then place power in 242 subbands, then skip | 417 // skip 5 DC, then place power in 242 subbands, then skip |
434 // the final 11 subbands and the guard band. | 418 // the final 11 subbands and the guard band. |
435 start1 = (nGuardBands / 2) + 12; | 419 start1 = (nGuardBands / 2) + 12; |
436 stop1 = start1 + 242 - 1; | 420 stop1 = start1 + 242 - 1; |
437 start2 = stop1 + 6; | 421 start2 = stop1 + 6; |
438 stop2 = start2 + 242 - 1; | 422 stop2 = start2 + 242 - 1; |
439 for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) | 423 subBands.push_back (std::make_pair (start1, stop1)); |
440 { | 424 subBands.push_back (std::make_pair (start2, stop2)); |
441 if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2)) | |
442 { | |
443 *vit = txPowerPerBand / (bit->fh - bit->fl); | |
444 } | |
445 else | |
446 { | |
447 *vit = 0; | |
448 } | |
449 } | |
450 NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 << | |
451 " and " << start2 << "-" << stop2); | |
452 break; | 425 break; |
453 case 80: | 426 case 80: |
454 // 996 subcarriers (980 data + 16 pilot) | 427 // 996 subcarriers (980 data + 16 pilot) |
455 txPowerPerBand = txPowerW / 996; | 428 txPowerPerBand = txPowerW / 996; |
456 NS_LOG_DEBUG ("Power per band " << txPowerPerBand); | 429 lowestPointDbm = -59.0; //dBm/MHz |
457 // skip the guard band and 11 subbands, then place power in 498 subbands, then | 430 // skip the guard band and 11 subbands, then place power in 498 subbands, then |
458 // skip 5 DC, then place power in 498 subbands, then skip | 431 // skip 5 DC, then place power in 498 subbands, then skip |
459 // the final 11 subbands and the guard band. | 432 // the final 11 subbands and the guard band. |
460 start1 = (nGuardBands / 2) + 12; | 433 start1 = (nGuardBands / 2) + 12; |
461 stop1 = start1 + 498 - 1; | 434 stop1 = start1 + 498 - 1; |
462 start2 = stop1 + 6; | 435 start2 = stop1 + 6; |
463 stop2 = start2 + 498 - 1; | 436 stop2 = start2 + 498 - 1; |
464 for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) | 437 subBands.push_back (std::make_pair (start1, stop1)); |
465 { | 438 subBands.push_back (std::make_pair (start2, stop2)); |
466 if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2)) | |
467 { | |
468 *vit = txPowerPerBand / (bit->fh - bit->fl); | |
469 } | |
470 else | |
471 { | |
472 *vit = 0; | |
473 } | |
474 } | |
475 NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 << | |
476 " and " << start2 << "-" << stop2); | |
477 break; | 439 break; |
478 case 160: | 440 case 160: |
479 // 2 x 996 subcarriers (2 x 80 MHZ bands) | 441 // 2 x 996 subcarriers (2 x 80 MHZ bands) |
480 txPowerPerBand = txPowerW / (2 * 996); | 442 txPowerPerBand = txPowerW / (2 * 996); |
481 NS_LOG_DEBUG ("Power per band " << txPowerPerBand); | 443 lowestPointDbm = -59.0; //dBm/MHz |
482 start1 = (nGuardBands / 2) + 12; | 444 start1 = (nGuardBands / 2) + 12; |
483 stop1 = start1 + 498 - 1; | 445 stop1 = start1 + 498 - 1; |
484 start2 = stop1 + 6; | 446 start2 = stop1 + 6; |
485 stop2 = start2 + 498 - 1; | 447 stop2 = start2 + 498 - 1; |
486 start3 = stop2 + (2 * 12); | 448 start3 = stop2 + (2 * 12); |
487 stop3 = start3 + 498 - 1; | 449 stop3 = start3 + 498 - 1; |
488 start4 = stop3 + 6; | 450 start4 = stop3 + 6; |
489 stop4 = start4 + 498 - 1; | 451 stop4 = start4 + 498 - 1; |
490 for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++, bit++) | 452 subBands.push_back (std::make_pair (start1, stop1)); |
491 { | 453 subBands.push_back (std::make_pair (start2, stop2)); |
492 if ((i >= start1 && i <= stop1) || (i >= start2 && i <= stop2) || | 454 subBands.push_back (std::make_pair (start3, stop3)); |
493 (i >= start3 && i <= stop3) || (i >= start4 && i <= stop4)) | 455 subBands.push_back (std::make_pair (start4, stop4)); |
494 { | |
495 *vit = txPowerPerBand / (bit->fh - bit->fl); | |
496 } | |
497 else | |
498 { | |
499 *vit = 0; | |
500 } | |
501 } | |
502 NS_LOG_DEBUG ("Added signal power to subbands " << start1 << "-" << stop1 << | |
503 ", " << start2 << "-" << stop2 << | |
504 ", " << start3 << "-" << stop3 << | |
505 ", " << start4 << "-" << stop4); | |
506 break; | 456 break; |
507 default: | 457 default: |
508 NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported"); | 458 NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported"); |
509 break; | 459 break; |
510 } | 460 } |
511 NS_LOG_DEBUG ("Integrated power " << Integral (*c)); | 461 |
462 //Build transmit spectrum mask | |
463 CreateSpectrumMaskForOfdm (c, subBands, maskBand, | |
464 txPowerPerBand, nGuardBands, | |
465 innerSlopeWidth, lowestPointDbr, lowestPointDbm); | |
466 NormalizeSpectrumMask (c, txPowerW); | |
512 NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation f ailed"); | 467 NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation f ailed"); |
513 return c; | 468 return c; |
514 } | 469 } |
515 | 470 |
516 Ptr<SpectrumValue> | 471 Ptr<SpectrumValue> |
517 WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequen cy, uint8_t channelWidth, double bandBandwidth, double noiseFigure, uint8_t guar dBandwidth) | 472 WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequen cy, uint8_t channelWidth, double bandBandwidth, double noiseFigure, uint8_t guar dBandwidth) |
518 { | 473 { |
519 Ptr<SpectrumModel> model = GetSpectrumModel (centerFrequency, channelWidth, ba ndBandwidth, guardBandwidth); | 474 Ptr<SpectrumModel> model = GetSpectrumModel (centerFrequency, channelWidth, ba ndBandwidth, guardBandwidth); |
520 return CreateNoisePowerSpectralDensity (noiseFigure, model); | 475 return CreateNoisePowerSpectralDensity (noiseFigure, model); |
521 } | 476 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 vit += startIndex; | 514 vit += startIndex; |
560 bit += startIndex; | 515 bit += startIndex; |
561 for (size_t i = startIndex; i < startIndex + numBandsInFilter; i++, vit++, bit ++) | 516 for (size_t i = startIndex; i < startIndex + numBandsInFilter; i++, vit++, bit ++) |
562 { | 517 { |
563 *vit = 1; | 518 *vit = 1; |
564 } | 519 } |
565 NS_LOG_DEBUG ("Added subbands " << startIndex << " to " << startIndex + numBan dsInFilter << " to filter"); | 520 NS_LOG_DEBUG ("Added subbands " << startIndex << " to " << startIndex + numBan dsInFilter << " to filter"); |
566 return c; | 521 return c; |
567 } | 522 } |
568 | 523 |
524 void | |
525 WifiSpectrumValueHelper::CreateSpectrumMaskForOfdm (Ptr<SpectrumValue> c, std::v ector <StartStop> allocatedSubBands, StartStop maskBand, | |
526 double txPowerPerBandW, uint 32_t nGuardBands, | |
527 uint32_t innerSlopeWidth, do uble lowestPointDbr, double lowestPointDbm) | |
528 { | |
529 NS_LOG_FUNCTION (c << allocatedSubBands.front ().first << allocatedSubBands.ba ck ().second << maskBand.first << maskBand.second << txPowerPerBandW << nGuardBa nds << innerSlopeWidth << lowestPointDbr << lowestPointDbm); | |
530 uint32_t numSubBands = allocatedSubBands.size (); | |
531 uint32_t numBands = c->GetSpectrumModel ()->GetNumBands (); | |
532 uint32_t numMaskBands = maskBand.second - maskBand.first + 1; | |
533 NS_ASSERT (numSubBands && numBands && numMaskBands); | |
534 NS_LOG_DEBUG ("Power per band " << txPowerPerBandW << "W"); | |
535 | |
536 //Different power levels | |
537 double txPowerPerBandDbm = (10.0 * std::log10 (txPowerPerBandW * 1000.0)); | |
538 double txPowerMinus20dBr = txPowerPerBandDbm - 20; | |
539 double txPowerMinus28dBr = txPowerPerBandDbm - 28; | |
540 double txPowerLowestPoint = txPowerPerBandDbm + lowestPointDbr; //Doing std::m ax (txPowerPerBandDbm + lowestPointDbr, lowestPointDbm) messed up everything for low signals (dBm/MHz to current band granularity conversion needed)... | |
541 | |
542 //Different widths (in number of bands) | |
543 uint32_t outerSlopeWidth = nGuardBands / 4; | |
544 uint32_t middleSlopeWidth = outerSlopeWidth - (innerSlopeWidth / 2); | |
545 StartStop outerBandLeft (maskBand.first, //to handle cases where allocated cha nnel is under WifiPhy configured channel width. | |
546 maskBand.first + outerSlopeWidth - 1); | |
547 StartStop middleBandLeft (outerBandLeft.second + 1, | |
548 outerBandLeft.second + middleSlopeWidth); | |
549 StartStop innerBandLeft (allocatedSubBands.front ().first - innerSlopeWidth, | |
550 allocatedSubBands.front ().first - 1); //better to pl ace slope based on allocated subcarriers | |
551 StartStop flatJunctionLeft (middleBandLeft.second + 1, | |
552 innerBandLeft.first - 1); //in order to handle shi ft due to guard subcarriers | |
553 StartStop outerBandRight (maskBand.second - outerSlopeWidth + 1, | |
554 maskBand.second); //start from outer edge to be able to compute flat junction width | |
555 StartStop middleBandRight (outerBandRight.first - middleSlopeWidth, | |
556 outerBandRight.first - 1); | |
557 StartStop innerBandRight (allocatedSubBands.back ().second + 1, | |
558 allocatedSubBands.back ().second + innerSlopeWidth); | |
559 StartStop flatJunctionRight (innerBandRight.second + 1, | |
560 middleBandRight.first - 1); | |
561 NS_LOG_DEBUG ("outerBandLeft=[" << outerBandLeft.first << ";" << outerBandLeft .second << "] " << | |
562 "middleBandLeft=[" << middleBandLeft.first << ";" << middleBandL eft.second << "] " << | |
563 "flatJunctionLeft=[" << flatJunctionLeft.first << ";" << flatJun ctionLeft.second << "] " << | |
564 "innerBandLeft=[" << innerBandLeft.first << ";" << innerBandLeft .second << "] " << | |
565 "subBands=[" << allocatedSubBands.front ().first << ";" << alloc atedSubBands.back ().second << "] " << | |
566 "innerBandRight=[" << innerBandRight.first << ";" << innerBandRi ght.second << "] " << | |
567 "flatJunctionRight=[" << flatJunctionRight.first << ";" << flatJ unctionRight.second << "] " << | |
568 "middleBandRight=[" << middleBandRight.first << ";" << middleBan dRight.second << "] " << | |
569 "outerBandRight=[" << outerBandRight.first << ";" << outerBandRi ght.second << "] "); | |
570 NS_ASSERT (numMaskBands == ((allocatedSubBands.back ().second - allocatedSubBa nds.front ().first + 1) //equivalent to allocatedBand (includes notches and DC) | |
571 + 2 * (innerSlopeWidth + middleSlopeWidth + outerSl opeWidth) | |
572 + (flatJunctionLeft.second - flatJunctionLeft.first + 1) //flat junctions | |
573 + (flatJunctionRight.second - flatJunctionRight.fir st + 1))); | |
574 | |
575 //Different slopes | |
576 double innerSlope = 20.0 / innerSlopeWidth; //0 to 20dBr | |
577 double middleSlope = 8.0 / middleSlopeWidth; //20 to 28dBr | |
578 double outerSlope = (txPowerMinus28dBr - txPowerLowestPoint) / outerSlopeWidth ; | |
579 | |
580 //Build spectrum mask | |
581 Values::iterator vit = c->ValuesBegin (); | |
582 Bands::const_iterator bit = c->ConstBandsBegin (); | |
583 double txPowerW = 0.0; | |
584 for (size_t i = 0; i < numBands; i++, vit++, bit++) | |
585 { | |
586 if (i < maskBand.first || i > maskBand.second) //outside the spectrum mask | |
587 { | |
588 txPowerW = 0.0; | |
589 } | |
590 else if (i <= outerBandLeft.second && i >= outerBandLeft.first) //better t o put greater first (less computation) | |
591 { | |
592 txPowerW = std::pow (10.0, (txPowerLowestPoint + ((i - outerBandLeft.f irst) * outerSlope)) / 10.0) / 1000.0; | |
593 } | |
594 else if (i <= middleBandLeft.second && i >= middleBandLeft.first) | |
595 { | |
596 txPowerW = std::pow (10.0, (txPowerMinus28dBr + ((i - middleBandLeft.f irst) * middleSlope)) / 10.0) / 1000.0; | |
597 } | |
598 else if (i <= flatJunctionLeft.second && i >= flatJunctionLeft.first) | |
599 { | |
600 txPowerW = std::pow (10.0, txPowerMinus20dBr / 10.0) / 1000.0; | |
601 } | |
602 else if (i <= innerBandLeft.second && i >= innerBandLeft.first) | |
603 { | |
604 txPowerW = std::pow (10.0, (txPowerMinus20dBr + ((i - innerBandLeft.fi rst) * innerSlope)) / 10.0) / 1000.0; | |
605 } | |
606 else if (i <= allocatedSubBands.back ().second && i >= allocatedSubBands.f ront ().first) //roughly in allocated band | |
607 { | |
608 bool insideSubBand = false; | |
609 for (uint32_t j = 0; !insideSubBand && j < numSubBands; j++) //continu e until inside a sub-band | |
610 { | |
611 insideSubBand = (i <= allocatedSubBands[j].second) && (i >= alloca tedSubBands[j].first); | |
612 } | |
613 if (insideSubBand) | |
614 { | |
615 txPowerW = txPowerPerBandW; | |
616 } | |
617 else | |
618 { | |
619 txPowerW = std::pow (10.0, txPowerMinus20dBr / 10.0) / 1000.0; //c onsider that nulled as much as possible inband but power leakage -> -20dBr | |
620 } | |
621 } | |
622 else if (i <= innerBandRight.second && i >= innerBandRight.first) | |
623 { | |
624 txPowerW = std::pow (10.0, (txPowerPerBandDbm - ((i - innerBandRight.f irst) * innerSlope)) / 10.0) / 1000.0; | |
625 } | |
626 else if (i <= flatJunctionRight.second && i >= flatJunctionRight.first) | |
627 { | |
628 txPowerW = std::pow (10.0, txPowerMinus20dBr / 10.0) / 1000.0; | |
629 } | |
630 else if (i <= middleBandRight.second && i >= middleBandRight.first) | |
631 { | |
632 txPowerW = std::pow (10.0, (txPowerMinus20dBr - ((i - middleBandRight. first) * middleSlope)) / 10.0) / 1000.0; | |
633 } | |
634 else if (i <= outerBandRight.second && i >= outerBandRight.first) | |
635 { | |
636 txPowerW = std::pow (10.0, (txPowerMinus28dBr - ((i - outerBandRight.f irst) * outerSlope)) / 10.0) / 1000.0; | |
637 } | |
638 else | |
639 { | |
640 NS_FATAL_ERROR ("Should have handled all cases"); | |
641 } | |
642 *vit = txPowerW / (bit->fh - bit->fl); | |
643 } | |
644 NS_LOG_DEBUG ("Added signal power to subbands " << allocatedSubBands.front (). first << "-" << allocatedSubBands.back ().second); | |
645 } | |
646 | |
647 void | |
648 WifiSpectrumValueHelper::NormalizeSpectrumMask (Ptr<SpectrumValue> c, double txP owerW) | |
649 { | |
650 NS_LOG_FUNCTION (c << txPowerW); | |
651 //Normalize power so that total signal power equals transmit power | |
652 double currentTxPowerW = Integral (*c); | |
653 double normalizationRatio = currentTxPowerW / txPowerW; | |
654 NS_LOG_DEBUG ("Current power: " << currentTxPowerW << "W vs expected power: " << txPowerW << "W" << | |
655 " -> ratio (C/E) = " << normalizationRatio); | |
656 Values::iterator vit = c->ValuesBegin (); | |
657 for (size_t i = 0; i < c->GetSpectrumModel ()->GetNumBands (); i++, vit++) | |
658 { | |
659 *vit = (*vit) / normalizationRatio; | |
660 } | |
661 } | |
662 | |
569 static Ptr<SpectrumModel> g_WifiSpectrumModel5Mhz; ///< static initializer for t he class | 663 static Ptr<SpectrumModel> g_WifiSpectrumModel5Mhz; ///< static initializer for t he class |
570 | 664 |
571 WifiSpectrumValueHelper::~WifiSpectrumValueHelper () | 665 WifiSpectrumValueHelper::~WifiSpectrumValueHelper () |
572 { | 666 { |
573 } | 667 } |
574 | 668 |
575 WifiSpectrumValue5MhzFactory::~WifiSpectrumValue5MhzFactory () | 669 WifiSpectrumValue5MhzFactory::~WifiSpectrumValue5MhzFactory () |
576 { | 670 { |
577 } | 671 } |
578 | 672 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
653 (*rf)[channel + 3] = 1; | 747 (*rf)[channel + 3] = 1; |
654 (*rf)[channel + 4] = 1; | 748 (*rf)[channel + 4] = 1; |
655 (*rf)[channel + 5] = 1; | 749 (*rf)[channel + 5] = 1; |
656 (*rf)[channel + 6] = 1; | 750 (*rf)[channel + 6] = 1; |
657 | 751 |
658 return rf; | 752 return rf; |
659 } | 753 } |
660 | 754 |
661 | 755 |
662 } // namespace ns3 | 756 } // namespace ns3 |
OLD | NEW |