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