A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
okumura-hata-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/log.h>
25#include <ns3/okumura-hata-propagation-loss-model.h>
26#include <ns3/string.h>
27#include <ns3/test.h>
28
29using namespace ns3;
30
31NS_LOG_COMPONENT_DEFINE("OkumuraHataPropagationLossModelTest");
32
39{
40 public:
54 double dist,
55 double hb,
56 double hm,
58 CitySize city,
59 double refValue,
60 std::string name);
62
63 private:
64 void DoRun() override;
65
72
73 double m_freq;
74 double m_dist;
75 double m_hb;
76 double m_hm;
79 double m_lossRef;
80};
81
83 double freq,
84 double dist,
85 double hb,
86 double hm,
88 CitySize city,
89 double refValue,
90 std::string name)
91 : TestCase(name),
92 m_freq(freq),
93 m_dist(dist),
94 m_hb(hb),
95 m_hm(hm),
96 m_env(env),
97 m_city(city),
98 m_lossRef(refValue)
99{
100}
101
103{
104}
105
106void
108{
109 NS_LOG_FUNCTION(this);
110
111 Ptr<MobilityModel> mma = CreateObject<ConstantPositionMobilityModel>();
112 mma->SetPosition(Vector(0.0, 0.0, m_hb));
113
114 Ptr<MobilityModel> mmb = CreateObject<ConstantPositionMobilityModel>();
115 mmb->SetPosition(Vector(m_dist, 0.0, m_hm));
116
117 Ptr<OkumuraHataPropagationLossModel> propagationLossModel =
118 CreateObject<OkumuraHataPropagationLossModel>();
119 propagationLossModel->SetAttribute("Frequency", DoubleValue(m_freq));
120 propagationLossModel->SetAttribute("Environment", EnumValue(m_env));
121 propagationLossModel->SetAttribute("CitySize", EnumValue(m_city));
122
123 double loss = propagationLossModel->GetLoss(mma, mmb);
124
125 NS_LOG_INFO("Calculated loss: " << loss);
126 NS_LOG_INFO("Theoretical loss: " << m_lossRef);
127
128 NS_TEST_ASSERT_MSG_EQ_TOL(loss, m_lossRef, 0.1, "Wrong loss!");
129}
130
143{
144 public:
146};
147
149 : TestSuite("okumura-hata", SYSTEM)
150{
151 LogComponentEnable("OkumuraHataPropagationLossModelTest", LOG_LEVEL_ALL);
152 // reference values obtained with the octave scripts in src/propagation/test/reference/
153
154 double freq = 869e6; // this will use the original OH model
156 2000,
157 30,
158 1,
160 LargeCity,
161 137.93,
162 "original OH Urban Large city"),
165 2000,
166 30,
167 1,
169 SmallCity,
170 137.88,
171 "original OH Urban small city"),
174 2000,
175 30,
176 1,
178 LargeCity,
179 128.03,
180 "original OH SubUrban"),
183 2000,
184 30,
185 1,
187 LargeCity,
188 110.21,
189 "original OH OpenAreas"),
191
192 freq = 2.1140e9; // this will use the extended COST231 OH model
194 2000,
195 30,
196 1,
198 LargeCity,
199 148.55,
200 "COST231 OH Urban Large city"),
204 2000,
205 30,
206 1,
208 SmallCity,
209 150.64,
210 "COST231 OH Urban small city and suburban"),
212}
213
OkumuraHataPropagationLossModel Test Case.
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
Create a MobilityModel.
OkumuraHataPropagationLossModelTestCase(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.
double m_dist
2D distance between UT and BS in meters
OkumuraHataPropagationLossModel 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:56
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
encapsulates test code
Definition: test.h:1060
@ QUICK
Fast test.
Definition: test.h:1065
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
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
static OkumuraHataPropagationLossModelTestSuite g_okumuraHataTestSuite
Static variable for test initialization.