A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
kun-2600-mhz-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/kun-2600-mhz-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
(
"Kun2600MhzPropagationLossModelTest"
);
32
39
class
Kun2600MhzPropagationLossModelTestCase
:
public
TestCase
40
{
41
public
:
51
Kun2600MhzPropagationLossModelTestCase
(
double
dist,
52
double
hb,
53
double
hm,
54
double
refValue,
55
std::string name);
56
~
Kun2600MhzPropagationLossModelTestCase
()
override
;
57
58
private
:
59
void
DoRun()
override
;
60
66
Ptr<MobilityModel>
CreateMobilityModel
(uint16_t index);
67
68
double
m_dist
;
69
double
m_hb
;
70
double
m_hm
;
71
double
m_lossRef
;
72
};
73
74
Kun2600MhzPropagationLossModelTestCase::Kun2600MhzPropagationLossModelTestCase
(
double
dist,
75
double
hb,
76
double
hm,
77
double
refValue,
78
std::string name)
79
:
TestCase
(name),
80
m_dist(dist),
81
m_hb(hb),
82
m_hm(hm),
83
m_lossRef(refValue)
84
{
85
}
86
87
Kun2600MhzPropagationLossModelTestCase::~Kun2600MhzPropagationLossModelTestCase
()
88
{
89
}
90
91
void
92
Kun2600MhzPropagationLossModelTestCase::DoRun
()
93
{
94
NS_LOG_FUNCTION
(
this
);
95
96
Ptr<MobilityModel>
mma = CreateObject<ConstantPositionMobilityModel>();
97
mma->
SetPosition
(Vector(0.0, 0.0,
m_hb
));
98
99
Ptr<MobilityModel>
mmb = CreateObject<ConstantPositionMobilityModel>();
100
mmb->
SetPosition
(Vector(
m_dist
, 0.0,
m_hm
));
101
102
Ptr<Kun2600MhzPropagationLossModel>
propagationLossModel =
103
CreateObject<Kun2600MhzPropagationLossModel>();
104
105
double
loss = propagationLossModel->GetLoss(mma, mmb);
106
107
NS_LOG_INFO
(
"Calculated loss: "
<< loss);
108
NS_LOG_INFO
(
"Theoretical loss: "
<<
m_lossRef
);
109
110
NS_TEST_ASSERT_MSG_EQ_TOL
(loss,
m_lossRef
, 0.1,
"Wrong loss!"
);
111
}
112
119
class
Kun2600MhzPropagationLossModelTestSuite
:
public
TestSuite
120
{
121
public
:
122
Kun2600MhzPropagationLossModelTestSuite
();
123
};
124
125
Kun2600MhzPropagationLossModelTestSuite::Kun2600MhzPropagationLossModelTestSuite
()
126
:
TestSuite
(
"kun-2600-mhz"
, SYSTEM)
127
{
128
LogComponentEnable
(
"Kun2600MhzPropagationLossModelTest"
,
LOG_LEVEL_ALL
);
129
130
AddTestCase
(
new
Kun2600MhzPropagationLossModelTestCase
(2000, 30, 1, 121.83,
"dist=2000m"
),
131
TestCase::QUICK);
132
}
133
135
static
Kun2600MhzPropagationLossModelTestSuite
g_kun2600MhzTestSuite
;
Kun2600MhzPropagationLossModelTestCase
Kun2600MhzPropagationLossModel Test Case.
Definition:
kun-2600-mhz-test-suite.cc:40
Kun2600MhzPropagationLossModelTestCase::CreateMobilityModel
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
Create a MobilityModel.
Kun2600MhzPropagationLossModelTestCase::Kun2600MhzPropagationLossModelTestCase
Kun2600MhzPropagationLossModelTestCase(double dist, double hb, double hm, double refValue, std::string name)
Constructor.
Definition:
kun-2600-mhz-test-suite.cc:74
Kun2600MhzPropagationLossModelTestCase::~Kun2600MhzPropagationLossModelTestCase
~Kun2600MhzPropagationLossModelTestCase() override
Definition:
kun-2600-mhz-test-suite.cc:87
Kun2600MhzPropagationLossModelTestCase::m_hm
double m_hm
height of UT in meters
Definition:
kun-2600-mhz-test-suite.cc:70
Kun2600MhzPropagationLossModelTestCase::m_hb
double m_hb
height of BS in meters
Definition:
kun-2600-mhz-test-suite.cc:69
Kun2600MhzPropagationLossModelTestCase::m_dist
double m_dist
2D distance between UT and BS in meters
Definition:
kun-2600-mhz-test-suite.cc:68
Kun2600MhzPropagationLossModelTestCase::m_lossRef
double m_lossRef
reference loss
Definition:
kun-2600-mhz-test-suite.cc:71
Kun2600MhzPropagationLossModelTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
kun-2600-mhz-test-suite.cc:92
Kun2600MhzPropagationLossModelTestSuite
Kun2600MhzPropagationLossModel TestSuite.
Definition:
kun-2600-mhz-test-suite.cc:120
Kun2600MhzPropagationLossModelTestSuite::Kun2600MhzPropagationLossModelTestSuite
Kun2600MhzPropagationLossModelTestSuite()
Definition:
kun-2600-mhz-test-suite.cc:125
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_kun2600MhzTestSuite
static Kun2600MhzPropagationLossModelTestSuite g_kun2600MhzTestSuite
Static variable for test initialization.
Definition:
kun-2600-mhz-test-suite.cc:135
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
kun-2600-mhz-test-suite.cc
Generated on Sun Mar 3 2024 17:11:07 for ns-3 by
1.9.1