A Discrete-Event Network Simulator
API
itu-r-1411-los-test-suite.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011,2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Marco Miozzo <marco.miozzo@cttc.es>
18  * Nicola Baldo <nbaldo@cttc.es>
19  */
20 
21 #include <ns3/constant-position-mobility-model.h>
22 #include <ns3/double.h>
23 #include <ns3/enum.h>
24 #include <ns3/itu-r-1411-los-propagation-loss-model.h>
25 #include <ns3/log.h>
26 #include <ns3/string.h>
27 #include <ns3/test.h>
28 
29 using namespace ns3;
30 
31 NS_LOG_COMPONENT_DEFINE("ItuR1411LosPropagationLossModelTest");
32 
40 {
41  public:
53  double dist,
54  double hb,
55  double hm,
56  double refValue,
57  std::string name);
59 
60  private:
61  void DoRun() override;
62 
69 
70  double m_freq;
71  double m_dist;
72  double m_hb;
73  double m_hm;
74  double m_lossRef;
75 };
76 
78  double dist,
79  double hb,
80  double hm,
81  double refValue,
82  std::string name)
83  : TestCase(name),
84  m_freq(freq),
85  m_dist(dist),
86  m_hb(hb),
87  m_hm(hm),
88  m_lossRef(refValue)
89 {
90 }
91 
93 {
94 }
95 
96 void
98 {
99  NS_LOG_FUNCTION(this);
100 
101  Ptr<MobilityModel> mma = CreateObject<ConstantPositionMobilityModel>();
102  mma->SetPosition(Vector(0.0, 0.0, m_hb));
103 
104  Ptr<MobilityModel> mmb = CreateObject<ConstantPositionMobilityModel>();
105  mmb->SetPosition(Vector(m_dist, 0.0, m_hm));
106 
107  Ptr<ItuR1411LosPropagationLossModel> propagationLossModel =
108  CreateObject<ItuR1411LosPropagationLossModel>();
109  propagationLossModel->SetAttribute("Frequency", DoubleValue(m_freq));
110 
111  double loss = propagationLossModel->GetLoss(mma, mmb);
112 
113  NS_LOG_INFO("Calculated loss: " << loss);
114  NS_LOG_INFO("Theoretical loss: " << m_lossRef);
115 
116  NS_TEST_ASSERT_MSG_EQ_TOL(loss, m_lossRef, 0.1, "Wrong loss!");
117 }
118 
126 {
127  public:
129 };
130 
132  : TestSuite("itu-r-1411-los", SYSTEM)
133 {
134  LogComponentEnable("ItuR1411LosPropagationLossModelTest", LOG_LEVEL_ALL);
135 
136  // reference values obtained with the octave scripts in src/propagation/test/reference/
138  100,
139  30,
140  1,
141  81.005,
142  "freq=2114MHz, dist=100m"),
143  TestCase::QUICK);
145  200,
146  30,
147  1,
148  87.060,
149  "freq=1999MHz, dist=200m"),
150  TestCase::QUICK);
151 }
152 
ItuR1411LosPropagationLossModel Test Case.
ItuR1411LosPropagationLossModelTestCase(double freq, double dist, double hb, double hm, double refValue, std::string name)
Constructor.
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
Create a MobilityModel.
void DoRun() override
Implementation to actually run this TestCase.
double m_dist
2D distance between UT and BS in meters
ItuR1411LosPropagationLossModel TestSuite.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
void SetPosition(const Vector &position)
encapsulates test code
Definition: test.h:1060
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition: test.h:337
static ItuR1411LosPropagationLossModelTestSuite g_ituR1411LosTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:302
@ LOG_LEVEL_ALL
Print everything.
Definition: log.h:116