A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
propagation
test
kun-2600-mhz-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/kun-2600-mhz-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
(
"Kun2600MhzPropagationLossModelTest"
);
35
36
class
Kun2600MhzPropagationLossModelTestCase
:
public
TestCase
37
{
38
public
:
39
Kun2600MhzPropagationLossModelTestCase
(
double
dist,
double
hb,
double
hm,
double
refValue, std::string name);
40
virtual
~
Kun2600MhzPropagationLossModelTestCase
();
41
42
private
:
43
virtual
void
DoRun (
void
);
44
Ptr<MobilityModel>
CreateMobilityModel (uint16_t index);
45
46
double
m_dist
;
47
double
m_hb
;
48
double
m_hm
;
49
double
m_lossRef
;
50
51
};
52
53
Kun2600MhzPropagationLossModelTestCase::Kun2600MhzPropagationLossModelTestCase
(
double
dist,
double
hb,
double
hm,
double
refValue, std::string name)
54
:
TestCase
(name),
55
m_dist (dist),
56
m_hb (hb),
57
m_hm (hm),
58
m_lossRef (refValue)
59
{
60
}
61
62
Kun2600MhzPropagationLossModelTestCase::~Kun2600MhzPropagationLossModelTestCase
()
63
{
64
}
65
66
67
68
void
69
Kun2600MhzPropagationLossModelTestCase::DoRun
(
void
)
70
{
71
NS_LOG_FUNCTION
(
this
);
72
73
74
Ptr<MobilityModel>
mma = CreateObject<ConstantPositionMobilityModel> ();
75
mma->
SetPosition
(Vector (0.0, 0.0,
m_hb
));
76
77
Ptr<MobilityModel>
mmb = CreateObject<ConstantPositionMobilityModel> ();
78
mmb->
SetPosition
(Vector (
m_dist
, 0.0,
m_hm
));
79
80
Ptr<Kun2600MhzPropagationLossModel>
propagationLossModel = CreateObject<Kun2600MhzPropagationLossModel> ();
81
82
double
loss = propagationLossModel->
GetLoss
(mma, mmb);
83
84
NS_LOG_INFO
(
"Calculated loss: "
<< loss);
85
NS_LOG_INFO
(
"Theoretical loss: "
<<
m_lossRef
);
86
87
NS_TEST_ASSERT_MSG_EQ_TOL
(loss,
m_lossRef
, 0.1,
"Wrong loss!"
);
88
89
}
90
91
92
93
class
Kun2600MhzPropagationLossModelTestSuite
:
public
TestSuite
94
{
95
public
:
96
Kun2600MhzPropagationLossModelTestSuite
();
97
};
98
99
100
101
Kun2600MhzPropagationLossModelTestSuite::Kun2600MhzPropagationLossModelTestSuite
()
102
:
TestSuite
(
"kun-2600-mhz"
, SYSTEM)
103
{
104
105
LogComponentEnable
(
"Kun2600MhzPropagationLossModelTest"
,
LOG_LEVEL_ALL
);
106
107
AddTestCase
(
new
Kun2600MhzPropagationLossModelTestCase
(2000, 30, 1, 121.83,
"dist=2000m"
), TestCase::QUICK);
108
109
110
}
111
112
113
114
static
Kun2600MhzPropagationLossModelTestSuite
g_kun2600MhzTestSuite
;
Kun2600MhzPropagationLossModelTestCase::~Kun2600MhzPropagationLossModelTestCase
virtual ~Kun2600MhzPropagationLossModelTestCase()
Definition:
kun-2600-mhz-test-suite.cc:62
Kun2600MhzPropagationLossModelTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
kun-2600-mhz-test-suite.cc:69
ns3::Ptr< MobilityModel >
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:213
ns3::Kun2600MhzPropagationLossModel::GetLoss
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Definition:
kun-2600-mhz-propagation-loss-model.cc:59
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1342
Kun2600MhzPropagationLossModelTestCase::m_dist
double m_dist
Definition:
kun-2600-mhz-test-suite.cc:46
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition:
log.h:278
ns3::TestCase
encapsulates test code
Definition:
test.h:1155
Kun2600MhzPropagationLossModelTestSuite::Kun2600MhzPropagationLossModelTestSuite
Kun2600MhzPropagationLossModelTestSuite()
Definition:
kun-2600-mhz-test-suite.cc:101
Kun2600MhzPropagationLossModelTestSuite
Definition:
kun-2600-mhz-test-suite.cc:93
ns3::LogComponentEnable
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition:
log.cc:369
Kun2600MhzPropagationLossModelTestCase
Definition:
kun-2600-mhz-test-suite.cc:36
Kun2600MhzPropagationLossModelTestCase::m_hb
double m_hb
Definition:
kun-2600-mhz-test-suite.cc:47
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:299
Kun2600MhzPropagationLossModelTestCase::m_lossRef
double m_lossRef
Definition:
kun-2600-mhz-test-suite.cc:49
Kun2600MhzPropagationLossModelTestCase::m_hm
double m_hm
Definition:
kun-2600-mhz-test-suite.cc:48
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:380
Kun2600MhzPropagationLossModelTestCase::Kun2600MhzPropagationLossModelTestCase
Kun2600MhzPropagationLossModelTestCase(double dist, double hb, double hm, double refValue, std::string name)
Definition:
kun-2600-mhz-test-suite.cc:53
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
g_kun2600MhzTestSuite
static Kun2600MhzPropagationLossModelTestSuite g_kun2600MhzTestSuite
Definition:
kun-2600-mhz-test-suite.cc:114
ns3::MobilityModel::SetPosition
void SetPosition(const Vector &position)
Definition:
mobility-model.cc:75
ns3::LOG_LEVEL_ALL
Print everything.
Definition:
log.h:113
Generated on Wed Nov 7 2018 10:02:09 for ns-3 by
1.8.14