A Discrete-Event Network Simulator
API
three-gpp-propagation-loss-model-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2019 SIGNET Lab, Department of Information Engineering,
4  * University of Padova
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #include "ns3/log.h"
21 #include "ns3/abort.h"
22 #include "ns3/test.h"
23 #include "ns3/config.h"
24 #include "ns3/double.h"
25 #include "ns3/boolean.h"
26 #include "ns3/channel-condition-model.h"
27 #include "ns3/three-gpp-propagation-loss-model.h"
28 #include "ns3/constant-position-mobility-model.h"
29 #include "ns3/constant-velocity-mobility-model.h"
30 #include "ns3/mobility-helper.h"
31 #include "ns3/simulator.h"
32 
33 using namespace ns3;
34 
35 NS_LOG_COMPONENT_DEFINE ("ThreeGppPropagationLossModelsTest");
36 
43 {
44 public:
49 
54 
55 private:
59  virtual void DoRun (void);
60 
64  typedef struct
65  {
66  double m_distance;
67  bool m_isLos;
68  double m_frequency;
69  double m_pt;
70  double m_pr;
71  } TestVector;
72 
74  double m_tolerance;
75 };
76 
78  : TestCase ("Test for the ThreeGppRmaPropagationLossModel class"),
79  m_testVectors (),
80  m_tolerance (5e-2)
81 {
82 }
83 
85 {
86 }
87 
88 void
90 {
91  TestVector testVector;
92 
93  testVector.m_distance = 10.0;
94  testVector.m_isLos = true;
95  testVector.m_frequency = 5.0e9;
96  testVector.m_pt = 0.0;
97  testVector.m_pr = -77.3784;
98  m_testVectors.Add (testVector);
99 
100  testVector.m_distance = 100.0;
101  testVector.m_isLos = true;
102  testVector.m_frequency = 5.0e9;
103  testVector.m_pt = 0.0;
104  testVector.m_pr = -87.2965;
105  m_testVectors.Add (testVector);
106 
107  testVector.m_distance = 1000.0;
108  testVector.m_isLos = true;
109  testVector.m_frequency = 5.0e9;
110  testVector.m_pt = 0.0;
111  testVector.m_pr = -108.5577;
112  m_testVectors.Add (testVector);
113 
114  testVector.m_distance = 10000.0;
115  testVector.m_isLos = true;
116  testVector.m_frequency = 5.0e9;
117  testVector.m_pt = 0.0;
118  testVector.m_pr = -140.3896;
119  m_testVectors.Add (testVector);
120 
121  testVector.m_distance = 10.0;
122  testVector.m_isLos = false;
123  testVector.m_frequency = 5.0e9;
124  testVector.m_pt = 0.0;
125  testVector.m_pr = -77.3784;
126  m_testVectors.Add (testVector);
127 
128  testVector.m_distance = 100.0;
129  testVector.m_isLos = false;
130  testVector.m_frequency = 5.0e9;
131  testVector.m_pt = 0.0;
132  testVector.m_pr = -95.7718;
133  m_testVectors.Add (testVector);
134 
135  testVector.m_distance = 1000.0;
136  testVector.m_isLos = false;
137  testVector.m_frequency = 5.0e9;
138  testVector.m_pt = 0.0;
139  testVector.m_pr = -133.5223;
140  m_testVectors.Add (testVector);
141 
142  testVector.m_distance = 5000.0;
143  testVector.m_isLos = false;
144  testVector.m_frequency = 5.0e9;
145  testVector.m_pt = 0.0;
146  testVector.m_pr = -160.5169;
147  m_testVectors.Add (testVector);
148 
149  // Create the nodes for BS and UT
151  nodes.Create (2);
152 
153  // Create the mobility models
154  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
155  nodes.Get (0)->AggregateObject (a);
156  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
157  nodes.Get (1)->AggregateObject (b);
158 
159  // Use a deterministic channel condition model
160  Ptr<ChannelConditionModel> losCondModel = CreateObject<AlwaysLosChannelConditionModel> ();
161  Ptr<ChannelConditionModel> nlosCondModel = CreateObject<NeverLosChannelConditionModel> ();
162 
163  // Create the propagation loss model
164  Ptr<ThreeGppRmaPropagationLossModel> lossModel = CreateObject<ThreeGppRmaPropagationLossModel> ();
165  lossModel->SetAttribute ("ShadowingEnabled", BooleanValue (false)); // disable the shadow fading
166 
167  for (uint32_t i = 0; i < m_testVectors.GetN (); i++)
168  {
169  TestVector testVector = m_testVectors.Get (i);
170 
171  Vector posBs = Vector (0.0, 0.0, 35.0);
172  Vector posUt = Vector (testVector.m_distance, 0.0, 1.5);
173 
174  // set the LOS or NLOS condition
175  if (testVector.m_isLos)
176  {
177  lossModel->SetChannelConditionModel (losCondModel);
178  }
179  else
180  {
181  lossModel->SetChannelConditionModel (nlosCondModel);
182  }
183 
184  a->SetPosition (posBs);
185  b->SetPosition (posUt);
186 
187  lossModel->SetAttribute ("Frequency", DoubleValue (testVector.m_frequency));
188  NS_TEST_EXPECT_MSG_EQ_TOL (lossModel->CalcRxPower (testVector.m_pt, a, b), testVector.m_pr, m_tolerance, "Got unexpected rcv power");
189  }
190 
191  Simulator::Destroy ();
192 }
193 
200 {
201 public:
206 
211 
212 private:
216  virtual void DoRun (void);
217 
221  typedef struct
222  {
223  double m_distance;
224  bool m_isLos;
225  double m_frequency;
226  double m_pt;
227  double m_pr;
228  } TestVector;
229 
231  double m_tolerance;
232 };
233 
235  : TestCase ("Test for the ThreeGppUmaPropagationLossModel class"),
236  m_testVectors (),
237  m_tolerance (5e-2)
238 {
239 }
240 
242 {
243 }
244 
245 void
247 {
248  TestVector testVector;
249 
250  testVector.m_distance = 10.0;
251  testVector.m_isLos = true;
252  testVector.m_frequency = 5.0e9;
253  testVector.m_pt = 0.0;
254  testVector.m_pr = -72.9380;
255  m_testVectors.Add (testVector);
256 
257  testVector.m_distance = 100.0;
258  testVector.m_isLos = true;
259  testVector.m_frequency = 5.0e9;
260  testVector.m_pt = 0.0;
261  testVector.m_pr = -86.2362;
262  m_testVectors.Add (testVector);
263 
264  testVector.m_distance = 1000.0;
265  testVector.m_isLos = true;
266  testVector.m_frequency = 5.0e9;
267  testVector.m_pt = 0.0;
268  testVector.m_pr = -109.7252;
269  m_testVectors.Add (testVector);
270 
271  testVector.m_distance = 5000.0;
272  testVector.m_isLos = true;
273  testVector.m_frequency = 5.0e9;
274  testVector.m_pt = 0.0;
275  testVector.m_pr = -137.6794;
276  m_testVectors.Add (testVector);
277 
278  testVector.m_distance = 10.0;
279  testVector.m_isLos = false;
280  testVector.m_frequency = 5.0e9;
281  testVector.m_pt = 0.0;
282  testVector.m_pr = -82.5131;
283  m_testVectors.Add (testVector);
284 
285  testVector.m_distance = 100.0;
286  testVector.m_isLos = false;
287  testVector.m_frequency = 5.0e9;
288  testVector.m_pt = 0.0;
289  testVector.m_pr = -106.1356;
290  m_testVectors.Add (testVector);
291 
292  testVector.m_distance = 1000.0;
293  testVector.m_isLos = false;
294  testVector.m_frequency = 5.0e9;
295  testVector.m_pt = 0.0;
296  testVector.m_pr = -144.7641;
297  m_testVectors.Add (testVector);
298 
299  testVector.m_distance = 5000.0;
300  testVector.m_isLos = false;
301  testVector.m_frequency = 5.0e9;
302  testVector.m_pt = 0.0;
303  testVector.m_pr = -172.0753;
304  m_testVectors.Add (testVector);
305 
306  // Create the nodes for BS and UT
308  nodes.Create (2);
309 
310  // Create the mobility models
311  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
312  nodes.Get (0)->AggregateObject (a);
313  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
314  nodes.Get (1)->AggregateObject (b);
315 
316  // Use a deterministic channel condition model
317  Ptr<ChannelConditionModel> losCondModel = CreateObject<AlwaysLosChannelConditionModel> ();
318  Ptr<ChannelConditionModel> nlosCondModel = CreateObject<NeverLosChannelConditionModel> ();
319 
320  // Create the propagation loss model
321  Ptr<ThreeGppUmaPropagationLossModel> lossModel = CreateObject<ThreeGppUmaPropagationLossModel> ();
322  lossModel->SetAttribute ("ShadowingEnabled", BooleanValue (false)); // disable the shadow fading
323 
324  for (uint32_t i = 0; i < m_testVectors.GetN (); i++)
325  {
326  TestVector testVector = m_testVectors.Get (i);
327 
328  Vector posBs = Vector (0.0, 0.0, 25.0);
329  Vector posUt = Vector (testVector.m_distance, 0.0, 1.5);
330 
331  // set the LOS or NLOS condition
332  if (testVector.m_isLos)
333  {
334  lossModel->SetChannelConditionModel (losCondModel);
335  }
336  else
337  {
338  lossModel->SetChannelConditionModel (nlosCondModel);
339  }
340 
341  a->SetPosition (posBs);
342  b->SetPosition (posUt);
343 
344  lossModel->SetAttribute ("Frequency", DoubleValue (testVector.m_frequency));
345  NS_TEST_EXPECT_MSG_EQ_TOL (lossModel->CalcRxPower (testVector.m_pt, a, b), testVector.m_pr, m_tolerance, "Got unexpected rcv power");
346  }
347 
348  Simulator::Destroy ();
349 }
350 
357 {
358 public:
363 
368 
369 private:
373  virtual void DoRun (void);
374 
378  typedef struct
379  {
380  double m_distance;
381  bool m_isLos;
382  double m_frequency;
383  double m_pt;
384  double m_pr;
385  } TestVector;
386 
388  double m_tolerance;
389 };
390 
392  : TestCase ("Test for the ThreeGppUmiPropagationLossModel class"),
393  m_testVectors (),
394  m_tolerance (5e-2)
395 {
396 }
397 
399 {
400 }
401 
402 void
404 {
405  TestVector testVector;
406 
407  testVector.m_distance = 10.0;
408  testVector.m_isLos = true;
409  testVector.m_frequency = 5.0e9;
410  testVector.m_pt = 0.0;
411  testVector.m_pr = -69.8591;
412  m_testVectors.Add (testVector);
413 
414  testVector.m_distance = 100.0;
415  testVector.m_isLos = true;
416  testVector.m_frequency = 5.0e9;
417  testVector.m_pt = 0.0;
418  testVector.m_pr = -88.4122;
419  m_testVectors.Add (testVector);
420 
421  testVector.m_distance = 1000.0;
422  testVector.m_isLos = true;
423  testVector.m_frequency = 5.0e9;
424  testVector.m_pt = 0.0;
425  testVector.m_pr = -119.3114;
426 
427  testVector.m_distance = 5000.0;
428  testVector.m_isLos = true;
429  testVector.m_frequency = 5.0e9;
430  testVector.m_pt = 0.0;
431  testVector.m_pr = -147.2696;
432 
433  testVector.m_distance = 10.0;
434  testVector.m_isLos = false;
435  testVector.m_frequency = 5.0e9;
436  testVector.m_pt = 0.0;
437  testVector.m_pr = -76.7563;
438 
439  testVector.m_distance = 100.0;
440  testVector.m_isLos = false;
441  testVector.m_frequency = 5.0e9;
442  testVector.m_pt = 0.0;
443  testVector.m_pr = -107.9432;
444 
445  testVector.m_distance = 1000.0;
446  testVector.m_isLos = false;
447  testVector.m_frequency = 5.0e9;
448  testVector.m_pt = 0.0;
449  testVector.m_pr = -143.1886;
450 
451  testVector.m_distance = 5000.0;
452  testVector.m_isLos = false;
453  testVector.m_frequency = 5.0e9;
454  testVector.m_pt = 0.0;
455  testVector.m_pr = -167.8617;
456 
457  // Create the nodes for BS and UT
459  nodes.Create (2);
460 
461  // Create the mobility models
462  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
463  nodes.Get (0)->AggregateObject (a);
464  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
465  nodes.Get (1)->AggregateObject (b);
466 
467  // Use a deterministic channel condition model
468  Ptr<ChannelConditionModel> losCondModel = CreateObject<AlwaysLosChannelConditionModel> ();
469  Ptr<ChannelConditionModel> nlosCondModel = CreateObject<NeverLosChannelConditionModel> ();
470 
471  // Create the propagation loss model
472  Ptr<ThreeGppUmiStreetCanyonPropagationLossModel> lossModel = CreateObject<ThreeGppUmiStreetCanyonPropagationLossModel> ();
473  lossModel->SetAttribute ("ShadowingEnabled", BooleanValue (false)); // disable the shadow fading
474 
475  for (uint32_t i = 0; i < m_testVectors.GetN (); i++)
476  {
477  TestVector testVector = m_testVectors.Get (i);
478 
479  Vector posBs = Vector (0.0, 0.0, 10.0);
480  Vector posUt = Vector (testVector.m_distance, 0.0, 1.5);
481 
482  // set the LOS or NLOS condition
483  if (testVector.m_isLos)
484  {
485  lossModel->SetChannelConditionModel (losCondModel);
486  }
487  else
488  {
489  lossModel->SetChannelConditionModel (nlosCondModel);
490  }
491 
492  a->SetPosition (posBs);
493  b->SetPosition (posUt);
494 
495  lossModel->SetAttribute ("Frequency", DoubleValue (testVector.m_frequency));
496  NS_TEST_EXPECT_MSG_EQ_TOL (lossModel->CalcRxPower (testVector.m_pt, a, b), testVector.m_pr, m_tolerance, "Got unexpected rcv power");
497  }
498 
499  Simulator::Destroy ();
500 }
501 
508 {
509 public:
514 
519 
520 private:
524  virtual void DoRun (void);
525 
529  typedef struct
530  {
531  double m_distance;
532  bool m_isLos;
533  double m_frequency;
534  double m_pt;
535  double m_pr;
536  } TestVector;
537 
539  double m_tolerance;
540 };
541 
543  : TestCase ("Test for the ThreeGppIndoorOfficePropagationLossModel class"),
544  m_testVectors (),
545  m_tolerance (5e-2)
546 {
547 }
548 
550 {
551 }
552 
553 void
555 {
556  TestVector testVector;
557 
558  testVector.m_distance = 1.0;
559  testVector.m_isLos = true;
560  testVector.m_frequency = 5.0e9;
561  testVector.m_pt = 0.0;
562  testVector.m_pr = -50.8072;
563  m_testVectors.Add (testVector);
564 
565  testVector.m_distance = 10.0;
566  testVector.m_isLos = true;
567  testVector.m_frequency = 5.0e9;
568  testVector.m_pt = 0.0;
569  testVector.m_pr = -63.7630;
570  m_testVectors.Add (testVector);
571 
572  testVector.m_distance = 50.0;
573  testVector.m_isLos = true;
574  testVector.m_frequency = 5.0e9;
575  testVector.m_pt = 0.0;
576  testVector.m_pr = -75.7750;
577  m_testVectors.Add (testVector);
578 
579  testVector.m_distance = 100.0;
580  testVector.m_isLos = true;
581  testVector.m_frequency = 5.0e9;
582  testVector.m_pt = 0.0;
583  testVector.m_pr = -80.9802;
584  m_testVectors.Add (testVector);
585 
586  testVector.m_distance = 1.0;
587  testVector.m_isLos = false;
588  testVector.m_frequency = 5.0e9;
589  testVector.m_pt = 0.0;
590  testVector.m_pr = -50.8072;
591  m_testVectors.Add (testVector);
592 
593  testVector.m_distance = 10.0;
594  testVector.m_isLos = false;
595  testVector.m_frequency = 5.0e9;
596  testVector.m_pt = 0.0;
597  testVector.m_pr = -73.1894;
598  m_testVectors.Add (testVector);
599 
600  testVector.m_distance = 50.0;
601  testVector.m_isLos = false;
602  testVector.m_frequency = 5.0e9;
603  testVector.m_pt = 0.0;
604  testVector.m_pr = -99.7824;
605  m_testVectors.Add (testVector);
606 
607  testVector.m_distance = 100.0;
608  testVector.m_isLos = false;
609  testVector.m_frequency = 5.0e9;
610  testVector.m_pt = 0.0;
611  testVector.m_pr = -111.3062;
612  m_testVectors.Add (testVector);
613 
614  // Create the nodes for BS and UT
616  nodes.Create (2);
617 
618  // Create the mobility models
619  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
620  nodes.Get (0)->AggregateObject (a);
621  Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
622  nodes.Get (1)->AggregateObject (b);
623 
624  // Use a deterministic channel condition model
625  Ptr<ChannelConditionModel> losCondModel = CreateObject<AlwaysLosChannelConditionModel> ();
626  Ptr<ChannelConditionModel> nlosCondModel = CreateObject<NeverLosChannelConditionModel> ();
627 
628  // Create the propagation loss model
629  Ptr<ThreeGppIndoorOfficePropagationLossModel> lossModel = CreateObject<ThreeGppIndoorOfficePropagationLossModel> ();
630  lossModel->SetAttribute ("ShadowingEnabled", BooleanValue (false)); // disable the shadow fading
631 
632  for (uint32_t i = 0; i < m_testVectors.GetN (); i++)
633  {
634  TestVector testVector = m_testVectors.Get (i);
635 
636  Vector posBs = Vector (0.0, 0.0, 3.0);
637  Vector posUt = Vector (testVector.m_distance, 0.0, 1.5);
638 
639  // set the LOS or NLOS condition
640  if (testVector.m_isLos)
641  {
642  lossModel->SetChannelConditionModel (losCondModel);
643  }
644  else
645  {
646  lossModel->SetChannelConditionModel (nlosCondModel);
647  }
648 
649  a->SetPosition (posBs);
650  b->SetPosition (posUt);
651 
652  lossModel->SetAttribute ("Frequency", DoubleValue (testVector.m_frequency));
653  NS_TEST_EXPECT_MSG_EQ_TOL (lossModel->CalcRxPower (testVector.m_pt, a, b), testVector.m_pr, m_tolerance, "Got unexpected rcv power");
654  }
655 
656  Simulator::Destroy ();
657 }
658 
659 // Test to check if the shadowing fading is correctly computed
661 {
662 public:
664  virtual ~ThreeGppShadowingTestCase ();
665 
666 private:
667  virtual void DoRun (void);
668 
678  void RunTest (uint16_t testNum, std::string propagationLossModelType, double hBs, double hUt, double distance, bool shadowingEnabled);
679 
680 
687  void EvaluateLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b, uint8_t testNum);
688 
690 
694  typedef struct
695  {
697  double m_hBs;
698  double m_hUt;
699  double m_distance;
702  } TestVector;
703 
706  std::map<uint16_t /* index of experiment */, std::vector<double> /* loss in dB for each run */> m_results;
707 };
708 
710  : TestCase ("Test to check if the shadow fading is correctly computed")
711 {
712 }
713 
715 {
716 }
717 
718 void
720 {
721  double loss = m_lossModel->CalcRxPower (0, a, b);
722  m_results.at (testNum).push_back (loss);
723 }
724 
725 void
727 {
729 }
730 
731 void
732 ThreeGppShadowingTestCase::RunTest (uint16_t testNum, std::string propagationLossModelType, double hBs, double hUt, double distance, bool shadowingEnabled)
733 {
734  // Add a new entry for this test in the results map
735  m_results [testNum] = std::vector<double> ();
736 
737  // Create the nodes for BS and UT
739  nodes.Create (2);
740 
741  // Create the mobility models
742  Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
743  a->SetPosition (Vector (0.0, 0.0, hBs));
744  nodes.Get (0)->AggregateObject (a);
745 
746  Ptr<ConstantVelocityMobilityModel> b = CreateObject<ConstantVelocityMobilityModel> ();
747  nodes.Get (1)->AggregateObject (b);
748  b->SetPosition (Vector (0.0, distance, hUt));
749  b->SetVelocity (Vector (1.0, 0.0, 0.0));
750 
751  // Create the propagation loss model
752  ObjectFactory propagationLossModelFactory = ObjectFactory (propagationLossModelType);
753  m_lossModel = propagationLossModelFactory.Create<ThreeGppPropagationLossModel> ();
754  m_lossModel->SetAttribute ("Frequency", DoubleValue (3.5e9));
755  m_lossModel->SetAttribute ("ShadowingEnabled", BooleanValue (shadowingEnabled)); // enable the shadow fading
756 
757  // Set the channel condition to LOS
758  Ptr<ChannelConditionModel> losCondModel = CreateObject<AlwaysLosChannelConditionModel> ();
759  m_lossModel->SetChannelConditionModel (losCondModel);
760  // Schedule a transition to NLOS
761  Ptr<ChannelConditionModel> nlosCondModel = CreateObject<NeverLosChannelConditionModel> ();
762  Simulator::Schedule (Seconds (99.5), &ThreeGppShadowingTestCase::ChangeChannelCondition, this, nlosCondModel);
763 
764  // Schedule multiple calls to EvaluateLoss. Use both EvaluateLoss (a,b) and
765  // EvaluateLoss (b,a) to check if the reciprocity holds.
766  for (int i = 0; i < 200; i++)
767  {
768  if (i % 2 == 0)
769  Simulator::Schedule (MilliSeconds (1000 * i), &ThreeGppShadowingTestCase::EvaluateLoss, this, a, b, testNum);
770  else
771  Simulator::Schedule (MilliSeconds (1000 * i), &ThreeGppShadowingTestCase::EvaluateLoss, this, b, a, testNum);
772  }
773 
774  Simulator::Run ();
775  Simulator::Destroy ();
776 }
777 
778 void
780 {
781  // The test scenario is composed of two nodes, one fixed
782  // at position (0,0) and the other moving with constant velocity from
783  // position (0,50) to position (200,50). A building is placed in such a way
784  // that the channel condition changes from LOS to NLOS when the second node
785  // reaches position (100,50).
786  // Each experiment computes the propagation loss between the two nodes
787  // every second, until the final position is reached, and saves the
788  // results in an entry of the map m_results.
789  // We run numSamples experiments and estimate the mean propagation loss in
790  // each position by averaging among the samples.
791  // Then, we perform the null hypothesis test with a significance level of
792  // 0.05.
793  // This procedure is repeated for all the 3GPP propagation scenarios, i.e.,
794  // RMa, UMa, UMi and Indoor-Office.
795 
796  TestVector testVector;
797  testVector.m_propagationLossModelType = "ns3::ThreeGppRmaPropagationLossModel";
798  testVector.m_hBs = 25;
799  testVector.m_hUt = 1.6;
800  testVector.m_distance = 100;
801  testVector.m_shadowingStdLos = 4;
802  testVector.m_shadowingStdNlos = 8;
803  m_testVectors.Add (testVector);
804 
805  testVector.m_propagationLossModelType = "ns3::ThreeGppRmaPropagationLossModel";
806  testVector.m_hBs = 25;
807  testVector.m_hUt = 1.6;
808  testVector.m_distance = 4000; // beyond the breakpoint distance
809  testVector.m_shadowingStdLos = 6;
810  testVector.m_shadowingStdNlos = 8;
811  m_testVectors.Add (testVector);
812 
813  testVector.m_propagationLossModelType = "ns3::ThreeGppUmaPropagationLossModel";
814  testVector.m_hBs = 25;
815  testVector.m_hUt = 1.6;
816  testVector.m_distance = 100;
817  testVector.m_shadowingStdLos = 4;
818  testVector.m_shadowingStdNlos = 6;
819  m_testVectors.Add (testVector);
820 
821  testVector.m_propagationLossModelType = "ns3::ThreeGppUmiStreetCanyonPropagationLossModel";
822  testVector.m_hBs = 10;
823  testVector.m_hUt = 1.6;
824  testVector.m_distance = 100;
825  testVector.m_shadowingStdLos = 4;
826  testVector.m_shadowingStdNlos = 7.82;
827  m_testVectors.Add (testVector);
828 
829  testVector.m_propagationLossModelType = "ns3::ThreeGppIndoorOfficePropagationLossModel";
830  testVector.m_hBs = 3;
831  testVector.m_hUt = 1;
832  testVector.m_distance = 50;
833  testVector.m_shadowingStdLos = 3;
834  testVector.m_shadowingStdNlos = 8.03;
835  m_testVectors.Add (testVector);
836 
837  uint16_t numSamples = 250;
838 
839  for (uint16_t tvIndex = 0; tvIndex < m_testVectors.GetN (); tvIndex++)
840  {
841  TestVector tv = m_testVectors.Get (tvIndex);
842 
843  // run the experiments.
844  for (uint16_t sampleIndex = 0; sampleIndex < numSamples; sampleIndex++)
845  {
846  RunTest (sampleIndex, tv.m_propagationLossModelType, tv.m_hBs, tv.m_hUt, tv.m_distance, true);
847  }
848 
849  // analyze the results
850  std::vector<double> mean_vector; // the vector containing the mean propagation loss for each position (sample mean)
851 
852  uint16_t numPositions = m_results.at (0).size ();
853  for (uint16_t k = 0; k < numPositions; k++)
854  {
855  // compute the mean propagation loss in position k
856  double mean = 0.0;
857  for (auto resIt : m_results)
858  {
859  mean += resIt.second.at (k);
860  }
861  mean /= m_results.size ();
862  mean_vector.push_back (mean);
863  }
864 
865  // compute the true mean - just the pathloss, without the shadowing component
866  RunTest (numSamples, tv.m_propagationLossModelType, tv.m_hBs, tv.m_hUt, tv.m_distance, false);
867  std::vector<double> true_mean = m_results.at (numSamples); // the result of the last test is the true mean
868 
869  // perform the null hypothesis test for the LOS case
870  // positions from (0, 50) to (99, 50) are LOS
871  for (uint16_t i = 0; i < mean_vector.size () / 2; i++)
872  {
873  double z = (mean_vector.at (i) - true_mean.at (i)) / (tv.m_shadowingStdLos / std::sqrt (mean_vector.size () / 2));
874  NS_TEST_EXPECT_MSG_EQ_TOL (z, 0.0, 1.96, "Null hypothesis test (LOS case) for the shadowing component rejected");
875  }
876 
877  // perform the null hypothesis test for the NLOS case
878  // positions from (100, 50) to (199, 50) are NLOS
879  for (uint16_t i = mean_vector.size () / 2; i < mean_vector.size (); i++)
880  {
881  double z = (mean_vector.at (i) - true_mean.at (i)) / (tv.m_shadowingStdNlos / std::sqrt (mean_vector.size () / 2));
882  NS_TEST_EXPECT_MSG_EQ_TOL (z, 0.0, 1.96, "Null hypothesis test (NLOS case) for the shadowing component rejected");
883  }
884  }
885 }
886 
888 {
889 public:
891 };
892 
894  : TestSuite ("three-gpp-propagation-loss-model", UNIT)
895 {
900  AddTestCase (new ThreeGppShadowingTestCase, TestCase::QUICK);
901 }
902 
virtual void DoRun(void)
Build the simulation scenario and run the tests.
double CalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account all the PropagationLossModel(s) chained to the current one...
AttributeValue implementation for Boolean.
Definition: boolean.h:36
Test case for the class ThreeGppIndoorOfficePropagationLossModel.
TestVectors< TestVector > m_testVectors
array containing all the test vectors
Test case for the class ThreeGppRmaPropagationLossModel.
A suite of tests to run.
Definition: test.h:1343
double m_shadowingStdNlos
the standard deviation of the shadowing component in the NLOS case in dB
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1078
void ChangeChannelCondition(Ptr< ChannelConditionModel > ccm)
encapsulates test code
Definition: test.h:1153
virtual void DoRun(void)
Build the simulation scenario and run the tests.
Ptr< ThreeGppPropagationLossModel > m_lossModel
the propagation loss model
A simple way to store test vectors (for stimulus or from responses)
Definition: test.h:1406
nodes
Definition: first.py:32
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
TestVectors< TestVector > m_testVectors
array containing all the test vectors
TestVectors< TestVector > m_testVectors
array containing all the test vectors
void RunTest(uint16_t testNum, std::string propagationLossModelType, double hBs, double hUt, double distance, bool shadowingEnabled)
Run the experiment.
virtual void DoRun(void)
Build the simulation scenario and run the tests.
void EvaluateLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b, uint8_t testNum)
Compute the propagation loss.
TestVectors< TestVector > m_testVectors
array containing all the test vectors
virtual void DoRun(void)
Implementation to actually run this TestCase.
double m_distance
the initial 2D distance in meters between BS and UT in meters
#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
std::string m_propagationLossModelType
the propagation loss model type id
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Struct containing the parameters for each test.
virtual void DoRun(void)
Build the simulation scenario and run the tests.
TestVectors< TestVector > m_testVectors
array containing all the test vectors
Test case for the class ThreeGppUmiStreetCanyonPropagationLossModel.
double m_shadowingStdLos
the standard deviation of the shadowing component in the LOS case in dB
void SetPosition(const Vector &position)
Instantiate subclasses of ns3::Object.
static ThreeGppPropagationLossModelsTestSuite propagationLossModelsTestSuite
std::map< uint16_t, std::vector< double > > m_results
used to store the test results
void SetChannelConditionModel(Ptr< ChannelConditionModel > model)
Set the channel condition model used to determine the channel state (e.g., the LOS/NLOS condition) ...
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
Test case for the class ThreeGppUmaPropagationLossModel.
Base class for the 3GPP propagation models.
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:187