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 * SPDX-License-Identifier: GPL-2.0-only
6 */
7
8#include "ns3/abort.h"
9#include "ns3/boolean.h"
10#include "ns3/channel-condition-model.h"
11#include "ns3/config.h"
12#include "ns3/constant-position-mobility-model.h"
13#include "ns3/constant-velocity-mobility-model.h"
14#include "ns3/double.h"
15#include "ns3/geocentric-constant-position-mobility-model.h"
16#include "ns3/log.h"
17#include "ns3/mobility-helper.h"
18#include "ns3/simulator.h"
19#include "ns3/test.h"
20#include "ns3/three-gpp-propagation-loss-model.h"
21#include "ns3/three-gpp-v2v-propagation-loss-model.h"
22
23using namespace ns3;
24
25NS_LOG_COMPONENT_DEFINE("ThreeGppNTNPropagationLossModelsTest");
26
27/**
28 * @ingroup propagation-tests
29 *
30 * Test case for the ThreeGppNTNPropagationLossModel classes.
31 * It computes the path loss between two nodes and compares it with the value
32 * obtained using the results provided in 3GPP TR 38.821.
33 */
35{
36 public:
38
39 /**
40 * Description of a single test point
41 */
42 struct TestPoint
43 {
44 /**
45 * @brief Constructor
46 *
47 * @param distance 2D distance between the test nodes
48 * @param isLos whether to compute the path loss for a channel LOS condition
49 * @param frequency carrier frequency in Hz
50 * @param pwrRxDbm expected received power in dBm
51 * @param lossModel the propagation loss model to test
52 */
53 TestPoint(double distance,
54 bool isLos,
55 double frequency,
56 double pwrRxDbm,
58 : m_distance(distance),
59 m_isLos(isLos),
60 m_frequency(frequency),
61 m_pwrRxDbm(pwrRxDbm),
62 m_propagationLossModel(lossModel)
63 {
64 }
65
66 double m_distance; //!< 2D distance between test nodes, in meters
67 bool m_isLos; //!< if true LOS, if false NLOS
68 double m_frequency; //!< carrier frequency in Hz
69 double m_pwrRxDbm; //!< received power in dBm
71 };
72
73 private:
74 /**
75 * Build the simulation scenario and run the tests
76 */
77 void DoRun() override;
78
79 /**
80 * Test the channel gain for a specific parameter configuration,
81 * by comparing the antenna gain obtained using CircularApertureAntennaModel::GetGainDb
82 * and the one of manually computed test instances.
83 *
84 * @param testPoint the parameter configuration to be tested
85 */
86 void TestChannelGain(TestPoint testPoint);
87};
88
90 : TestCase("Creating ThreeGppNTNPropagationLossModelTestCase")
91
92{
93}
94
95void
97{
98 // Create the PLMs and disable shadowing to obtain deterministic results
101 denseUrbanModel->SetAttribute("ShadowingEnabled", BooleanValue(false));
104 urbanModel->SetAttribute("ShadowingEnabled", BooleanValue(false));
107 suburbanModel->SetAttribute("ShadowingEnabled", BooleanValue(false));
110 ruralModel->SetAttribute("ShadowingEnabled", BooleanValue(false));
111
112 // Vector of test points
113 std::vector<TestPoint> testPoints = {
114 // LOS, test points are identical for all path loss models, since the LOS path loss
115 // is independent from the specific class.
116 // Dense-Urban LOS
117 {35786000, true, 20.0e9, -209.915, denseUrbanModel},
118 {35786000, true, 30.0e9, -213.437, denseUrbanModel},
119 {35786000, true, 2.0e9, -191.744, denseUrbanModel},
120 {600000, true, 20.0e9, -174.404, denseUrbanModel},
121 {600000, true, 30.0e9, -177.925, denseUrbanModel},
122 {600000, true, 2.0e9, -156.233, denseUrbanModel},
123 {1200000, true, 20.0e9, -180.424, denseUrbanModel},
124 {1200000, true, 30.0e9, -183.946, denseUrbanModel},
125 {1200000, true, 2.0e9, -162.253, denseUrbanModel},
126 // Urban LOS
127 {35786000, true, 20.0e9, -209.915, urbanModel},
128 {35786000, true, 30.0e9, -213.437, urbanModel},
129 {35786000, true, 2.0e9, -191.744, urbanModel},
130 {600000, true, 20.0e9, -174.404, urbanModel},
131 {600000, true, 30.0e9, -177.925, urbanModel},
132 {600000, true, 2.0e9, -156.233, urbanModel},
133 {1200000, true, 20.0e9, -180.424, urbanModel},
134 {1200000, true, 30.0e9, -183.946, urbanModel},
135 {1200000, true, 2.0e9, -162.253, urbanModel},
136 // Suburban LOS
137 {35786000, true, 20.0e9, -209.915, suburbanModel},
138 {35786000, true, 30.0e9, -213.437, suburbanModel},
139 {35786000, true, 2.0e9, -191.744, suburbanModel},
140 {600000, true, 20.0e9, -174.404, suburbanModel},
141 {600000, true, 30.0e9, -177.925, suburbanModel},
142 {600000, true, 2.0e9, -156.233, suburbanModel},
143 {1200000, true, 20.0e9, -180.424, suburbanModel},
144 {1200000, true, 30.0e9, -183.946, suburbanModel},
145 {1200000, true, 2.0e9, -162.253, suburbanModel},
146 // Rural LOS
147 {35786000, true, 20.0e9, -209.915, ruralModel},
148 {35786000, true, 30.0e9, -213.437, ruralModel},
149 {35786000, true, 2.0e9, -191.744, ruralModel},
150 {600000, true, 20.0e9, -174.404, ruralModel},
151 {600000, true, 30.0e9, -177.925, ruralModel},
152 {600000, true, 2.0e9, -156.233, ruralModel},
153 {1200000, true, 20.0e9, -180.424, ruralModel},
154 {1200000, true, 30.0e9, -183.946, ruralModel},
155 {1200000, true, 2.0e9, -162.253, ruralModel}};
156
157 // Call TestChannelGain on each test point
158 for (auto& point : testPoints)
159 {
160 TestChannelGain(point);
161 }
162}
163
164void
166{
167 // Create the nodes for BS and UT
169 nodes.Create(2);
170
171 // Create the mobility models
176
177 // Set fixed position of one of the nodes
178 Vector posA = Vector(0.0, 0.0, 0.0);
179 a->SetPosition(posA);
180 Vector posB = Vector(0.0, 0.0, testPoint.m_distance);
181 b->SetPosition(posB);
182
183 // Declare condition model
184 Ptr<ChannelConditionModel> conditionModel;
185
186 // Set the channel condition using a deterministic channel condition model
187 if (testPoint.m_isLos)
188 {
190 }
191 else
192 {
194 }
195
196 testPoint.m_propagationLossModel->SetChannelConditionModel(conditionModel);
197 testPoint.m_propagationLossModel->SetAttribute("Frequency", DoubleValue(testPoint.m_frequency));
198 NS_TEST_EXPECT_MSG_EQ_TOL(testPoint.m_propagationLossModel->CalcRxPower(0.0, a, b),
199 testPoint.m_pwrRxDbm,
200 5e-3,
201 "Obtained unexpected received power");
202
204}
205
206/**
207 * @ingroup propagation-tests
208 *
209 * @brief 3GPP NTN Propagation models TestSuite
210 *
211 * This TestSuite tests the following models:
212 * - ThreeGppNTNDenseUrbanPropagationLossModel
213 * - ThreeGppNTNUrbanPropagationLossModel
214 * - ThreeGppNTNSuburbanPropagationLossModel
215 * - ThreeGppNTNRuralPropagationLossModel
216 */
222
228
229/// 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 ...
AttributeValue implementation for Boolean.
Definition boolean.h:26
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
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 AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition object.cc:298
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
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
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#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:500
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.