A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
three-gpp-propagation-loss-model.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 SIGNET Lab, Department of Information Engineering,
3 * University of Padova
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 */
7
9
12
13#include "ns3/boolean.h"
14#include "ns3/double.h"
15#include "ns3/geocentric-constant-position-mobility-model.h"
16#include "ns3/log.h"
17#include "ns3/mobility-model.h"
18#include "ns3/node.h"
19#include "ns3/pointer.h"
20#include "ns3/simulator.h"
21
22#include <cmath>
23#include <cstdint>
24
25namespace
26{
27
28/// Shadow-fading random fields, one per (site, condition), see SpatialGaussianField.
30
31/**
32 * Indoor-distance and penetration-loss-deviation random fields, see
33 * SpatialGaussianField. Both are properties of the terminal location rather
34 * than of the link, so they are not keyed on the site.
35 */
38
39/// Field keys of kO2iPenetrationField.
41{
42 DISTANCE_2D_IN_1 = 0, ///< first uniform variable of the 2D-in distance
43 DISTANCE_2D_IN_2 = 1, ///< second uniform variable of the 2D-in distance
44 DEVIATION = 2, ///< penetration loss deviation
45};
46
47/// Correlation distance of the uniform variables of the 2D-in distance, TR 38.901 Sec. 7.6.3.3.
48constexpr double kDistance2dInCorrelationDistance = 25.0;
49
50/// Correlation distance of the penetration loss deviation, TR 38.901 Sec. 7.6.3.3.
52
53/// Standard deviation in dB of the low-loss penetration loss, TR 38.901 Table 7.4.3-2.
54constexpr double kO2iLowLossStd = 4.4;
55
56/// Standard deviation in dB of the high-loss penetration loss, TR 38.901 Table 7.4.3-2.
57constexpr double kO2iHighLossStd = 6.5;
58
59/**
60 * @brief Sample the spatially consistent O2I 2D-in distance at a terminal
61 * position (TR 38.901 Sec. 7.6.3.3).
62 *
63 * @param position Terminal position (only x and y are used).
64 * @param maxDistance Upper bound of the uniform variables in meters.
65 * @param minOfTwo True for the minimum of two uniform variables (TR 38.901
66 * Table 7.4.3-2), false for a single one (Table 7.4.3-3).
67 * @return The 2D-in distance in meters.
68 */
69double
70SampleO2iDistance2dIn(const ns3::Vector& position, double maxDistance, bool minOfTwo)
71{
72 double u = kO2iPenetrationField.SampleUniform(DISTANCE_2D_IN_1,
73 position,
75 if (minOfTwo)
76 {
77 u = std::min(u,
79 position,
81 }
82 return u * maxDistance;
83}
84
85/**
86 * @brief Low-loss O2I penetration loss through the external wall, TR 38.901 Table 7.4.3-2.
87 * @param frequency The centre frequency in Hz.
88 * @return The loss in dB.
89 */
90double
91O2iLowLossTw(double frequency)
92{
93 const double lGlass = 2 + 0.2 * frequency / 1e9;
94 const double lConcrete = 5 + 4 * frequency / 1e9;
95 return 5 - 10 * log10(0.3 * std::pow(10, -lGlass / 10) + 0.7 * std::pow(10, -lConcrete / 10));
96}
97
98/**
99 * @brief High-loss O2I penetration loss through the external wall, TR 38.901 Table 7.4.3-2.
100 * @param frequency The centre frequency in Hz.
101 * @return The loss in dB.
102 */
103double
104O2iHighLossTw(double frequency)
105{
106 const double lIIRGlass = 23 + 0.3 * frequency / 1e9;
107 const double lConcrete = 5 + 4 * frequency / 1e9;
108 return 5 -
109 10 * log10(0.7 * std::pow(10, -lIIRGlass / 10) + 0.3 * std::pow(10, -lConcrete / 10));
110}
111
112/**
113 * The enumerator used for code clarity when performing parameter assignment in the GetLoss Methods
114 */
124
125/**
126 * The map containing the 3GPP value regarding Shadow Fading and Clutter Loss tables for the
127 * NTN Dense Urban scenario
128 */
129const std::map<int, std::vector<float>> SFCL_DenseUrban{
130 {10, {3.5, 15.5, 34.3, 2.9, 17.1, 44.3}},
131 {20, {3.4, 13.9, 30.9, 2.4, 17.1, 39.9}},
132 {30, {2.9, 12.4, 29.0, 2.7, 15.6, 37.5}},
133 {40, {3.0, 11.7, 27.7, 2.4, 14.6, 35.8}},
134 {50, {3.1, 10.6, 26.8, 2.4, 14.2, 34.6}},
135 {60, {2.7, 10.5, 26.2, 2.7, 12.6, 33.8}},
136 {70, {2.5, 10.1, 25.8, 2.6, 12.1, 33.3}},
137 {80, {2.3, 9.2, 25.5, 2.8, 12.3, 33.0}},
138 {90, {1.2, 9.2, 25.5, 0.6, 12.3, 32.9}},
139};
140
141/**
142 * The map containing the 3GPP value regarding Shadow Fading and Clutter Loss tables for the
143 * NTN Urban scenario
144 */
145const std::map<int, std::vector<float>> SFCL_Urban{
146 {10, {4, 6, 34.3, 4, 6, 44.3}},
147 {20, {4, 6, 30.9, 4, 6, 39.9}},
148 {30, {4, 6, 29.0, 4, 6, 37.5}},
149 {40, {4, 6, 27.7, 4, 6, 35.8}},
150 {50, {4, 6, 26.8, 4, 6, 34.6}},
151 {60, {4, 6, 26.2, 4, 6, 33.8}},
152 {70, {4, 6, 25.8, 4, 6, 33.3}},
153 {80, {4, 6, 25.5, 4, 6, 33.0}},
154 {90, {4, 6, 25.5, 4, 6, 32.9}},
155};
156
157/**
158 * The map containing the 3GPP value regarding Shadow Fading and Clutter Loss tables for the
159 * NTN Suburban and Rural scenarios
160 */
161const std::map<int, std::vector<float>> SFCL_SuburbanRural{
162 {10, {1.79, 8.93, 19.52, 1.9, 10.7, 29.5}},
163 {20, {1.14, 9.08, 18.17, 1.6, 10.0, 24.6}},
164 {30, {1.14, 8.78, 18.42, 1.9, 11.2, 21.9}},
165 {40, {0.92, 10.25, 18.28, 2.3, 11.6, 20.0}},
166 {50, {1.42, 10.56, 18.63, 2.7, 11.8, 18.7}},
167 {60, {1.56, 10.74, 17.68, 3.1, 10.8, 17.8}},
168 {70, {0.85, 10.17, 16.5, 3.0, 10.8, 17.2}},
169 {80, {0.72, 11.52, 16.3, 3.6, 10.8, 16.9}},
170 {90, {0.72, 11.52, 16.3, 0.4, 10.8, 16.8}},
171};
172
173/**
174 * Array containing the attenuation given by atmospheric absorption. 100 samples are selected for
175 * frequencies from 1GHz to 100GHz. In order to get the atmospheric absorption loss for a given
176 * frequency f: 1- round f to the closest integer between 0 and 100. 2- use the obtained integer to
177 * access the corresponding element in the array, that will give the attenuation at that frequency.
178 * Data is obtained form ITU-R P.676 Figure 6.
179 */
180const double atmosphericAbsorption[101] = {
181 0, 0.0300, 0.0350, 0.0380, 0.0390, 0.0410, 0.0420, 0.0450, 0.0480, 0.0500,
182 0.0530, 0.0587, 0.0674, 0.0789, 0.0935, 0.1113, 0.1322, 0.1565, 0.1841, 0.2153,
183 0.2500, 0.3362, 0.4581, 0.5200, 0.5200, 0.5000, 0.4500, 0.3850, 0.3200, 0.2700,
184 0.2500, 0.2517, 0.2568, 0.2651, 0.2765, 0.2907, 0.3077, 0.3273, 0.3493, 0.3736,
185 0.4000, 0.4375, 0.4966, 0.5795, 0.6881, 0.8247, 0.9912, 1.1900, 1.4229, 1.6922,
186 2.0000, 4.2654, 10.1504, 19.2717, 31.2457, 45.6890, 62.2182, 80.4496, 100.0000, 140.0205,
187 170.0000, 100.0000, 78.1682, 59.3955, 43.5434, 30.4733, 20.0465, 12.1244, 6.5683, 3.2397,
188 2.0000, 1.7708, 1.5660, 1.3858, 1.2298, 1.0981, 0.9905, 0.9070, 0.8475, 0.8119,
189 0.8000, 0.8000, 0.8000, 0.8000, 0.8000, 0.8000, 0.8000, 0.8000, 0.8000, 0.8000,
190 0.8000, 0.8029, 0.8112, 0.8243, 0.8416, 0.8625, 0.8864, 0.9127, 0.9408, 0.9701,
191 1.0000};
192
193/**
194 * Map containing the Tropospheric attenuation in dB with 99% probability at 20 GHz in Toulouse
195 * used for tropospheric scintillation losses. From Table 6.6.6.2.1-1 of 3GPP TR 38.811.
196 */
197const std::map<int, float> troposphericScintillationLoss{
198 {10, {1.08}},
199 {20, {0.48}},
200 {30, {0.30}},
201 {40, {0.22}},
202 {50, {0.17}},
203 {60, {0.13}},
204 {70, {0.12}},
205 {80, {0.12}},
206 {90, {0.12}},
207};
208
209/**
210 * @brief Get the base station and user terminal relative distances and heights
211 *
212 * @param a the mobility model of terminal a
213 * @param b the mobility model of terminal b
214 *
215 * @return The tuple [dist2D, dist3D, hBs, hUt], where dist2D and dist3D
216 * are the 2D and 3D distances between a and b, respectively, hBs is the bigger
217 * height and hUt the smallest.
218 */
219std::tuple<double, double, double, double>
222{
223 auto aPos = a->GetPosition();
224 auto bPos = b->GetPosition();
225 double distance2D = ns3::ThreeGppChannelConditionModel::Calculate2dDistance(aPos, bPos);
226 double distance3D = ns3::CalculateDistance(aPos, bPos);
227 double hBs = std::max(aPos.z, bPos.z);
228 double hUt = std::min(aPos.z, bPos.z);
229 return std::make_tuple(distance2D, distance3D, hBs, hUt);
230}
231
232/**
233 * @brief Get the base station and user terminal heights for the UmiStreetCanyon scenario
234 *
235 * @param heightA the first height in meters
236 * @param heightB the second height in meters
237 *
238 * @return The tuple [hBs, hUt], where hBs is assumed to be = 10 and hUt other height.
239 */
240std::tuple<double, double>
241GetBsUtHeightsUmiStreetCanyon(double heightA, double heightB)
242{
243 double hBs = (heightA == 10) ? heightA : heightB;
244 double hUt = (heightA == 10) ? heightB : heightA;
245 return std::make_tuple(hBs, hUt);
246}
247
248/**
249 * Finite, large loss returned for links outside the domain of the TR 38.811 model
250 * (non-positive elevation angles), in dB.
251 */
252constexpr double OUT_OF_DOMAIN_LOSS_DB = 500.0;
253
254/**
255 * @brief Computes the free-space path loss using the formula described in 3GPP TR 38.811,
256 * Table 6.6.2
257 *
258 * @param freq the operating frequency
259 * @param dist3d the 3D distance between the communicating nodes
260 *
261 * @return the path loss for NTN scenarios
262 */
263double
264ComputeNtnPathloss(double freq, double dist3d)
265{
266 return 32.45 + 20 * log10(freq / 1e9) + 20 * log10(dist3d);
267}
268
269/**
270 * @brief Computes the atmospheric absorption loss using the formula described in 3GPP TR 38.811,
271 * Sec 6.6.4
272 *
273 * @param freq the operating frequency
274 * @param elevAngle the elevation angle between the communicating nodes
275 *
276 * @return the atmospheric absorption loss for NTN scenarios
277 */
278double
279ComputeAtmosphericAbsorptionLoss(double freq, double elevAngle)
280{
281 double loss = 0;
282 if ((elevAngle < 10 && freq > 1e9) || freq >= 10e9)
283 {
284 int roundedFreq = round(freq / 10e8);
285 loss += atmosphericAbsorption[roundedFreq] / sin(elevAngle * (M_PI / 180));
286 }
287
288 return loss;
289}
290
291/**
292 * @brief Computes the ionospheric plus tropospheric scintillation loss using the formulas
293 * described in 3GPP TR 38.811, Sec 6.6.6.1-4 and 6.6.6.2, respectively.
294 *
295 * The ionospheric term applies below 6 GHz and the tropospheric term at 6 GHz
296 * and above; either can be excluded via its enable flag.
297 *
298 * @param freq the operating frequency
299 * @param elevAngleQuantized the quantized elevation angle between the communicating nodes
300 * @param ionoScintLossEnabled whether to apply the ionospheric scintillation loss
301 * @param tropoScintLossEnabled whether to apply the tropospheric scintillation loss
302 *
303 * @return the ionospheric plus tropospheric scintillation loss for NTN scenarios
304 */
305double
307 double elevAngleQuantized,
308 bool ionoScintLossEnabled,
309 bool tropoScintLossEnabled)
310{
311 double loss = 0;
312 if (freq < 6e9)
313 {
314 // Ionospheric
315 if (ionoScintLossEnabled)
316 {
317 loss = 6.22 / (pow(freq / 1e9, 1.5));
318 }
319 }
320 else
321 {
322 // Tropospheric
323 if (tropoScintLossEnabled)
324 {
325 loss = troposphericScintillationLoss.at(elevAngleQuantized);
326 }
327 }
328 return loss;
329}
330
331/**
332 * @brief Computes the clutter loss using the formula
333 * described in 3GPP TR 38.811, Sec 6.6.6.1-4 and 6.6.6.2, respectively.
334 *
335 * @param freq the operating frequency
336 * @param elevAngleQuantized the quantized elevation angle between the communicating nodes
337 * @param sfcl the nested map containing the Shadow Fading and
338 * Clutter Loss values for the NTN Suburban and Rural scenario
339 *
340 * @return the clutter loss for NTN scenarios
341 */
342double
344 const std::map<int, std::vector<float>>* sfcl,
345 double elevAngleQuantized)
346{
347 double loss = 0;
348 if (freq < 13.0e9)
349 {
350 loss += (*sfcl).at(elevAngleQuantized)[SFCL_params::S_NLOS_CL]; // Get the Clutter Loss for
351 // the S Band
352 }
353 else
354 {
355 loss += (*sfcl).at(elevAngleQuantized)[SFCL_params::Ka_NLOS_CL]; // Get the Clutter Loss for
356 // the Ka Band
357 }
358
359 return loss;
360}
361
362constexpr double M_C = 299792458.0; //!< speed of light in vacuum [m/s] (@issueid{1092})
363
364} // namespace
365
366namespace ns3
367{
368
369NS_LOG_COMPONENT_DEFINE("ThreeGppPropagationLossModel");
370
371NS_OBJECT_ENSURE_REGISTERED(ThreeGppPropagationLossModel);
372
373TypeId
375{
376 static TypeId tid =
377 TypeId("ns3::ThreeGppPropagationLossModel")
379 .SetGroupName("Propagation")
380 .AddAttribute("Frequency",
381 "The centre frequency in Hz.",
382 DoubleValue(500.0e6),
386 .AddAttribute("ShadowingEnabled",
387 "Enable/disable shadowing.",
388 BooleanValue(true),
391 .AddAttribute(
392 "ChannelConditionModel",
393 "Pointer to the channel condition model.",
394 PointerValue(),
398 .AddAttribute("EnforceParameterRanges",
399 "Whether to strictly enforce TR38.901 applicability ranges",
400 BooleanValue(false),
403 .AddAttribute(
404 "BuildingPenetrationLossesEnabled",
405 "Enable/disable Building Penetration Losses.",
406 BooleanValue(true),
409 .AddAttribute("MeanVehicularLoss",
410 "9dB for standard cars, 20dB for cars with "
411 "metal coated glass panels.",
412 DoubleValue(9),
415 return tid;
416}
417
420{
421 NS_LOG_FUNCTION(this);
422
423 // initialize the normal random variables
425 m_normRandomVariable->SetAttribute("Mean", DoubleValue(0));
426 m_normRandomVariable->SetAttribute("Variance", DoubleValue(1));
427
430
432 m_normalO2iLowLossVar->SetAttribute("Mean", DoubleValue(0));
433 m_normalO2iLowLossVar->SetStdDev(kO2iLowLossStd);
434
436 m_normalO2iHighLossVar->SetAttribute("Mean", DoubleValue(0));
437 m_normalO2iHighLossVar->SetStdDev(kO2iHighLossStd);
438
440 // mean is set via an attribute, so must be set in NotifyConstructionCompleted
441 m_normalO2iVehicularLossVar->SetStdDev(5);
442}
443
448
449void
456
457void
462
463void
469
476
477void
479{
480 NS_LOG_FUNCTION(this);
481 NS_ASSERT_MSG(f >= 500.0e6 && f <= 100.0e9,
482 "Frequency should be between 0.5 and 100 GHz but is " << f);
483 m_frequency = f;
484}
485
486double
492
493bool
498
499double
502 Ptr<MobilityModel> b) const
503{
504 NS_LOG_FUNCTION(this);
505
506 // check if the model is initialized
507 NS_ASSERT_MSG(m_frequency != 0.0, "First set the centre frequency");
508
509 // retrieve the channel condition
510 NS_ASSERT_MSG(m_channelConditionModel, "First set the channel condition model");
511 Ptr<ChannelCondition> cond = m_channelConditionModel->GetChannelCondition(a, b);
512
513 double rxPow = txPowerDbm;
514 rxPow -= GetLoss(cond, a, b);
515
517 {
518 rxPow -= GetShadowing(a, b, cond->GetLosCondition());
519 }
520
521 // get o2i losses
523 ((cond->GetO2iCondition() == ChannelCondition::O2iConditionValue::O2I) ||
524 (cond->GetO2iCondition() == ChannelCondition::O2iConditionValue::I2I &&
525 cond->GetLosCondition() == ChannelCondition::LosConditionValue::NLOS)))
526 {
527 if (m_frequency < 6e9)
528 {
529 // TR 38.901 has a backward compatibility O2I penetration loss for sub 6GHz channels
530 rxPow -= GetO2iSub6GhzPenetrationLoss(a, b, cond->GetLosCondition());
531 }
532 else
533 {
534 if (IsO2iLowPenetrationLoss(cond))
535 {
536 rxPow -= GetO2iLowPenetrationLoss(a, b, cond->GetLosCondition());
537 }
538 else
539 {
540 rxPow -= GetO2iHighPenetrationLoss(a, b, cond->GetLosCondition());
541 }
542 }
543 }
544
545 rxPow -= GetO2iVehicularLoss(a, b, cond->GetO2iCondition());
546
547 return rxPow;
548}
549
550double
553 Ptr<MobilityModel> b) const
554{
555 NS_LOG_FUNCTION(this);
556
557 double loss = 0;
558 switch (cond->GetLosCondition())
559 {
561 loss = GetLossLos(a, b);
562 break;
564 loss = GetLossNlosv(a, b);
565 break;
567 loss = GetLossNlos(a, b);
568 break;
569 default:
570 NS_FATAL_ERROR("Unknown channel condition");
571 }
572
573 return loss;
574}
575
576double
581{
582 NS_LOG_FUNCTION(this);
583
584 if (m_channelConditionModel->IsInterUeSpatialConsistencyEnabled())
585 {
586 // Spatially consistent indoor distance at the terminal position
587 // (TR 38.901 Sec. 7.6.3.3), re-evaluated at every call instead of
588 // cached per link.
589 const Vector termPos =
590 m_channelConditionModel->GetSiteAndTerminal(a, b).second->GetPosition();
591 return 20 + 0.5 * SampleO2iDistance2dIn(termPos, GetO2iDistance2dInSub6GhzMax(), false);
592 }
593
594 double o2iLossValue = 0;
595 double lossTw = 0;
596 double lossIn = 0;
597 double lossNormalVariate = 0;
598
599 // compute the channel key
600 uint32_t key = GetKey(a, b);
601
602 bool notFound = false; // indicates if the o2iLoss value has not been computed yet
603 bool newCondition = false; // indicates if the channel condition has changed
604
605 auto it = m_o2iLossMap.end(); // the o2iLoss map iterator
606 if (m_o2iLossMap.find(key) != m_o2iLossMap.end())
607 {
608 // found the o2iLoss value in the map
609 it = m_o2iLossMap.find(key);
610 newCondition = (it->second.m_condition != cond); // true if the condition changed
611 }
612 else
613 {
614 notFound = true;
615 // add a new entry in the map and update the iterator
616 O2iLossMapItem newItem;
617 it = m_o2iLossMap.insert(it, std::make_pair(key, newItem));
618 }
619
620 if (notFound || newCondition)
621 {
622 // distance2dIn is a single, link-specific, uniformly distributed variable
623 // between 0 and 25 m for UMa and UMi-Street Canyon.
624 double distance2dIn = GetO2iDistance2dInSub6Ghz();
625
626 // calculate penetration losses, see TR 38.901 Table 7.4.3-3
627 lossTw = 20;
628
629 // calculate indoor loss
630 lossIn = 0.5 * distance2dIn;
631
632 // calculate low loss standard deviation
633 lossNormalVariate = 0;
634
635 o2iLossValue = lossTw + lossIn + lossNormalVariate;
636
637 // update the entry in the map
638 it->second.m_o2iLoss = o2iLossValue;
639 it->second.m_condition = cond;
640 }
641 else
642 {
643 o2iLossValue = it->second.m_o2iLoss;
644 }
645
646 return o2iLossValue;
647}
648
649double
654{
655 NS_LOG_FUNCTION(this);
656
657 if (m_channelConditionModel->IsInterUeSpatialConsistencyEnabled())
658 {
659 // Spatially consistent indoor distance and penetration loss deviation at the terminal
660 // position (TR 38.901 Sec. 7.6.3.3), re-evaluated at every call instead of cached per link.
661 const Vector termPos =
662 m_channelConditionModel->GetSiteAndTerminal(a, b).second->GetPosition();
663 return O2iLowLossTw(m_frequency) +
664 0.5 * SampleO2iDistance2dIn(termPos, GetO2iDistance2dInMax(), true) +
665 kO2iLowLossStd *
666 kO2iPenetrationField.Sample(DEVIATION,
667 termPos,
668 kPenetrationDeviationCorrelationDistance);
669 }
670
671 double o2iLossValue = 0;
672 double lowLossTw = 0;
673 double lossIn = 0;
674 double lowlossNormalVariate = 0;
675
676 // compute the channel key
677 uint32_t key = GetKey(a, b);
678
679 bool notFound = false; // indicates if the o2iLoss value has not been computed yet
680 bool newCondition = false; // indicates if the channel condition has changed
681
682 auto it = m_o2iLossMap.end(); // the o2iLoss map iterator
683 if (m_o2iLossMap.find(key) != m_o2iLossMap.end())
684 {
685 // found the o2iLoss value in the map
686 it = m_o2iLossMap.find(key);
687 newCondition = (it->second.m_condition != cond); // true if the condition changed
688 }
689 else
690 {
691 notFound = true;
692 // add a new entry in the map and update the iterator
693 O2iLossMapItem newItem;
694 it = m_o2iLossMap.insert(it, std::make_pair(key, newItem));
695 }
696
697 if (notFound || newCondition)
698 {
699 // distance2dIn is minimum of two independently generated uniformly distributed
700 // variables between 0 and 25 m for UMa and UMi-Street Canyon, and between 0 and
701 // 10 m for RMa. 2D−in d shall be UT-specifically generated.
702 double distance2dIn = GetO2iDistance2dIn();
703
704 // calculate material penetration losses, see TR 38.901 Table 7.4.3-1
705 lowLossTw = O2iLowLossTw(m_frequency);
706
707 // calculate indoor loss
708 lossIn = 0.5 * distance2dIn;
709
710 // calculate low loss standard deviation
711 lowlossNormalVariate = m_normalO2iLowLossVar->GetValue();
712
713 o2iLossValue = lowLossTw + lossIn + lowlossNormalVariate;
714
715 // update the entry in the map
716 it->second.m_o2iLoss = o2iLossValue;
717 it->second.m_condition = cond;
718 }
719 else
720 {
721 o2iLossValue = it->second.m_o2iLoss;
722 }
723
724 return o2iLossValue;
725}
726
727double
732{
733 NS_LOG_FUNCTION(this);
734
735 if (m_channelConditionModel->IsInterUeSpatialConsistencyEnabled())
736 {
737 // Spatially consistent indoor distance and penetration loss deviation at the terminal
738 // position (TR 38.901 Sec. 7.6.3.3), re-evaluated at every call instead of cached per link.
739 const Vector termPos =
740 m_channelConditionModel->GetSiteAndTerminal(a, b).second->GetPosition();
741 return O2iHighLossTw(m_frequency) +
742 0.5 * SampleO2iDistance2dIn(termPos, GetO2iDistance2dInMax(), true) +
743 kO2iHighLossStd *
744 kO2iPenetrationField.Sample(DEVIATION,
745 termPos,
746 kPenetrationDeviationCorrelationDistance);
747 }
748
749 double o2iLossValue = 0;
750 double highLossTw = 0;
751 double lossIn = 0;
752 double highlossNormalVariate = 0;
753
754 // compute the channel key
755 uint32_t key = GetKey(a, b);
756
757 bool notFound = false; // indicates if the o2iLoss value has not been computed yet
758 bool newCondition = false; // indicates if the channel condition has changed
759
760 auto it = m_o2iLossMap.end(); // the o2iLoss map iterator
761 if (m_o2iLossMap.find(key) != m_o2iLossMap.end())
762 {
763 // found the o2iLoss value in the map
764 it = m_o2iLossMap.find(key);
765 newCondition = (it->second.m_condition != cond); // true if the condition changed
766 }
767 else
768 {
769 notFound = true;
770 // add a new entry in the map and update the iterator
771 O2iLossMapItem newItem;
772 it = m_o2iLossMap.insert(it, std::make_pair(key, newItem));
773 }
774
775 if (notFound || newCondition)
776 {
777 // generate a new independent realization
778
779 // distance2dIn is minimum of two independently generated uniformly distributed
780 // variables between 0 and 25 m for UMa and UMi-Street Canyon, and between 0 and
781 // 10 m for RMa. 2D−in d shall be UT-specifically generated.
782 double distance2dIn = GetO2iDistance2dIn();
783
784 // calculate material penetration losses, see TR 38.901 Table 7.4.3-1
785 highLossTw = O2iHighLossTw(m_frequency);
786
787 // calculate indoor loss
788 lossIn = 0.5 * distance2dIn;
789
790 // calculate low loss standard deviation
791 highlossNormalVariate = m_normalO2iHighLossVar->GetValue();
792
793 o2iLossValue = highLossTw + lossIn + highlossNormalVariate;
794
795 // update the entry in the map
796 it->second.m_o2iLoss = o2iLossValue;
797 it->second.m_condition = cond;
798 }
799 else
800 {
801 o2iLossValue = it->second.m_o2iLoss;
802 }
803
804 return o2iLossValue;
805}
806
807bool
809{
810 if (cond->GetO2iLowHighCondition() == ChannelCondition::O2iLowHighConditionValue::LOW)
811 {
812 return true;
813 }
814 else if (cond->GetO2iLowHighCondition() == ChannelCondition::O2iLowHighConditionValue::HIGH)
815 {
816 return false;
817 }
818 else
819 {
820 NS_ABORT_MSG("If we have set the O2I condition, we shouldn't be here");
821 }
822}
823
824double
826{
827 NS_LOG_FUNCTION(this);
828 NS_FATAL_ERROR("Unsupported channel condition (NLOSv)");
829 return 0;
830}
831
832double
836{
837 NS_LOG_FUNCTION(this);
838
839 if (m_channelConditionModel->IsInterUeSpatialConsistencyEnabled())
840 {
841 // Drop-based spatial consistency (TR 38.901 Sec. 7.6.3.1): draw the
842 // shadow-fading realization from a per-site spatially-correlated
843 // Gaussian field sampled at the terminal position, instead of the
844 // per-link displacement-autocorrelated map below. Re-evaluating the
845 // field at a moving terminal's successive positions reproduces the
846 // temporal correlation automatically, so no map bookkeeping is needed.
847 const auto [site, terminal] = m_channelConditionModel->GetSiteAndTerminal(a, b);
848 const uint32_t siteNodeId = site->GetObject<Node>()->GetId();
849 const Vector termPos = terminal->GetPosition();
850 // O2I links own a third field with the O2I correlation distance of
851 // Table 7.5-6, as the spec treats O2I as its own state.
852 const bool isO2i = m_channelConditionModel->GetChannelCondition(a, b)->GetO2iCondition() ==
854 const uint8_t condSlot = isO2i ? 2 : (cond == ChannelCondition::LOS ? 0 : 1);
855 const double corrDist =
857 return SampleSpatiallyCorrelatedNormal(siteNodeId, condSlot, termPos, corrDist) *
858 GetShadowingStd(a, b, cond);
859 }
860
861 double shadowingValue;
862
863 // compute the channel key
864 uint32_t key = GetKey(a, b);
865
866 bool notFound = false; // indicates if the shadowing value has not been computed yet
867 bool newCondition = false; // indicates if the channel condition has changed
868 Vector newDistance; // the distance vector, that is not a distance but a difference
869 auto it = m_shadowingMap.end(); // the shadowing map iterator
870 if (m_shadowingMap.find(key) != m_shadowingMap.end())
871 {
872 // found the shadowing value in the map
873 it = m_shadowingMap.find(key);
874 newDistance = GetVectorDifference(a, b);
875 newCondition = (it->second.m_condition != cond); // true if the condition changed
876 }
877 else
878 {
879 notFound = true;
880
881 // add a new entry in the map and update the iterator
882 ShadowingMapItem newItem;
883 it = m_shadowingMap.insert(it, std::make_pair(key, newItem));
884 }
885
886 if (notFound || newCondition)
887 {
888 // generate a new independent realization
889 shadowingValue = m_normRandomVariable->GetValue() * GetShadowingStd(a, b, cond);
890 }
891 else
892 {
893 // compute a new correlated shadowing loss
894 Vector2D displacement(newDistance.x - it->second.m_distance.x,
895 newDistance.y - it->second.m_distance.y);
896 double R = exp(-1 * displacement.GetLength() / GetShadowingCorrelationDistance(cond));
897 shadowingValue = R * it->second.m_shadowing + sqrt(1 - R * R) *
898 m_normRandomVariable->GetValue() *
899 GetShadowingStd(a, b, cond);
900 }
901
902 // update the entry in the map
903 it->second.m_shadowing = shadowingValue;
904 it->second.m_distance = newDistance; // Save the (0,0,0) vector in case it's the first time we
905 // are calculating this value
906 it->second.m_condition = cond;
907
908 return shadowingValue;
909}
910
911double
913{
914 NS_LOG_FUNCTION(this);
915 // Scenarios without an O2I column in TR 38.901 Table 7.5-6 (InH, NTN)
916 // reuse the NLOS correlation distance.
918}
919
920double
922 uint8_t condSlot,
923 const Vector& position,
924 double corrDist) const
925{
926 // One independent field per (site, condition slot).
927 const uint64_t fieldKey =
928 (static_cast<uint64_t>(siteNodeId) << 2) | static_cast<uint64_t>(condSlot);
929 return kShadowFadingField.Sample(fieldKey, position, corrDist);
930}
931
932int64_t
934{
935 NS_LOG_FUNCTION(this);
936
937 m_normRandomVariable->SetStream(stream);
938 m_randomO2iVar1->SetStream(stream + 1);
939 m_randomO2iVar2->SetStream(stream + 2);
940 m_normalO2iLowLossVar->SetStream(stream + 3);
941 m_normalO2iHighLossVar->SetStream(stream + 4);
942 m_normalO2iVehicularLossVar->SetStream(stream + 5);
943 return 6;
944}
945
946double
948{
949 double x = a.x - b.x;
950 double y = a.y - b.y;
951 double distance2D = sqrt(x * x + y * y);
952
953 return distance2D;
954}
955
958{
959 // use the nodes ids to obtain an unique key for the channel between a and b
960 // sort the nodes ids so that the key is reciprocal
961 uint32_t x1 = std::min(a->GetObject<Node>()->GetId(), b->GetObject<Node>()->GetId());
962 uint32_t x2 = std::max(a->GetObject<Node>()->GetId(), b->GetObject<Node>()->GetId());
963
964 // use the cantor function to obtain the key
965 uint32_t key = (((x1 + x2) * (x1 + x2 + 1)) / 2) + x2;
966
967 return key;
968}
969
970Vector
972{
973 uint32_t x1 = a->GetObject<Node>()->GetId();
974 uint32_t x2 = b->GetObject<Node>()->GetId();
975
976 if (x1 < x2)
977 {
978 return b->GetPosition() - a->GetPosition();
979 }
980 else
981 {
982 return a->GetPosition() - b->GetPosition();
983 }
984}
985
986double
991
992double
997
998double
1003
1004void
1011
1012double
1016{
1017 NS_LOG_FUNCTION(this);
1018 double o2iVehicularLoss = 0.0;
1019
1020 // O2I penetration loss for vehicles only applies between 600 MHz and 60 GHz.
1021 if (m_frequency >= 0.6e9 && m_frequency < 60e9)
1022 {
1023 for (const auto& mob : {a, b})
1024 {
1025 auto velocityKmH = mob->GetVelocity().GetLength() * 3.6;
1026 auto idNode = mob->GetObject<Node>()->GetId();
1027 // Slow nodes are considered as pedestrians (no loss)
1028 if (velocityKmH < 30)
1029 {
1030 m_o2iVehicularUtLossMap[idNode] = 0.0;
1031 }
1032 // Fast nodes are considered vehicles.
1033 // Create one loss per terminal, and reuse throughout simulation.
1034 else if (velocityKmH >= 30 && velocityKmH <= 120)
1035 {
1036 if (m_o2iVehicularUtLossMap.find(idNode) == m_o2iVehicularUtLossMap.end())
1037 {
1039 }
1040 }
1041 // Very fast nodes are not modeled
1042 else
1043 {
1044 m_o2iVehicularUtLossMap[idNode] = 0.0;
1046 "O2I loss for high-speed (>120 km/h) transit and satellites not implemented");
1047 }
1048
1049 // Sum vehicle individual losses
1051 {
1052 o2iVehicularLoss += m_o2iVehicularUtLossMap.at(idNode);
1053 }
1054 }
1055 }
1056 return o2iVehicularLoss;
1057}
1058
1059// ------------------------------------------------------------------------- //
1060
1062
1063TypeId
1065{
1066 static TypeId tid = TypeId("ns3::ThreeGppRmaPropagationLossModel")
1068 .SetGroupName("Propagation")
1069 .AddConstructor<ThreeGppRmaPropagationLossModel>()
1070 .AddAttribute("AvgBuildingHeight",
1071 "The average building height in meters.",
1072 DoubleValue(5.0),
1074 MakeDoubleChecker<double>(5.0, 50.0))
1075 .AddAttribute("AvgStreetWidth",
1076 "The average street width in meters.",
1077 DoubleValue(20.0),
1079 MakeDoubleChecker<double>(5.0, 50.0));
1080 return tid;
1081}
1082
1091
1096
1097double
1099{
1100 // distance2dIn is minimum of two independently generated uniformly distributed variables
1101 // between 0 and 10 m for RMa. 2D−in d shall be UT-specifically generated.
1102 return std::min(m_randomO2iVar1->GetValue(0, GetO2iDistance2dInMax()),
1103 m_randomO2iVar2->GetValue(0, GetO2iDistance2dInMax()));
1104}
1105
1106double
1111
1112bool
1114 [[maybe_unused]]) const
1115{
1116 // Based on 3GPP 38.901 7.4.3.1 in RMa only low losses are applied.
1117 // Therefore enforce low losses.
1118 return true;
1119}
1120
1121double
1123{
1124 NS_LOG_FUNCTION(this);
1125 NS_ASSERT_MSG(m_frequency <= 30.0e9,
1126 "RMa scenario is valid for frequencies between 0.5 and 30 GHz.");
1127
1128 auto [distance2D, distance3D, hBs, hUt] = GetBsUtDistancesAndHeights(a, b);
1129
1130 // check if hBS and hUT are within the specified validity range
1131 if (hUt < 1.0 || hUt > 10.0)
1132 {
1133 NS_ABORT_MSG_IF(m_enforceRanges, "Rma UT height out of range");
1135 "The height of the UT should be between 1 and 10 m (see TR 38.901, Table 7.4.1-1)");
1136 }
1137
1138 if (hBs < 10.0 || hBs > 150.0)
1139 {
1140 NS_ABORT_MSG_IF(m_enforceRanges, "Rma BS height out of range");
1142 "The height of the BS should be between 10 and 150 m (see TR 38.901, Table 7.4.1-1)");
1143 }
1144
1145 // NOTE The model is intended to be used for BS-UT links, however we may need to
1146 // compute the pathloss between two BSs or UTs, e.g., to evaluate the
1147 // interference. In order to apply the model, we need to retrieve the values of
1148 // hBS and hUT, but in these cases one of the two falls outside the validity
1149 // range and the warning message is printed (hBS for the UT-UT case and hUT
1150 // for the BS-BS case).
1151
1152 double distanceBp = GetBpDistance(m_frequency, hBs, hUt);
1153 NS_LOG_DEBUG("breakpoint distance " << distanceBp);
1155 distanceBp > 0,
1156 "Breakpoint distance is zero (divide-by-zero below); are either hBs or hUt = 0?");
1157
1158 // check if the distance is outside the validity range
1159 if (distance2D < 10.0 || distance2D > 10.0e3)
1160 {
1161 NS_ABORT_MSG_IF(m_enforceRanges, "Rma distance2D out of range");
1162 NS_LOG_WARN("The 2D distance is outside the validity range, the pathloss value may not be "
1163 "accurate");
1164 }
1165
1166 // compute the pathloss (see 3GPP TR 38.901, Table 7.4.1-1)
1167 double loss = 0;
1168 if (distance2D <= distanceBp)
1169 {
1170 // use PL1
1171 loss = Pl1(m_frequency, distance3D, m_h, m_w);
1172 }
1173 else
1174 {
1175 // use PL2
1176 loss = Pl1(m_frequency, distanceBp, m_h, m_w) + 40 * log10(distance3D / distanceBp);
1177 }
1178
1179 NS_LOG_DEBUG("Loss " << loss);
1180
1181 return loss;
1182}
1183
1184double
1186{
1187 NS_LOG_FUNCTION(this);
1188 NS_ASSERT_MSG(m_frequency <= 30.0e9,
1189 "RMa scenario is valid for frequencies between 0.5 and 30 GHz.");
1190
1191 auto [distance2D, distance3D, hBs, hUt] = GetBsUtDistancesAndHeights(a, b);
1192
1193 // check if hBs and hUt are within the validity range
1194 if (hUt < 1.0 || hUt > 10.0)
1195 {
1196 NS_ABORT_MSG_IF(m_enforceRanges, "Rma UT height out of range");
1198 "The height of the UT should be between 1 and 10 m (see TR 38.901, Table 7.4.1-1)");
1199 }
1200
1201 if (hBs < 10.0 || hBs > 150.0)
1202 {
1203 NS_ABORT_MSG_IF(m_enforceRanges, "Rma BS height out of range");
1205 "The height of the BS should be between 10 and 150 m (see TR 38.901, Table 7.4.1-1)");
1206 }
1207
1208 // NOTE The model is intended to be used for BS-UT links, however we may need to
1209 // compute the pathloss between two BSs or UTs, e.g., to evaluate the
1210 // interference. In order to apply the model, we need to retrieve the values of
1211 // hBS and hUT, but in these cases one of the two falls outside the validity
1212 // range and the warning message is printed (hBS for the UT-UT case and hUT
1213 // for the BS-BS case).
1214
1215 // check if the distance is outside the validity range
1216 if (distance2D < 10.0 || distance2D > 5.0e3)
1217 {
1218 NS_ABORT_MSG_IF(m_enforceRanges, "distance2D out of range");
1219 NS_LOG_WARN("The 2D distance is outside the validity range, the pathloss value may not be "
1220 "accurate");
1221 }
1222
1223 // compute the pathloss
1224 double plNlos = 161.04 - 7.1 * log10(m_w) + 7.5 * log10(m_h) -
1225 (24.37 - 3.7 * pow((m_h / hBs), 2)) * log10(hBs) +
1226 (43.42 - 3.1 * log10(hBs)) * (log10(distance3D) - 3.0) +
1227 20.0 * log10(m_frequency / 1e9) - (3.2 * pow(log10(11.75 * hUt), 2) - 4.97);
1228
1229 double loss = std::max(GetLossLos(a, b), plNlos);
1230
1231 NS_LOG_DEBUG("Loss " << loss);
1232
1233 return loss;
1234}
1235
1236double
1240{
1241 NS_LOG_FUNCTION(this);
1242 double shadowingStd;
1243
1245 {
1246 // compute the 2D distance between the two nodes
1247 double distance2d = Calculate2dDistance(a->GetPosition(), b->GetPosition());
1248
1249 // compute the breakpoint distance (see 3GPP TR 38.901, Table 7.4.1-1, note 5)
1250 double distanceBp = GetBpDistance(m_frequency, a->GetPosition().z, b->GetPosition().z);
1251
1252 if (distance2d <= distanceBp)
1253 {
1254 shadowingStd = 4.0;
1255 }
1256 else
1257 {
1258 shadowingStd = 6.0;
1259 }
1260 }
1262 {
1263 shadowingStd = 8.0;
1264 }
1265 else
1266 {
1267 NS_FATAL_ERROR("Unknown channel condition");
1268 }
1269
1270 return shadowingStd;
1271}
1272
1273double
1275{
1276 NS_LOG_FUNCTION(this);
1277 // See 3GPP TR 38.901, Table 7.5-6, O2I column
1278 return 120;
1279}
1280
1281double
1284{
1285 NS_LOG_FUNCTION(this);
1286 double correlationDistance;
1287
1288 // See 3GPP TR 38.901, Table 7.5-6
1290 {
1291 correlationDistance = 37;
1292 }
1294 {
1295 correlationDistance = 120;
1296 }
1297 else
1298 {
1299 NS_FATAL_ERROR("Unknown channel condition");
1300 }
1301
1302 return correlationDistance;
1303}
1304
1305double
1306ThreeGppRmaPropagationLossModel::Pl1(double frequency, double distance3D, double h, double /* w */)
1307{
1308 double loss = 20.0 * log10(40.0 * M_PI * distance3D * frequency / 1e9 / 3.0) +
1309 std::min(0.03 * pow(h, 1.72), 10.0) * log10(distance3D) -
1310 std::min(0.044 * pow(h, 1.72), 14.77) + 0.002 * log10(h) * distance3D;
1311 return loss;
1312}
1313
1314double
1315ThreeGppRmaPropagationLossModel::GetBpDistance(double frequency, double hA, double hB)
1316{
1317 double distanceBp = 2.0 * M_PI * hA * hB * frequency / M_C;
1318 return distanceBp;
1319}
1320
1321// ------------------------------------------------------------------------- //
1322
1324
1325TypeId
1327{
1328 static TypeId tid = TypeId("ns3::ThreeGppUmaPropagationLossModel")
1330 .SetGroupName("Propagation")
1331 .AddConstructor<ThreeGppUmaPropagationLossModel>();
1332 return tid;
1333}
1334
1343
1348
1349double
1350ThreeGppUmaPropagationLossModel::GetBpDistance(double hUt, double hBs, double distance2D) const
1351{
1352 NS_LOG_FUNCTION(this);
1353
1354 // compute g (d2D) (see 3GPP TR 38.901, Table 7.4.1-1, Note 1)
1355 double g = 0.0;
1356 if (distance2D > 18.0)
1357 {
1358 g = 5.0 / 4.0 * pow(distance2D / 100.0, 3) * exp(-distance2D / 150.0);
1359 }
1360
1361 // compute C (hUt, d2D) (see 3GPP TR 38.901, Table 7.4.1-1, Note 1)
1362 double c = 0.0;
1363 if (hUt >= 13.0)
1364 {
1365 c = pow((hUt - 13.0) / 10.0, 1.5) * g;
1366 }
1367
1368 // compute hE (see 3GPP TR 38.901, Table 7.4.1-1, Note 1)
1369 double prob = 1.0 / (1.0 + c);
1370 double hE = 0.0;
1371 if (m_uniformVar->GetValue() < prob)
1372 {
1373 hE = 1.0;
1374 }
1375 else
1376 {
1377 int random = m_uniformVar->GetInteger(12, std::max(12, (int)(hUt - 1.5)));
1378 hE = (double)floor(random / 3.0) * 3.0;
1379 }
1380
1381 // compute dBP' (see 3GPP TR 38.901, Table 7.4.1-1, Note 1)
1382 double distanceBp = 4 * (hBs - hE) * (hUt - hE) * m_frequency / M_C;
1383
1384 return distanceBp;
1385}
1386
1387double
1389{
1390 NS_LOG_FUNCTION(this);
1391
1392 auto [distance2D, distance3D, hBs, hUt] = GetBsUtDistancesAndHeights(a, b);
1393
1394 // check if hBS and hUT are within the validity range
1395 if (hUt < 1.5 || hUt > 22.5)
1396 {
1397 NS_ABORT_MSG_IF(m_enforceRanges, "Uma UT height out of range");
1399 "The height of the UT should be between 1.5 and 22.5 m (see TR 38.901, Table 7.4.1-1)");
1400 }
1401
1402 if (hBs != 25.0)
1403 {
1404 NS_ABORT_MSG_IF(m_enforceRanges, "Uma BS height out of range");
1405 NS_LOG_WARN("The height of the BS should be equal to 25 m (see TR 38.901, Table 7.4.1-1)");
1406 }
1407
1408 // NOTE The model is intended to be used for BS-UT links, however we may need to
1409 // compute the pathloss between two BSs or UTs, e.g., to evaluate the
1410 // interference. In order to apply the model, we need to retrieve the values of
1411 // hBS and hUT, but in these cases one of the two falls outside the validity
1412 // range and the warning message is printed (hBS for the UT-UT case and hUT
1413 // for the BS-BS case).
1414
1415 // compute the breakpoint distance (see 3GPP TR 38.901, Table 7.4.1-1, note 1)
1416 double distanceBp = GetBpDistance(hUt, hBs, distance2D);
1417 NS_LOG_DEBUG("breakpoint distance " << distanceBp);
1418
1419 // check if the distance is outside the validity range
1420 if (distance2D < 10.0 || distance2D > 5.0e3)
1421 {
1422 NS_ABORT_MSG_IF(m_enforceRanges, "Uma 2D distance out of range");
1423 NS_LOG_WARN("The 2D distance is outside the validity range, the pathloss value may not be "
1424 "accurate");
1425 }
1426
1427 // compute the pathloss (see 3GPP TR 38.901, Table 7.4.1-1)
1428 double loss = 0;
1429 if (distance2D <= distanceBp)
1430 {
1431 // use PL1
1432 loss = 28.0 + 22.0 * log10(distance3D) + 20.0 * log10(m_frequency / 1e9);
1433 }
1434 else
1435 {
1436 // use PL2
1437 loss = 28.0 + 40.0 * log10(distance3D) + 20.0 * log10(m_frequency / 1e9) -
1438 9.0 * log10(pow(distanceBp, 2) + pow(hBs - hUt, 2));
1439 }
1440
1441 NS_LOG_DEBUG("Loss " << loss);
1442
1443 return loss;
1444}
1445
1446double
1448{
1449 // distance2dIn is minimum of two independently generated uniformly distributed variables
1450 // between 0 and 25 m for UMa and UMi-Street Canyon. 2D−in d shall be UT-specifically generated.
1451 return std::min(m_randomO2iVar1->GetValue(0, GetO2iDistance2dInMax()),
1452 m_randomO2iVar2->GetValue(0, GetO2iDistance2dInMax()));
1453}
1454
1455double
1457{
1458 // distance2dIn is a single, link-specific, uniformly distributed variable between 0 and 25 m.
1459 return m_randomO2iVar1->GetValue(0, GetO2iDistance2dInSub6GhzMax());
1460}
1461
1462double
1467
1468double
1473
1474double
1476{
1477 NS_LOG_FUNCTION(this);
1478
1479 auto [distance2D, distance3D, hBs, hUt] = GetBsUtDistancesAndHeights(a, b);
1480
1481 // check if hBS and hUT are within the validity range
1482 if (hUt < 1.5 || hUt > 22.5)
1483 {
1484 NS_ABORT_MSG_IF(m_enforceRanges, "Uma UT height out of range");
1486 "The height of the UT should be between 1.5 and 22.5 m (see TR 38.901, Table 7.4.1-1)");
1487 }
1488
1489 if (hBs != 25.0)
1490 {
1491 NS_ABORT_MSG_IF(m_enforceRanges, "Uma BS height out of range");
1492 NS_LOG_WARN("The height of the BS should be equal to 25 m (see TR 38.901, Table 7.4.1-1)");
1493 }
1494
1495 // NOTE The model is intended to be used for BS-UT links, however we may need to
1496 // compute the pathloss between two BSs or UTs, e.g., to evaluate the
1497 // interference. In order to apply the model, we need to retrieve the values of
1498 // hBS and hUT, but in these cases one of the two falls outside the validity
1499 // range and the warning message is printed (hBS for the UT-UT case and hUT
1500 // for the BS-BS case).
1501
1502 // check if the distance is outside the validity range
1503 if (distance2D < 10.0 || distance2D > 5.0e3)
1504 {
1505 NS_ABORT_MSG_IF(m_enforceRanges, "Uma 2D distance out of range");
1506 NS_LOG_WARN("The 2D distance is outside the validity range, the pathloss value may not be "
1507 "accurate");
1508 }
1509
1510 // compute the pathloss
1511 double plNlos =
1512 13.54 + 39.08 * log10(distance3D) + 20.0 * log10(m_frequency / 1e9) - 0.6 * (hUt - 1.5);
1513 double loss = std::max(GetLossLos(a, b), plNlos);
1514 NS_LOG_DEBUG("Loss " << loss);
1515
1516 return loss;
1517}
1518
1519double
1521 Ptr<MobilityModel> /* b */,
1523{
1524 NS_LOG_FUNCTION(this);
1525 double shadowingStd;
1526 if (m_frequency < 6e9)
1527 {
1528 shadowingStd = 7.0;
1529 }
1530 else
1531 {
1533 {
1534 shadowingStd = 4.0;
1535 }
1537 {
1538 shadowingStd = 6.0;
1539 }
1540 else
1541 {
1542 NS_FATAL_ERROR("Unknown channel condition");
1543 }
1544 }
1545 return shadowingStd;
1546}
1547
1548double
1550{
1551 NS_LOG_FUNCTION(this);
1552 // See 3GPP TR 38.901, Table 7.5-6, O2I column
1553 return 7;
1554}
1555
1556double
1559{
1560 NS_LOG_FUNCTION(this);
1561 double correlationDistance;
1562
1563 // See 3GPP TR 38.901, Table 7.5-6
1565 {
1566 correlationDistance = 37;
1567 }
1569 {
1570 correlationDistance = 50;
1571 }
1572 else
1573 {
1574 NS_FATAL_ERROR("Unknown channel condition");
1575 }
1576
1577 return correlationDistance;
1578}
1579
1580int64_t
1582{
1583 NS_LOG_FUNCTION(this);
1584
1585 int64_t streams = ThreeGppPropagationLossModel::DoAssignStreams(stream);
1586 m_uniformVar->SetStream(stream + streams);
1587 return streams + 1;
1588}
1589
1590// ------------------------------------------------------------------------- //
1591
1593
1594TypeId
1596{
1597 static TypeId tid = TypeId("ns3::ThreeGppUmiStreetCanyonPropagationLossModel")
1599 .SetGroupName("Propagation")
1601 return tid;
1602}
1603
1612
1617
1618double
1620 double hBs,
1621 double /* distance2D */) const
1622{
1623 NS_LOG_FUNCTION(this);
1624
1625 // compute hE (see 3GPP TR 38.901, Table 7.4.1-1, Note 1)
1626 double hE = 1.0;
1627
1628 // compute dBP' (see 3GPP TR 38.901, Table 7.4.1-1, Note 1)
1629 double distanceBp = 4 * (hBs - hE) * (hUt - hE) * m_frequency / M_C;
1630
1631 return distanceBp;
1632}
1633
1634double
1636{
1637 // distance2dIn is minimum of two independently generated uniformly distributed variables
1638 // between 0 and 25 m for UMa and UMi-Street Canyon. 2D−in d shall be UT-specifically generated.
1639 return std::min(m_randomO2iVar1->GetValue(0, GetO2iDistance2dInMax()),
1640 m_randomO2iVar2->GetValue(0, GetO2iDistance2dInMax()));
1641}
1642
1643double
1645{
1646 // distance2dIn is a single, link-specific, uniformly distributed variable between 0 and 25 m.
1647 return m_randomO2iVar1->GetValue(0, GetO2iDistance2dInSub6GhzMax());
1648}
1649
1650double
1655
1656double
1661
1662double
1664 Ptr<MobilityModel> b) const
1665{
1666 NS_LOG_FUNCTION(this);
1667
1668 double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
1669 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
1670 auto [hBs, hUt] = GetBsUtHeightsUmiStreetCanyon(a->GetPosition().z, b->GetPosition().z);
1671
1672 // check if hBS and hUT are within the validity range
1673 if (hUt < 1.5 || hUt >= 10.0)
1674 {
1675 NS_ABORT_MSG_IF(m_enforceRanges, "UmiStreetCanyon UT height out of range");
1677 "The height of the UT should be between 1.5 and 22.5 m (see TR 38.901, Table 7.4.1-1). "
1678 "We further assume hUT < hBS, then hUT is upper bounded by hBS, which should be 10 m");
1679 }
1680
1681 if (hBs != 10.0)
1682 {
1683 NS_ABORT_MSG_IF(m_enforceRanges, "UmiStreetCanyon BS height out of range");
1684 NS_LOG_WARN("The height of the BS should be equal to 10 m (see TR 38.901, Table 7.4.1-1)");
1685 }
1686
1687 // NOTE The model is intended to be used for BS-UT links, however we may need to
1688 // compute the pathloss between two BSs or UTs, e.g., to evaluate the
1689 // interference. In order to apply the model, we need to retrieve the values of
1690 // hBS and hUT, but in these cases one of the two falls outside the validity
1691 // range and the warning message is printed (hBS for the UT-UT case and hUT
1692 // for the BS-BS case).
1693
1694 // compute the breakpoint distance (see 3GPP TR 38.901, Table 7.4.1-1, note 1)
1695 double distanceBp = GetBpDistance(hUt, hBs, distance2D);
1696 NS_LOG_DEBUG("breakpoint distance " << distanceBp);
1697
1698 // check if the distance is outside the validity range
1699 if (distance2D < 10.0 || distance2D > 5.0e3)
1700 {
1701 NS_ABORT_MSG_IF(m_enforceRanges, "UmiStreetCanyon 2D distance out of range");
1702 NS_LOG_WARN("The 2D distance is outside the validity range, the pathloss value may not be "
1703 "accurate");
1704 }
1705
1706 // compute the pathloss (see 3GPP TR 38.901, Table 7.4.1-1)
1707 double loss = 0;
1708 if (distance2D <= distanceBp)
1709 {
1710 // use PL1
1711 loss = 32.4 + 21.0 * log10(distance3D) + 20.0 * log10(m_frequency / 1e9);
1712 }
1713 else
1714 {
1715 // use PL2
1716 loss = 32.4 + 40.0 * log10(distance3D) + 20.0 * log10(m_frequency / 1e9) -
1717 9.5 * log10(pow(distanceBp, 2) + pow(hBs - hUt, 2));
1718 }
1719
1720 NS_LOG_DEBUG("Loss " << loss);
1721
1722 return loss;
1723}
1724
1725double
1727 Ptr<MobilityModel> b) const
1728{
1729 NS_LOG_FUNCTION(this);
1730
1731 double distance2D = Calculate2dDistance(a->GetPosition(), b->GetPosition());
1732 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
1733 auto [hBs, hUt] = GetBsUtHeightsUmiStreetCanyon(a->GetPosition().z, b->GetPosition().z);
1734
1735 // check if hBS and hUT are within the validity range
1736 if (hUt < 1.5 || hUt >= 10.0)
1737 {
1738 NS_ABORT_MSG_IF(m_enforceRanges, "UmiStreetCanyon UT height out of range");
1740 "The height of the UT should be between 1.5 and 22.5 m (see TR 38.901, Table 7.4.1-1). "
1741 "We further assume hUT < hBS, then hUT is upper bounded by hBS, which should be 10 m");
1742 }
1743
1744 if (hBs != 10.0)
1745 {
1746 NS_ABORT_MSG_IF(m_enforceRanges, "UmiStreetCanyon BS height out of range");
1747 NS_LOG_WARN("The height of the BS should be equal to 10 m (see TR 38.901, Table 7.4.1-1)");
1748 }
1749
1750 // NOTE The model is intended to be used for BS-UT links, however we may need to
1751 // compute the pathloss between two BSs or UTs, e.g., to evaluate the
1752 // interference. In order to apply the model, we need to retrieve the values of
1753 // hBS and hUT, but in these cases one of the two falls outside the validity
1754 // range and the warning message is printed (hBS for the UT-UT case and hUT
1755 // for the BS-BS case).
1756
1757 // check if the distance is outside the validity range
1758 if (distance2D < 10.0 || distance2D > 5.0e3)
1759 {
1760 NS_ABORT_MSG_IF(m_enforceRanges, "UmiStreetCanyon 2D distance out of range");
1761 NS_LOG_WARN("The 2D distance is outside the validity range, the pathloss value may not be "
1762 "accurate");
1763 }
1764
1765 // compute the pathloss
1766 double plNlos =
1767 22.4 + 35.3 * log10(distance3D) + 21.3 * log10(m_frequency / 1e9) - 0.3 * (hUt - 1.5);
1768 double loss = std::max(GetLossLos(a, b), plNlos);
1769 NS_LOG_DEBUG("Loss " << loss);
1770
1771 return loss;
1772}
1773
1774double
1776 Ptr<MobilityModel> /* a */,
1777 Ptr<MobilityModel> /* b */,
1779{
1780 NS_LOG_FUNCTION(this);
1781 double shadowingStd;
1782
1783 if (m_frequency < 6e9)
1784 {
1785 shadowingStd = 7.0;
1786 }
1787 else
1788 {
1790 {
1791 shadowingStd = 4.0;
1792 }
1794 {
1795 shadowingStd = 7.82;
1796 }
1797 else
1798 {
1799 NS_FATAL_ERROR("Unknown channel condition");
1800 }
1801 }
1802 return shadowingStd;
1803}
1804
1805double
1807{
1808 NS_LOG_FUNCTION(this);
1809 // See 3GPP TR 38.901, Table 7.5-6, O2I column
1810 return 7;
1811}
1812
1813double
1816{
1817 NS_LOG_FUNCTION(this);
1818 double correlationDistance;
1819
1820 // See 3GPP TR 38.901, Table 7.5-6
1822 {
1823 correlationDistance = 10;
1824 }
1826 {
1827 correlationDistance = 13;
1828 }
1829 else
1830 {
1831 NS_FATAL_ERROR("Unknown channel condition");
1832 }
1833
1834 return correlationDistance;
1835}
1836
1837// ------------------------------------------------------------------------- //
1838
1840
1841TypeId
1843{
1844 static TypeId tid = TypeId("ns3::ThreeGppIndoorOfficePropagationLossModel")
1846 .SetGroupName("Propagation")
1848 return tid;
1849}
1850
1859
1864
1865double
1870
1871double
1873 Ptr<MobilityModel> b) const
1874{
1875 NS_LOG_FUNCTION(this);
1876
1877 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
1878
1879 // check if the distance is outside the validity range
1880 if (distance3D < 1.0 || distance3D > 150.0)
1881 {
1882 NS_ABORT_MSG_IF(m_enforceRanges, "IndoorOffice 3D distance out of range");
1883 NS_LOG_WARN("The 3D distance is outside the validity range, the pathloss value may not be "
1884 "accurate");
1885 }
1886
1887 // compute the pathloss (see 3GPP TR 38.901, Table 7.4.1-1)
1888 double loss = 32.4 + 17.3 * log10(distance3D) + 20.0 * log10(m_frequency / 1e9);
1889
1890 NS_LOG_DEBUG("Loss " << loss);
1891
1892 return loss;
1893}
1894
1895double
1897 Ptr<MobilityModel> b) const
1898{
1899 NS_LOG_FUNCTION(this);
1900
1901 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
1902
1903 // check if the distance is outside the validity range
1904 if (distance3D < 1.0 || distance3D > 150.0)
1905 {
1906 NS_ABORT_MSG_IF(m_enforceRanges, "IndoorOffice 3D distance out of range");
1907 NS_LOG_WARN("The 3D distance is outside the validity range, the pathloss value may not be "
1908 "accurate");
1909 }
1910
1911 // compute the pathloss
1912 double plNlos = 17.3 + 38.3 * log10(distance3D) + 24.9 * log10(m_frequency / 1e9);
1913 double loss = std::max(GetLossLos(a, b), plNlos);
1914
1915 NS_LOG_DEBUG("Loss " << loss);
1916
1917 return loss;
1918}
1919
1920double
1922 Ptr<MobilityModel> /* a */,
1923 Ptr<MobilityModel> /* b */,
1925{
1926 NS_LOG_FUNCTION(this);
1927 double shadowingStd;
1928
1930 {
1931 shadowingStd = 3.0;
1932 }
1934 {
1935 shadowingStd = 8.03;
1936 }
1937 else
1938 {
1939 NS_FATAL_ERROR("Unknown channel condition");
1940 }
1941
1942 return shadowingStd;
1943}
1944
1945double
1948{
1949 NS_LOG_FUNCTION(this);
1950
1951 // See 3GPP TR 38.901, Table 7.5-6
1952 double correlationDistance;
1953
1955 {
1956 correlationDistance = 10;
1957 }
1959 {
1960 correlationDistance = 6;
1961 }
1962 else
1963 {
1964 NS_FATAL_ERROR("Unknown channel condition");
1965 }
1966
1967 return correlationDistance;
1968}
1969
1971
1972TypeId
1974{
1975 static TypeId tid =
1976 TypeId("ns3::ThreeGppNTNPropagationLossModel")
1978 .SetGroupName("Propagation")
1979 .AddAttribute(
1980 "IonosphericScintillationLossEnabled",
1981 "Whether to apply the ionospheric scintillation loss "
1982 "(3GPP TR 38.811, Sec 6.6.6.1-4; applied below 6 GHz)",
1983 BooleanValue(true),
1986 .AddAttribute(
1987 "TroposphericScintillationLossEnabled",
1988 "Whether to apply the tropospheric scintillation loss "
1989 "(3GPP TR 38.811, Sec 6.6.6.2; applied at 6 GHz and above)",
1990 BooleanValue(true),
1993 return tid;
1994}
1995
1996double
2001
2002double
2004{
2005 NS_LOG_FUNCTION(this);
2006 NS_ASSERT_MSG(m_frequency <= 100.0e9,
2007 "NTN communications are valid for frequencies between 0.5 and 100 GHz.");
2008
2009 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
2010 auto [elevAngle, elevAngleQuantized] =
2012
2013 // Issue #1354: Avoid unbounded negative loss (gain) for ground-ground transmissions
2014 if (!std::isfinite(elevAngle) || elevAngle <= 0.0)
2015 {
2016 NS_LOG_DEBUG("Elevation angle " << elevAngle << " deg is non-positive, returning "
2017 << OUT_OF_DOMAIN_LOSS_DB << " dB loss");
2018 return OUT_OF_DOMAIN_LOSS_DB;
2019 }
2020
2021 // compute the pathloss (see 3GPP TR 38.811, Table 6.6.2)
2022 double loss = ComputeNtnPathloss(m_frequency, distance3D);
2023
2024 // Apply Atmospheric Absorption Loss 3GPP 38.811 6.6.4
2025 loss += ComputeAtmosphericAbsorptionLoss(m_frequency, elevAngle);
2026
2027 // Apply Ionospheric plus Tropospheric Scintillation Loss
2028 loss += ComputeIonosphericPlusTroposphericScintillationLoss(m_frequency,
2029 elevAngleQuantized,
2032
2033 NS_LOG_DEBUG("Loss " << loss);
2034 return loss;
2035}
2036
2037double
2039{
2040 NS_LOG_FUNCTION(this);
2041 NS_ASSERT_MSG(m_frequency <= 100.0e9,
2042 "NTN communications are valid for frequencies between 0.5 and 100 GHz.");
2043
2044 double distance3D = CalculateDistance(a->GetPosition(), b->GetPosition());
2045 auto [elevAngle, elevAngleQuantized] =
2047
2048 // Issue #1354: Avoid unbounded negative loss (gain) for ground-ground transmissions
2049 if (!std::isfinite(elevAngle) || elevAngle <= 0.0)
2050 {
2051 NS_LOG_DEBUG("Elevation angle " << elevAngle << " deg is non-positive, returning "
2052 << OUT_OF_DOMAIN_LOSS_DB << " dB loss");
2053 return OUT_OF_DOMAIN_LOSS_DB;
2054 }
2055
2056 // compute the pathloss (see 3GPP TR 38.811, Table 6.6.2)
2057 double loss = ComputeNtnPathloss(m_frequency, distance3D);
2058
2059 // Apply Clutter Loss
2060 loss += ComputeClutterLoss(m_frequency, m_SFCL, elevAngleQuantized);
2061
2062 // Apply Atmospheric Absorption Loss 3GPP 38.811 6.6.4
2063 loss += ComputeAtmosphericAbsorptionLoss(m_frequency, elevAngle);
2064
2065 // Apply Ionospheric plus Tropospheric Scintillation Loss
2066 loss += ComputeIonosphericPlusTroposphericScintillationLoss(m_frequency,
2067 elevAngleQuantized,
2070
2071 NS_LOG_DEBUG("Loss " << loss);
2072 return loss;
2073}
2074
2075double
2079{
2080 NS_LOG_FUNCTION(this);
2081 double shadowingStd;
2082
2083 std::string freqBand = (m_frequency < 13.0e9) ? "S" : "Ka";
2084 auto [elevAngle, elevAngleQuantized] =
2086
2087 // Assign Shadowing Standard Deviation according to table 6.6.2-1
2088 if (cond == ChannelCondition::LosConditionValue::LOS && freqBand == "S")
2089 {
2090 shadowingStd = (*m_SFCL).at(elevAngleQuantized)[SFCL_params::S_LOS_sigF];
2091 }
2092 else if (cond == ChannelCondition::LosConditionValue::LOS && freqBand == "Ka")
2093 {
2094 shadowingStd = (*m_SFCL).at(elevAngleQuantized)[SFCL_params::Ka_LOS_sigF];
2095 }
2096 else if (cond == ChannelCondition::LosConditionValue::NLOS && freqBand == "S")
2097 {
2098 shadowingStd = (*m_SFCL).at(elevAngleQuantized)[SFCL_params::S_NLOS_sigF];
2099 }
2100 else if (cond == ChannelCondition::LosConditionValue::NLOS && freqBand == "Ka")
2101 {
2102 shadowingStd = (*m_SFCL).at(elevAngleQuantized)[SFCL_params::Ka_NLOS_sigF];
2103 }
2104 else
2105 {
2106 NS_FATAL_ERROR("Unknown channel condition");
2107 }
2108
2109 return shadowingStd;
2110}
2111
2112double
2115{
2116 NS_LOG_FUNCTION(this);
2117 double correlationDistance;
2118
2120 {
2121 correlationDistance = m_shadowingCorrDistanceLos;
2122 }
2124 {
2125 correlationDistance = m_shadowingCorrDistanceNlos;
2126 }
2127 else
2128 {
2129 NS_FATAL_ERROR("Unknown channel condition");
2130 }
2131
2132 return correlationDistance;
2133}
2134
2136
2137TypeId
2139{
2140 static TypeId tid = TypeId("ns3::ThreeGppNTNDenseUrbanPropagationLossModel")
2142 .SetGroupName("Propagation")
2144 return tid;
2145}
2146
2157
2162
2163// ------------------------------------------------------------------------- //
2164
2166
2167TypeId
2169{
2170 static TypeId tid = TypeId("ns3::ThreeGppNTNUrbanPropagationLossModel")
2172 .SetGroupName("Propagation")
2173 .AddConstructor<ThreeGppNTNUrbanPropagationLossModel>();
2174 return tid;
2175}
2176
2187
2192
2193// ------------------------------------------------------------------------- //
2194
2196
2197TypeId
2199{
2200 static TypeId tid = TypeId("ns3::ThreeGppNTNSuburbanPropagationLossModel")
2202 .SetGroupName("Propagation")
2203 .AddConstructor<ThreeGppNTNSuburbanPropagationLossModel>();
2204 return tid;
2205}
2206
2217
2222
2223// ------------------------------------------------------------------------- //
2224
2226
2227TypeId
2229{
2230 static TypeId tid = TypeId("ns3::ThreeGppNTNRuralPropagationLossModel")
2232 .SetGroupName("Propagation")
2233 .AddConstructor<ThreeGppNTNRuralPropagationLossModel>();
2234 return tid;
2235}
2236
2247
2252
2253} // namespace ns3
cairo_uint64_t x
_cairo_uint_96by64_32x64_divrem:
uint32_t u
O2iConditionValue
Possible values for Outdoor to Indoor condition.
@ LOW
Low Penetration Losses.
@ HIGH
High Penetration Losses.
LosConditionValue
Possible values for Line-of-Sight condition.
@ NLOSv
Non Line of Sight due to a vehicle.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
A network Node.
Definition node.h:46
uint32_t GetId() const
Definition node.cc:106
AttributeValue implementation for Pointer.
Definition pointer.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Stateless, position-keyed, spatially-correlated Gaussian random field.
double Sample(uint64_t fieldKey, const Vector &position, double corrDist) const
Sample the spatially-correlated field at a position; a non-positive correlation distance degrades to ...
@ SHADOW_FADING
Shadow fading, ThreeGppPropagationLossModel.
@ O2I_PENETRATION
Indoor distance and penetration loss, ThreeGppPropagationLossModel.
static double Calculate2dDistance(const Vector &a, const Vector &b)
Computes the 2D distance between two 3D vectors.
static std::tuple< double, double > GetQuantizedElevationAngle(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b)
Computes and quantizes the elevation angle to a two-digits integer in [10, 90].
Implements the pathloss model defined in 3GPP TR 38.901, Table 7.4.1-1 for the Indoor Office scenario...
double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
double GetShadowingStd(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading standard deviation.
double GetO2iDistance2dIn() const override
Returns the minimum of the two independently generated distances according to the uniform distributio...
double GetLossNlos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Computes the pathloss between a and b considering that the line of sight is obstructed.
double GetLossLos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Computes the pathloss between a and b considering that the line of sight is not obstructed.
Implements the pathloss model defined in 3GPP TR 38.811, Sec.
Base class for the NTN pathloss models defined in 3GPP TR 38.811.
const std::map< int, std::vector< float > > * m_SFCL
The nested map containing the Shadow Fading and Clutter Loss values for the scenario,...
double GetO2iDistance2dIn() const override
Returns the minimum of the two independently generated distances according to the uniform distributio...
double GetShadowingStd(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading standard deviation.
double GetLossLos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Computes the pathloss between a and b considering that the line of sight is not obstructed.
double m_shadowingCorrDistanceLos
shadowing correlation distance for LOS, in meters
bool m_tropoScintLossEnabled
whether the tropospheric scintillation loss is applied
double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
bool m_ionoScintLossEnabled
whether the ionospheric scintillation loss is applied
double m_shadowingCorrDistanceNlos
shadowing correlation distance for NLOS, in meters
double GetLossNlos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Computes the pathloss between a and b considering that the line of sight is obstructed.
Implements the pathloss model defined in 3GPP TR 38.811, Sec.
Implements the pathloss model defined in 3GPP TR 38.811, Sec.
Implements the pathloss model defined in 3GPP TR 38.811, Sec.
Ptr< ChannelConditionModel > GetChannelConditionModel() const
Returns the associated channel condition model.
virtual double GetO2iLowPenetrationLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const
Retrieves the o2i building penetration loss value by looking at m_o2iLossMap.
Ptr< UniformRandomVariable > m_randomO2iVar2
a uniform random variable for the calculation of the indoor loss, see TR38.901 Table 7....
double m_meanVehicleO2iLoss
normal cars (9dB), cars with metal coated glass panels (20dB)
double GetFrequency() const
Return the current central frequency.
virtual double GetO2iShadowingCorrelationDistance() const
Returns the shadow fading correlation distance of O2I links (3GPP TR 38.901 Table 7....
double GetLoss(Ptr< ChannelCondition > cond, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Computes the pathloss between a and b.
Ptr< UniformRandomVariable > m_randomO2iVar1
a uniform random variable for the calculation of the indoor loss, see TR38.901 Table 7....
double GetShadowing(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const
Retrieves the shadowing value by looking at m_shadowingMap.
static double Calculate2dDistance(Vector a, Vector b)
Computes the 2D distance between two 3D vectors.
void SetChannelConditionModel(Ptr< ChannelConditionModel > model)
Set the channel condition model used to determine the channel state (e.g., the LOS/NLOS condition).
std::unordered_map< uint32_t, ShadowingMapItem > m_shadowingMap
map to store the shadowing values
virtual double GetLossNlos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const =0
Computes the pathloss between a and b considering that the line of sight is obstructed.
virtual bool DoIsO2iLowPenetrationLoss(Ptr< const ChannelCondition > cond) const
Indicates the condition of the o2i building penetration loss (defined in 3GPP TR 38....
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
virtual double GetLossNlosv(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Computes the pathloss between a and b considering that the line of sight is obstructed by a vehicle.
Ptr< NormalRandomVariable > m_normalO2iVehicularLossVar
a normal random variable for the calculation of penetration loss for vehicles see TR38....
virtual double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const =0
Returns the shadow fading correlation distance.
Ptr< NormalRandomVariable > m_normRandomVariable
normal random variable
Ptr< ChannelConditionModel > m_channelConditionModel
pointer to the channel condition model
void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
std::unordered_map< uint32_t, O2iLossMapItem > m_o2iLossMap
map to store the o2i Loss values
virtual double GetO2iDistance2dIn() const =0
Returns the minimum of the two independently generated distances according to the uniform distributio...
std::unordered_map< uint32_t, double > m_o2iVehicularUtLossMap
vehicular O2I loss for each individual UT with speed x, such that 30 < x <= 120 km/h.
virtual double GetO2iHighPenetrationLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const
Retrieves the o2i building penetration loss value by looking at m_o2iLossMap.
double SampleSpatiallyCorrelatedNormal(uint32_t siteNodeId, uint8_t condSlot, const Vector &position, double corrDist) const
Sample the SpatialGaussianField of shadow fading owned by a (site, condition slot) pair,...
bool IsO2iLowPenetrationLoss(Ptr< const ChannelCondition > cond) const
Return true if the O2I Building Penetration loss corresponds to a low loss condition.
virtual double GetO2iDistance2dInMax() const
Returns the upper bound of the uniform variables of the O2I 2D-in distance of GetO2iDistance2dIn(),...
virtual double GetO2iDistance2dInSub6Ghz() const
Returns a a single, link-specific, uniformly distributed variable value depending on the specific 3GP...
void SetFrequency(double f)
Set the central frequency of the model.
void ClearO2iLossCacheMap()
Clear cached O2I Building Penetration loss.
virtual double GetO2iDistance2dInSub6GhzMax() const
Returns the upper bound of the uniform variable of the O2I 2D-in distance of GetO2iDistance2dInSub6Gh...
void DoDispose() override
Destructor implementation.
static uint32_t GetKey(Ptr< MobilityModel > a, Ptr< MobilityModel > b)
Returns an unique key for the channel between a and b.
Ptr< NormalRandomVariable > m_normalO2iLowLossVar
a normal random variable for the calculation of 02i low loss, see TR38.901 Table 7....
bool m_enforceRanges
strictly enforce TR 38.901 parameter ranges
virtual double GetShadowingStd(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const =0
Returns the shadow fading standard deviation.
Ptr< NormalRandomVariable > m_normalO2iHighLossVar
a normal random variable for the calculation of 02i high loss, see TR38.901 Table 7....
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Computes the received power by applying the pathloss model described in 3GPP TR 38....
double GetO2iSub6GhzPenetrationLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const
Retrieves the o2i building penetration loss value by looking at m_o2iLossMap.
static Vector GetVectorDifference(Ptr< MobilityModel > a, Ptr< MobilityModel > b)
Get the difference between the node position.
bool m_buildingPenLossesEnabled
enable/disable building penetration losses
double GetO2iVehicularLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::O2iConditionValue cond) const
Computes the o2i vehicular penetration loss by looking at m_o2iVehicularUtLossMap.
virtual double GetLossLos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const =0
Computes the pathloss between a and b considering that the line of sight is not obstructed.
Implements the pathloss model defined in 3GPP TR 38.901, Table 7.4.1-1 for the RMa scenario.
double GetLossNlos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Computes the pathloss between a and b considering that the line of sight is obstructed.
double GetShadowingStd(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading standard deviation.
static double Pl1(double frequency, double distance3D, double h, double w)
Computes the PL1 formula for the RMa scenario.
double GetLossLos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Computes the pathloss between a and b considering that the line of sight is not obstructed.
double GetO2iDistance2dIn() const override
Returns the minimum of the two independently generated distances according to the uniform distributio...
double GetO2iDistance2dInMax() const override
Returns the upper bound of the uniform variables of the O2I 2D-in distance of GetO2iDistance2dIn(),...
double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
double m_h
average building height in meters
static double GetBpDistance(double frequency, double hA, double hB)
Computes the breakpoint distance for the RMa scenario.
bool DoIsO2iLowPenetrationLoss(Ptr< const ChannelCondition > cond) const override
Indicates the condition of the o2i building penetration loss (defined in 3GPP TR 38....
double GetO2iShadowingCorrelationDistance() const override
Returns the shadow fading correlation distance of O2I links (3GPP TR 38.901 Table 7....
Implements the pathloss model defined in 3GPP TR 38.901, Table 7.4.1-1 for the UMa scenario.
double GetLossNlos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Computes the pathloss between a and b considering that the line of sight is obstructed.
double GetBpDistance(double hUt, double hBs, double distance2D) const
Computes the breakpoint distance.
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
double GetLossLos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Computes the pathloss between a and b considering that the line of sight is not obstructed.
double GetO2iShadowingCorrelationDistance() const override
Returns the shadow fading correlation distance of O2I links (3GPP TR 38.901 Table 7....
double GetO2iDistance2dInMax() const override
Returns the upper bound of the uniform variables of the O2I 2D-in distance of GetO2iDistance2dIn(),...
double GetO2iDistance2dIn() const override
Returns the minimum of the two independently generated distances according to the uniform distributio...
double GetO2iDistance2dInSub6GhzMax() const override
Returns the upper bound of the uniform variable of the O2I 2D-in distance of GetO2iDistance2dInSub6Gh...
Ptr< UniformRandomVariable > m_uniformVar
a uniform random variable used for the computation of the breakpoint distance
double GetShadowingStd(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading standard deviation.
double GetO2iDistance2dInSub6Ghz() const override
Returns a a single, link-specific, uniformly distributed variable value depending on the specific 3GP...
double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
Implements the pathloss model defined in 3GPP TR 38.901, Table 7.4.1-1 for the UMi-Street Canyon scen...
double GetO2iShadowingCorrelationDistance() const override
Returns the shadow fading correlation distance of O2I links (3GPP TR 38.901 Table 7....
double GetO2iDistance2dInSub6Ghz() const override
Returns a a single, link-specific, uniformly distributed variable value depending on the specific 3GP...
double GetLossNlos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Computes the pathloss between a and b considering that the line of sight is obstructed.
double GetShadowingStd(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading standard deviation.
double GetBpDistance(double hUt, double hBs, double distance2D) const
Computes the breakpoint distance.
double GetO2iDistance2dIn() const override
Returns the minimum of the two independently generated distances according to the uniform distributio...
double GetLossLos(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
Computes the pathloss between a and b considering that the line of sight is not obstructed.
double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
double GetO2iDistance2dInMax() const override
Returns the upper bound of the uniform variables of the O2I 2D-in distance of GetO2iDistance2dIn(),...
double GetO2iDistance2dInSub6GhzMax() const override
Returns the upper bound of the uniform variable of the O2I 2D-in distance of GetO2iDistance2dInSub6Gh...
a unique identifier for an interface.
Definition type-id.h:50
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1003
a 2d vector
Definition vector.h:204
double GetLength() const
Compute the length (magnitude) of the vector.
Definition vector.cc:75
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:76
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition pointer.h:250
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:273
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
Definition abort.h:136
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition abort.h:38
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:99
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:201
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:267
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition log.h:260
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:627
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
const std::map< int, std::vector< float > > SFCL_SuburbanRural
The map containing the 3GPP value regarding Shadow Fading and Clutter Loss tables for the NTN Suburba...
const ns3::SpatialGaussianField kO2iPenetrationField
Indoor-distance and penetration-loss-deviation random fields, see SpatialGaussianField.
double SampleO2iDistance2dIn(const ns3::Vector &position, double maxDistance, bool minOfTwo)
Sample the spatially consistent O2I 2D-in distance at a terminal position (TR 38.901 Sec.
constexpr double kDistance2dInCorrelationDistance
Correlation distance of the uniform variables of the 2D-in distance, TR 38.901 Sec....
constexpr double kO2iHighLossStd
Standard deviation in dB of the high-loss penetration loss, TR 38.901 Table 7.4.3-2.
constexpr double M_C
speed of light in vacuum [m/s] (Issue 1092)
std::tuple< double, double, double, double > GetBsUtDistancesAndHeights(ns3::Ptr< const ns3::MobilityModel > a, ns3::Ptr< const ns3::MobilityModel > b)
Get the base station and user terminal relative distances and heights.
double ComputeAtmosphericAbsorptionLoss(double freq, double elevAngle)
Computes the atmospheric absorption loss using the formula described in 3GPP TR 38....
double O2iHighLossTw(double frequency)
High-loss O2I penetration loss through the external wall, TR 38.901 Table 7.4.3-2.
constexpr double kO2iLowLossStd
Standard deviation in dB of the low-loss penetration loss, TR 38.901 Table 7.4.3-2.
double ComputeIonosphericPlusTroposphericScintillationLoss(double freq, double elevAngleQuantized, bool ionoScintLossEnabled, bool tropoScintLossEnabled)
Computes the ionospheric plus tropospheric scintillation loss using the formulas described in 3GPP TR...
double ComputeNtnPathloss(double freq, double dist3d)
Computes the free-space path loss using the formula described in 3GPP TR 38.811, Table 6....
const ns3::SpatialGaussianField kShadowFadingField
Shadow-fading random fields, one per (site, condition), see SpatialGaussianField.
const double atmosphericAbsorption[101]
Array containing the attenuation given by atmospheric absorption.
const std::map< int, float > troposphericScintillationLoss
Map containing the Tropospheric attenuation in dB with 99% probability at 20 GHz in Toulouse used for...
const std::map< int, std::vector< float > > SFCL_Urban
The map containing the 3GPP value regarding Shadow Fading and Clutter Loss tables for the NTN Urban s...
double ComputeClutterLoss(double freq, const std::map< int, std::vector< float > > *sfcl, double elevAngleQuantized)
Computes the clutter loss using the formula described in 3GPP TR 38.811, Sec 6.6.6....
SFCL_params
The enumerator used for code clarity when performing parameter assignment in the GetLoss Methods.
constexpr double OUT_OF_DOMAIN_LOSS_DB
Finite, large loss returned for links outside the domain of the TR 38.811 model (non-positive elevati...
std::tuple< double, double > GetBsUtHeightsUmiStreetCanyon(double heightA, double heightB)
Get the base station and user terminal heights for the UmiStreetCanyon scenario.
const std::map< int, std::vector< float > > SFCL_DenseUrban
The map containing the 3GPP value regarding Shadow Fading and Clutter Loss tables for the NTN Dense U...
constexpr double kPenetrationDeviationCorrelationDistance
Correlation distance of the penetration loss deviation, TR 38.901 Sec. 7.6.3.3.
double O2iLowLossTw(double frequency)
Low-loss O2I penetration loss through the external wall, TR 38.901 Table 7.4.3-2.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition boolean.cc:113
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Definition vector.cc:96
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition boolean.h:70
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32