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-phy-standard.h"
27 
28 using namespace ns3;
29 
30 NS_LOG_COMPONENT_DEFINE ("WifiTransmitMaskTest");
31 
40 {
41 public:
45  typedef std::pair<uint32_t, double> IndexPowerPair;
46 
50  typedef std::vector<IndexPowerPair> IndexPowerVect;
51 
64  WifiOfdmMaskSlopesTestCase (const char* str, WifiPhyStandard standard, uint8_t bw,
65  IndexPowerVect maskRefsLeft, IndexPowerVect maskRefsRight, double tol);
66  virtual ~WifiOfdmMaskSlopesTestCase ();
67 
68 protected:
72  double m_tolerance;
73 
74 private:
75  virtual void DoRun (void);
86  static void InterpolateAndAppendValues (IndexPowerVect &vect, IndexPowerPair start, IndexPowerPair stop,
87  double tol);
88 };
89 
91  IndexPowerVect maskRefsLeft, IndexPowerVect maskRefsRight,
92  double tol)
93  : TestCase (std::string ("SpectrumValue ") + str)
94 {
95  NS_LOG_FUNCTION (this << str << standard << +bw << tol);
96  NS_ASSERT (maskRefsLeft.size () % 2 == 0 && maskRefsRight.size () % 2 == 0); //start/stop pairs expected
97  uint16_t freq = 5170 + (bw / 2); // so as to have 5180/5190/5210/5250 for 20/40/80/160
98  double refTxPowerW = 1; // have to work in dBr when comparing though
99  m_tolerance = tol; // in dB
100 
101  switch (standard)
102  {
104  NS_ASSERT (bw == 5);
105  freq = 5860;
106  m_actualSpectrum = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw);
107  break;
109  NS_ASSERT (bw == 10);
110  freq = 5860;
111  m_actualSpectrum = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw);
112  break;
113 
114  // 11g and 11a
116  freq = 2412;
117  // no break on purpose
120  NS_ASSERT (bw == 20);
121  m_actualSpectrum = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw);
122  break;
123 
124  // 11n
126  freq = 2402 + (bw / 2); //so as to have 2412/2422 for 20/40
127  // no break on purpose
129  NS_ASSERT (bw == 20 || bw == 40);
130  m_actualSpectrum = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw);
131  break;
132 
133  // 11ac
135  NS_ASSERT (bw == 20 || bw == 40 || bw == 80 || bw == 160);
136  m_actualSpectrum = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw);
137  break;
138 
139  // 11ax
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  // no break on purpose
145  NS_ASSERT (bw == 20 || bw == 40 || bw == 80 || bw == 160);
146  m_actualSpectrum = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw);
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 ("WifiTransmitMaskTestSuite", logLevel);
251 // LogComponentEnable ("WifiSpectrumValueHelper", logLevel);
252 
253  NS_LOG_INFO ("Creating WifiTransmitMaskTestSuite");
254 
257  double tol = 0.001; // in dB
258 
259  // ============================================================================================
260  // 11 5MHz
261  NS_LOG_FUNCTION ("Check slopes for 11 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  maskSlopesLeft, maskSlopesRight, tol),
280  TestCase::QUICK);
281 
282  // 11 10MHz
283  NS_LOG_FUNCTION ("Check slopes for 11 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  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  maskSlopesLeft, maskSlopesRight, tol),
330  TestCase::QUICK);
331 
332  // 11a (holland)
333  NS_LOG_FUNCTION ("Check slopes for 11a (holland)");
334  // same slopes as 11a (same PHY layer)
336  maskSlopesLeft, maskSlopesRight, tol),
337  TestCase::QUICK);
338 
339  // 11g
340  NS_LOG_FUNCTION ("Check slopes for 11g");
341  // same slppes as 11g
343  maskSlopesLeft, maskSlopesRight, tol),
344  TestCase::QUICK);
345 
346 
347  // ============================================================================================
348  // 11n 20MHz @ 2.4GHz
349  NS_LOG_FUNCTION ("Check slopes for 11n 20MHz @ 2.4GHz ");
350  maskSlopesLeft.clear ();
351  maskSlopesRight.clear ();
352  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
353  maskSlopesLeft.push_back (std::make_pair (31, -28.531)); // Outer band left (stop)
354  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
355  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
356  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
357  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (stop)
358  maskSlopesLeft.push_back (std::make_pair (62, -20.0)); // Inner band left (start)
359  maskSlopesLeft.push_back (std::make_pair (67, -3.333)); // Inner band left (stop)
360  maskSlopesRight.push_back (std::make_pair (125, -3.333)); // Inner band right (start)
361  maskSlopesRight.push_back (std::make_pair (130, -20.0)); // Inner band right (stop)
362  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (start)
363  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
364  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
365  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
366  maskSlopesRight.push_back (std::make_pair (161, -28.531)); // Outer band right (start)
367  maskSlopesRight.push_back (std::make_pair (192, -45.000)); // Outer band right (stop)
369  maskSlopesLeft, maskSlopesRight, tol),
370  TestCase::QUICK);
371 
372  // 11n 20MHz @ 5GHz
373  NS_LOG_FUNCTION ("Check slopes for 11n 20MHz @ 5GHz");
374  maskSlopesLeft.clear ();
375  maskSlopesRight.clear ();
376  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
377  maskSlopesLeft.push_back (std::make_pair (31, -28.375)); // Outer band left (stop)
378  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
379  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
380  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
381  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (stop)
382  maskSlopesLeft.push_back (std::make_pair (62, -20.0)); // Inner band left (start)
383  maskSlopesLeft.push_back (std::make_pair (67, -3.333)); // Inner band left (stop)
384  maskSlopesRight.push_back (std::make_pair (125, -3.333)); // Inner band right (start)
385  maskSlopesRight.push_back (std::make_pair (130, -20.0)); // Inner band right (stop)
386  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (start)
387  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
388  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
389  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
390  maskSlopesRight.push_back (std::make_pair (161, -28.375)); // Outer band right (start)
391  maskSlopesRight.push_back (std::make_pair (192, -40.0)); // Outer band right (stop)
393  maskSlopesLeft, maskSlopesRight, tol),
394  TestCase::QUICK);
395 
396  // 11n 40MHz @ 2.4GHz
397  NS_LOG_FUNCTION ("Check slopes for 11n 40MHz @ 2.4GHz ");
398  maskSlopesLeft.clear ();
399  maskSlopesRight.clear ();
400  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
401  maskSlopesLeft.push_back (std::make_pair (63, -28.266)); // Outer band left (stop)
402  maskSlopesLeft.push_back (std::make_pair (64, -28.000)); // Middle band left (start)
403  maskSlopesLeft.push_back (std::make_pair (124, -20.131)); // Middle band left (stop)
404  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (start)
405  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (stop)
406  maskSlopesLeft.push_back (std::make_pair (126, -20.0)); // Inner band left (start)
407  maskSlopesLeft.push_back (std::make_pair (131, -3.333)); // Inner band left (stop)
408  maskSlopesRight.push_back (std::make_pair (253, -3.333)); // Inner band right (start)
409  maskSlopesRight.push_back (std::make_pair (258, -20.0)); // Inner band right (stop)
410  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (start)
411  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (stop)
412  maskSlopesRight.push_back (std::make_pair (260, -20.131)); // Middle band right (start)
413  maskSlopesRight.push_back (std::make_pair (320, -28.000)); // Middle band right (stop)
414  maskSlopesRight.push_back (std::make_pair (321, -28.266)); // Outer band right (start)
415  maskSlopesRight.push_back (std::make_pair (384, -45.000)); // Outer band right (stop)
417  maskSlopesLeft, maskSlopesRight, tol),
418  TestCase::QUICK);
419 
420  // 11n 20MHz @ 5GHz
421  NS_LOG_FUNCTION ("Check slopes for 11n 40MHz @ 5GHz");
422  maskSlopesLeft.clear ();
423  maskSlopesRight.clear ();
424  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
425  maskSlopesLeft.push_back (std::make_pair (63, -28.188)); // Outer band left (stop)
426  maskSlopesLeft.push_back (std::make_pair (64, -28.000)); // Middle band left (start)
427  maskSlopesLeft.push_back (std::make_pair (124, -20.131)); // Middle band left (stop)
428  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (start)
429  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (stop)
430  maskSlopesLeft.push_back (std::make_pair (126, -20.0)); // Inner band left (start)
431  maskSlopesLeft.push_back (std::make_pair (131, -3.333)); // Inner band left (stop)
432  maskSlopesRight.push_back (std::make_pair (253, -3.333)); // Inner band right (start)
433  maskSlopesRight.push_back (std::make_pair (258, -20.0)); // Inner band right (stop)
434  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (start)
435  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (stop)
436  maskSlopesRight.push_back (std::make_pair (260, -20.131)); // Middle band right (start)
437  maskSlopesRight.push_back (std::make_pair (320, -28.000)); // Middle band right (stop)
438  maskSlopesRight.push_back (std::make_pair (321, -28.188)); // Outer band right (start)
439  maskSlopesRight.push_back (std::make_pair (384, -40.0)); // Outer band right (stop)
441  maskSlopesLeft, maskSlopesRight, tol),
442  TestCase::QUICK);
443 
444 
445  // ============================================================================================
446  // 11ac 20MHz
447  NS_LOG_FUNCTION ("Check slopes for 11ac 20MHz");
448  maskSlopesLeft.clear ();
449  maskSlopesRight.clear ();
450  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
451  maskSlopesLeft.push_back (std::make_pair (31, -28.375)); // Outer band left (stop)
452  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
453  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
454  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
455  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (stop)
456  maskSlopesLeft.push_back (std::make_pair (62, -20.0)); // Inner band left (start)
457  maskSlopesLeft.push_back (std::make_pair (67, -3.333)); // Inner band left (stop)
458  maskSlopesRight.push_back (std::make_pair (125, -3.333)); // Inner band right (start)
459  maskSlopesRight.push_back (std::make_pair (130, -20.0)); // Inner band right (stop)
460  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (start)
461  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
462  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
463  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
464  maskSlopesRight.push_back (std::make_pair (161, -28.375)); // Outer band right (start)
465  maskSlopesRight.push_back (std::make_pair (192, -40.0)); // Outer band right (stop)
467  maskSlopesLeft, maskSlopesRight, tol),
468  TestCase::QUICK);
469 
470  // 11ac 20MHz
471  NS_LOG_FUNCTION ("Check slopes for 11ac 40MHz");
472  maskSlopesLeft.clear ();
473  maskSlopesRight.clear ();
474  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
475  maskSlopesLeft.push_back (std::make_pair (63, -28.188)); // Outer band left (stop)
476  maskSlopesLeft.push_back (std::make_pair (64, -28.000)); // Middle band left (start)
477  maskSlopesLeft.push_back (std::make_pair (124, -20.131)); // Middle band left (stop)
478  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (start)
479  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (stop)
480  maskSlopesLeft.push_back (std::make_pair (126, -20.0)); // Inner band left (start)
481  maskSlopesLeft.push_back (std::make_pair (131, -3.333)); // Inner band left (stop)
482  maskSlopesRight.push_back (std::make_pair (253, -3.333)); // Inner band right (start)
483  maskSlopesRight.push_back (std::make_pair (258, -20.0)); // Inner band right (stop)
484  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (start)
485  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (stop)
486  maskSlopesRight.push_back (std::make_pair (260, -20.131)); // Middle band right (start)
487  maskSlopesRight.push_back (std::make_pair (320, -28.000)); // Middle band right (stop)
488  maskSlopesRight.push_back (std::make_pair (321, -28.188)); // Outer band right (start)
489  maskSlopesRight.push_back (std::make_pair (384, -40.0)); // Outer band right (stop)
491  maskSlopesLeft, maskSlopesRight, tol),
492  TestCase::QUICK);
493 
494  // 11ac 80MHz
495  NS_LOG_FUNCTION ("Check slopes for 11ac 80MHz");
496  maskSlopesLeft.clear ();
497  maskSlopesRight.clear ();
498  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
499  maskSlopesLeft.push_back (std::make_pair (127, -28.094)); // Outer band left (stop)
500  maskSlopesLeft.push_back (std::make_pair (128, -28.000)); // Middle band left (start)
501  maskSlopesLeft.push_back (std::make_pair (252, -20.064)); // Middle band left (stop)
502  maskSlopesLeft.push_back (std::make_pair (253, -20.0)); // Flat junction band left (start)
503  maskSlopesLeft.push_back (std::make_pair (253, -20.0)); // Flat junction band left (stop)
504  maskSlopesLeft.push_back (std::make_pair (254, -20.0)); // Inner band left (start)
505  maskSlopesLeft.push_back (std::make_pair (259, -3.333)); // Inner band left (stop)
506  maskSlopesRight.push_back (std::make_pair (509, -3.333)); // Inner band right (start)
507  maskSlopesRight.push_back (std::make_pair (514, -20.0)); // Inner band right (stop)
508  maskSlopesRight.push_back (std::make_pair (515, -20.0)); // Flat junction band right (start)
509  maskSlopesRight.push_back (std::make_pair (515, -20.0)); // Flat junction band right (stop)
510  maskSlopesRight.push_back (std::make_pair (516, -20.064)); // Middle band right (start)
511  maskSlopesRight.push_back (std::make_pair (640, -28.000)); // Middle band right (stop)
512  maskSlopesRight.push_back (std::make_pair (641, -28.094)); // Outer band right (start)
513  maskSlopesRight.push_back (std::make_pair (768, -40.0)); // Outer band right (stop)
515  maskSlopesLeft, maskSlopesRight, tol),
516  TestCase::QUICK);
517 
518  // 11ac 20MHz
519  NS_LOG_FUNCTION ("Check slopes for 11ac 160MHz");
520  maskSlopesLeft.clear ();
521  maskSlopesRight.clear ();
522  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
523  maskSlopesLeft.push_back (std::make_pair (255, -28.047)); // Outer band left (stop)
524  maskSlopesLeft.push_back (std::make_pair (256, -28.000)); // Middle band left (start)
525  maskSlopesLeft.push_back (std::make_pair (508, -20.032)); // Middle band left (stop)
526  maskSlopesLeft.push_back (std::make_pair (509, -20.0)); // Flat junction band left (start)
527  maskSlopesLeft.push_back (std::make_pair (509, -20.0)); // Flat junction band left (stop)
528  maskSlopesLeft.push_back (std::make_pair (510, -20.0)); // Inner band left (start)
529  maskSlopesLeft.push_back (std::make_pair (515, -3.333)); // Inner band left (stop)
530  maskSlopesRight.push_back (std::make_pair (1021, -3.333)); // Inner band right (start)
531  maskSlopesRight.push_back (std::make_pair (1026, -20.0)); // Inner band right (stop)
532  maskSlopesRight.push_back (std::make_pair (1027, -20.0)); // Flat junction band right (start)
533  maskSlopesRight.push_back (std::make_pair (1027, -20.0)); // Flat junction band right (stop)
534  maskSlopesRight.push_back (std::make_pair (1028, -20.032)); // Middle band right (start)
535  maskSlopesRight.push_back (std::make_pair (1280, -28.000)); // Middle band right (stop)
536  maskSlopesRight.push_back (std::make_pair (1281, -28.047)); // Outer band right (start)
537  maskSlopesRight.push_back (std::make_pair (1536, -40.0)); // Outer band right (stop)
539  maskSlopesLeft, maskSlopesRight, tol),
540  TestCase::QUICK);
541 
542 
543  // ============================================================================================
544  // 11ax 20MHz @ 2.4GHz
545  NS_LOG_FUNCTION ("Check slopes for 11ax 20MHz @ 2.4GHz ");
546  maskSlopesLeft.clear ();
547  maskSlopesRight.clear ();
548  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
549  maskSlopesLeft.push_back (std::make_pair (127, -28.133)); // Outer band left (stop)
550  maskSlopesLeft.push_back (std::make_pair (128, -28.000)); // Middle band left (start)
551  maskSlopesLeft.push_back (std::make_pair (252, -20.064)); // Middle band left (stop)
552  maskSlopesLeft.push_back (std::make_pair (253, -20.0)); // Flat junction band left (start)
553  maskSlopesLeft.push_back (std::make_pair (255, -20.0)); // Flat junction band left (stop)
554  maskSlopesLeft.push_back (std::make_pair (256, -20.0)); // Inner band left (start)
555  maskSlopesLeft.push_back (std::make_pair (261, -3.333)); // Inner band left (stop)
556  maskSlopesRight.push_back (std::make_pair (507, -3.333)); // Inner band right (start)
557  maskSlopesRight.push_back (std::make_pair (512, -20.0)); // Inner band right (stop)
558  maskSlopesRight.push_back (std::make_pair (513, -20.0)); // Flat junction band right (start)
559  maskSlopesRight.push_back (std::make_pair (515, -20.0)); // Flat junction band right (stop)
560  maskSlopesRight.push_back (std::make_pair (516, -20.064)); // Middle band right (start)
561  maskSlopesRight.push_back (std::make_pair (640, -28.000)); // Middle band right (stop)
562  maskSlopesRight.push_back (std::make_pair (641, -28.133)); // Outer band right (start)
563  maskSlopesRight.push_back (std::make_pair (768, -45.000)); // Outer band right (stop)
565  maskSlopesLeft, maskSlopesRight, tol),
566  TestCase::QUICK);
567 
568  // 11ax 20MHz @ 5GHz
569  NS_LOG_FUNCTION ("Check slopes for 11ax 20MHz @ 5GHz");
570  maskSlopesLeft.clear ();
571  maskSlopesRight.clear ();
572  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
573  maskSlopesLeft.push_back (std::make_pair (127, -28.094)); // Outer band left (stop)
574  maskSlopesLeft.push_back (std::make_pair (128, -28.000)); // Middle band left (start)
575  maskSlopesLeft.push_back (std::make_pair (252, -20.064)); // Middle band left (stop)
576  maskSlopesLeft.push_back (std::make_pair (253, -20.0)); // Flat junction band left (start)
577  maskSlopesLeft.push_back (std::make_pair (255, -20.0)); // Flat junction band left (stop)
578  maskSlopesLeft.push_back (std::make_pair (256, -20.0)); // Inner band left (start)
579  maskSlopesLeft.push_back (std::make_pair (261, -3.333)); // Inner band left (stop)
580  maskSlopesRight.push_back (std::make_pair (507, -3.333)); // Inner band right (start)
581  maskSlopesRight.push_back (std::make_pair (512, -20.0)); // Inner band right (stop)
582  maskSlopesRight.push_back (std::make_pair (513, -20.0)); // Flat junction band right (start)
583  maskSlopesRight.push_back (std::make_pair (515, -20.0)); // Flat junction band right (stop)
584  maskSlopesRight.push_back (std::make_pair (516, -20.064)); // Middle band right (start)
585  maskSlopesRight.push_back (std::make_pair (640, -28.000)); // Middle band right (stop)
586  maskSlopesRight.push_back (std::make_pair (641, -28.094)); // Outer band right (start)
587  maskSlopesRight.push_back (std::make_pair (768, -40.0)); // Outer band right (stop)
589  maskSlopesLeft, maskSlopesRight, tol),
590  TestCase::QUICK);
591 
592  // 11ax 40MHz @ 2.4GHz
593  NS_LOG_FUNCTION ("Check slopes for 11ax 40MHz @ 2.4GHz ");
594  maskSlopesLeft.clear ();
595  maskSlopesRight.clear ();
596  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
597  maskSlopesLeft.push_back (std::make_pair (255, -28.066)); // Outer band left (stop)
598  maskSlopesLeft.push_back (std::make_pair (256, -28.000)); // Middle band left (start)
599  maskSlopesLeft.push_back (std::make_pair (505, -20.032)); // Middle band left (stop)
600  maskSlopesLeft.push_back (std::make_pair (506, -20.0)); // Flat junction band left (start)
601  maskSlopesLeft.push_back (std::make_pair (510, -20.0)); // Flat junction band left (stop)
602  maskSlopesLeft.push_back (std::make_pair (511, -20.0)); // Inner band left (start)
603  maskSlopesLeft.push_back (std::make_pair (523, -1.538)); // Inner band left (stop)
604  maskSlopesRight.push_back (std::make_pair (1013, -1.538)); // Inner band right (start)
605  maskSlopesRight.push_back (std::make_pair (1025, -20.0)); // Inner band right (stop)
606  maskSlopesRight.push_back (std::make_pair (1026, -20.0)); // Flat junction band right (start)
607  maskSlopesRight.push_back (std::make_pair (1030, -20.0)); // Flat junction band right (stop)
608  maskSlopesRight.push_back (std::make_pair (1031, -20.032)); // Middle band right (start)
609  maskSlopesRight.push_back (std::make_pair (1280, -28.000)); // Middle band right (stop)
610  maskSlopesRight.push_back (std::make_pair (1281, -28.066)); // Outer band right (start)
611  maskSlopesRight.push_back (std::make_pair (1536, -45.000)); // Outer band right (stop)
613  maskSlopesLeft, maskSlopesRight, tol),
614  TestCase::QUICK);
615 
616  // 11ax 40MHz @ 5GHz
617  NS_LOG_FUNCTION ("Check slopes for 11ax 40MHz @ 5GHz");
618  maskSlopesLeft.clear ();
619  maskSlopesRight.clear ();
620  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
621  maskSlopesLeft.push_back (std::make_pair (255, -28.047)); // Outer band left (stop)
622  maskSlopesLeft.push_back (std::make_pair (256, -28.000)); // Middle band left (start)
623  maskSlopesLeft.push_back (std::make_pair (505, -20.032)); // Middle band left (stop)
624  maskSlopesLeft.push_back (std::make_pair (506, -20.0)); // Flat junction band left (start)
625  maskSlopesLeft.push_back (std::make_pair (510, -20.0)); // Flat junction band left (stop)
626  maskSlopesLeft.push_back (std::make_pair (511, -20.0)); // Inner band left (start)
627  maskSlopesLeft.push_back (std::make_pair (523, -1.538)); // Inner band left (stop)
628  maskSlopesRight.push_back (std::make_pair (1013, -1.538)); // Inner band right (start)
629  maskSlopesRight.push_back (std::make_pair (1025, -20.0)); // Inner band right (stop)
630  maskSlopesRight.push_back (std::make_pair (1026, -20.0)); // Flat junction band right (start)
631  maskSlopesRight.push_back (std::make_pair (1030, -20.0)); // Flat junction band right (stop)
632  maskSlopesRight.push_back (std::make_pair (1031, -20.032)); // Middle band right (start)
633  maskSlopesRight.push_back (std::make_pair (1280, -28.000)); // Middle band right (stop)
634  maskSlopesRight.push_back (std::make_pair (1281, -28.047)); // Outer band right (start)
635  maskSlopesRight.push_back (std::make_pair (1536, -40.0)); // Outer band right (stop)
637  maskSlopesLeft, maskSlopesRight, tol),
638  TestCase::QUICK);
639 
640  // 11ax 80MHz @ 2.4GHz
641  NS_LOG_FUNCTION ("Check slopes for 11ax 80MHz @ 2.4GHz ");
642  maskSlopesLeft.clear ();
643  maskSlopesRight.clear ();
644  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
645  maskSlopesLeft.push_back (std::make_pair (511, -28.033)); // Outer band left (stop)
646  maskSlopesLeft.push_back (std::make_pair (512, -28.000)); // Middle band left (start)
647  maskSlopesLeft.push_back (std::make_pair (1017, -20.016)); // Middle band left (stop)
648  maskSlopesLeft.push_back (std::make_pair (1018, -20.0)); // Flat junction band left (start)
649  maskSlopesLeft.push_back (std::make_pair (1022, -20.0)); // Flat junction band left (stop)
650  maskSlopesLeft.push_back (std::make_pair (1023, -20.0)); // Inner band left (start)
651  maskSlopesLeft.push_back (std::make_pair (1035, -1.538)); // Inner band left (stop)
652  maskSlopesRight.push_back (std::make_pair (2037, -1.538)); // Inner band right (start)
653  maskSlopesRight.push_back (std::make_pair (2049, -20.0)); // Inner band right (stop)
654  maskSlopesRight.push_back (std::make_pair (2050, -20.0)); // Flat junction band right (start)
655  maskSlopesRight.push_back (std::make_pair (2054, -20.0)); // Flat junction band right (stop)
656  maskSlopesRight.push_back (std::make_pair (2055, -20.016)); // Middle band right (start)
657  maskSlopesRight.push_back (std::make_pair (2560, -28.000)); // Middle band right (stop)
658  maskSlopesRight.push_back (std::make_pair (2561, -28.033)); // Outer band right (start)
659  maskSlopesRight.push_back (std::make_pair (3072, -45.000)); // Outer band right (stop)
661  maskSlopesLeft, maskSlopesRight, tol),
662  TestCase::QUICK);
663 
664  // 11ax 80MHz @ 5GHz
665  NS_LOG_FUNCTION ("Check slopes for 11ax 80MHz @ 5GHz");
666  maskSlopesLeft.clear ();
667  maskSlopesRight.clear ();
668  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
669  maskSlopesLeft.push_back (std::make_pair (511, -28.023)); // Outer band left (stop)
670  maskSlopesLeft.push_back (std::make_pair (512, -28.000)); // Middle band left (start)
671  maskSlopesLeft.push_back (std::make_pair (1017, -20.016)); // Middle band left (stop)
672  maskSlopesLeft.push_back (std::make_pair (1018, -20.0)); // Flat junction band left (start)
673  maskSlopesLeft.push_back (std::make_pair (1022, -20.0)); // Flat junction band left (stop)
674  maskSlopesLeft.push_back (std::make_pair (1023, -20.0)); // Inner band left (start)
675  maskSlopesLeft.push_back (std::make_pair (1035, -1.538)); // Inner band left (stop)
676  maskSlopesRight.push_back (std::make_pair (2037, -1.538)); // Inner band right (start)
677  maskSlopesRight.push_back (std::make_pair (2049, -20.0)); // Inner band right (stop)
678  maskSlopesRight.push_back (std::make_pair (2050, -20.0)); // Flat junction band right (start)
679  maskSlopesRight.push_back (std::make_pair (2054, -20.0)); // Flat junction band right (stop)
680  maskSlopesRight.push_back (std::make_pair (2055, -20.016)); // Middle band right (start)
681  maskSlopesRight.push_back (std::make_pair (2560, -28.000)); // Middle band right (stop)
682  maskSlopesRight.push_back (std::make_pair (2561, -28.023)); // Outer band right (start)
683  maskSlopesRight.push_back (std::make_pair (3072, -40.0)); // Outer band right (stop)
685  maskSlopesLeft, maskSlopesRight, tol),
686  TestCase::QUICK);
687 
688  // 11ax 160MHz @ 2.4GHz -> not enough space so skip
689 
690  // 11ax 160MHz @ 5GHz
691  NS_LOG_FUNCTION ("Check slopes for 11ax 160MHz @ 5GHz");
692  maskSlopesLeft.clear ();
693  maskSlopesRight.clear ();
694  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
695  maskSlopesLeft.push_back (std::make_pair (1023, -28.012)); // Outer band left (stop)
696  maskSlopesLeft.push_back (std::make_pair (1024, -28.000)); // Middle band left (start)
697  maskSlopesLeft.push_back (std::make_pair (2041, -20.008)); // Middle band left (stop)
698  maskSlopesLeft.push_back (std::make_pair (2042, -20.0)); // Flat junction band left (start)
699  maskSlopesLeft.push_back (std::make_pair (2046, -20.0)); // Flat junction band left (stop)
700  maskSlopesLeft.push_back (std::make_pair (2047, -20.0)); // Inner band left (start)
701  maskSlopesLeft.push_back (std::make_pair (2059, -1.538)); // Inner band left (stop)
702  maskSlopesRight.push_back (std::make_pair (4085, -1.538)); // Inner band right (start)
703  maskSlopesRight.push_back (std::make_pair (4097, -20.0)); // Inner band right (stop)
704  maskSlopesRight.push_back (std::make_pair (4098, -20.0)); // Flat junction band right (start)
705  maskSlopesRight.push_back (std::make_pair (4102, -20.0)); // Flat junction band right (stop)
706  maskSlopesRight.push_back (std::make_pair (4103, -20.008)); // Middle band right (start)
707  maskSlopesRight.push_back (std::make_pair (5120, -28.000)); // Middle band right (stop)
708  maskSlopesRight.push_back (std::make_pair (5121, -28.012)); // Outer band right (start)
709  maskSlopesRight.push_back (std::make_pair (6144, -40.0)); // Outer band right (stop)
711  maskSlopesLeft, maskSlopesRight, tol),
712  TestCase::QUICK);
713 
714 }
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 "...
OFDM PHY for the 5 GHz band (Clause 17 with 5 MHz channel bandwidth)
Test suite for checking the consistency of different OFDM-based transmit masks.
HT PHY for the 5 GHz band (clause 20)
IndexPowerVect m_expectedLeftPsd
expected power values for left guard bandwidth
WifiOfdmMaskSlopesTestCase(const char *str, WifiPhyStandard standard, uint8_t bw, IndexPowerVect maskRefsLeft, IndexPowerVect maskRefsRight, double tol)
Constructor.
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:1342
def start()
Definition: core.py:1844
#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:202
std::pair< uint32_t, double > IndexPowerPair
typedef for a pair of sub-band index and relative power value (dBr)
HE PHY for the 2.4 GHz band (clause 26)
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:278
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
HT PHY for the 2.4 GHz band (clause 20)
encapsulates test code
Definition: test.h:1155
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.
HE PHY for the 5 GHz band (clause 26)
#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
#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:565
IndexPowerVect m_expectedRightPsd
expected power values for right guard bandwidth
This is intended to be the configuration used in this paper: Gavin Holland, Nitin Vaidya and Paramvir...
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Values::const_iterator ConstValuesEnd() const
std::vector< IndexPowerPair > IndexPowerVect
typedef for a vector of pairs of sub-band index and relative power value (dBr)
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
static WifiTransmitMaskTestSuite g_WifiTransmitMaskTestSuite
virtual void DoRun(void)
Implementation to actually run this TestCase.