A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
itu-r-1411-los-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/itu-r-1411-los-propagation-loss-model.h>
25
#include <ns3/log.h>
26
#include <ns3/string.h>
27
#include <ns3/test.h>
28
29
using namespace
ns3
;
30
31
NS_LOG_COMPONENT_DEFINE
(
"ItuR1411LosPropagationLossModelTest"
);
32
39
class
ItuR1411LosPropagationLossModelTestCase
:
public
TestCase
40
{
41
public
:
52
ItuR1411LosPropagationLossModelTestCase
(
double
freq,
53
double
dist,
54
double
hb,
55
double
hm,
56
double
refValue,
57
std::string name);
58
~
ItuR1411LosPropagationLossModelTestCase
()
override
;
59
60
private
:
61
void
DoRun()
override
;
62
68
Ptr<MobilityModel>
CreateMobilityModel
(uint16_t index);
69
70
double
m_freq
;
71
double
m_dist
;
72
double
m_hb
;
73
double
m_hm
;
74
double
m_lossRef
;
75
};
76
77
ItuR1411LosPropagationLossModelTestCase::ItuR1411LosPropagationLossModelTestCase
(
double
freq,
78
double
dist,
79
double
hb,
80
double
hm,
81
double
refValue,
82
std::string name)
83
:
TestCase
(name),
84
m_freq(freq),
85
m_dist(dist),
86
m_hb(hb),
87
m_hm(hm),
88
m_lossRef(refValue)
89
{
90
}
91
92
ItuR1411LosPropagationLossModelTestCase::~ItuR1411LosPropagationLossModelTestCase
()
93
{
94
}
95
96
void
97
ItuR1411LosPropagationLossModelTestCase::DoRun
()
98
{
99
NS_LOG_FUNCTION
(
this
);
100
101
Ptr<MobilityModel>
mma = CreateObject<ConstantPositionMobilityModel>();
102
mma->
SetPosition
(Vector(0.0, 0.0,
m_hb
));
103
104
Ptr<MobilityModel>
mmb = CreateObject<ConstantPositionMobilityModel>();
105
mmb->
SetPosition
(Vector(
m_dist
, 0.0,
m_hm
));
106
107
Ptr<ItuR1411LosPropagationLossModel>
propagationLossModel =
108
CreateObject<ItuR1411LosPropagationLossModel>();
109
propagationLossModel->SetAttribute(
"Frequency"
,
DoubleValue
(
m_freq
));
110
111
double
loss = propagationLossModel->GetLoss(mma, mmb);
112
113
NS_LOG_INFO
(
"Calculated loss: "
<< loss);
114
NS_LOG_INFO
(
"Theoretical loss: "
<<
m_lossRef
);
115
116
NS_TEST_ASSERT_MSG_EQ_TOL
(loss,
m_lossRef
, 0.1,
"Wrong loss!"
);
117
}
118
125
class
ItuR1411LosPropagationLossModelTestSuite
:
public
TestSuite
126
{
127
public
:
128
ItuR1411LosPropagationLossModelTestSuite
();
129
};
130
131
ItuR1411LosPropagationLossModelTestSuite::ItuR1411LosPropagationLossModelTestSuite
()
132
:
TestSuite
(
"itu-r-1411-los"
, SYSTEM)
133
{
134
LogComponentEnable
(
"ItuR1411LosPropagationLossModelTest"
,
LOG_LEVEL_ALL
);
135
136
// reference values obtained with the octave scripts in src/propagation/test/reference/
137
AddTestCase
(
new
ItuR1411LosPropagationLossModelTestCase
(2.1140e9,
138
100,
139
30,
140
1,
141
81.005,
142
"freq=2114MHz, dist=100m"
),
143
TestCase::QUICK);
144
AddTestCase
(
new
ItuR1411LosPropagationLossModelTestCase
(1999e6,
145
200,
146
30,
147
1,
148
87.060,
149
"freq=1999MHz, dist=200m"
),
150
TestCase::QUICK);
151
}
152
154
static
ItuR1411LosPropagationLossModelTestSuite
g_ituR1411LosTestSuite
;
ItuR1411LosPropagationLossModelTestCase
ItuR1411LosPropagationLossModel Test Case.
Definition:
itu-r-1411-los-test-suite.cc:40
ItuR1411LosPropagationLossModelTestCase::~ItuR1411LosPropagationLossModelTestCase
~ItuR1411LosPropagationLossModelTestCase() override
Definition:
itu-r-1411-los-test-suite.cc:92
ItuR1411LosPropagationLossModelTestCase::ItuR1411LosPropagationLossModelTestCase
ItuR1411LosPropagationLossModelTestCase(double freq, double dist, double hb, double hm, double refValue, std::string name)
Constructor.
Definition:
itu-r-1411-los-test-suite.cc:77
ItuR1411LosPropagationLossModelTestCase::m_lossRef
double m_lossRef
reference loss
Definition:
itu-r-1411-los-test-suite.cc:74
ItuR1411LosPropagationLossModelTestCase::m_freq
double m_freq
carrier frequency in Hz
Definition:
itu-r-1411-los-test-suite.cc:70
ItuR1411LosPropagationLossModelTestCase::CreateMobilityModel
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
Create a MobilityModel.
ItuR1411LosPropagationLossModelTestCase::m_hb
double m_hb
height of BS in meters
Definition:
itu-r-1411-los-test-suite.cc:72
ItuR1411LosPropagationLossModelTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
itu-r-1411-los-test-suite.cc:97
ItuR1411LosPropagationLossModelTestCase::m_hm
double m_hm
height of UT in meters
Definition:
itu-r-1411-los-test-suite.cc:73
ItuR1411LosPropagationLossModelTestCase::m_dist
double m_dist
2D distance between UT and BS in meters
Definition:
itu-r-1411-los-test-suite.cc:71
ItuR1411LosPropagationLossModelTestSuite
ItuR1411LosPropagationLossModel TestSuite.
Definition:
itu-r-1411-los-test-suite.cc:126
ItuR1411LosPropagationLossModelTestSuite::ItuR1411LosPropagationLossModelTestSuite
ItuR1411LosPropagationLossModelTestSuite()
Definition:
itu-r-1411-los-test-suite.cc:131
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:42
ns3::MobilityModel::SetPosition
void SetPosition(const Vector &position)
Definition:
mobility-model.cc:92
ns3::Ptr< MobilityModel >
ns3::TestCase
encapsulates test code
Definition:
test.h:1060
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:301
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1256
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
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:240
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition:
log.h:275
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:337
g_ituR1411LosTestSuite
static ItuR1411LosPropagationLossModelTestSuite g_ituR1411LosTestSuite
Static variable for test initialization.
Definition:
itu-r-1411-los-test-suite.cc:154
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:302
ns3::LOG_LEVEL_ALL
@ LOG_LEVEL_ALL
Print everything.
Definition:
log.h:116
src
propagation
test
itu-r-1411-los-test-suite.cc
Generated on Sun Mar 3 2024 17:11:07 for ns-3 by
1.9.1