A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
18
using namespace
ns3
;
19
20
NS_LOG_COMPONENT_DEFINE
(
"OkumuraHataPropagationLossModelTest"
);
21
22
/**
23
* @ingroup propagation-tests
24
*
25
* @brief OkumuraHataPropagationLossModel Test Case
26
*/
27
class
OkumuraHataPropagationLossModelTestCase
:
public
TestCase
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
*/
42
OkumuraHataPropagationLossModelTestCase
(
double
freq,
43
double
dist,
44
double
hb,
45
double
hm,
46
EnvironmentType
env,
47
CitySize
city,
48
double
refValue,
49
std::string name);
50
~OkumuraHataPropagationLossModelTestCase
()
override
;
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
*/
60
Ptr<MobilityModel>
CreateMobilityModel
(uint16_t index);
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
71
OkumuraHataPropagationLossModelTestCase::OkumuraHataPropagationLossModelTestCase
(
72
double
freq,
73
double
dist,
74
double
hb,
75
double
hm,
76
EnvironmentType
env,
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
91
OkumuraHataPropagationLossModelTestCase::~OkumuraHataPropagationLossModelTestCase
()
92
{
93
}
94
95
void
96
OkumuraHataPropagationLossModelTestCase::DoRun
()
97
{
98
NS_LOG_FUNCTION
(
this
);
99
100
Ptr<MobilityModel>
mma =
CreateObject<ConstantPositionMobilityModel>
();
101
mma->SetPosition(Vector(0.0, 0.0,
m_hb
));
102
103
Ptr<MobilityModel>
mmb =
CreateObject<ConstantPositionMobilityModel>
();
104
mmb->SetPosition(Vector(
m_dist
, 0.0,
m_hm
));
105
106
Ptr<OkumuraHataPropagationLossModel>
propagationLossModel =
107
CreateObject<OkumuraHataPropagationLossModel>
();
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
*/
131
class
OkumuraHataPropagationLossModelTestSuite
:
public
TestSuite
132
{
133
public
:
134
OkumuraHataPropagationLossModelTestSuite
();
135
};
136
137
OkumuraHataPropagationLossModelTestSuite::OkumuraHataPropagationLossModelTestSuite
()
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
144
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq,
145
2000,
146
30,
147
1,
148
UrbanEnvironment
,
149
LargeCity
,
150
137.93,
151
"original OH Urban Large city"
),
152
TestCase::Duration::QUICK);
153
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq,
154
2000,
155
30,
156
1,
157
UrbanEnvironment
,
158
SmallCity
,
159
137.88,
160
"original OH Urban small city"
),
161
TestCase::Duration::QUICK);
162
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq,
163
2000,
164
30,
165
1,
166
SubUrbanEnvironment
,
167
LargeCity
,
168
128.03,
169
"original OH SubUrban"
),
170
TestCase::Duration::QUICK);
171
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq,
172
2000,
173
30,
174
1,
175
OpenAreasEnvironment
,
176
LargeCity
,
177
110.21,
178
"original OH OpenAreas"
),
179
TestCase::Duration::QUICK);
180
181
freq = 2.1140e9;
// this will use the extended COST231 OH model
182
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq,
183
2000,
184
30,
185
1,
186
UrbanEnvironment
,
187
LargeCity
,
188
148.55,
189
"COST231 OH Urban Large city"
),
190
TestCase::Duration::QUICK);
191
AddTestCase
(
192
new
OkumuraHataPropagationLossModelTestCase
(freq,
193
2000,
194
30,
195
1,
196
UrbanEnvironment
,
197
SmallCity
,
198
150.64,
199
"COST231 OH Urban small city and suburban"
),
200
TestCase::Duration::QUICK);
201
}
202
203
/// Static variable for test initialization
204
static
OkumuraHataPropagationLossModelTestSuite
g_okumuraHataTestSuite
;
OkumuraHataPropagationLossModelTestCase
OkumuraHataPropagationLossModel Test Case.
Definition
okumura-hata-test-suite.cc:28
OkumuraHataPropagationLossModelTestCase::m_env
EnvironmentType m_env
environment type
Definition
okumura-hata-test-suite.cc:66
OkumuraHataPropagationLossModelTestCase::CreateMobilityModel
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
Create a MobilityModel.
OkumuraHataPropagationLossModelTestCase::~OkumuraHataPropagationLossModelTestCase
~OkumuraHataPropagationLossModelTestCase() override
Definition
okumura-hata-test-suite.cc:91
OkumuraHataPropagationLossModelTestCase::m_city
CitySize m_city
city type
Definition
okumura-hata-test-suite.cc:67
OkumuraHataPropagationLossModelTestCase::m_hm
double m_hm
height of UT in meters
Definition
okumura-hata-test-suite.cc:65
OkumuraHataPropagationLossModelTestCase::OkumuraHataPropagationLossModelTestCase
OkumuraHataPropagationLossModelTestCase(double freq, double dist, double hb, double hm, EnvironmentType env, CitySize city, double refValue, std::string name)
Constructor.
Definition
okumura-hata-test-suite.cc:71
OkumuraHataPropagationLossModelTestCase::m_freq
double m_freq
carrier frequency in Hz
Definition
okumura-hata-test-suite.cc:62
OkumuraHataPropagationLossModelTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
okumura-hata-test-suite.cc:96
OkumuraHataPropagationLossModelTestCase::m_hb
double m_hb
height of BS in meters
Definition
okumura-hata-test-suite.cc:64
OkumuraHataPropagationLossModelTestCase::m_dist
double m_dist
2D distance between UT and BS in meters
Definition
okumura-hata-test-suite.cc:63
OkumuraHataPropagationLossModelTestCase::m_lossRef
double m_lossRef
reference loss
Definition
okumura-hata-test-suite.cc:68
OkumuraHataPropagationLossModelTestSuite
OkumuraHataPropagationLossModel TestSuite.
Definition
okumura-hata-test-suite.cc:132
OkumuraHataPropagationLossModelTestSuite::OkumuraHataPropagationLossModelTestSuite
OkumuraHataPropagationLossModelTestSuite()
Definition
okumura-hata-test-suite.cc:137
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::EnumValue
Hold variables of type enum.
Definition
enum.h:52
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TestCase
encapsulates test code
Definition
test.h:1050
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition
test.cc:292
ns3::TestSuite
A suite of tests to run.
Definition
test.h:1267
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1274
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition
log.h:264
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
ns3::EnvironmentType
EnvironmentType
The type of propagation environment.
Definition
propagation-environment.h:24
ns3::CitySize
CitySize
The size of the city in which propagation takes place.
Definition
propagation-environment.h:37
ns3::SubUrbanEnvironment
@ SubUrbanEnvironment
Definition
propagation-environment.h:26
ns3::OpenAreasEnvironment
@ OpenAreasEnvironment
Definition
propagation-environment.h:27
ns3::UrbanEnvironment
@ UrbanEnvironment
Definition
propagation-environment.h:25
ns3::LargeCity
@ LargeCity
Definition
propagation-environment.h:40
ns3::SmallCity
@ SmallCity
Definition
propagation-environment.h:38
NS_TEST_ASSERT_MSG_EQ_TOL
#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
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::LogComponentEnable
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition
log.cc:291
ns3::LOG_LEVEL_ALL
@ LOG_LEVEL_ALL
Print everything.
Definition
log.h:105
g_okumuraHataTestSuite
static OkumuraHataPropagationLossModelTestSuite g_okumuraHataTestSuite
Static variable for test initialization.
Definition
okumura-hata-test-suite.cc:204
src
propagation
test
okumura-hata-test-suite.cc
Generated on Tue Dec 10 2024 18:20:47 for ns-3 by
1.11.0