A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
three-gpp-ntn-propagation-loss-model-test-suite.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 SIGNET Lab, Department of Information Engineering,
3 * University of Padova
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
19#include "ns3/abort.h"
20#include "ns3/boolean.h"
21#include "ns3/channel-condition-model.h"
22#include "ns3/config.h"
23#include "ns3/constant-position-mobility-model.h"
24#include "ns3/constant-velocity-mobility-model.h"
25#include "ns3/double.h"
26#include "ns3/geocentric-constant-position-mobility-model.h"
27#include "ns3/log.h"
28#include "ns3/mobility-helper.h"
29#include "ns3/simulator.h"
30#include "ns3/test.h"
31#include "ns3/three-gpp-propagation-loss-model.h"
32#include "ns3/three-gpp-v2v-propagation-loss-model.h"
33
34using namespace ns3;
35
36NS_LOG_COMPONENT_DEFINE("ThreeGppNTNPropagationLossModelsTest");
37
38/**
39 * \ingroup propagation-tests
40 *
41 * Test case for the ThreeGppNTNPropagationLossModel classes.
42 * It computes the path loss between two nodes and compares it with the value
43 * obtained using the results provided in 3GPP TR 38.821.
44 */
46{
47 public:
49
50 /**
51 * Description of a single test point
52 */
53 struct TestPoint
54 {
55 /**
56 * @brief Constructor
57 *
58 * @param distance 2D distance between the test nodes
59 * @param isLos whether to compute the path loss for a channel LOS condition
60 * @param frequency carrier frequency in Hz
61 * @param pwrRxDbm expected received power in dBm
62 * @param lossModel the propagation loss model to test
63 */
64 TestPoint(double distance,
65 bool isLos,
66 double frequency,
67 double pwrRxDbm,
69 : m_distance(distance),
70 m_isLos(isLos),
71 m_frequency(frequency),
72 m_pwrRxDbm(pwrRxDbm),
73 m_propagationLossModel(lossModel)
74 {
75 }
76
77 double m_distance; //!< 2D distance between test nodes, in meters
78 bool m_isLos; //!< if true LOS, if false NLOS
79 double m_frequency; //!< carrier frequency in Hz
80 double m_pwrRxDbm; //!< received power in dBm
82 };
83
84 private:
85 /**
86 * Build the simulation scenario and run the tests
87 */
88 void DoRun() override;
89
90 /**
91 * Test the channel gain for a specific parameter configuration,
92 * by comparing the antenna gain obtained using CircularApertureAntennaModel::GetGainDb
93 * and the one of manually computed test instances.
94 *
95 * @param testPoint the parameter configuration to be tested
96 */
97 void TestChannelGain(TestPoint testPoint);
98};
99
101 : TestCase("Creating ThreeGppNTNPropagationLossModelTestCase")
102
103{
104}
105
106void
108{
109 // Create the PLMs and disable shadowing to obtain deterministic results
111 CreateObject<ThreeGppNTNDenseUrbanPropagationLossModel>();
112 denseUrbanModel->SetAttribute("ShadowingEnabled", BooleanValue(false));
114 CreateObject<ThreeGppNTNUrbanPropagationLossModel>();
115 urbanModel->SetAttribute("ShadowingEnabled", BooleanValue(false));
117 CreateObject<ThreeGppNTNSuburbanPropagationLossModel>();
118 suburbanModel->SetAttribute("ShadowingEnabled", BooleanValue(false));
120 CreateObject<ThreeGppNTNRuralPropagationLossModel>();
121 ruralModel->SetAttribute("ShadowingEnabled", BooleanValue(false));
122
123 // Vector of test points
124 std::vector<TestPoint> testPoints = {
125 // LOS, test points are identical for all path loss models, since the LOS path loss
126 // is independent from the specific class.
127 // Dense-Urban LOS
128 {35786000, true, 20.0e9, -209.915, denseUrbanModel},
129 {35786000, true, 30.0e9, -213.437, denseUrbanModel},
130 {35786000, true, 2.0e9, -191.744, denseUrbanModel},
131 {600000, true, 20.0e9, -174.404, denseUrbanModel},
132 {600000, true, 30.0e9, -177.925, denseUrbanModel},
133 {600000, true, 2.0e9, -156.233, denseUrbanModel},
134 {1200000, true, 20.0e9, -180.424, denseUrbanModel},
135 {1200000, true, 30.0e9, -183.946, denseUrbanModel},
136 {1200000, true, 2.0e9, -162.253, denseUrbanModel},
137 // Urban LOS
138 {35786000, true, 20.0e9, -209.915, urbanModel},
139 {35786000, true, 30.0e9, -213.437, urbanModel},
140 {35786000, true, 2.0e9, -191.744, urbanModel},
141 {600000, true, 20.0e9, -174.404, urbanModel},
142 {600000, true, 30.0e9, -177.925, urbanModel},
143 {600000, true, 2.0e9, -156.233, urbanModel},
144 {1200000, true, 20.0e9, -180.424, urbanModel},
145 {1200000, true, 30.0e9, -183.946, urbanModel},
146 {1200000, true, 2.0e9, -162.253, urbanModel},
147 // Suburban LOS
148 {35786000, true, 20.0e9, -209.915, suburbanModel},
149 {35786000, true, 30.0e9, -213.437, suburbanModel},
150 {35786000, true, 2.0e9, -191.744, suburbanModel},
151 {600000, true, 20.0e9, -174.404, suburbanModel},
152 {600000, true, 30.0e9, -177.925, suburbanModel},
153 {600000, true, 2.0e9, -156.233, suburbanModel},
154 {1200000, true, 20.0e9, -180.424, suburbanModel},
155 {1200000, true, 30.0e9, -183.946, suburbanModel},
156 {1200000, true, 2.0e9, -162.253, suburbanModel},
157 // Rural LOS
158 {35786000, true, 20.0e9, -209.915, ruralModel},
159 {35786000, true, 30.0e9, -213.437, ruralModel},
160 {35786000, true, 2.0e9, -191.744, ruralModel},
161 {600000, true, 20.0e9, -174.404, ruralModel},
162 {600000, true, 30.0e9, -177.925, ruralModel},
163 {600000, true, 2.0e9, -156.233, ruralModel},
164 {1200000, true, 20.0e9, -180.424, ruralModel},
165 {1200000, true, 30.0e9, -183.946, ruralModel},
166 {1200000, true, 2.0e9, -162.253, ruralModel}};
167
168 // Call TestChannelGain on each test point
169 for (auto& point : testPoints)
170 {
171 TestChannelGain(point);
172 }
173}
174
175void
177{
178 // Create the nodes for BS and UT
180 nodes.Create(2);
181
182 // Create the mobility models
183 Ptr<MobilityModel> a = CreateObject<GeocentricConstantPositionMobilityModel>();
185 Ptr<MobilityModel> b = CreateObject<GeocentricConstantPositionMobilityModel>();
187
188 // Set fixed position of one of the nodes
189 Vector posA = Vector(0.0, 0.0, 0.0);
190 a->SetPosition(posA);
191 Vector posB = Vector(0.0, 0.0, testPoint.m_distance);
192 b->SetPosition(posB);
193
194 // Declare condition model
195 Ptr<ChannelConditionModel> conditionModel;
196
197 // Set the channel condition using a deterministic channel condition model
198 if (testPoint.m_isLos)
199 {
200 conditionModel = CreateObject<AlwaysLosChannelConditionModel>();
201 }
202 else
203 {
204 conditionModel = CreateObject<NeverLosChannelConditionModel>();
205 }
206
207 testPoint.m_propagationLossModel->SetChannelConditionModel(conditionModel);
208 testPoint.m_propagationLossModel->SetAttribute("Frequency", DoubleValue(testPoint.m_frequency));
210 testPoint.m_pwrRxDbm,
211 5e-3,
212 "Obtained unexpected received power");
213
215}
216
217/**
218 * \ingroup propagation-tests
219 *
220 * \brief 3GPP NTN Propagation models TestSuite
221 *
222 * This TestSuite tests the following models:
223 * - ThreeGppNTNDenseUrbanPropagationLossModel
224 * - ThreeGppNTNUrbanPropagationLossModel
225 * - ThreeGppNTNSuburbanPropagationLossModel
226 * - ThreeGppNTNRuralPropagationLossModel
227 */
229{
230 public:
232};
233
235 : TestSuite("three-gpp-ntn-propagation-loss-model", Type::UNIT)
236{
238}
239
240/// Static variable for test initialization
Test case for the ThreeGppNTNPropagationLossModel classes.
void DoRun() override
Build the simulation scenario and run the tests.
void TestChannelGain(TestPoint testPoint)
Test the channel gain for a specific parameter configuration, by comparing the antenna gain obtained ...
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:211
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:309
double CalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account all the PropagationLossModel(s) chained to the current one.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
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:302
A suite of tests to run.
Definition: test.h:1273
Type
Type of test.
Definition: test.h:1280
void SetChannelConditionModel(Ptr< ChannelConditionModel > model)
Set the channel condition model used to determine the channel state (e.g., the LOS/NLOS condition)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if ...
Definition: test.h:511
NodeContainer nodes
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TestPoint(double distance, bool isLos, double frequency, double pwrRxDbm, Ptr< ThreeGppPropagationLossModel > lossModel)
Constructor.
Ptr< ThreeGppPropagationLossModel > m_propagationLossModel
the path loss model to test
static ThreeGppNTNPropagationLossModelsTestSuite g_propagationLossModelsTestSuite
Static variable for test initialization.