A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
itu-r-1411-los-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/itu-r-1411-los-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
(
"ItuR1411LosPropagationLossModelTest"
);
35
36
class
ItuR1411LosPropagationLossModelTestCase
:
public
TestCase
37
{
38
public
:
39
ItuR1411LosPropagationLossModelTestCase
(
double
freq,
double
dist,
double
hb,
double
hm,
double
refValue, std::string name);
40
virtual
~
ItuR1411LosPropagationLossModelTestCase
();
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
double
m_lossRef
;
51
52
};
53
54
ItuR1411LosPropagationLossModelTestCase::ItuR1411LosPropagationLossModelTestCase
(
double
freq,
double
dist,
double
hb,
double
hm,
double
refValue, std::string name)
55
:
TestCase
(name),
56
m_freq (freq),
57
m_dist (dist),
58
m_hb (hb),
59
m_hm (hm),
60
m_lossRef (refValue)
61
{
62
}
63
64
ItuR1411LosPropagationLossModelTestCase::~ItuR1411LosPropagationLossModelTestCase
()
65
{
66
}
67
68
69
70
void
71
ItuR1411LosPropagationLossModelTestCase::DoRun
(
void
)
72
{
73
NS_LOG_FUNCTION
(
this
);
74
75
76
Ptr<MobilityModel>
mma = CreateObject<ConstantPositionMobilityModel> ();
77
mma->
SetPosition
(Vector (0.0, 0.0,
m_hb
));
78
79
Ptr<MobilityModel>
mmb = CreateObject<ConstantPositionMobilityModel> ();
80
mmb->
SetPosition
(Vector (
m_dist
, 0.0,
m_hm
));
81
82
Ptr<ItuR1411LosPropagationLossModel>
propagationLossModel = CreateObject<ItuR1411LosPropagationLossModel> ();
83
propagationLossModel->
SetAttribute
(
"Frequency"
,
DoubleValue
(
m_freq
));
84
85
double
loss = propagationLossModel->
GetLoss
(mma, mmb);
86
87
NS_LOG_INFO
(
"Calculated loss: "
<< loss);
88
NS_LOG_INFO
(
"Theoretical loss: "
<<
m_lossRef
);
89
90
NS_TEST_ASSERT_MSG_EQ_TOL
(loss,
m_lossRef
, 0.1,
"Wrong loss!"
);
91
92
}
93
94
95
96
class
ItuR1411LosPropagationLossModelTestSuite
:
public
TestSuite
97
{
98
public
:
99
ItuR1411LosPropagationLossModelTestSuite
();
100
};
101
102
103
104
ItuR1411LosPropagationLossModelTestSuite::ItuR1411LosPropagationLossModelTestSuite
()
105
:
TestSuite
(
"itu-r-1411-los"
, SYSTEM)
106
{
107
108
LogComponentEnable
(
"ItuR1411LosPropagationLossModelTest"
,
LOG_LEVEL_ALL
);
109
110
// reference values obtained with the octave scripts in src/propagation/test/reference/
111
112
AddTestCase
(
new
ItuR1411LosPropagationLossModelTestCase
(2.1140e9, 100, 30, 1, 81.005,
"freq=2114MHz, dist=100m"
), TestCase::QUICK);
113
114
AddTestCase
(
new
ItuR1411LosPropagationLossModelTestCase
(1999e6, 200, 30, 1, 87.060,
"freq=1999MHz, dist=200m"
), TestCase::QUICK);
115
116
117
118
119
}
120
121
122
123
static
ItuR1411LosPropagationLossModelTestSuite
g_ituR1411LosTestSuite
;
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
ItuR1411LosPropagationLossModelTestCase::CreateMobilityModel
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
ItuR1411LosPropagationLossModelTestCase::m_freq
double m_freq
Definition:
itu-r-1411-los-test-suite.cc:46
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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
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
ItuR1411LosPropagationLossModelTestSuite::ItuR1411LosPropagationLossModelTestSuite
ItuR1411LosPropagationLossModelTestSuite()
Definition:
itu-r-1411-los-test-suite.cc:104
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:41
ItuR1411LosPropagationLossModelTestCase::ItuR1411LosPropagationLossModelTestCase
ItuR1411LosPropagationLossModelTestCase(double freq, double dist, double hb, double hm, double refValue, std::string name)
Definition:
itu-r-1411-los-test-suite.cc:54
ns3::TestCase
encapsulates test code
Definition:
test.h:1154
ns3::Ptr< MobilityModel >
ItuR1411LosPropagationLossModelTestCase::~ItuR1411LosPropagationLossModelTestCase
virtual ~ItuR1411LosPropagationLossModelTestCase()
Definition:
itu-r-1411-los-test-suite.cc:64
ItuR1411LosPropagationLossModelTestCase::m_lossRef
double m_lossRef
Definition:
itu-r-1411-los-test-suite.cc:50
ItuR1411LosPropagationLossModelTestCase::m_hb
double m_hb
Definition:
itu-r-1411-los-test-suite.cc:48
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition:
log.h:281
g_ituR1411LosTestSuite
static ItuR1411LosPropagationLossModelTestSuite g_ituR1411LosTestSuite
Definition:
itu-r-1411-los-test-suite.cc:123
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
ns3::ItuR1411LosPropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
itu-r-1411-los-propagation-loss-model.cc:62
ItuR1411LosPropagationLossModelTestCase
Definition:
itu-r-1411-los-test-suite.cc:37
ItuR1411LosPropagationLossModelTestCase::m_hm
double m_hm
Definition:
itu-r-1411-los-test-suite.cc:49
ItuR1411LosPropagationLossModelTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
itu-r-1411-los-test-suite.cc:71
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1344
ItuR1411LosPropagationLossModelTestSuite
Definition:
itu-r-1411-los-test-suite.cc:97
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
ItuR1411LosPropagationLossModelTestCase::m_dist
double m_dist
Definition:
itu-r-1411-los-test-suite.cc:47
src
propagation
test
itu-r-1411-los-test-suite.cc
Generated on Fri Oct 1 2021 17:03:34 for ns-3 by
1.8.20