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 * 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/itu-r-1411-los-propagation-loss-model.h>
14#include <ns3/log.h>
15#include <ns3/string.h>
16#include <ns3/test.h>
17
18using namespace ns3;
19
20NS_LOG_COMPONENT_DEFINE("ItuR1411LosPropagationLossModelTest");
21
22/**
23 * \ingroup propagation-tests
24 *
25 * \brief ItuR1411LosPropagationLossModel Test Case
26 *
27 */
29{
30 public:
31 /**
32 * Constructor
33 *
34 * \param freq carrier frequency in Hz
35 * \param dist 2D distance between UT and BS in meters
36 * \param hb height of BS in meters
37 * \param hm height of UT in meters
38 * \param refValue reference loss value
39 * \param name TestCase name
40 */
42 double dist,
43 double hb,
44 double hm,
45 double refValue,
46 std::string name);
48
49 private:
50 void DoRun() override;
51
52 /**
53 * Create a MobilityModel
54 * \param index mobility model index
55 * \return a new MobilityModel
56 */
58
59 double m_freq; //!< carrier frequency in Hz
60 double m_dist; //!< 2D distance between UT and BS in meters
61 double m_hb; //!< height of BS in meters
62 double m_hm; //!< height of UT in meters
63 double m_lossRef; //!< reference loss
64};
65
67 double dist,
68 double hb,
69 double hm,
70 double refValue,
71 std::string name)
72 : TestCase(name),
73 m_freq(freq),
74 m_dist(dist),
75 m_hb(hb),
76 m_hm(hm),
77 m_lossRef(refValue)
78{
79}
80
84
85void
87{
88 NS_LOG_FUNCTION(this);
89
91 mma->SetPosition(Vector(0.0, 0.0, m_hb));
92
94 mmb->SetPosition(Vector(m_dist, 0.0, m_hm));
95
96 Ptr<ItuR1411LosPropagationLossModel> propagationLossModel =
98 propagationLossModel->SetAttribute("Frequency", DoubleValue(m_freq));
99
100 double loss = propagationLossModel->GetLoss(mma, mmb);
101
102 NS_LOG_INFO("Calculated loss: " << loss);
103 NS_LOG_INFO("Theoretical loss: " << m_lossRef);
104
105 NS_TEST_ASSERT_MSG_EQ_TOL(loss, m_lossRef, 0.1, "Wrong loss!");
106}
107
108/**
109 * \ingroup propagation-tests
110 *
111 * \brief ItuR1411LosPropagationLossModel TestSuite
112 *
113 */
119
121 : TestSuite("itu-r-1411-los", Type::SYSTEM)
122{
123 LogComponentEnable("ItuR1411LosPropagationLossModelTest", LOG_LEVEL_ALL);
124
125 // reference values obtained with the octave scripts in src/propagation/test/reference/
127 100,
128 30,
129 1,
130 81.005,
131 "freq=2114MHz, dist=100m"),
132 TestCase::Duration::QUICK);
134 200,
135 30,
136 1,
137 87.060,
138 "freq=1999MHz, dist=200m"),
139 TestCase::Duration::QUICK);
140}
141
142/// 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:31
Smart pointer class similar to boost::intrusive_ptr.
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#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
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:291
@ LOG_LEVEL_ALL
Print everything.
Definition log.h:105