A Discrete-Event Network Simulator
API
itu-r-1411-nlos-over-rooftop-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-nlos-over-rooftop-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("ItuR1411NlosOverRooftopPropagationLossModelTest");
32 
40 {
41  public:
55  double dist,
56  double hb,
57  double hm,
58  EnvironmentType env,
59  CitySize city,
60  double refValue,
61  std::string name);
63 
64  private:
65  void DoRun() override;
66 
73 
74  double m_freq;
75  double m_dist;
76  double m_hb;
77  double m_hm;
80  double m_lossRef;
81 };
82 
85  double dist,
86  double hb,
87  double hm,
88  EnvironmentType env,
89  CitySize city,
90  double refValue,
91  std::string name)
92  : TestCase(name),
93  m_freq(freq),
94  m_dist(dist),
95  m_hb(hb),
96  m_hm(hm),
97  m_env(env),
98  m_city(city),
99  m_lossRef(refValue)
100 {
101 }
102 
105 {
106 }
107 
108 void
110 {
111  NS_LOG_FUNCTION(this);
112 
113  Ptr<MobilityModel> mma = CreateObject<ConstantPositionMobilityModel>();
114  mma->SetPosition(Vector(0.0, 0.0, m_hb));
115 
116  Ptr<MobilityModel> mmb = CreateObject<ConstantPositionMobilityModel>();
117  mmb->SetPosition(Vector(m_dist, 0.0, m_hm));
118 
120  CreateObject<ItuR1411NlosOverRooftopPropagationLossModel>();
121  propagationLossModel->SetAttribute("Frequency", DoubleValue(m_freq));
122  propagationLossModel->SetAttribute("Environment", EnumValue(m_env));
123  propagationLossModel->SetAttribute("CitySize", EnumValue(m_city));
124 
125  double loss = propagationLossModel->GetLoss(mma, mmb);
126 
127  NS_LOG_INFO("Calculated loss: " << loss);
128  NS_LOG_INFO("Theoretical loss: " << m_lossRef);
129 
130  NS_TEST_ASSERT_MSG_EQ_TOL(loss, m_lossRef, 0.1, "Wrong loss!");
131 }
132 
140 {
141  public:
143 };
144 
147  : TestSuite("itu-r-1411-nlos-over-rooftop", SYSTEM)
148 {
149  LogComponentEnable("ItuR1411NlosOverRooftopPropagationLossModelTest", LOG_LEVEL_ALL);
150 
151  // reference values obtained with the octave scripts in src/propagation/test/reference/
153  2.1140e9,
154  900,
155  30,
156  1,
158  LargeCity,
159  143.68,
160  "f=2114Mhz, dist=900, urban large city"),
161  TestCase::QUICK);
163  1.865e9,
164  500,
165  30,
166  1,
168  LargeCity,
169  132.84,
170  "f=2114Mhz, dist=900, urban large city"),
171  TestCase::QUICK);
172 }
173 
ItuR1411NlosOverRooftopPropagationLossModel Test Case.
ItuR1411NlosOverRooftopPropagationLossModelTestCase(double freq, double dist, double hb, double hm, EnvironmentType env, CitySize city, double refValue, std::string name)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
Create a MobilityModel.
ItuR1411NlosOverRooftopPropagationLossModel TestSuite.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Hold variables of type enum.
Definition: enum.h:62
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
EnvironmentType
The type of propagation environment.
CitySize
The size of the city in which propagation takes place.
#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 ItuR1411NlosOverRooftopPropagationLossModelTestSuite g_ituR1411NlosOverRooftopTestSuite
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