A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
okumura-hata-test-suite.cc
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011,2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Marco Miozzo <marco.miozzo@cttc.es>
19
* Nicola Baldo <nbaldo@cttc.es>
20
*/
21
22
23
#include <ns3/log.h>
24
#include <ns3/test.h>
25
#include <ns3/okumura-hata-propagation-loss-model.h>
26
#include <ns3/string.h>
27
#include <ns3/double.h>
28
#include <ns3/constant-position-mobility-model.h>
29
#include <ns3/enum.h>
30
31
32
using namespace
ns3
;
33
34
NS_LOG_COMPONENT_DEFINE
(
"OkumuraHataPropagationLossModelTest"
);
35
36
class
OkumuraHataPropagationLossModelTestCase
:
public
TestCase
37
{
38
public
:
39
OkumuraHataPropagationLossModelTestCase
(
double
freq,
double
dist,
double
hb,
double
hm,
EnvironmentType
env,
CitySize
city,
double
refValue, std::string name);
40
virtual
~
OkumuraHataPropagationLossModelTestCase
();
41
42
private
:
43
virtual
void
DoRun (
void
);
44
Ptr<MobilityModel>
CreateMobilityModel
(uint16_t index);
45
46
double
m_freq
;
47
double
m_dist
;
48
double
m_hb
;
49
double
m_hm
;
50
EnvironmentType
m_env
;
51
CitySize
m_city
;
52
double
m_lossRef
;
53
54
};
55
56
OkumuraHataPropagationLossModelTestCase::OkumuraHataPropagationLossModelTestCase
(
double
freq,
double
dist,
double
hb,
double
hm,
EnvironmentType
env,
CitySize
city,
double
refValue, std::string name)
57
:
TestCase
(name),
58
m_freq (freq),
59
m_dist (dist),
60
m_hb (hb),
61
m_hm (hm),
62
m_env (env),
63
m_city (city),
64
m_lossRef (refValue)
65
{
66
}
67
68
OkumuraHataPropagationLossModelTestCase::~OkumuraHataPropagationLossModelTestCase
()
69
{
70
}
71
72
73
74
void
75
OkumuraHataPropagationLossModelTestCase::DoRun
(
void
)
76
{
77
NS_LOG_FUNCTION
(
this
);
78
79
80
Ptr<MobilityModel>
mma = CreateObject<ConstantPositionMobilityModel> ();
81
mma->
SetPosition
(Vector (0.0, 0.0,
m_hb
));
82
83
Ptr<MobilityModel>
mmb = CreateObject<ConstantPositionMobilityModel> ();
84
mmb->
SetPosition
(Vector (
m_dist
, 0.0,
m_hm
));
85
86
Ptr<OkumuraHataPropagationLossModel>
propagationLossModel = CreateObject<OkumuraHataPropagationLossModel> ();
87
propagationLossModel->
SetAttribute
(
"Frequency"
,
DoubleValue
(
m_freq
));
88
propagationLossModel->
SetAttribute
(
"Environment"
,
EnumValue
(
m_env
));
89
propagationLossModel->
SetAttribute
(
"CitySize"
,
EnumValue
(
m_city
));
90
91
double
loss = propagationLossModel->
GetLoss
(mma, mmb);
92
93
NS_LOG_INFO
(
"Calculated loss: "
<< loss);
94
NS_LOG_INFO
(
"Theoretical loss: "
<<
m_lossRef
);
95
96
NS_TEST_ASSERT_MSG_EQ_TOL
(loss,
m_lossRef
, 0.1,
"Wrong loss!"
);
97
98
}
99
100
101
102
class
OkumuraHataPropagationLossModelTestSuite
:
public
TestSuite
103
{
104
public
:
105
OkumuraHataPropagationLossModelTestSuite
();
106
};
107
108
109
110
OkumuraHataPropagationLossModelTestSuite::OkumuraHataPropagationLossModelTestSuite
()
111
:
TestSuite
(
"okumura-hata"
, SYSTEM)
112
{
113
114
LogComponentEnable
(
"OkumuraHataPropagationLossModelTest"
,
LOG_LEVEL_ALL
);
115
116
117
// reference values obtained with the octave scripts in src/propagation/test/reference/
118
119
120
double
freq = 869e6;
// this will use the original OH model
121
122
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq, 2000, 30, 1,
UrbanEnvironment
,
LargeCity
, 137.93,
"original OH Urban Large city"
), TestCase::QUICK);
123
124
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq, 2000, 30, 1,
UrbanEnvironment
,
SmallCity
, 137.88,
"original OH Urban small city"
), TestCase::QUICK);
125
126
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq, 2000, 30, 1,
SubUrbanEnvironment
,
LargeCity
, 128.03,
"original OH SubUrban"
), TestCase::QUICK);
127
128
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq, 2000, 30, 1,
OpenAreasEnvironment
,
LargeCity
, 110.21,
"original OH OpenAreas"
), TestCase::QUICK);
129
130
131
freq = 2.1140e9;
// this will use the extended COST231 OH model
132
133
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq, 2000, 30, 1,
UrbanEnvironment
,
LargeCity
, 148.55,
"COST231 OH Urban Large city"
), TestCase::QUICK);
134
135
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq, 2000, 30, 1,
UrbanEnvironment
,
SmallCity
, 150.64,
"COST231 OH Urban small city and suburban"
), TestCase::QUICK);
136
137
}
138
139
140
141
static
OkumuraHataPropagationLossModelTestSuite
g_okumuraHataTestSuite
;
ns3::SubUrbanEnvironment
@ SubUrbanEnvironment
Definition:
propagation-environment.h:38
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:299
OkumuraHataPropagationLossModelTestSuite::OkumuraHataPropagationLossModelTestSuite
OkumuraHataPropagationLossModelTestSuite()
Definition:
okumura-hata-test-suite.cc:110
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SmallCity
@ SmallCity
Definition:
propagation-environment.h:50
ns3::LargeCity
@ LargeCity
Definition:
propagation-environment.h:50
ns3::UrbanEnvironment
@ UrbanEnvironment
Definition:
propagation-environment.h:38
ns3::LOG_LEVEL_ALL
@ LOG_LEVEL_ALL
Print everything.
Definition:
log.h:116
ns3::MobilityModel::SetPosition
void SetPosition(const Vector &position)
Definition:
mobility-model.cc:88
ns3::LogComponentEnable
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition:
log.cc:361
OkumuraHataPropagationLossModelTestCase::m_dist
double m_dist
Definition:
okumura-hata-test-suite.cc:47
ns3::ObjectBase::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition:
object-base.cc:185
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:41
OkumuraHataPropagationLossModelTestSuite
Definition:
okumura-hata-test-suite.cc:103
ns3::EnumValue
Hold variables of type enum.
Definition:
enum.h:55
ns3::TestCase
encapsulates test code
Definition:
test.h:1154
OkumuraHataPropagationLossModelTestCase::~OkumuraHataPropagationLossModelTestCase
virtual ~OkumuraHataPropagationLossModelTestCase()
Definition:
okumura-hata-test-suite.cc:68
ns3::Ptr< MobilityModel >
ns3::OpenAreasEnvironment
@ OpenAreasEnvironment
Definition:
propagation-environment.h:38
ns3::CitySize
CitySize
The size of the city in which propagation takes place.
Definition:
propagation-environment.h:49
OkumuraHataPropagationLossModelTestCase::OkumuraHataPropagationLossModelTestCase
OkumuraHataPropagationLossModelTestCase(double freq, double dist, double hb, double hm, EnvironmentType env, CitySize city, double refValue, std::string name)
Definition:
okumura-hata-test-suite.cc:56
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition:
log.h:281
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:378
OkumuraHataPropagationLossModelTestCase::m_hm
double m_hm
Definition:
okumura-hata-test-suite.cc:49
OkumuraHataPropagationLossModelTestCase::m_env
EnvironmentType m_env
Definition:
okumura-hata-test-suite.cc:50
OkumuraHataPropagationLossModelTestCase::m_freq
double m_freq
Definition:
okumura-hata-test-suite.cc:46
ns3::EnvironmentType
EnvironmentType
The type of propagation environment.
Definition:
propagation-environment.h:37
OkumuraHataPropagationLossModelTestCase::CreateMobilityModel
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
OkumuraHataPropagationLossModelTestCase
Definition:
okumura-hata-test-suite.cc:37
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1344
OkumuraHataPropagationLossModelTestCase::m_city
CitySize m_city
Definition:
okumura-hata-test-suite.cc:51
OkumuraHataPropagationLossModelTestCase::m_lossRef
double m_lossRef
Definition:
okumura-hata-test-suite.cc:52
OkumuraHataPropagationLossModelTestCase::m_hb
double m_hb
Definition:
okumura-hata-test-suite.cc:48
ns3::OkumuraHataPropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
okumura-hata-propagation-loss-model.cc:76
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:244
OkumuraHataPropagationLossModelTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
okumura-hata-test-suite.cc:75
g_okumuraHataTestSuite
static OkumuraHataPropagationLossModelTestSuite g_okumuraHataTestSuite
Definition:
okumura-hata-test-suite.cc:141
src
propagation
test
okumura-hata-test-suite.cc
Generated on Fri Oct 1 2021 17:03:34 for ns-3 by
1.8.20