A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
namespace
ns3 {
33
34
NS_LOG_COMPONENT_DEFINE
(
"OkumuraHataPropagationLossModelTest"
);
35
36
37
class
OkumuraHataPropagationLossModelTestCase
:
public
TestCase
38
{
39
public
:
40
OkumuraHataPropagationLossModelTestCase
(
double
freq,
double
dist,
double
hb,
double
hm,
EnvironmentType
env,
CitySize
city,
double
refValue, std::string name);
41
virtual
~OkumuraHataPropagationLossModelTestCase
();
42
43
private
:
44
virtual
void
DoRun
(
void
);
45
Ptr<MobilityModel>
CreateMobilityModel
(uint16_t index);
46
47
double
m_freq
;
48
double
m_dist
;
49
double
m_hb
;
50
double
m_hm
;
51
EnvironmentType
m_env
;
52
CitySize
m_city
;
53
double
m_lossRef
;
54
55
};
56
57
OkumuraHataPropagationLossModelTestCase::OkumuraHataPropagationLossModelTestCase
(
double
freq,
double
dist,
double
hb,
double
hm,
EnvironmentType
env,
CitySize
city,
double
refValue, std::string name)
58
:
TestCase
(name),
59
m_freq (freq),
60
m_dist (dist),
61
m_hb (hb),
62
m_hm (hm),
63
m_env (env),
64
m_city (city),
65
m_lossRef (refValue)
66
{
67
}
68
69
OkumuraHataPropagationLossModelTestCase::~OkumuraHataPropagationLossModelTestCase
()
70
{
71
}
72
73
74
75
void
76
OkumuraHataPropagationLossModelTestCase::DoRun
(
void
)
77
{
78
NS_LOG_FUNCTION
(
this
);
79
80
81
Ptr<MobilityModel>
mma = CreateObject<ConstantPositionMobilityModel> ();
82
mma->
SetPosition
(
Vector
(0.0, 0.0,
m_hb
));
83
84
Ptr<MobilityModel>
mmb = CreateObject<ConstantPositionMobilityModel> ();
85
mmb->
SetPosition
(
Vector
(
m_dist
, 0.0,
m_hm
));
86
87
Ptr<OkumuraHataPropagationLossModel>
propagationLossModel = CreateObject<OkumuraHataPropagationLossModel> ();
88
propagationLossModel->
SetAttribute
(
"Frequency"
,
DoubleValue
(
m_freq
));
89
propagationLossModel->
SetAttribute
(
"Environment"
,
EnumValue
(
m_env
));
90
propagationLossModel->
SetAttribute
(
"CitySize"
,
EnumValue
(
m_city
));
91
92
double
loss = propagationLossModel->
GetLoss
(mma, mmb);
93
94
NS_LOG_INFO
(
"Calculated loss: "
<< loss);
95
NS_LOG_INFO
(
"Theoretical loss: "
<<
m_lossRef
);
96
97
NS_TEST_ASSERT_MSG_EQ_TOL
(loss,
m_lossRef
, 0.1,
"Wrong loss!"
);
98
99
}
100
101
102
103
class
OkumuraHataPropagationLossModelTestSuite
:
public
TestSuite
104
{
105
public
:
106
OkumuraHataPropagationLossModelTestSuite
();
107
};
108
109
110
111
OkumuraHataPropagationLossModelTestSuite::OkumuraHataPropagationLossModelTestSuite
()
112
:
TestSuite
(
"okumura-hata"
, SYSTEM)
113
{
114
115
LogComponentEnable
(
"OkumuraHataPropagationLossModelTest"
,
LOG_LEVEL_ALL
);
116
117
118
// reference values obtained with the octave scripts in src/propagation/test/reference/
119
120
121
double
freq = 869e6;
// this will use the original OH model
122
123
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq, 2000, 30, 1,
UrbanEnvironment
,
LargeCity
, 137.93,
"original OH Urban Large city"
));
124
125
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq, 2000, 30, 1,
UrbanEnvironment
,
SmallCity
, 137.88,
"original OH Urban small city"
));
126
127
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq, 2000, 30, 1,
SubUrbanEnvironment
,
LargeCity
, 128.03,
"original OH SubUrban"
));
128
129
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq, 2000, 30, 1,
OpenAreasEnvironment
,
LargeCity
, 110.21,
"original OH OpenAreas"
));
130
131
132
freq = 2.1140e9;
// this will use the extended COST231 OH model
133
134
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq, 2000, 30, 1,
UrbanEnvironment
,
LargeCity
, 148.55,
"COST231 OH Urban Large city"
));
135
136
AddTestCase
(
new
OkumuraHataPropagationLossModelTestCase
(freq, 2000, 30, 1,
UrbanEnvironment
,
SmallCity
, 150.64,
"COST231 OH Urban small city and suburban"
));
137
138
}
139
140
141
142
static
OkumuraHataPropagationLossModelTestSuite
g_okumuraHataTestSuite
;
143
144
145
146
}
// namespace ns3
src
propagation
test
okumura-hata-test-suite.cc
Generated on Tue Oct 9 2012 16:45:45 for ns-3 by
1.8.1.2