A Discrete-Event Network Simulator
API
wifi-transmit-mask-test.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2017 Orange Labs
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Rediet <getachew.redieteab@orange.com>
19  */
20 
21 #include <cmath>
22 #include "ns3/test.h"
23 #include "ns3/log.h"
24 #include "ns3/fatal-error.h"
25 #include "ns3/wifi-spectrum-value-helper.h"
26 #include "ns3/wifi-standards.h"
27 #include "ns3/wifi-phy-band.h"
28 
29 using namespace ns3;
30 
31 NS_LOG_COMPONENT_DEFINE ("WifiTransmitMaskTest");
32 
41 {
42 public:
46  typedef std::pair<uint32_t, double> IndexPowerPair;
47 
51  typedef std::vector<IndexPowerPair> IndexPowerVect;
52 
66  WifiOfdmMaskSlopesTestCase (const char* str, WifiPhyStandard standard, WifiPhyBand band, uint8_t bw,
67  IndexPowerVect maskRefsLeft, IndexPowerVect maskRefsRight, double tol);
68  virtual ~WifiOfdmMaskSlopesTestCase ();
69 
70 protected:
74  double m_tolerance;
75 
76 private:
77  void DoRun (void) override;
88  static void InterpolateAndAppendValues (IndexPowerVect &vect, IndexPowerPair start, IndexPowerPair stop,
89  double tol);
90 };
91 
93  IndexPowerVect maskRefsLeft, IndexPowerVect maskRefsRight, double tol)
94  : TestCase (std::string ("SpectrumValue ") + str)
95 {
96  NS_LOG_FUNCTION (this << str << standard << band << +bw << tol);
97  NS_ASSERT (maskRefsLeft.size () % 2 == 0 && maskRefsRight.size () % 2 == 0); //start/stop pairs expected
98  uint16_t freq = 5170 + (bw / 2); // so as to have 5180/5190/5210/5250 for 20/40/80/160
99  double refTxPowerW = 1; // have to work in dBr when comparing though
100  m_tolerance = tol; // in dB
101  double outerBandMaximumRejection = -40; // in dBr
102 
103  switch (standard)
104  {
106  NS_ASSERT ((bw == 5) || (bw == 10));
107  freq = 5860;
108  m_actualSpectrum = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw, -20.0, -28.0, outerBandMaximumRejection);
109  break;
110 
111  // 11g and 11a
113  freq = 2412;
114  // no break on purpose
116  NS_ASSERT (bw == 20);
117  m_actualSpectrum = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw, -20.0, -28.0, outerBandMaximumRejection);
118  break;
119 
120  // 11n
122  if (band == WIFI_PHY_BAND_2_4GHZ)
123  {
124  freq = 2402 + (bw / 2); //so as to have 2412/2422 for 20/40
125  outerBandMaximumRejection = -45;
126  }
127  NS_ASSERT (bw == 20 || bw == 40);
128  m_actualSpectrum = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw, -20.0, -28.0, outerBandMaximumRejection);
129  break;
130 
131  // 11ac
133  NS_ASSERT (bw == 20 || bw == 40 || bw == 80 || bw == 160);
134  m_actualSpectrum = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw, -20.0, -28.0, outerBandMaximumRejection);
135  break;
136 
137  // 11ax
139  if (band == WIFI_PHY_BAND_2_4GHZ)
140  {
141  NS_ASSERT (bw != 160); // not enough space in 2.4 GHz bands
142  freq = 2402 + (bw / 2); //so as to have 2412/2422 for 20/40
143  outerBandMaximumRejection = -45;
144  }
145  NS_ASSERT (bw == 20 || bw == 40 || bw == 80 || bw == 160);
146  m_actualSpectrum = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw, -20.0, -28.0, outerBandMaximumRejection);
147  break;
148 
149  // other
150  default:
151  NS_FATAL_ERROR ("Standard unknown or non-OFDM");
152  break;
153  }
154 
155  NS_LOG_INFO ("Build expected left PSD");
156  for (uint32_t i = 0; i < maskRefsLeft.size (); i = i + 2)
157  {
158  InterpolateAndAppendValues (m_expectedLeftPsd, maskRefsLeft[i], maskRefsLeft[i + 1], tol);
159  }
160  NS_ASSERT (m_expectedLeftPsd.size () == (m_expectedLeftPsd.back ().first - m_expectedLeftPsd.front ().first + 1));
161 
162  NS_LOG_INFO ("Build expected right PSD");
163  for (uint32_t i = 0; i < maskRefsRight.size (); i = i + 2)
164  {
165  InterpolateAndAppendValues (m_expectedRightPsd, maskRefsRight[i], maskRefsRight[i + 1], tol);
166  }
167  NS_ASSERT (m_expectedRightPsd.size () == (m_expectedRightPsd.back ().first - m_expectedRightPsd.front ().first + 1));
168 
169 }
170 
172 {
173 }
174 
175 void
177  double tol)
178 {
179  NS_LOG_FUNCTION (start.first << start.second << stop.first << stop.second);
180  NS_ASSERT (start.first <= stop.first);
181 
182  if (start.first == stop.first) //only one point, no need to interpolate
183  {
184  NS_ASSERT (start.second == stop.second);
185  vect.push_back (start);
186  NS_LOG_LOGIC ("Append (" << start.first << ", " << stop.second << ")");
187  return;
188  }
189 
190  double slope = (stop.second - start.second) / (stop.first - start.first);
191  for (uint32_t i = start.first; i <= stop.first; i++)
192  {
193  double val = start.second + slope * (i - start.first);
194  vect.push_back (std::make_pair (i, val));
195  NS_LOG_LOGIC ("Append (" << i << ", " << val << ")");
196  }
197  NS_ASSERT (vect.back ().first == stop.first
198  && TestDoubleIsEqual (vect.back ().second, stop.second, tol));
199 }
200 
201 void
203 {
204  NS_LOG_FUNCTION (this);
205  double currentPowerDbr = 0.0; //have to work in dBr so as to compare with expected slopes
206  double maxPowerW = (*m_actualSpectrum)[0];
207  for (Values::const_iterator vit = m_actualSpectrum->ConstValuesBegin (); vit != m_actualSpectrum->ConstValuesEnd (); vit++)
208  {
209  maxPowerW = std::max (maxPowerW, *vit);
210  }
211 
212  NS_LOG_INFO ("Compare expected left PSD");
213  for (IndexPowerVect::const_iterator it = m_expectedLeftPsd.begin (); it != m_expectedLeftPsd.end (); it++)
214  {
215  currentPowerDbr = 10.0 * std::log10 ((*m_actualSpectrum)[it->first] / maxPowerW);
216  NS_LOG_LOGIC ("For " << it->first << ", expected: " << it->second << " vs obtained: " << currentPowerDbr);
217  NS_TEST_EXPECT_MSG_EQ_TOL (currentPowerDbr, it->second, m_tolerance,
218  "Spectrum value mismatch for left guard band (" << it->first << ")");
219  }
220  NS_LOG_INFO ("Compare expected right PSD");
221  for (IndexPowerVect::const_iterator it = m_expectedRightPsd.begin (); it != m_expectedRightPsd.end (); it++)
222  {
223  currentPowerDbr = 10.0 * std::log10 ((*m_actualSpectrum)[it->first] / maxPowerW);
224  NS_LOG_LOGIC ("For " << it->first << ", expected: " << it->second << " vs obtained: " << currentPowerDbr);
225  NS_TEST_EXPECT_MSG_EQ_TOL (currentPowerDbr, it->second, m_tolerance,
226  "Spectrum value mismatch for right guard band (" << it->first << ")");
227  }
228 }
229 
230 
231 
239 {
240 public:
242 };
243 
245 
247  : TestSuite ("wifi-transmit-mask", UNIT)
248 {
249 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
250 // LogComponentEnable ("WifiTransmitMaskTest", logLevel);
251 // LogComponentEnable ("WifiSpectrumValueHelper", logLevel);
252 
253  NS_LOG_INFO ("Creating WifiTransmitMaskTestSuite");
254 
257  double tol = 0.001; // in dB
258 
259  // ============================================================================================
260  // 11p 5MHz
261  NS_LOG_FUNCTION ("Check slopes for 11p 5MHz");
262  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
263  maskSlopesLeft.push_back (std::make_pair (31, -28.375)); // Outer band left (stop)
264  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
265  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
266  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
267  maskSlopesLeft.push_back (std::make_pair (63, -20.0)); // Flat junction band left (stop)
268  maskSlopesLeft.push_back (std::make_pair (64, -20.0)); // Inner band left (start)
269  maskSlopesLeft.push_back (std::make_pair (69, -3.333)); // Inner band left (stop)
270  maskSlopesRight.push_back (std::make_pair (123, -3.333)); // Inner band right (start)
271  maskSlopesRight.push_back (std::make_pair (128, -20.0)); // Inner band right (stop)
272  maskSlopesRight.push_back (std::make_pair (129, -20.0)); // Flat junction band right (start)
273  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
274  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
275  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
276  maskSlopesRight.push_back (std::make_pair (161, -28.375)); // Outer band right (start)
277  maskSlopesRight.push_back (std::make_pair (192, -40.0)); // Outer band right (stop)
279  5, maskSlopesLeft, maskSlopesRight, tol),
280  TestCase::QUICK);
281 
282  // 11p 10MHz
283  NS_LOG_FUNCTION ("Check slopes for 11p 10MHz");
284  maskSlopesLeft.clear ();
285  maskSlopesRight.clear ();
286  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
287  maskSlopesLeft.push_back (std::make_pair (31, -28.375)); // Outer band left (stop)
288  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
289  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
290  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
291  maskSlopesLeft.push_back (std::make_pair (63, -20.0)); // Flat junction band left (stop)
292  maskSlopesLeft.push_back (std::make_pair (64, -20.0)); // Inner band left (start)
293  maskSlopesLeft.push_back (std::make_pair (69, -3.333)); // Inner band left (stop)
294  maskSlopesRight.push_back (std::make_pair (123, -3.333)); // Inner band right (start)
295  maskSlopesRight.push_back (std::make_pair (128, -20.0)); // Inner band right (stop)
296  maskSlopesRight.push_back (std::make_pair (129, -20.0)); // Flat junction band right (start)
297  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
298  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
299  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
300  maskSlopesRight.push_back (std::make_pair (161, -28.375)); // Outer band right (start)
301  maskSlopesRight.push_back (std::make_pair (192, -40.0)); // Outer band right (stop)
303  10, maskSlopesLeft, maskSlopesRight, tol),
304  TestCase::QUICK);
305 
306 
307  // ============================================================================================
308  // 11a
309  NS_LOG_FUNCTION ("Check slopes for 11a");
310  maskSlopesLeft.clear ();
311  maskSlopesRight.clear ();
312  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
313  maskSlopesLeft.push_back (std::make_pair (31, -28.375)); // Outer band left (stop)
314  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
315  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
316  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
317  maskSlopesLeft.push_back (std::make_pair (63, -20.0)); // Flat junction band left (stop)
318  maskSlopesLeft.push_back (std::make_pair (64, -20.0)); // Inner band left (start)
319  maskSlopesLeft.push_back (std::make_pair (69, -3.333)); // Inner band left (stop)
320  maskSlopesRight.push_back (std::make_pair (123, -3.333)); // Inner band right (start)
321  maskSlopesRight.push_back (std::make_pair (128, -20.0)); // Inner band right (stop)
322  maskSlopesRight.push_back (std::make_pair (129, -20.0)); // Flat junction band right (start)
323  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
324  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
325  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
326  maskSlopesRight.push_back (std::make_pair (161, -28.375)); // Outer band right (start)
327  maskSlopesRight.push_back (std::make_pair (192, -40.0)); // Outer band right (stop)
329  20, maskSlopesLeft, maskSlopesRight, tol),
330  TestCase::QUICK);
331 
332  // 11g
333  NS_LOG_FUNCTION ("Check slopes for 11g");
334  // same slppes as 11g
336  20, maskSlopesLeft, maskSlopesRight, tol),
337  TestCase::QUICK);
338 
339 
340  // ============================================================================================
341  // 11n 20MHz @ 2.4GHz
342  NS_LOG_FUNCTION ("Check slopes for 11n 20MHz @ 2.4GHz");
343  maskSlopesLeft.clear ();
344  maskSlopesRight.clear ();
345  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
346  maskSlopesLeft.push_back (std::make_pair (31, -28.531)); // Outer band left (stop)
347  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
348  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
349  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
350  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (stop)
351  maskSlopesLeft.push_back (std::make_pair (62, -20.0)); // Inner band left (start)
352  maskSlopesLeft.push_back (std::make_pair (67, -3.333)); // Inner band left (stop)
353  maskSlopesRight.push_back (std::make_pair (125, -3.333)); // Inner band right (start)
354  maskSlopesRight.push_back (std::make_pair (130, -20.0)); // Inner band right (stop)
355  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (start)
356  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
357  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
358  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
359  maskSlopesRight.push_back (std::make_pair (161, -28.531)); // Outer band right (start)
360  maskSlopesRight.push_back (std::make_pair (192, -45.000)); // Outer band right (stop)
362  20, maskSlopesLeft, maskSlopesRight, tol),
363  TestCase::QUICK);
364 
365  // 11n 20MHz @ 5GHz
366  NS_LOG_FUNCTION ("Check slopes for 11n 20MHz @ 5GHz");
367  maskSlopesLeft.clear ();
368  maskSlopesRight.clear ();
369  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
370  maskSlopesLeft.push_back (std::make_pair (31, -28.375)); // Outer band left (stop)
371  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
372  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
373  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
374  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (stop)
375  maskSlopesLeft.push_back (std::make_pair (62, -20.0)); // Inner band left (start)
376  maskSlopesLeft.push_back (std::make_pair (67, -3.333)); // Inner band left (stop)
377  maskSlopesRight.push_back (std::make_pair (125, -3.333)); // Inner band right (start)
378  maskSlopesRight.push_back (std::make_pair (130, -20.0)); // Inner band right (stop)
379  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (start)
380  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
381  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
382  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
383  maskSlopesRight.push_back (std::make_pair (161, -28.375)); // Outer band right (start)
384  maskSlopesRight.push_back (std::make_pair (192, -40.0)); // Outer band right (stop)
386  20, maskSlopesLeft, maskSlopesRight, tol),
387  TestCase::QUICK);
388 
389  // 11n 40MHz @ 2.4GHz
390  NS_LOG_FUNCTION ("Check slopes for 11n 40MHz @ 2.4GHz");
391  maskSlopesLeft.clear ();
392  maskSlopesRight.clear ();
393  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
394  maskSlopesLeft.push_back (std::make_pair (63, -28.266)); // Outer band left (stop)
395  maskSlopesLeft.push_back (std::make_pair (64, -28.000)); // Middle band left (start)
396  maskSlopesLeft.push_back (std::make_pair (124, -20.131)); // Middle band left (stop)
397  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (start)
398  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (stop)
399  maskSlopesLeft.push_back (std::make_pair (126, -20.0)); // Inner band left (start)
400  maskSlopesLeft.push_back (std::make_pair (131, -3.333)); // Inner band left (stop)
401  maskSlopesRight.push_back (std::make_pair (253, -3.333)); // Inner band right (start)
402  maskSlopesRight.push_back (std::make_pair (258, -20.0)); // Inner band right (stop)
403  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (start)
404  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (stop)
405  maskSlopesRight.push_back (std::make_pair (260, -20.131)); // Middle band right (start)
406  maskSlopesRight.push_back (std::make_pair (320, -28.000)); // Middle band right (stop)
407  maskSlopesRight.push_back (std::make_pair (321, -28.266)); // Outer band right (start)
408  maskSlopesRight.push_back (std::make_pair (384, -45.000)); // Outer band right (stop)
410  40, maskSlopesLeft, maskSlopesRight, tol),
411  TestCase::QUICK);
412 
413  // 11n 20MHz @ 5GHz
414  NS_LOG_FUNCTION ("Check slopes for 11n 40MHz @ 5GHz");
415  maskSlopesLeft.clear ();
416  maskSlopesRight.clear ();
417  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
418  maskSlopesLeft.push_back (std::make_pair (63, -28.188)); // Outer band left (stop)
419  maskSlopesLeft.push_back (std::make_pair (64, -28.000)); // Middle band left (start)
420  maskSlopesLeft.push_back (std::make_pair (124, -20.131)); // Middle band left (stop)
421  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (start)
422  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (stop)
423  maskSlopesLeft.push_back (std::make_pair (126, -20.0)); // Inner band left (start)
424  maskSlopesLeft.push_back (std::make_pair (131, -3.333)); // Inner band left (stop)
425  maskSlopesRight.push_back (std::make_pair (253, -3.333)); // Inner band right (start)
426  maskSlopesRight.push_back (std::make_pair (258, -20.0)); // Inner band right (stop)
427  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (start)
428  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (stop)
429  maskSlopesRight.push_back (std::make_pair (260, -20.131)); // Middle band right (start)
430  maskSlopesRight.push_back (std::make_pair (320, -28.000)); // Middle band right (stop)
431  maskSlopesRight.push_back (std::make_pair (321, -28.188)); // Outer band right (start)
432  maskSlopesRight.push_back (std::make_pair (384, -40.0)); // Outer band right (stop)
434  40, maskSlopesLeft, maskSlopesRight, tol),
435  TestCase::QUICK);
436 
437 
438  // ============================================================================================
439  // 11ac 20MHz
440  NS_LOG_FUNCTION ("Check slopes for 11ac 20MHz");
441  maskSlopesLeft.clear ();
442  maskSlopesRight.clear ();
443  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
444  maskSlopesLeft.push_back (std::make_pair (31, -28.375)); // Outer band left (stop)
445  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
446  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
447  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
448  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (stop)
449  maskSlopesLeft.push_back (std::make_pair (62, -20.0)); // Inner band left (start)
450  maskSlopesLeft.push_back (std::make_pair (67, -3.333)); // Inner band left (stop)
451  maskSlopesRight.push_back (std::make_pair (125, -3.333)); // Inner band right (start)
452  maskSlopesRight.push_back (std::make_pair (130, -20.0)); // Inner band right (stop)
453  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (start)
454  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
455  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
456  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
457  maskSlopesRight.push_back (std::make_pair (161, -28.375)); // Outer band right (start)
458  maskSlopesRight.push_back (std::make_pair (192, -40.0)); // Outer band right (stop)
460  20, maskSlopesLeft, maskSlopesRight, tol),
461  TestCase::QUICK);
462 
463  // 11ac 20MHz
464  NS_LOG_FUNCTION ("Check slopes for 11ac 40MHz");
465  maskSlopesLeft.clear ();
466  maskSlopesRight.clear ();
467  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
468  maskSlopesLeft.push_back (std::make_pair (63, -28.188)); // Outer band left (stop)
469  maskSlopesLeft.push_back (std::make_pair (64, -28.000)); // Middle band left (start)
470  maskSlopesLeft.push_back (std::make_pair (124, -20.131)); // Middle band left (stop)
471  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (start)
472  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (stop)
473  maskSlopesLeft.push_back (std::make_pair (126, -20.0)); // Inner band left (start)
474  maskSlopesLeft.push_back (std::make_pair (131, -3.333)); // Inner band left (stop)
475  maskSlopesRight.push_back (std::make_pair (253, -3.333)); // Inner band right (start)
476  maskSlopesRight.push_back (std::make_pair (258, -20.0)); // Inner band right (stop)
477  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (start)
478  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (stop)
479  maskSlopesRight.push_back (std::make_pair (260, -20.131)); // Middle band right (start)
480  maskSlopesRight.push_back (std::make_pair (320, -28.000)); // Middle band right (stop)
481  maskSlopesRight.push_back (std::make_pair (321, -28.188)); // Outer band right (start)
482  maskSlopesRight.push_back (std::make_pair (384, -40.0)); // Outer band right (stop)
484  40, maskSlopesLeft, maskSlopesRight, tol),
485  TestCase::QUICK);
486 
487  // 11ac 80MHz
488  NS_LOG_FUNCTION ("Check slopes for 11ac 80MHz");
489  maskSlopesLeft.clear ();
490  maskSlopesRight.clear ();
491  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
492  maskSlopesLeft.push_back (std::make_pair (127, -28.094)); // Outer band left (stop)
493  maskSlopesLeft.push_back (std::make_pair (128, -28.000)); // Middle band left (start)
494  maskSlopesLeft.push_back (std::make_pair (252, -20.064)); // Middle band left (stop)
495  maskSlopesLeft.push_back (std::make_pair (253, -20.0)); // Flat junction band left (start)
496  maskSlopesLeft.push_back (std::make_pair (253, -20.0)); // Flat junction band left (stop)
497  maskSlopesLeft.push_back (std::make_pair (254, -20.0)); // Inner band left (start)
498  maskSlopesLeft.push_back (std::make_pair (259, -3.333)); // Inner band left (stop)
499  maskSlopesRight.push_back (std::make_pair (509, -3.333)); // Inner band right (start)
500  maskSlopesRight.push_back (std::make_pair (514, -20.0)); // Inner band right (stop)
501  maskSlopesRight.push_back (std::make_pair (515, -20.0)); // Flat junction band right (start)
502  maskSlopesRight.push_back (std::make_pair (515, -20.0)); // Flat junction band right (stop)
503  maskSlopesRight.push_back (std::make_pair (516, -20.064)); // Middle band right (start)
504  maskSlopesRight.push_back (std::make_pair (640, -28.000)); // Middle band right (stop)
505  maskSlopesRight.push_back (std::make_pair (641, -28.094)); // Outer band right (start)
506  maskSlopesRight.push_back (std::make_pair (768, -40.0)); // Outer band right (stop)
508  80, maskSlopesLeft, maskSlopesRight, tol),
509  TestCase::QUICK);
510 
511  // 11ac 20MHz
512  NS_LOG_FUNCTION ("Check slopes for 11ac 160MHz");
513  maskSlopesLeft.clear ();
514  maskSlopesRight.clear ();
515  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
516  maskSlopesLeft.push_back (std::make_pair (255, -28.047)); // Outer band left (stop)
517  maskSlopesLeft.push_back (std::make_pair (256, -28.000)); // Middle band left (start)
518  maskSlopesLeft.push_back (std::make_pair (508, -20.032)); // Middle band left (stop)
519  maskSlopesLeft.push_back (std::make_pair (509, -20.0)); // Flat junction band left (start)
520  maskSlopesLeft.push_back (std::make_pair (509, -20.0)); // Flat junction band left (stop)
521  maskSlopesLeft.push_back (std::make_pair (510, -20.0)); // Inner band left (start)
522  maskSlopesLeft.push_back (std::make_pair (515, -3.333)); // Inner band left (stop)
523  maskSlopesRight.push_back (std::make_pair (1021, -3.333)); // Inner band right (start)
524  maskSlopesRight.push_back (std::make_pair (1026, -20.0)); // Inner band right (stop)
525  maskSlopesRight.push_back (std::make_pair (1027, -20.0)); // Flat junction band right (start)
526  maskSlopesRight.push_back (std::make_pair (1027, -20.0)); // Flat junction band right (stop)
527  maskSlopesRight.push_back (std::make_pair (1028, -20.032)); // Middle band right (start)
528  maskSlopesRight.push_back (std::make_pair (1280, -28.000)); // Middle band right (stop)
529  maskSlopesRight.push_back (std::make_pair (1281, -28.047)); // Outer band right (start)
530  maskSlopesRight.push_back (std::make_pair (1536, -40.0)); // Outer band right (stop)
532  160, maskSlopesLeft, maskSlopesRight, tol),
533  TestCase::QUICK);
534 
535 
536  // ============================================================================================
537  // 11ax 20MHz @ 2.4GHz
538  NS_LOG_FUNCTION ("Check slopes for 11ax 20MHz @ 2.4GHz");
539  maskSlopesLeft.clear ();
540  maskSlopesRight.clear ();
541  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
542  maskSlopesLeft.push_back (std::make_pair (127, -28.133)); // Outer band left (stop)
543  maskSlopesLeft.push_back (std::make_pair (128, -28.000)); // Middle band left (start)
544  maskSlopesLeft.push_back (std::make_pair (252, -20.064)); // Middle band left (stop)
545  maskSlopesLeft.push_back (std::make_pair (253, -20.0)); // Flat junction band left (start)
546  maskSlopesLeft.push_back (std::make_pair (255, -20.0)); // Flat junction band left (stop)
547  maskSlopesLeft.push_back (std::make_pair (256, -20.0)); // Inner band left (start)
548  maskSlopesLeft.push_back (std::make_pair (261, -3.333)); // Inner band left (stop)
549  maskSlopesRight.push_back (std::make_pair (507, -3.333)); // Inner band right (start)
550  maskSlopesRight.push_back (std::make_pair (512, -20.0)); // Inner band right (stop)
551  maskSlopesRight.push_back (std::make_pair (513, -20.0)); // Flat junction band right (start)
552  maskSlopesRight.push_back (std::make_pair (515, -20.0)); // Flat junction band right (stop)
553  maskSlopesRight.push_back (std::make_pair (516, -20.064)); // Middle band right (start)
554  maskSlopesRight.push_back (std::make_pair (640, -28.000)); // Middle band right (stop)
555  maskSlopesRight.push_back (std::make_pair (641, -28.133)); // Outer band right (start)
556  maskSlopesRight.push_back (std::make_pair (768, -45.000)); // Outer band right (stop)
558  20, maskSlopesLeft, maskSlopesRight, tol),
559  TestCase::QUICK);
560 
561  // 11ax 20MHz @ 5GHz
562  NS_LOG_FUNCTION ("Check slopes for 11ax 20MHz @ 5GHz");
563  maskSlopesLeft.clear ();
564  maskSlopesRight.clear ();
565  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
566  maskSlopesLeft.push_back (std::make_pair (127, -28.094)); // Outer band left (stop)
567  maskSlopesLeft.push_back (std::make_pair (128, -28.000)); // Middle band left (start)
568  maskSlopesLeft.push_back (std::make_pair (252, -20.064)); // Middle band left (stop)
569  maskSlopesLeft.push_back (std::make_pair (253, -20.0)); // Flat junction band left (start)
570  maskSlopesLeft.push_back (std::make_pair (255, -20.0)); // Flat junction band left (stop)
571  maskSlopesLeft.push_back (std::make_pair (256, -20.0)); // Inner band left (start)
572  maskSlopesLeft.push_back (std::make_pair (261, -3.333)); // Inner band left (stop)
573  maskSlopesRight.push_back (std::make_pair (507, -3.333)); // Inner band right (start)
574  maskSlopesRight.push_back (std::make_pair (512, -20.0)); // Inner band right (stop)
575  maskSlopesRight.push_back (std::make_pair (513, -20.0)); // Flat junction band right (start)
576  maskSlopesRight.push_back (std::make_pair (515, -20.0)); // Flat junction band right (stop)
577  maskSlopesRight.push_back (std::make_pair (516, -20.064)); // Middle band right (start)
578  maskSlopesRight.push_back (std::make_pair (640, -28.000)); // Middle band right (stop)
579  maskSlopesRight.push_back (std::make_pair (641, -28.094)); // Outer band right (start)
580  maskSlopesRight.push_back (std::make_pair (768, -40.0)); // Outer band right (stop)
582  20, maskSlopesLeft, maskSlopesRight, tol),
583  TestCase::QUICK);
584 
585  // 11ax 40MHz @ 2.4GHz
586  NS_LOG_FUNCTION ("Check slopes for 11ax 40MHz @ 2.4GHz");
587  maskSlopesLeft.clear ();
588  maskSlopesRight.clear ();
589  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
590  maskSlopesLeft.push_back (std::make_pair (255, -28.066)); // Outer band left (stop)
591  maskSlopesLeft.push_back (std::make_pair (256, -28.000)); // Middle band left (start)
592  maskSlopesLeft.push_back (std::make_pair (505, -20.032)); // Middle band left (stop)
593  maskSlopesLeft.push_back (std::make_pair (506, -20.0)); // Flat junction band left (start)
594  maskSlopesLeft.push_back (std::make_pair (510, -20.0)); // Flat junction band left (stop)
595  maskSlopesLeft.push_back (std::make_pair (511, -20.0)); // Inner band left (start)
596  maskSlopesLeft.push_back (std::make_pair (523, -1.538)); // Inner band left (stop)
597  maskSlopesRight.push_back (std::make_pair (1013, -1.538)); // Inner band right (start)
598  maskSlopesRight.push_back (std::make_pair (1025, -20.0)); // Inner band right (stop)
599  maskSlopesRight.push_back (std::make_pair (1026, -20.0)); // Flat junction band right (start)
600  maskSlopesRight.push_back (std::make_pair (1030, -20.0)); // Flat junction band right (stop)
601  maskSlopesRight.push_back (std::make_pair (1031, -20.032)); // Middle band right (start)
602  maskSlopesRight.push_back (std::make_pair (1280, -28.000)); // Middle band right (stop)
603  maskSlopesRight.push_back (std::make_pair (1281, -28.066)); // Outer band right (start)
604  maskSlopesRight.push_back (std::make_pair (1536, -45.000)); // Outer band right (stop)
606  40, maskSlopesLeft, maskSlopesRight, tol),
607  TestCase::QUICK);
608 
609  // 11ax 40MHz @ 5GHz
610  NS_LOG_FUNCTION ("Check slopes for 11ax 40MHz @ 5GHz");
611  maskSlopesLeft.clear ();
612  maskSlopesRight.clear ();
613  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
614  maskSlopesLeft.push_back (std::make_pair (255, -28.047)); // Outer band left (stop)
615  maskSlopesLeft.push_back (std::make_pair (256, -28.000)); // Middle band left (start)
616  maskSlopesLeft.push_back (std::make_pair (505, -20.032)); // Middle band left (stop)
617  maskSlopesLeft.push_back (std::make_pair (506, -20.0)); // Flat junction band left (start)
618  maskSlopesLeft.push_back (std::make_pair (510, -20.0)); // Flat junction band left (stop)
619  maskSlopesLeft.push_back (std::make_pair (511, -20.0)); // Inner band left (start)
620  maskSlopesLeft.push_back (std::make_pair (523, -1.538)); // Inner band left (stop)
621  maskSlopesRight.push_back (std::make_pair (1013, -1.538)); // Inner band right (start)
622  maskSlopesRight.push_back (std::make_pair (1025, -20.0)); // Inner band right (stop)
623  maskSlopesRight.push_back (std::make_pair (1026, -20.0)); // Flat junction band right (start)
624  maskSlopesRight.push_back (std::make_pair (1030, -20.0)); // Flat junction band right (stop)
625  maskSlopesRight.push_back (std::make_pair (1031, -20.032)); // Middle band right (start)
626  maskSlopesRight.push_back (std::make_pair (1280, -28.000)); // Middle band right (stop)
627  maskSlopesRight.push_back (std::make_pair (1281, -28.047)); // Outer band right (start)
628  maskSlopesRight.push_back (std::make_pair (1536, -40.0)); // Outer band right (stop)
630  40, maskSlopesLeft, maskSlopesRight, tol),
631  TestCase::QUICK);
632 
633  // 11ax 80MHz @ 2.4GHz
634  NS_LOG_FUNCTION ("Check slopes for 11ax 80MHz @ 2.4GHz");
635  maskSlopesLeft.clear ();
636  maskSlopesRight.clear ();
637  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
638  maskSlopesLeft.push_back (std::make_pair (511, -28.033)); // Outer band left (stop)
639  maskSlopesLeft.push_back (std::make_pair (512, -28.000)); // Middle band left (start)
640  maskSlopesLeft.push_back (std::make_pair (1017, -20.016)); // Middle band left (stop)
641  maskSlopesLeft.push_back (std::make_pair (1018, -20.0)); // Flat junction band left (start)
642  maskSlopesLeft.push_back (std::make_pair (1022, -20.0)); // Flat junction band left (stop)
643  maskSlopesLeft.push_back (std::make_pair (1023, -20.0)); // Inner band left (start)
644  maskSlopesLeft.push_back (std::make_pair (1035, -1.538)); // Inner band left (stop)
645  maskSlopesRight.push_back (std::make_pair (2037, -1.538)); // Inner band right (start)
646  maskSlopesRight.push_back (std::make_pair (2049, -20.0)); // Inner band right (stop)
647  maskSlopesRight.push_back (std::make_pair (2050, -20.0)); // Flat junction band right (start)
648  maskSlopesRight.push_back (std::make_pair (2054, -20.0)); // Flat junction band right (stop)
649  maskSlopesRight.push_back (std::make_pair (2055, -20.016)); // Middle band right (start)
650  maskSlopesRight.push_back (std::make_pair (2560, -28.000)); // Middle band right (stop)
651  maskSlopesRight.push_back (std::make_pair (2561, -28.033)); // Outer band right (start)
652  maskSlopesRight.push_back (std::make_pair (3072, -45.000)); // Outer band right (stop)
654  80, maskSlopesLeft, maskSlopesRight, tol),
655  TestCase::QUICK);
656 
657  // 11ax 80MHz @ 5GHz
658  NS_LOG_FUNCTION ("Check slopes for 11ax 80MHz @ 5GHz");
659  maskSlopesLeft.clear ();
660  maskSlopesRight.clear ();
661  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
662  maskSlopesLeft.push_back (std::make_pair (511, -28.023)); // Outer band left (stop)
663  maskSlopesLeft.push_back (std::make_pair (512, -28.000)); // Middle band left (start)
664  maskSlopesLeft.push_back (std::make_pair (1017, -20.016)); // Middle band left (stop)
665  maskSlopesLeft.push_back (std::make_pair (1018, -20.0)); // Flat junction band left (start)
666  maskSlopesLeft.push_back (std::make_pair (1022, -20.0)); // Flat junction band left (stop)
667  maskSlopesLeft.push_back (std::make_pair (1023, -20.0)); // Inner band left (start)
668  maskSlopesLeft.push_back (std::make_pair (1035, -1.538)); // Inner band left (stop)
669  maskSlopesRight.push_back (std::make_pair (2037, -1.538)); // Inner band right (start)
670  maskSlopesRight.push_back (std::make_pair (2049, -20.0)); // Inner band right (stop)
671  maskSlopesRight.push_back (std::make_pair (2050, -20.0)); // Flat junction band right (start)
672  maskSlopesRight.push_back (std::make_pair (2054, -20.0)); // Flat junction band right (stop)
673  maskSlopesRight.push_back (std::make_pair (2055, -20.016)); // Middle band right (start)
674  maskSlopesRight.push_back (std::make_pair (2560, -28.000)); // Middle band right (stop)
675  maskSlopesRight.push_back (std::make_pair (2561, -28.023)); // Outer band right (start)
676  maskSlopesRight.push_back (std::make_pair (3072, -40.0)); // Outer band right (stop)
678  80, maskSlopesLeft, maskSlopesRight, tol),
679  TestCase::QUICK);
680 
681  // 11ax 160MHz @ 2.4GHz -> not enough space so skip
682 
683  // 11ax 160MHz @ 5GHz
684  NS_LOG_FUNCTION ("Check slopes for 11ax 160MHz @ 5GHz");
685  maskSlopesLeft.clear ();
686  maskSlopesRight.clear ();
687  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
688  maskSlopesLeft.push_back (std::make_pair (1023, -28.012)); // Outer band left (stop)
689  maskSlopesLeft.push_back (std::make_pair (1024, -28.000)); // Middle band left (start)
690  maskSlopesLeft.push_back (std::make_pair (2041, -20.008)); // Middle band left (stop)
691  maskSlopesLeft.push_back (std::make_pair (2042, -20.0)); // Flat junction band left (start)
692  maskSlopesLeft.push_back (std::make_pair (2046, -20.0)); // Flat junction band left (stop)
693  maskSlopesLeft.push_back (std::make_pair (2047, -20.0)); // Inner band left (start)
694  maskSlopesLeft.push_back (std::make_pair (2059, -1.538)); // Inner band left (stop)
695  maskSlopesRight.push_back (std::make_pair (4085, -1.538)); // Inner band right (start)
696  maskSlopesRight.push_back (std::make_pair (4097, -20.0)); // Inner band right (stop)
697  maskSlopesRight.push_back (std::make_pair (4098, -20.0)); // Flat junction band right (start)
698  maskSlopesRight.push_back (std::make_pair (4102, -20.0)); // Flat junction band right (stop)
699  maskSlopesRight.push_back (std::make_pair (4103, -20.008)); // Middle band right (start)
700  maskSlopesRight.push_back (std::make_pair (5120, -28.000)); // Middle band right (stop)
701  maskSlopesRight.push_back (std::make_pair (5121, -28.012)); // Outer band right (start)
702  maskSlopesRight.push_back (std::make_pair (6144, -40.0)); // Outer band right (stop)
704  160, maskSlopesLeft, maskSlopesRight, tol),
705  TestCase::QUICK);
706 
707  maskSlopesLeft.clear ();
708  maskSlopesRight.clear ();
709 }
ERP-OFDM PHY (Clause 19, Section 19.5)
Ptr< SpectrumValue > m_actualSpectrum
actual spectrum value
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Test suite for checking the consistency of different OFDM-based transmit masks.
IndexPowerVect m_expectedLeftPsd
expected power values for left guard bandwidth
double m_tolerance
tolerance (in dB)
Test checks if Wifi spectrum values for OFDM are generated properly.
A suite of tests to run.
Definition: test.h:1343
def start()
Definition: core.py:1855
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
std::pair< uint32_t, double > IndexPowerPair
typedef for a pair of sub-band index and relative power value (dBr)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
The 5 GHz band.
Definition: wifi-phy-band.h:37
encapsulates test code
Definition: test.h:1153
STL namespace.
Values::const_iterator ConstValuesBegin() const
static void InterpolateAndAppendValues(IndexPowerVect &vect, IndexPowerPair start, IndexPowerPair stop, double tol)
Interpolate PSD values for indexes between provided start and stop and append to provided vector...
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
#define max(a, b)
Definition: 80211b.c:43
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
bool TestDoubleIsEqual(const double x1, const double x2, const double epsilon)
Compare two double precision floating point numbers and declare them equal if they are within some ep...
Definition: test.cc:44
OFDM PHY (Clause 17 - amendment for 10 MHz and 5 MHz channels)
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if ...
Definition: test.h:563
IndexPowerVect m_expectedRightPsd
expected power values for right guard bandwidth
WifiOfdmMaskSlopesTestCase(const char *str, WifiPhyStandard standard, WifiPhyBand band, uint8_t bw, IndexPowerVect maskRefsLeft, IndexPowerVect maskRefsRight, double tol)
Constructor.
OFDM PHY (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Values::const_iterator ConstValuesEnd() const
The 2.4 GHz band.
Definition: wifi-phy-band.h:35
std::vector< IndexPowerPair > IndexPowerVect
typedef for a vector of pairs of sub-band index and relative power value (dBr)
void DoRun(void) override
Implementation to actually run this TestCase.
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:32
static WifiTransmitMaskTestSuite g_WifiTransmitMaskTestSuite