A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Marco Miozzo <marco.miozzo@cttc.es>
7
* Nicola Baldo <nbaldo@cttc.es>
8
*/
9
10
#include <ns3/constant-position-mobility-model.h>
11
#include <ns3/double.h>
12
#include <ns3/enum.h>
13
#include <ns3/kun-2600-mhz-propagation-loss-model.h>
14
#include <ns3/log.h>
15
#include <ns3/string.h>
16
#include <ns3/test.h>
17
18
using namespace
ns3
;
19
20
NS_LOG_COMPONENT_DEFINE
(
"Kun2600MhzPropagationLossModelTest"
);
21
22
/**
23
* \ingroup propagation-tests
24
*
25
* \brief Kun2600MhzPropagationLossModel Test Case
26
*
27
*/
28
class
Kun2600MhzPropagationLossModelTestCase
:
public
TestCase
29
{
30
public
:
31
/**
32
* Constructor
33
*
34
* \param dist 2D distance between UT and BS in meters
35
* \param hb height of BS in meters
36
* \param hm height of UT in meters
37
* \param refValue reference loss value
38
* \param name TestCase name
39
*/
40
Kun2600MhzPropagationLossModelTestCase
(
double
dist,
41
double
hb,
42
double
hm,
43
double
refValue,
44
std::string name);
45
~Kun2600MhzPropagationLossModelTestCase
()
override
;
46
47
private
:
48
void
DoRun
()
override
;
49
50
/**
51
* Create a MobilityModel
52
* \param index mobility model index
53
* \return a new MobilityModel
54
*/
55
Ptr<MobilityModel>
CreateMobilityModel
(uint16_t index);
56
57
double
m_dist
;
//!< 2D distance between UT and BS in meters
58
double
m_hb
;
//!< height of BS in meters
59
double
m_hm
;
//!< height of UT in meters
60
double
m_lossRef
;
//!< reference loss
61
};
62
63
Kun2600MhzPropagationLossModelTestCase::Kun2600MhzPropagationLossModelTestCase
(
double
dist,
64
double
hb,
65
double
hm,
66
double
refValue,
67
std::string name)
68
:
TestCase
(name),
69
m_dist(dist),
70
m_hb(hb),
71
m_hm(hm),
72
m_lossRef(refValue)
73
{
74
}
75
76
Kun2600MhzPropagationLossModelTestCase::~Kun2600MhzPropagationLossModelTestCase
()
77
{
78
}
79
80
void
81
Kun2600MhzPropagationLossModelTestCase::DoRun
()
82
{
83
NS_LOG_FUNCTION
(
this
);
84
85
Ptr<MobilityModel>
mma =
CreateObject<ConstantPositionMobilityModel>
();
86
mma->SetPosition(Vector(0.0, 0.0,
m_hb
));
87
88
Ptr<MobilityModel>
mmb =
CreateObject<ConstantPositionMobilityModel>
();
89
mmb->SetPosition(Vector(
m_dist
, 0.0,
m_hm
));
90
91
Ptr<Kun2600MhzPropagationLossModel>
propagationLossModel =
92
CreateObject<Kun2600MhzPropagationLossModel>
();
93
94
double
loss = propagationLossModel->GetLoss(mma, mmb);
95
96
NS_LOG_INFO
(
"Calculated loss: "
<< loss);
97
NS_LOG_INFO
(
"Theoretical loss: "
<<
m_lossRef
);
98
99
NS_TEST_ASSERT_MSG_EQ_TOL
(loss,
m_lossRef
, 0.1,
"Wrong loss!"
);
100
}
101
102
/**
103
* \ingroup propagation-tests
104
*
105
* \brief Kun2600MhzPropagationLossModel TestSuite
106
*
107
*/
108
class
Kun2600MhzPropagationLossModelTestSuite
:
public
TestSuite
109
{
110
public
:
111
Kun2600MhzPropagationLossModelTestSuite
();
112
};
113
114
Kun2600MhzPropagationLossModelTestSuite::Kun2600MhzPropagationLossModelTestSuite
()
115
:
TestSuite
(
"kun-2600-mhz"
,
Type
::SYSTEM)
116
{
117
LogComponentEnable
(
"Kun2600MhzPropagationLossModelTest"
,
LOG_LEVEL_ALL
);
118
119
AddTestCase
(
new
Kun2600MhzPropagationLossModelTestCase
(2000, 30, 1, 121.83,
"dist=2000m"
),
120
TestCase::Duration::QUICK);
121
}
122
123
/// Static variable for test initialization
124
static
Kun2600MhzPropagationLossModelTestSuite
g_kun2600MhzTestSuite
;
Kun2600MhzPropagationLossModelTestCase
Kun2600MhzPropagationLossModel Test Case.
Definition
kun-2600-mhz-test-suite.cc:29
Kun2600MhzPropagationLossModelTestCase::Kun2600MhzPropagationLossModelTestCase
Kun2600MhzPropagationLossModelTestCase(double dist, double hb, double hm, double refValue, std::string name)
Constructor.
Definition
kun-2600-mhz-test-suite.cc:63
Kun2600MhzPropagationLossModelTestCase::~Kun2600MhzPropagationLossModelTestCase
~Kun2600MhzPropagationLossModelTestCase() override
Definition
kun-2600-mhz-test-suite.cc:76
Kun2600MhzPropagationLossModelTestCase::m_hm
double m_hm
height of UT in meters
Definition
kun-2600-mhz-test-suite.cc:59
Kun2600MhzPropagationLossModelTestCase::m_hb
double m_hb
height of BS in meters
Definition
kun-2600-mhz-test-suite.cc:58
Kun2600MhzPropagationLossModelTestCase::m_dist
double m_dist
2D distance between UT and BS in meters
Definition
kun-2600-mhz-test-suite.cc:57
Kun2600MhzPropagationLossModelTestCase::CreateMobilityModel
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
Create a MobilityModel.
Kun2600MhzPropagationLossModelTestCase::m_lossRef
double m_lossRef
reference loss
Definition
kun-2600-mhz-test-suite.cc:60
Kun2600MhzPropagationLossModelTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
kun-2600-mhz-test-suite.cc:81
Kun2600MhzPropagationLossModelTestSuite
Kun2600MhzPropagationLossModel TestSuite.
Definition
kun-2600-mhz-test-suite.cc:109
Kun2600MhzPropagationLossModelTestSuite::Kun2600MhzPropagationLossModelTestSuite
Kun2600MhzPropagationLossModelTestSuite()
Definition
kun-2600-mhz-test-suite.cc:114
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TestCase
encapsulates test code
Definition
test.h:1050
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition
test.cc:292
ns3::TestSuite
A suite of tests to run.
Definition
test.h:1267
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1274
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
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:229
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition
log.h:264
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
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:327
g_kun2600MhzTestSuite
static Kun2600MhzPropagationLossModelTestSuite g_kun2600MhzTestSuite
Static variable for test initialization.
Definition
kun-2600-mhz-test-suite.cc:124
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:291
ns3::LOG_LEVEL_ALL
@ LOG_LEVEL_ALL
Print everything.
Definition
log.h:105
src
propagation
test
kun-2600-mhz-test-suite.cc
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0