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  virtual void DoRun (void);
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 
102  switch (standard)
103  {
105  NS_ASSERT ((bw == 5) || (bw == 10));
106  freq = 5860;
107  m_actualSpectrum = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw);
108  break;
109 
110  // 11g and 11a
112  freq = 2412;
113  // no break on purpose
116  NS_ASSERT (bw == 20);
117  m_actualSpectrum = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw);
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  }
126  NS_ASSERT (bw == 20 || bw == 40);
127  m_actualSpectrum = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw);
128  break;
129 
130  // 11ac
132  NS_ASSERT (bw == 20 || bw == 40 || bw == 80 || bw == 160);
133  m_actualSpectrum = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw);
134  break;
135 
136  // 11ax
138  if (band == WIFI_PHY_BAND_2_4GHZ)
139  {
140  NS_ASSERT (bw != 160); // not enough space in 2.4 GHz bands
141  freq = 2402 + (bw / 2); //so as to have 2412/2422 for 20/40
142  }
143  NS_ASSERT (bw == 20 || bw == 40 || bw == 80 || bw == 160);
144  m_actualSpectrum = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw);
145  break;
146 
147  // other
148  default:
149  NS_FATAL_ERROR ("Standard unknown or non-OFDM");
150  break;
151  }
152 
153  NS_LOG_INFO ("Build expected left PSD");
154  for (uint32_t i = 0; i < maskRefsLeft.size (); i = i + 2)
155  {
156  InterpolateAndAppendValues (m_expectedLeftPsd, maskRefsLeft[i], maskRefsLeft[i + 1], tol);
157  }
158  NS_ASSERT (m_expectedLeftPsd.size () == (m_expectedLeftPsd.back ().first - m_expectedLeftPsd.front ().first + 1));
159 
160  NS_LOG_INFO ("Build expected right PSD");
161  for (uint32_t i = 0; i < maskRefsRight.size (); i = i + 2)
162  {
163  InterpolateAndAppendValues (m_expectedRightPsd, maskRefsRight[i], maskRefsRight[i + 1], tol);
164  }
165  NS_ASSERT (m_expectedRightPsd.size () == (m_expectedRightPsd.back ().first - m_expectedRightPsd.front ().first + 1));
166 
167 }
168 
170 {
171 }
172 
173 void
175  double tol)
176 {
177  NS_LOG_FUNCTION (start.first << start.second << stop.first << stop.second);
178  NS_ASSERT (start.first <= stop.first);
179 
180  if (start.first == stop.first) //only one point, no need to interpolate
181  {
182  NS_ASSERT (start.second == stop.second);
183  vect.push_back (start);
184  NS_LOG_LOGIC ("Append (" << start.first << ", " << stop.second << ")");
185  return;
186  }
187 
188  double slope = (stop.second - start.second) / (stop.first - start.first);
189  for (uint32_t i = start.first; i <= stop.first; i++)
190  {
191  double val = start.second + slope * (i - start.first);
192  vect.push_back (std::make_pair (i, val));
193  NS_LOG_LOGIC ("Append (" << i << ", " << val << ")");
194  }
195  NS_ASSERT (vect.back ().first == stop.first
196  && TestDoubleIsEqual (vect.back ().second, stop.second, tol));
197 }
198 
199 void
201 {
202  NS_LOG_FUNCTION (this);
203  double currentPowerDbr = 0.0; //have to work in dBr so as to compare with expected slopes
204  double maxPowerW = (*m_actualSpectrum)[0];
205  for (Values::const_iterator vit = m_actualSpectrum->ConstValuesBegin (); vit != m_actualSpectrum->ConstValuesEnd (); vit++)
206  {
207  maxPowerW = std::max (maxPowerW, *vit);
208  }
209 
210  NS_LOG_INFO ("Compare expected left PSD");
211  for (IndexPowerVect::const_iterator it = m_expectedLeftPsd.begin (); it != m_expectedLeftPsd.end (); it++)
212  {
213  currentPowerDbr = 10.0 * std::log10 ((*m_actualSpectrum)[it->first] / maxPowerW);
214  NS_LOG_LOGIC ("For " << it->first << ", expected: " << it->second << " vs obtained: " << currentPowerDbr);
215  NS_TEST_EXPECT_MSG_EQ_TOL (currentPowerDbr, it->second, m_tolerance,
216  "Spectrum value mismatch for left guard band (" << it->first << ")");
217  }
218  NS_LOG_INFO ("Compare expected right PSD");
219  for (IndexPowerVect::const_iterator it = m_expectedRightPsd.begin (); it != m_expectedRightPsd.end (); it++)
220  {
221  currentPowerDbr = 10.0 * std::log10 ((*m_actualSpectrum)[it->first] / maxPowerW);
222  NS_LOG_LOGIC ("For " << it->first << ", expected: " << it->second << " vs obtained: " << currentPowerDbr);
223  NS_TEST_EXPECT_MSG_EQ_TOL (currentPowerDbr, it->second, m_tolerance,
224  "Spectrum value mismatch for right guard band (" << it->first << ")");
225  }
226 }
227 
228 
229 
237 {
238 public:
240 };
241 
243 
245  : TestSuite ("wifi-transmit-mask", UNIT)
246 {
247 // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
248 // LogComponentEnable ("WifiTransmitMaskTestSuite", logLevel);
249 // LogComponentEnable ("WifiSpectrumValueHelper", logLevel);
250 
251  NS_LOG_INFO ("Creating WifiTransmitMaskTestSuite");
252 
255  double tol = 0.001; // in dB
256 
257  // ============================================================================================
258  // 11p 5MHz
259  NS_LOG_FUNCTION ("Check slopes for 11p 5MHz");
260  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
261  maskSlopesLeft.push_back (std::make_pair (31, -28.375)); // Outer band left (stop)
262  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
263  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
264  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
265  maskSlopesLeft.push_back (std::make_pair (63, -20.0)); // Flat junction band left (stop)
266  maskSlopesLeft.push_back (std::make_pair (64, -20.0)); // Inner band left (start)
267  maskSlopesLeft.push_back (std::make_pair (69, -3.333)); // Inner band left (stop)
268  maskSlopesRight.push_back (std::make_pair (123, -3.333)); // Inner band right (start)
269  maskSlopesRight.push_back (std::make_pair (128, -20.0)); // Inner band right (stop)
270  maskSlopesRight.push_back (std::make_pair (129, -20.0)); // Flat junction band right (start)
271  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
272  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
273  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
274  maskSlopesRight.push_back (std::make_pair (161, -28.375)); // Outer band right (start)
275  maskSlopesRight.push_back (std::make_pair (192, -40.0)); // Outer band right (stop)
277  5, maskSlopesLeft, maskSlopesRight, tol),
278  TestCase::QUICK);
279 
280  // 11p 10MHz
281  NS_LOG_FUNCTION ("Check slopes for 11p 10MHz");
282  maskSlopesLeft.clear ();
283  maskSlopesRight.clear ();
284  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
285  maskSlopesLeft.push_back (std::make_pair (31, -28.375)); // Outer band left (stop)
286  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
287  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
288  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
289  maskSlopesLeft.push_back (std::make_pair (63, -20.0)); // Flat junction band left (stop)
290  maskSlopesLeft.push_back (std::make_pair (64, -20.0)); // Inner band left (start)
291  maskSlopesLeft.push_back (std::make_pair (69, -3.333)); // Inner band left (stop)
292  maskSlopesRight.push_back (std::make_pair (123, -3.333)); // Inner band right (start)
293  maskSlopesRight.push_back (std::make_pair (128, -20.0)); // Inner band right (stop)
294  maskSlopesRight.push_back (std::make_pair (129, -20.0)); // Flat junction band right (start)
295  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
296  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
297  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
298  maskSlopesRight.push_back (std::make_pair (161, -28.375)); // Outer band right (start)
299  maskSlopesRight.push_back (std::make_pair (192, -40.0)); // Outer band right (stop)
301  10, maskSlopesLeft, maskSlopesRight, tol),
302  TestCase::QUICK);
303 
304 
305  // ============================================================================================
306  // 11a
307  NS_LOG_FUNCTION ("Check slopes for 11a");
308  maskSlopesLeft.clear ();
309  maskSlopesRight.clear ();
310  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
311  maskSlopesLeft.push_back (std::make_pair (31, -28.375)); // Outer band left (stop)
312  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
313  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
314  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
315  maskSlopesLeft.push_back (std::make_pair (63, -20.0)); // Flat junction band left (stop)
316  maskSlopesLeft.push_back (std::make_pair (64, -20.0)); // Inner band left (start)
317  maskSlopesLeft.push_back (std::make_pair (69, -3.333)); // Inner band left (stop)
318  maskSlopesRight.push_back (std::make_pair (123, -3.333)); // Inner band right (start)
319  maskSlopesRight.push_back (std::make_pair (128, -20.0)); // Inner band right (stop)
320  maskSlopesRight.push_back (std::make_pair (129, -20.0)); // Flat junction band right (start)
321  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
322  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
323  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
324  maskSlopesRight.push_back (std::make_pair (161, -28.375)); // Outer band right (start)
325  maskSlopesRight.push_back (std::make_pair (192, -40.0)); // Outer band right (stop)
327  20, maskSlopesLeft, maskSlopesRight, tol),
328  TestCase::QUICK);
329 
330  // 11a (holland)
331  NS_LOG_FUNCTION ("Check slopes for 11a (holland)");
332  // same slopes as 11a (same PHY layer)
334  20, maskSlopesLeft, maskSlopesRight, tol),
335  TestCase::QUICK);
336 
337  // 11g
338  NS_LOG_FUNCTION ("Check slopes for 11g");
339  // same slppes as 11g
341  20, maskSlopesLeft, maskSlopesRight, tol),
342  TestCase::QUICK);
343 
344 
345  // ============================================================================================
346  // 11n 20MHz @ 2.4GHz
347  NS_LOG_FUNCTION ("Check slopes for 11n 20MHz @ 2.4GHz");
348  maskSlopesLeft.clear ();
349  maskSlopesRight.clear ();
350  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
351  maskSlopesLeft.push_back (std::make_pair (31, -28.531)); // Outer band left (stop)
352  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
353  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
354  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
355  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (stop)
356  maskSlopesLeft.push_back (std::make_pair (62, -20.0)); // Inner band left (start)
357  maskSlopesLeft.push_back (std::make_pair (67, -3.333)); // Inner band left (stop)
358  maskSlopesRight.push_back (std::make_pair (125, -3.333)); // Inner band right (start)
359  maskSlopesRight.push_back (std::make_pair (130, -20.0)); // Inner band right (stop)
360  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (start)
361  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
362  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
363  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
364  maskSlopesRight.push_back (std::make_pair (161, -28.531)); // Outer band right (start)
365  maskSlopesRight.push_back (std::make_pair (192, -45.000)); // Outer band right (stop)
367  20, maskSlopesLeft, maskSlopesRight, tol),
368  TestCase::QUICK);
369 
370  // 11n 20MHz @ 5GHz
371  NS_LOG_FUNCTION ("Check slopes for 11n 20MHz @ 5GHz");
372  maskSlopesLeft.clear ();
373  maskSlopesRight.clear ();
374  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
375  maskSlopesLeft.push_back (std::make_pair (31, -28.375)); // Outer band left (stop)
376  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
377  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
378  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
379  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (stop)
380  maskSlopesLeft.push_back (std::make_pair (62, -20.0)); // Inner band left (start)
381  maskSlopesLeft.push_back (std::make_pair (67, -3.333)); // Inner band left (stop)
382  maskSlopesRight.push_back (std::make_pair (125, -3.333)); // Inner band right (start)
383  maskSlopesRight.push_back (std::make_pair (130, -20.0)); // Inner band right (stop)
384  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (start)
385  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
386  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
387  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
388  maskSlopesRight.push_back (std::make_pair (161, -28.375)); // Outer band right (start)
389  maskSlopesRight.push_back (std::make_pair (192, -40.0)); // Outer band right (stop)
391  20, maskSlopesLeft, maskSlopesRight, tol),
392  TestCase::QUICK);
393 
394  // 11n 40MHz @ 2.4GHz
395  NS_LOG_FUNCTION ("Check slopes for 11n 40MHz @ 2.4GHz");
396  maskSlopesLeft.clear ();
397  maskSlopesRight.clear ();
398  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
399  maskSlopesLeft.push_back (std::make_pair (63, -28.266)); // Outer band left (stop)
400  maskSlopesLeft.push_back (std::make_pair (64, -28.000)); // Middle band left (start)
401  maskSlopesLeft.push_back (std::make_pair (124, -20.131)); // Middle band left (stop)
402  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (start)
403  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (stop)
404  maskSlopesLeft.push_back (std::make_pair (126, -20.0)); // Inner band left (start)
405  maskSlopesLeft.push_back (std::make_pair (131, -3.333)); // Inner band left (stop)
406  maskSlopesRight.push_back (std::make_pair (253, -3.333)); // Inner band right (start)
407  maskSlopesRight.push_back (std::make_pair (258, -20.0)); // Inner band right (stop)
408  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (start)
409  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (stop)
410  maskSlopesRight.push_back (std::make_pair (260, -20.131)); // Middle band right (start)
411  maskSlopesRight.push_back (std::make_pair (320, -28.000)); // Middle band right (stop)
412  maskSlopesRight.push_back (std::make_pair (321, -28.266)); // Outer band right (start)
413  maskSlopesRight.push_back (std::make_pair (384, -45.000)); // Outer band right (stop)
415  40, maskSlopesLeft, maskSlopesRight, tol),
416  TestCase::QUICK);
417 
418  // 11n 20MHz @ 5GHz
419  NS_LOG_FUNCTION ("Check slopes for 11n 40MHz @ 5GHz");
420  maskSlopesLeft.clear ();
421  maskSlopesRight.clear ();
422  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
423  maskSlopesLeft.push_back (std::make_pair (63, -28.188)); // Outer band left (stop)
424  maskSlopesLeft.push_back (std::make_pair (64, -28.000)); // Middle band left (start)
425  maskSlopesLeft.push_back (std::make_pair (124, -20.131)); // Middle band left (stop)
426  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (start)
427  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (stop)
428  maskSlopesLeft.push_back (std::make_pair (126, -20.0)); // Inner band left (start)
429  maskSlopesLeft.push_back (std::make_pair (131, -3.333)); // Inner band left (stop)
430  maskSlopesRight.push_back (std::make_pair (253, -3.333)); // Inner band right (start)
431  maskSlopesRight.push_back (std::make_pair (258, -20.0)); // Inner band right (stop)
432  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (start)
433  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (stop)
434  maskSlopesRight.push_back (std::make_pair (260, -20.131)); // Middle band right (start)
435  maskSlopesRight.push_back (std::make_pair (320, -28.000)); // Middle band right (stop)
436  maskSlopesRight.push_back (std::make_pair (321, -28.188)); // Outer band right (start)
437  maskSlopesRight.push_back (std::make_pair (384, -40.0)); // Outer band right (stop)
439  40, maskSlopesLeft, maskSlopesRight, tol),
440  TestCase::QUICK);
441 
442 
443  // ============================================================================================
444  // 11ac 20MHz
445  NS_LOG_FUNCTION ("Check slopes for 11ac 20MHz");
446  maskSlopesLeft.clear ();
447  maskSlopesRight.clear ();
448  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
449  maskSlopesLeft.push_back (std::make_pair (31, -28.375)); // Outer band left (stop)
450  maskSlopesLeft.push_back (std::make_pair (32, -28.000)); // Middle band left (start)
451  maskSlopesLeft.push_back (std::make_pair (60, -20.276)); // Middle band left (stop)
452  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (start)
453  maskSlopesLeft.push_back (std::make_pair (61, -20.0)); // Flat junction band left (stop)
454  maskSlopesLeft.push_back (std::make_pair (62, -20.0)); // Inner band left (start)
455  maskSlopesLeft.push_back (std::make_pair (67, -3.333)); // Inner band left (stop)
456  maskSlopesRight.push_back (std::make_pair (125, -3.333)); // Inner band right (start)
457  maskSlopesRight.push_back (std::make_pair (130, -20.0)); // Inner band right (stop)
458  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (start)
459  maskSlopesRight.push_back (std::make_pair (131, -20.0)); // Flat junction band right (stop)
460  maskSlopesRight.push_back (std::make_pair (132, -20.276)); // Middle band right (start)
461  maskSlopesRight.push_back (std::make_pair (160, -28.000)); // Middle band right (stop)
462  maskSlopesRight.push_back (std::make_pair (161, -28.375)); // Outer band right (start)
463  maskSlopesRight.push_back (std::make_pair (192, -40.0)); // Outer band right (stop)
465  20, maskSlopesLeft, maskSlopesRight, tol),
466  TestCase::QUICK);
467 
468  // 11ac 20MHz
469  NS_LOG_FUNCTION ("Check slopes for 11ac 40MHz");
470  maskSlopesLeft.clear ();
471  maskSlopesRight.clear ();
472  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
473  maskSlopesLeft.push_back (std::make_pair (63, -28.188)); // Outer band left (stop)
474  maskSlopesLeft.push_back (std::make_pair (64, -28.000)); // Middle band left (start)
475  maskSlopesLeft.push_back (std::make_pair (124, -20.131)); // Middle band left (stop)
476  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (start)
477  maskSlopesLeft.push_back (std::make_pair (125, -20.0)); // Flat junction band left (stop)
478  maskSlopesLeft.push_back (std::make_pair (126, -20.0)); // Inner band left (start)
479  maskSlopesLeft.push_back (std::make_pair (131, -3.333)); // Inner band left (stop)
480  maskSlopesRight.push_back (std::make_pair (253, -3.333)); // Inner band right (start)
481  maskSlopesRight.push_back (std::make_pair (258, -20.0)); // Inner band right (stop)
482  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (start)
483  maskSlopesRight.push_back (std::make_pair (259, -20.0)); // Flat junction band right (stop)
484  maskSlopesRight.push_back (std::make_pair (260, -20.131)); // Middle band right (start)
485  maskSlopesRight.push_back (std::make_pair (320, -28.000)); // Middle band right (stop)
486  maskSlopesRight.push_back (std::make_pair (321, -28.188)); // Outer band right (start)
487  maskSlopesRight.push_back (std::make_pair (384, -40.0)); // Outer band right (stop)
489  40, maskSlopesLeft, maskSlopesRight, tol),
490  TestCase::QUICK);
491 
492  // 11ac 80MHz
493  NS_LOG_FUNCTION ("Check slopes for 11ac 80MHz");
494  maskSlopesLeft.clear ();
495  maskSlopesRight.clear ();
496  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
497  maskSlopesLeft.push_back (std::make_pair (127, -28.094)); // Outer band left (stop)
498  maskSlopesLeft.push_back (std::make_pair (128, -28.000)); // Middle band left (start)
499  maskSlopesLeft.push_back (std::make_pair (252, -20.064)); // Middle band left (stop)
500  maskSlopesLeft.push_back (std::make_pair (253, -20.0)); // Flat junction band left (start)
501  maskSlopesLeft.push_back (std::make_pair (253, -20.0)); // Flat junction band left (stop)
502  maskSlopesLeft.push_back (std::make_pair (254, -20.0)); // Inner band left (start)
503  maskSlopesLeft.push_back (std::make_pair (259, -3.333)); // Inner band left (stop)
504  maskSlopesRight.push_back (std::make_pair (509, -3.333)); // Inner band right (start)
505  maskSlopesRight.push_back (std::make_pair (514, -20.0)); // Inner band right (stop)
506  maskSlopesRight.push_back (std::make_pair (515, -20.0)); // Flat junction band right (start)
507  maskSlopesRight.push_back (std::make_pair (515, -20.0)); // Flat junction band right (stop)
508  maskSlopesRight.push_back (std::make_pair (516, -20.064)); // Middle band right (start)
509  maskSlopesRight.push_back (std::make_pair (640, -28.000)); // Middle band right (stop)
510  maskSlopesRight.push_back (std::make_pair (641, -28.094)); // Outer band right (start)
511  maskSlopesRight.push_back (std::make_pair (768, -40.0)); // Outer band right (stop)
513  80, maskSlopesLeft, maskSlopesRight, tol),
514  TestCase::QUICK);
515 
516  // 11ac 20MHz
517  NS_LOG_FUNCTION ("Check slopes for 11ac 160MHz");
518  maskSlopesLeft.clear ();
519  maskSlopesRight.clear ();
520  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
521  maskSlopesLeft.push_back (std::make_pair (255, -28.047)); // Outer band left (stop)
522  maskSlopesLeft.push_back (std::make_pair (256, -28.000)); // Middle band left (start)
523  maskSlopesLeft.push_back (std::make_pair (508, -20.032)); // Middle band left (stop)
524  maskSlopesLeft.push_back (std::make_pair (509, -20.0)); // Flat junction band left (start)
525  maskSlopesLeft.push_back (std::make_pair (509, -20.0)); // Flat junction band left (stop)
526  maskSlopesLeft.push_back (std::make_pair (510, -20.0)); // Inner band left (start)
527  maskSlopesLeft.push_back (std::make_pair (515, -3.333)); // Inner band left (stop)
528  maskSlopesRight.push_back (std::make_pair (1021, -3.333)); // Inner band right (start)
529  maskSlopesRight.push_back (std::make_pair (1026, -20.0)); // Inner band right (stop)
530  maskSlopesRight.push_back (std::make_pair (1027, -20.0)); // Flat junction band right (start)
531  maskSlopesRight.push_back (std::make_pair (1027, -20.0)); // Flat junction band right (stop)
532  maskSlopesRight.push_back (std::make_pair (1028, -20.032)); // Middle band right (start)
533  maskSlopesRight.push_back (std::make_pair (1280, -28.000)); // Middle band right (stop)
534  maskSlopesRight.push_back (std::make_pair (1281, -28.047)); // Outer band right (start)
535  maskSlopesRight.push_back (std::make_pair (1536, -40.0)); // Outer band right (stop)
537  160, maskSlopesLeft, maskSlopesRight, tol),
538  TestCase::QUICK);
539 
540 
541  // ============================================================================================
542  // 11ax 20MHz @ 2.4GHz
543  NS_LOG_FUNCTION ("Check slopes for 11ax 20MHz @ 2.4GHz");
544  maskSlopesLeft.clear ();
545  maskSlopesRight.clear ();
546  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
547  maskSlopesLeft.push_back (std::make_pair (127, -28.133)); // Outer band left (stop)
548  maskSlopesLeft.push_back (std::make_pair (128, -28.000)); // Middle band left (start)
549  maskSlopesLeft.push_back (std::make_pair (252, -20.064)); // Middle band left (stop)
550  maskSlopesLeft.push_back (std::make_pair (253, -20.0)); // Flat junction band left (start)
551  maskSlopesLeft.push_back (std::make_pair (255, -20.0)); // Flat junction band left (stop)
552  maskSlopesLeft.push_back (std::make_pair (256, -20.0)); // Inner band left (start)
553  maskSlopesLeft.push_back (std::make_pair (261, -3.333)); // Inner band left (stop)
554  maskSlopesRight.push_back (std::make_pair (507, -3.333)); // Inner band right (start)
555  maskSlopesRight.push_back (std::make_pair (512, -20.0)); // Inner band right (stop)
556  maskSlopesRight.push_back (std::make_pair (513, -20.0)); // Flat junction band right (start)
557  maskSlopesRight.push_back (std::make_pair (515, -20.0)); // Flat junction band right (stop)
558  maskSlopesRight.push_back (std::make_pair (516, -20.064)); // Middle band right (start)
559  maskSlopesRight.push_back (std::make_pair (640, -28.000)); // Middle band right (stop)
560  maskSlopesRight.push_back (std::make_pair (641, -28.133)); // Outer band right (start)
561  maskSlopesRight.push_back (std::make_pair (768, -45.000)); // Outer band right (stop)
563  20, maskSlopesLeft, maskSlopesRight, tol),
564  TestCase::QUICK);
565 
566  // 11ax 20MHz @ 5GHz
567  NS_LOG_FUNCTION ("Check slopes for 11ax 20MHz @ 5GHz");
568  maskSlopesLeft.clear ();
569  maskSlopesRight.clear ();
570  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
571  maskSlopesLeft.push_back (std::make_pair (127, -28.094)); // Outer band left (stop)
572  maskSlopesLeft.push_back (std::make_pair (128, -28.000)); // Middle band left (start)
573  maskSlopesLeft.push_back (std::make_pair (252, -20.064)); // Middle band left (stop)
574  maskSlopesLeft.push_back (std::make_pair (253, -20.0)); // Flat junction band left (start)
575  maskSlopesLeft.push_back (std::make_pair (255, -20.0)); // Flat junction band left (stop)
576  maskSlopesLeft.push_back (std::make_pair (256, -20.0)); // Inner band left (start)
577  maskSlopesLeft.push_back (std::make_pair (261, -3.333)); // Inner band left (stop)
578  maskSlopesRight.push_back (std::make_pair (507, -3.333)); // Inner band right (start)
579  maskSlopesRight.push_back (std::make_pair (512, -20.0)); // Inner band right (stop)
580  maskSlopesRight.push_back (std::make_pair (513, -20.0)); // Flat junction band right (start)
581  maskSlopesRight.push_back (std::make_pair (515, -20.0)); // Flat junction band right (stop)
582  maskSlopesRight.push_back (std::make_pair (516, -20.064)); // Middle band right (start)
583  maskSlopesRight.push_back (std::make_pair (640, -28.000)); // Middle band right (stop)
584  maskSlopesRight.push_back (std::make_pair (641, -28.094)); // Outer band right (start)
585  maskSlopesRight.push_back (std::make_pair (768, -40.0)); // Outer band right (stop)
587  20, maskSlopesLeft, maskSlopesRight, tol),
588  TestCase::QUICK);
589 
590  // 11ax 40MHz @ 2.4GHz
591  NS_LOG_FUNCTION ("Check slopes for 11ax 40MHz @ 2.4GHz");
592  maskSlopesLeft.clear ();
593  maskSlopesRight.clear ();
594  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
595  maskSlopesLeft.push_back (std::make_pair (255, -28.066)); // Outer band left (stop)
596  maskSlopesLeft.push_back (std::make_pair (256, -28.000)); // Middle band left (start)
597  maskSlopesLeft.push_back (std::make_pair (505, -20.032)); // Middle band left (stop)
598  maskSlopesLeft.push_back (std::make_pair (506, -20.0)); // Flat junction band left (start)
599  maskSlopesLeft.push_back (std::make_pair (510, -20.0)); // Flat junction band left (stop)
600  maskSlopesLeft.push_back (std::make_pair (511, -20.0)); // Inner band left (start)
601  maskSlopesLeft.push_back (std::make_pair (523, -1.538)); // Inner band left (stop)
602  maskSlopesRight.push_back (std::make_pair (1013, -1.538)); // Inner band right (start)
603  maskSlopesRight.push_back (std::make_pair (1025, -20.0)); // Inner band right (stop)
604  maskSlopesRight.push_back (std::make_pair (1026, -20.0)); // Flat junction band right (start)
605  maskSlopesRight.push_back (std::make_pair (1030, -20.0)); // Flat junction band right (stop)
606  maskSlopesRight.push_back (std::make_pair (1031, -20.032)); // Middle band right (start)
607  maskSlopesRight.push_back (std::make_pair (1280, -28.000)); // Middle band right (stop)
608  maskSlopesRight.push_back (std::make_pair (1281, -28.066)); // Outer band right (start)
609  maskSlopesRight.push_back (std::make_pair (1536, -45.000)); // Outer band right (stop)
611  40, maskSlopesLeft, maskSlopesRight, tol),
612  TestCase::QUICK);
613 
614  // 11ax 40MHz @ 5GHz
615  NS_LOG_FUNCTION ("Check slopes for 11ax 40MHz @ 5GHz");
616  maskSlopesLeft.clear ();
617  maskSlopesRight.clear ();
618  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
619  maskSlopesLeft.push_back (std::make_pair (255, -28.047)); // Outer band left (stop)
620  maskSlopesLeft.push_back (std::make_pair (256, -28.000)); // Middle band left (start)
621  maskSlopesLeft.push_back (std::make_pair (505, -20.032)); // Middle band left (stop)
622  maskSlopesLeft.push_back (std::make_pair (506, -20.0)); // Flat junction band left (start)
623  maskSlopesLeft.push_back (std::make_pair (510, -20.0)); // Flat junction band left (stop)
624  maskSlopesLeft.push_back (std::make_pair (511, -20.0)); // Inner band left (start)
625  maskSlopesLeft.push_back (std::make_pair (523, -1.538)); // Inner band left (stop)
626  maskSlopesRight.push_back (std::make_pair (1013, -1.538)); // Inner band right (start)
627  maskSlopesRight.push_back (std::make_pair (1025, -20.0)); // Inner band right (stop)
628  maskSlopesRight.push_back (std::make_pair (1026, -20.0)); // Flat junction band right (start)
629  maskSlopesRight.push_back (std::make_pair (1030, -20.0)); // Flat junction band right (stop)
630  maskSlopesRight.push_back (std::make_pair (1031, -20.032)); // Middle band right (start)
631  maskSlopesRight.push_back (std::make_pair (1280, -28.000)); // Middle band right (stop)
632  maskSlopesRight.push_back (std::make_pair (1281, -28.047)); // Outer band right (start)
633  maskSlopesRight.push_back (std::make_pair (1536, -40.0)); // Outer band right (stop)
635  40, maskSlopesLeft, maskSlopesRight, tol),
636  TestCase::QUICK);
637 
638  // 11ax 80MHz @ 2.4GHz
639  NS_LOG_FUNCTION ("Check slopes for 11ax 80MHz @ 2.4GHz");
640  maskSlopesLeft.clear ();
641  maskSlopesRight.clear ();
642  maskSlopesLeft.push_back (std::make_pair (0, -45.000)); // Outer band left (start)
643  maskSlopesLeft.push_back (std::make_pair (511, -28.033)); // Outer band left (stop)
644  maskSlopesLeft.push_back (std::make_pair (512, -28.000)); // Middle band left (start)
645  maskSlopesLeft.push_back (std::make_pair (1017, -20.016)); // Middle band left (stop)
646  maskSlopesLeft.push_back (std::make_pair (1018, -20.0)); // Flat junction band left (start)
647  maskSlopesLeft.push_back (std::make_pair (1022, -20.0)); // Flat junction band left (stop)
648  maskSlopesLeft.push_back (std::make_pair (1023, -20.0)); // Inner band left (start)
649  maskSlopesLeft.push_back (std::make_pair (1035, -1.538)); // Inner band left (stop)
650  maskSlopesRight.push_back (std::make_pair (2037, -1.538)); // Inner band right (start)
651  maskSlopesRight.push_back (std::make_pair (2049, -20.0)); // Inner band right (stop)
652  maskSlopesRight.push_back (std::make_pair (2050, -20.0)); // Flat junction band right (start)
653  maskSlopesRight.push_back (std::make_pair (2054, -20.0)); // Flat junction band right (stop)
654  maskSlopesRight.push_back (std::make_pair (2055, -20.016)); // Middle band right (start)
655  maskSlopesRight.push_back (std::make_pair (2560, -28.000)); // Middle band right (stop)
656  maskSlopesRight.push_back (std::make_pair (2561, -28.033)); // Outer band right (start)
657  maskSlopesRight.push_back (std::make_pair (3072, -45.000)); // Outer band right (stop)
659  80, maskSlopesLeft, maskSlopesRight, tol),
660  TestCase::QUICK);
661 
662  // 11ax 80MHz @ 5GHz
663  NS_LOG_FUNCTION ("Check slopes for 11ax 80MHz @ 5GHz");
664  maskSlopesLeft.clear ();
665  maskSlopesRight.clear ();
666  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
667  maskSlopesLeft.push_back (std::make_pair (511, -28.023)); // Outer band left (stop)
668  maskSlopesLeft.push_back (std::make_pair (512, -28.000)); // Middle band left (start)
669  maskSlopesLeft.push_back (std::make_pair (1017, -20.016)); // Middle band left (stop)
670  maskSlopesLeft.push_back (std::make_pair (1018, -20.0)); // Flat junction band left (start)
671  maskSlopesLeft.push_back (std::make_pair (1022, -20.0)); // Flat junction band left (stop)
672  maskSlopesLeft.push_back (std::make_pair (1023, -20.0)); // Inner band left (start)
673  maskSlopesLeft.push_back (std::make_pair (1035, -1.538)); // Inner band left (stop)
674  maskSlopesRight.push_back (std::make_pair (2037, -1.538)); // Inner band right (start)
675  maskSlopesRight.push_back (std::make_pair (2049, -20.0)); // Inner band right (stop)
676  maskSlopesRight.push_back (std::make_pair (2050, -20.0)); // Flat junction band right (start)
677  maskSlopesRight.push_back (std::make_pair (2054, -20.0)); // Flat junction band right (stop)
678  maskSlopesRight.push_back (std::make_pair (2055, -20.016)); // Middle band right (start)
679  maskSlopesRight.push_back (std::make_pair (2560, -28.000)); // Middle band right (stop)
680  maskSlopesRight.push_back (std::make_pair (2561, -28.023)); // Outer band right (start)
681  maskSlopesRight.push_back (std::make_pair (3072, -40.0)); // Outer band right (stop)
683  80, maskSlopesLeft, maskSlopesRight, tol),
684  TestCase::QUICK);
685 
686  // 11ax 160MHz @ 2.4GHz -> not enough space so skip
687 
688  // 11ax 160MHz @ 5GHz
689  NS_LOG_FUNCTION ("Check slopes for 11ax 160MHz @ 5GHz");
690  maskSlopesLeft.clear ();
691  maskSlopesRight.clear ();
692  maskSlopesLeft.push_back (std::make_pair (0, -40.0)); // Outer band left (start)
693  maskSlopesLeft.push_back (std::make_pair (1023, -28.012)); // Outer band left (stop)
694  maskSlopesLeft.push_back (std::make_pair (1024, -28.000)); // Middle band left (start)
695  maskSlopesLeft.push_back (std::make_pair (2041, -20.008)); // Middle band left (stop)
696  maskSlopesLeft.push_back (std::make_pair (2042, -20.0)); // Flat junction band left (start)
697  maskSlopesLeft.push_back (std::make_pair (2046, -20.0)); // Flat junction band left (stop)
698  maskSlopesLeft.push_back (std::make_pair (2047, -20.0)); // Inner band left (start)
699  maskSlopesLeft.push_back (std::make_pair (2059, -1.538)); // Inner band left (stop)
700  maskSlopesRight.push_back (std::make_pair (4085, -1.538)); // Inner band right (start)
701  maskSlopesRight.push_back (std::make_pair (4097, -20.0)); // Inner band right (stop)
702  maskSlopesRight.push_back (std::make_pair (4098, -20.0)); // Flat junction band right (start)
703  maskSlopesRight.push_back (std::make_pair (4102, -20.0)); // Flat junction band right (stop)
704  maskSlopesRight.push_back (std::make_pair (4103, -20.008)); // Middle band right (start)
705  maskSlopesRight.push_back (std::make_pair (5120, -28.000)); // Middle band right (stop)
706  maskSlopesRight.push_back (std::make_pair (5121, -28.012)); // Outer band right (start)
707  maskSlopesRight.push_back (std::make_pair (6144, -40.0)); // Outer band right (stop)
709  160, maskSlopesLeft, maskSlopesRight, tol),
710  TestCase::QUICK);
711 }
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:35
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.
This is intended to be the configuration used in this paper: Gavin Holland, Nitin Vaidya and Paramvir...
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:33
std::vector< IndexPowerPair > IndexPowerVect
typedef for a vector of pairs of sub-band index and relative power value (dBr)
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:30
static WifiTransmitMaskTestSuite g_WifiTransmitMaskTestSuite
virtual void DoRun(void)
Implementation to actually run this TestCase.