A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
buildings-penetration-loss-pathloss-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7#include "ns3/abort.h"
8#include "ns3/boolean.h"
9#include "ns3/building.h"
10#include "ns3/buildings-channel-condition-model.h"
11#include "ns3/channel-condition-model.h"
12#include "ns3/config.h"
13#include "ns3/constant-position-mobility-model.h"
14#include "ns3/constant-velocity-mobility-model.h"
15#include "ns3/double.h"
16#include "ns3/log.h"
17#include "ns3/mobility-building-info.h"
18#include "ns3/mobility-helper.h"
19#include "ns3/rng-seed-manager.h"
20#include "ns3/simulator.h"
21#include "ns3/test.h"
22#include "ns3/three-gpp-propagation-loss-model.h"
23
24#include <numeric>
25
26using namespace ns3;
27
28NS_LOG_COMPONENT_DEFINE("BuildingsPenetrationLossesTest");
29
31
32/**
33 * @ingroup propagation-tests
34 *
35 * Test case for the 3GPP channel building and vehicular O2I penetration losses.
36 * It considers pre-determined scenarios and based on the outdoor/indoor
37 * condition (O2O/O2I) checks whether the calculated received power
38 * is aligned with the calculation in 3GPP TR 38.901.
39 *
40 * For O2O condition the calculation is done according to Table 7.4.1-1
41 * and we check if the calculated received power is equal to the expected
42 * value. O2O condition is also tested when unblocked (LOS),
43 * or blocked (NLOS) by a building.
44
45 * For the O2I condition with frequencies equal or above 6GHz,
46 * the calculation is done considering the building penetration losses
47 * based on the material of the building walls, as specified
48 * in Table 7.4.3-1 and Table 7.4.3-2.
49 * For the O2I condition with frequencies below 6GHz, the calculation
50 * is done considering the backward compatibility model in Table 7.4.3-3.
51 * In both cases, we check if the calculated received power is within
52 * the expected normal distribution.
53 *
54 * All cases are tested with one node at 0 or 30 km/h, representing pedestrian or vehicles.
55 * In case a vehicle is part of a channel link, its O2I losses are applied to the channel,
56 * following procedure in 3GPP TR 38901 Section 7.4.3.2.
57 */
58
60{
61 public:
62 /**
63 * Constructor
64 */
66
67 /**
68 * Destructor
69 */
71
72 private:
73 /**
74 * Builds the simulation scenario and perform the tests
75 */
76 void DoRun() override;
77
78 /**
79 * Struct containing the parameters for each test
80 */
82 {
83 Vector m_positionA; //!< the position of the first node
84 Vector m_positionB; //!< the position of the second node
85 double m_ueVelocity; //!< velocity in km/h
86 double m_frequency; //!< carrier frequency in Hz
87 TypeId m_propModel; //!< the type ID of the propagation loss model to be used
88 O2ILH m_o2iLossType; //!< type of O2I loss (low/high)
89 double m_expectedMean; //!< expected mean in dBm
90 double m_expectedStddev; //!< expected deviation in dBm
91 };
92
93 std::vector<TestVector> m_testVectors; //!< array containing all the test vectors
94 Ptr<ThreeGppPropagationLossModel> m_propModel; //!< the propagation loss model
95};
96
98 : TestCase("Test case for BuildingsPenetrationLosses"),
100{
101}
102
106
107void
109{
113 // create the test vector
114 // clang-format off
115 m_testVectors = {
116 // PosA, PosB, B velocity, frequency, propagation model, O2I loss type, channel condition, mean and standard deviation of expected gaussian
117 // 6GHz, pedestrian, Low O2I loss
118 {{0, 0, 35.0}, { 10, 0, 1.5}, 0, 6e9, RMa, O2ILH::LOW, -93.0, 4.5}, // RMa O2I
119 {{0, 0, 35.0}, { 100, 0, 1.5}, 0, 6e9, RMa, O2ILH::LOW, -112.0, 4.5}, // RMa O2I
120 {{0, 0, 10.0}, { 50, 15, 1.5}, 0, 6e9, RMa, O2ILH::LOW, -97.0, 0.1}, // RMa O2O unblocked
121 {{0, 0, 10.0}, {1000, 0, 1.5}, 0, 6e9, RMa, O2ILH::LOW, -110.0, 0.1}, // RMa O2O blocked
122 {{0, 0, 25.0}, { 10, 0, 1.5}, 0, 6e9, UMa, O2ILH::LOW, -101.0, 5.3}, // UMa O2I
123 {{0, 0, 25.0}, { 100, 0, 1.5}, 0, 6e9, UMa, O2ILH::LOW, -125.0, 5.3}, // UMa O2I
124 {{0, 0, 10.0}, { 50, 15, 1.5}, 0, 6e9, UMa, O2ILH::LOW, -96.0, 0.1}, // UMa O2O unblocked
125 {{0, 0, 10.0}, {1000, 0, 1.5}, 0, 6e9, UMa, O2ILH::LOW, -117.0, 0.1}, // UMa O2O blocked
126 {{0, 0, 10.0}, { 10, 0, 1.5}, 0, 6e9, UMi, O2ILH::LOW, -96.0, 5.3}, // UMi O2I
127 {{0, 0, 10.0}, { 100, 0, 1.5}, 0, 6e9, UMi, O2ILH::LOW, -127.0, 5.0}, // UMi O2I
128 {{0, 0, 10.0}, { 50, 15, 1.5}, 0, 6e9, UMi, O2ILH::LOW, -99.0, 0.1}, // UMi O2O unblocked
129 {{0, 0, 10.0}, {1000, 0, 1.5}, 0, 6e9, UMi, O2ILH::LOW, -119.0, 0.1}, // UMi O2O blocked
130 // 6GHz, pedestrian, High O2I loss
131 {{0, 0, 35.0}, { 10, 0, 1.5}, 0, 6e9, RMa, O2ILH::HIGH, -93.0, 4.5}, // RMa O2I
132 {{0, 0, 35.0}, { 100, 0, 1.5}, 0, 6e9, RMa, O2ILH::HIGH, -112.0, 4.5}, // RMa O2I
133 {{0, 0, 10.0}, { 50, 15, 1.5}, 0, 6e9, RMa, O2ILH::HIGH, -97.0, 0.1}, // RMa O2O unblocked
134 {{0, 0, 10.0}, {1000, 0, 1.5}, 0, 6e9, RMa, O2ILH::HIGH, -110.0, 0.1}, // RMa O2O blocked
135 {{0, 0, 25.0}, { 10, 0, 1.5}, 0, 6e9, UMa, O2ILH::HIGH, -101.0, 5.3}, // UMa O2I
136 {{0, 0, 25.0}, { 100, 0, 1.5}, 0, 6e9, UMa, O2ILH::HIGH, -125.0, 5.3}, // UMa O2I
137 {{0, 0, 10.0}, { 50, 15, 1.5}, 0, 6e9, UMa, O2ILH::HIGH, -96.0, 0.1}, // UMa O2O unblocked
138 {{0, 0, 10.0}, {1000, 0, 1.5}, 0, 6e9, UMa, O2ILH::HIGH, -117.0, 0.1}, // UMa O2O blocked
139 {{0, 0, 10.0}, { 10, 0, 1.5}, 0, 6e9, UMi, O2ILH::HIGH, -95.0, 5.3}, // UMi O2I
140 {{0, 0, 10.0}, { 100, 0, 1.5}, 0, 6e9, UMi, O2ILH::HIGH, -127.0, 5.3}, // UMi O2I
141 {{0, 0, 10.0}, { 50, 15, 1.5}, 0, 6e9, UMi, O2ILH::HIGH, -99.0, 0.1}, // UMi O2O unblocked
142 {{0, 0, 10.0}, {1000, 0, 1.5}, 0, 6e9, UMi, O2ILH::HIGH, -119.0, 0.1}, // UMi O2O blocked
143 // 6GHz, vehicles, High O2I loss
144 {{0, 0, 35.0}, { 10, 0, 1.5}, 30, 6e9, RMa, O2ILH::HIGH, -94.0, 4.5}, // RMa O2I
145 {{0, 0, 35.0}, { 100, 0, 1.5}, 30, 6e9, RMa, O2ILH::HIGH, -112.0, 4.5}, // RMa O2I
146 {{0, 0, 10.0}, { 50, 15, 1.5}, 30, 6e9, RMa, O2ILH::HIGH, -98.0, 5.3}, // RMa O2O unblocked
147 {{0, 0, 10.0}, {1000, 0, 1.5}, 30, 6e9, RMa, O2ILH::HIGH, -110.0, 5.3}, // RMa O2O blocked
148 {{0, 0, 25.0}, { 10, 0, 1.5}, 30, 6e9, UMa, O2ILH::HIGH, -101.0, 5.3}, // UMa O2I
149 {{0, 0, 25.0}, { 100, 0, 1.5}, 30, 6e9, UMa, O2ILH::HIGH, -125.0, 5.3}, // UMa O2I
150 {{0, 0, 10.0}, { 50, 15, 1.5}, 30, 6e9, UMa, O2ILH::HIGH, -96.0, 5.3}, // UMa O2O unblocked
151 {{0, 0, 10.0}, {1000, 0, 1.5}, 30, 6e9, UMa, O2ILH::HIGH, -117.0, 5.3}, // UMa O2O blocked
152 {{0, 0, 10.0}, { 10, 0, 1.5}, 30, 6e9, UMi, O2ILH::HIGH, -95.0, 5.3}, // UMi O2I
153 {{0, 0, 10.0}, { 100, 0, 1.5}, 30, 6e9, UMi, O2ILH::HIGH, -127.0, 5.3}, // UMi O2I
154 {{0, 0, 10.0}, { 50, 15, 1.5}, 30, 6e9, UMi, O2ILH::HIGH, -100.0, 5.3}, // UMi O2O unblocked
155 {{0, 0, 10.0}, {1000, 0, 1.5}, 30, 6e9, UMi, O2ILH::HIGH, -119.0, 5.3}, // UMi O2O blocked
156 // Sub-6GHz, pedestrian, legacy O2I
157 {{0, 0, 35.0}, { 10, 0, 1.5}, 0, 5e9, RMa, O2ILH::HIGH, -97.0, 0.1}, // RMa O2I
158 {{0, 0, 35.0}, { 100, 0, 1.5}, 0, 5e9, RMa, O2ILH::HIGH, -115.0, 0.1}, // RMa O2I
159 {{0, 0, 10.0}, { 50, 15, 1.5}, 0, 5e9, RMa, O2ILH::HIGH, -96.0, 0.1}, // RMa O2O unblocked
160 {{0, 0, 10.0}, {1000, 0, 1.5}, 0, 5e9, RMa, O2ILH::HIGH, -108.0, 0.1}, // RMa O2O blocked
161 {{0, 0, 25.0}, { 10, 0, 1.5}, 0, 5e9, UMa, O2ILH::HIGH, -108.0, 3.6}, // UMa O2I
162 {{0, 0, 25.0}, { 100, 0, 1.5}, 0, 5e9, UMa, O2ILH::HIGH, -132.0, 3.6}, // UMa O2I
163 {{0, 0, 10.0}, { 50, 15, 1.5}, 0, 5e9, UMa, O2ILH::HIGH, -94.0, 0.1}, // UMa O2O unblocked
164 {{0, 0, 10.0}, {1000, 0, 1.5}, 0, 5e9, UMa, O2ILH::HIGH, -117.0, 0.1}, // UMa O2O blocked
165 {{0, 0, 10.0}, { 10, 0, 1.5}, 0, 5e9, UMi, O2ILH::HIGH, -103.0, 3.6}, // UMi O2I
166 {{0, 0, 10.0}, { 100, 0, 1.5}, 0, 5e9, UMi, O2ILH::HIGH, -134.0, 3.6}, // UMi O2I
167 {{0, 0, 10.0}, { 50, 15, 1.5}, 0, 5e9, UMi, O2ILH::HIGH, -98.0, 0.1}, // UMi O2O unblocked
168 {{0, 0, 10.0}, {1000, 0, 1.5}, 0, 5e9, UMi, O2ILH::HIGH, -119.0, 0.1}, // UMi O2O blocked
169 // Sub-6GHz, vehicles, legacy O2I
170 {{0, 0, 35.0}, { 10, 0, 1.5}, 30, 5e9, RMa, O2ILH::HIGH, -97.0, 0.1}, // RMa O2I
171 {{0, 0, 35.0}, { 100, 0, 1.5}, 30, 5e9, RMa, O2ILH::HIGH, -115.0, 0.1}, // RMa O2I
172 {{0, 0, 10.0}, { 50, 15, 1.5}, 30, 5e9, RMa, O2ILH::HIGH, -96.0, 5.0}, // RMa O2O unblocked
173 {{0, 0, 10.0}, {1000, 0, 1.5}, 30, 5e9, RMa, O2ILH::HIGH, -108.0, 5.0}, // RMa O2O blocked
174 {{0, 0, 25.0}, { 10, 0, 1.5}, 30, 5e9, UMa, O2ILH::HIGH, -108.0, 3.6}, // UMa O2I
175 {{0, 0, 25.0}, { 100, 0, 1.5}, 30, 5e9, UMa, O2ILH::HIGH, -132.0, 3.6}, // UMa O2I
176 {{0, 0, 10.0}, { 50, 15, 1.5}, 30, 5e9, UMa, O2ILH::HIGH, -103.0, 5.0}, // UMa O2O unblocked
177 {{0, 0, 10.0}, {1000, 0, 1.5}, 30, 5e9, UMa, O2ILH::HIGH, -117.0, 5.0}, // UMa O2O blocked
178 {{0, 0, 10.0}, { 10, 0, 1.5}, 30, 5e9, UMi, O2ILH::HIGH, -102.0, 3.6}, // UMi O2I
179 {{0, 0, 10.0}, { 100, 0, 1.5}, 30, 5e9, UMi, O2ILH::HIGH, -134.0, 3.6}, // UMi O2I
180 {{0, 0, 10.0}, { 50, 15, 1.5}, 30, 5e9, UMi, O2ILH::HIGH, -98.0, 5.0}, // UMi O2O unblocked
181 {{0, 0, 10.0}, {1000, 0, 1.5}, 30, 5e9, UMi, O2ILH::HIGH, -119.0, 5.0}, // UMi O2O blocked
182 };
183 // clang-format on
186 for (std::size_t i = 0; i < m_testVectors.size(); i++)
187 {
189 // create the factory for the propagation loss model
190 ObjectFactory propModelFactory;
191
192 auto building = CreateObject<Building>();
193 building->SetExtWallsType(Building::ExtWallsType_t::ConcreteWithWindows);
194 building->SetNRoomsX(1);
195 building->SetNRoomsY(1);
196 building->SetNFloors(2);
197 building->SetBoundaries(Box(0.0, 100.0, 0.0, 10.0, 0.0, 5.0));
198
199 // create the two nodes
201 nodes.Create(2);
202
203 // create the mobility models
207
208 // aggregate the nodes and the mobility models
209 nodes.Get(0)->AggregateObject(a);
210 nodes.Get(1)->AggregateObject(b);
211
214 a->AggregateObject(buildingInfoA); // operation usually done by BuildingsHelper::Install
215 buildingInfoA->MakeConsistent(a);
216
217 b->AggregateObject(buildingInfoB); // operation usually done by BuildingsHelper::Install
218 buildingInfoB->MakeConsistent(b);
219
221 int64_t streamOffset = 0;
222 streamOffset += condModel->AssignStreams(streamOffset);
223
224 // Configure test case setup
225 const auto& testVector = m_testVectors.at(i);
226 a->SetPosition(testVector.m_positionA);
227 b->SetPosition(testVector.m_positionB);
228 bcv->SetVelocity({testVector.m_ueVelocity / 3.6, 0, 0});
229 bool isAIndoor = buildingInfoA->IsIndoor();
230 bool isBIndoor = buildingInfoB->IsIndoor();
231
232 Ptr<ChannelCondition> cond = condModel->GetChannelCondition(a, b);
233 cond->SetO2iLowHighCondition(testVector.m_o2iLossType);
234 if (!isAIndoor && !isBIndoor) // a and b are outdoor
235 {
236 cond->SetO2iCondition(ChannelCondition::O2iConditionValue::O2O);
237 }
238 else
239 {
240 cond->SetO2iCondition(ChannelCondition::O2iConditionValue::O2I);
241 }
242
243 propModelFactory.SetTypeId(testVector.m_propModel);
244 m_propModel = propModelFactory.Create<ThreeGppPropagationLossModel>();
245 m_propModel->SetAttribute("Frequency", DoubleValue(testVector.m_frequency));
246 m_propModel->SetAttribute("ShadowingEnabled", BooleanValue(false));
247 streamOffset += m_propModel->AssignStreams(streamOffset);
248 streamOffset += m_propModel->GetChannelConditionModel()->AssignStreams(streamOffset);
249 m_propModel->SetChannelConditionModel(condModel);
250 streamOffset += m_propModel->AssignStreams(streamOffset);
251 m_propModel->GetChannelConditionModel()->AssignStreams(streamOffset);
252 std::vector<double> samples(1000);
253 for (auto& sample : samples)
254 {
255 // Compute total loss
256 sample = m_propModel->CalcRxPower(0.0, a, b);
257 // Trigger another random variable usage
258 m_propModel->ClearO2iLossCacheMap();
259 }
260
261 auto getMeanAndStddev = [](const std::vector<double> vec) {
262 // Calculate the mean
263 double sum = std::accumulate(vec.begin(), vec.end(), 0.0);
264 double mean = sum / vec.size();
265
266 // Calculate variance and standard deviation
267 double sq_sum = std::inner_product(vec.begin(), vec.end(), vec.begin(), 0.0);
268 double stddev = std::sqrt((sq_sum / vec.size()) - mean * mean);
269 return std::make_pair(mean, stddev);
270 };
271
272 auto [mean, stddev] = getMeanAndStddev(samples);
274 testVector.m_expectedMean,
275 -testVector.m_expectedMean * 0.1,
276 "Test vector " << i << ", mean outside expected range");
278 testVector.m_expectedStddev,
279 std::max(0.1, testVector.m_expectedStddev * 0.1),
280 "Test vector " << i
281 << ", standard deviation outside expected range");
282 m_propModel = nullptr;
284 }
285}
286
287/**
288 * @ingroup propagation-tests
289 *
290 * Test suite for the buildings penetration losses
291 */
297
303
304/// Static variable for test initialization
static BuildingsPenetrationLossesTestSuite g_buildingsPenetrationLossesTestSuite
Static variable for test initialization.
ChannelCondition::O2iLowHighConditionValue O2ILH
Test case for the 3GPP channel building and vehicular O2I penetration losses.
Ptr< ThreeGppPropagationLossModel > m_propModel
the propagation loss model
void DoRun() override
Builds the simulation scenario and perform the tests.
std::vector< TestVector > m_testVectors
array containing all the test vectors
Test suite for the buildings penetration losses.
AttributeValue implementation for Boolean.
Definition boolean.h:26
a 3d box
Definition box.h:24
@ ConcreteWithWindows
Definition building.h:58
O2iLowHighConditionValue
Possible values for Low-High Penetration Loss condition.
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.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
static void SetRun(uint64_t run)
Set the run number of simulation.
static void ResetNextStreamIndex()
Resets the global stream index counter.
static void SetSeed(uint32_t seed)
Set the seed.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:293
@ QUICK
Fast test.
Definition test.h:1054
TestCase(const TestCase &)=delete
Type
Type of test.
Definition test.h:1257
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition test.cc:491
Base class for the 3GPP propagation models.
a unique identifier for an interface.
Definition type-id.h:49
#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_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:326
NodeContainer nodes
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:585
TypeId m_propModel
the type ID of the propagation loss model to be used