A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
29using namespace ns3;
30
31NS_LOG_COMPONENT_DEFINE("ItuR1411LosPropagationLossModelTest");
32
33/**
34 * \ingroup propagation-tests
35 *
36 * \brief ItuR1411LosPropagationLossModel Test Case
37 *
38 */
40{
41 public:
42 /**
43 * Constructor
44 *
45 * \param freq carrier frequency in Hz
46 * \param dist 2D distance between UT and BS in meters
47 * \param hb height of BS in meters
48 * \param hm height of UT in meters
49 * \param refValue reference loss value
50 * \param name TestCase name
51 */
53 double dist,
54 double hb,
55 double hm,
56 double refValue,
57 std::string name);
59
60 private:
61 void DoRun() override;
62
63 /**
64 * Create a MobilityModel
65 * \param index mobility model index
66 * \return a new MobilityModel
67 */
69
70 double m_freq; //!< carrier frequency in Hz
71 double m_dist; //!< 2D distance between UT and BS in meters
72 double m_hb; //!< height of BS in meters
73 double m_hm; //!< height of UT in meters
74 double m_lossRef; //!< reference loss
75};
76
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
93{
94}
95
96void
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
119/**
120 * \ingroup propagation-tests
121 *
122 * \brief ItuR1411LosPropagationLossModel TestSuite
123 *
124 */
126{
127 public:
129};
130
132 : TestSuite("itu-r-1411-los", Type::SYSTEM)
133{
134 LogComponentEnable("ItuR1411LosPropagationLossModelTest", LOG_LEVEL_ALL);
135
136 // reference values obtained with the octave scripts in src/propagation/test/reference/
138 100,
139 30,
140 1,
141 81.005,
142 "freq=2114MHz, dist=100m"),
143 TestCase::Duration::QUICK);
145 200,
146 30,
147 1,
148 87.060,
149 "freq=1999MHz, dist=200m"),
150 TestCase::Duration::QUICK);
151}
152
153/// Static variable for test initialization
ItuR1411LosPropagationLossModel Test Case.
ItuR1411LosPropagationLossModelTestCase(double freq, double dist, double hb, double hm, double refValue, std::string name)
Constructor.
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
Create a MobilityModel.
void DoRun() override
Implementation to actually run this TestCase.
double m_dist
2D distance between UT and BS in meters
ItuR1411LosPropagationLossModel TestSuite.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
encapsulates test code
Definition: test.h:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#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:338
static ItuR1411LosPropagationLossModelTestSuite g_ituR1411LosTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:302
@ LOG_LEVEL_ALL
Print everything.
Definition: log.h:116