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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Marco Miozzo <marco.miozzo@cttc.es>
7 * Nicola Baldo <nbaldo@cttc.es>
8 */
9
10#include "ns3/constant-position-mobility-model.h"
11#include "ns3/double.h"
12#include "ns3/enum.h"
13#include "ns3/log.h"
14#include "ns3/okumura-hata-propagation-loss-model.h"
15#include "ns3/string.h"
16#include "ns3/test.h"
17
18using namespace ns3;
19
20NS_LOG_COMPONENT_DEFINE("OkumuraHataPropagationLossModelTest");
21
22/**
23 * @ingroup propagation-tests
24 *
25 * @brief OkumuraHataPropagationLossModel Test Case
26 */
28{
29 public:
30 /**
31 * Constructor
32 *
33 * @param freq carrier frequency in Hz
34 * @param dist 2D distance between UT and BS in meters
35 * @param hb height of BS in meters
36 * @param hm height of UT in meters
37 * @param env environment type
38 * @param city city type
39 * @param refValue reference loss value
40 * @param name TestCase name
41 */
43 double dist,
44 double hb,
45 double hm,
47 CitySize city,
48 double refValue,
49 std::string name);
51
52 private:
53 void DoRun() override;
54
55 /**
56 * Create a MobilityModel
57 * @param index mobility model index
58 * @return a new MobilityModel
59 */
61
62 double m_freq; //!< carrier frequency in Hz
63 double m_dist; //!< 2D distance between UT and BS in meters
64 double m_hb; //!< height of BS in meters
65 double m_hm; //!< height of UT in meters
66 EnvironmentType m_env; //!< environment type
67 CitySize m_city; //!< city type
68 double m_lossRef; //!< reference loss
69};
70
72 double freq,
73 double dist,
74 double hb,
75 double hm,
77 CitySize city,
78 double refValue,
79 std::string name)
80 : TestCase(name),
81 m_freq(freq),
82 m_dist(dist),
83 m_hb(hb),
84 m_hm(hm),
85 m_env(env),
86 m_city(city),
87 m_lossRef(refValue)
88{
89}
90
94
95void
97{
98 NS_LOG_FUNCTION(this);
99
101 mma->SetPosition(Vector(0.0, 0.0, m_hb));
102
104 mmb->SetPosition(Vector(m_dist, 0.0, m_hm));
105
106 Ptr<OkumuraHataPropagationLossModel> propagationLossModel =
108 propagationLossModel->SetAttribute("Frequency", DoubleValue(m_freq));
109 propagationLossModel->SetAttribute("Environment", EnumValue(m_env));
110 propagationLossModel->SetAttribute("CitySize", EnumValue(m_city));
111
112 double loss = propagationLossModel->GetLoss(mma, mmb);
113
114 NS_LOG_INFO("Calculated loss: " << loss);
115 NS_LOG_INFO("Theoretical loss: " << m_lossRef);
116
117 NS_TEST_ASSERT_MSG_EQ_TOL(loss, m_lossRef, 0.1, "Wrong loss!");
118}
119
120/**
121 * @ingroup propagation-tests
122 *
123 * @brief OkumuraHataPropagationLossModel TestSuite
124 *
125 * This TestSuite tests the following cases:
126 * - UrbanEnvironment - Large City (original OH and COST231 OH)
127 * - UrbanEnvironment - Small City (original OH and COST231 OH)
128 * - SubUrbanEnvironment (original OH only)
129 * - OpenAreasEnvironment (original OH only)
130 */
136
138 : TestSuite("okumura-hata", Type::SYSTEM)
139{
140 LogComponentEnable("OkumuraHataPropagationLossModelTest", LOG_LEVEL_ALL);
141 // reference values obtained with the octave scripts in src/propagation/test/reference/
142
143 double freq = 869e6; // this will use the original OH model
145 2000,
146 30,
147 1,
149 LargeCity,
150 137.93,
151 "original OH Urban Large city"),
154 2000,
155 30,
156 1,
158 SmallCity,
159 137.88,
160 "original OH Urban small city"),
163 2000,
164 30,
165 1,
167 LargeCity,
168 128.03,
169 "original OH SubUrban"),
172 2000,
173 30,
174 1,
176 LargeCity,
177 109.66,
178 "original OH OpenAreas"),
180
181 freq = 2.1140e9; // this will use the extended COST231 OH model
183 2000,
184 30,
185 1,
187 LargeCity,
188 148.55,
189 "COST231 OH Urban Large city"),
193 2000,
194 30,
195 1,
197 SmallCity,
198 150.64,
199 "COST231 OH Urban small city and suburban"),
201}
202
203/// Static variable for test initialization
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:31
Hold variables of type enum.
Definition enum.h:52
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
@ QUICK
Fast test.
Definition test.h:1055
TestCase(const TestCase &)=delete
Type
Type of test.
Definition test.h:1274
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition test.cc:490
static constexpr auto SYSTEM
Definition test.h:1293
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
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:327
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:291
@ LOG_LEVEL_ALL
Print everything.
Definition log.h:105
static OkumuraHataPropagationLossModelTestSuite g_okumuraHataTestSuite
Static variable for test initialization.