12#include "ns3/boolean.h" 
   13#include "ns3/double.h" 
   14#include "ns3/geocentric-constant-position-mobility-model.h" 
   16#include "ns3/mobility-model.h" 
   18#include "ns3/pointer.h" 
   19#include "ns3/simulator.h" 
   43    {10, {3.5, 15.5, 34.3, 2.9, 17.1, 44.3}},
 
   44    {20, {3.4, 13.9, 30.9, 2.4, 17.1, 39.9}},
 
   45    {30, {2.9, 12.4, 29.0, 2.7, 15.6, 37.5}},
 
   46    {40, {3.0, 11.7, 27.7, 2.4, 14.6, 35.8}},
 
   47    {50, {3.1, 10.6, 26.8, 2.4, 14.2, 34.6}},
 
   48    {60, {2.7, 10.5, 26.2, 2.7, 12.6, 33.8}},
 
   49    {70, {2.5, 10.1, 25.8, 2.6, 12.1, 33.3}},
 
   50    {80, {2.3, 9.2, 25.5, 2.8, 12.3, 33.0}},
 
   51    {90, {1.2, 9.2, 25.5, 0.6, 12.3, 32.9}},
 
 
   59    {10, {4, 6, 34.3, 4, 6, 44.3}},
 
   60    {20, {4, 6, 30.9, 4, 6, 39.9}},
 
   61    {30, {4, 6, 29.0, 4, 6, 37.5}},
 
   62    {40, {4, 6, 27.7, 4, 6, 35.8}},
 
   63    {50, {4, 6, 26.8, 4, 6, 34.6}},
 
   64    {60, {4, 6, 26.2, 4, 6, 33.8}},
 
   65    {70, {4, 6, 25.8, 4, 6, 33.3}},
 
   66    {80, {4, 6, 25.5, 4, 6, 33.0}},
 
   67    {90, {4, 6, 25.5, 4, 6, 32.9}},
 
 
   75    {10, {1.79, 8.93, 19.52, 1.9, 10.7, 29.5}},
 
   76    {20, {1.14, 9.08, 18.17, 1.6, 10.0, 24.6}},
 
   77    {30, {1.14, 8.78, 18.42, 1.9, 11.2, 21.9}},
 
   78    {40, {0.92, 10.25, 18.28, 2.3, 11.6, 20.0}},
 
   79    {50, {1.42, 10.56, 18.63, 2.7, 11.8, 18.7}},
 
   80    {60, {1.56, 10.74, 17.68, 3.1, 10.8, 17.8}},
 
   81    {70, {0.85, 10.17, 16.5, 3.0, 10.8, 17.2}},
 
   82    {80, {0.72, 11.52, 16.3, 3.6, 10.8, 16.9}},
 
   83    {90, {0.72, 11.52, 16.3, 0.4, 10.8, 16.8}},
 
 
   94    0,        0.0300,   0.0350,  0.0380,  0.0390,  0.0410,  0.0420,  0.0450,  0.0480,   0.0500,
 
   95    0.0530,   0.0587,   0.0674,  0.0789,  0.0935,  0.1113,  0.1322,  0.1565,  0.1841,   0.2153,
 
   96    0.2500,   0.3362,   0.4581,  0.5200,  0.5200,  0.5000,  0.4500,  0.3850,  0.3200,   0.2700,
 
   97    0.2500,   0.2517,   0.2568,  0.2651,  0.2765,  0.2907,  0.3077,  0.3273,  0.3493,   0.3736,
 
   98    0.4000,   0.4375,   0.4966,  0.5795,  0.6881,  0.8247,  0.9912,  1.1900,  1.4229,   1.6922,
 
   99    2.0000,   4.2654,   10.1504, 19.2717, 31.2457, 45.6890, 62.2182, 80.4496, 100.0000, 140.0205,
 
  100    170.0000, 100.0000, 78.1682, 59.3955, 43.5434, 30.4733, 20.0465, 12.1244, 6.5683,   3.2397,
 
  101    2.0000,   1.7708,   1.5660,  1.3858,  1.2298,  1.0981,  0.9905,  0.9070,  0.8475,   0.8119,
 
  102    0.8000,   0.8000,   0.8000,  0.8000,  0.8000,  0.8000,  0.8000,  0.8000,  0.8000,   0.8000,
 
  103    0.8000,   0.8029,   0.8112,  0.8243,  0.8416,  0.8625,  0.8864,  0.9127,  0.9408,   0.9701,
 
 
  132std::tuple<double, double, double, double>
 
  136    auto aPos = a->GetPosition();
 
  137    auto bPos = b->GetPosition();
 
  140    double hBs = std::max(aPos.z, bPos.z);
 
  141    double hUt = std::min(aPos.z, bPos.z);
 
  142    return std::make_tuple(distance2D, distance3D, hBs, hUt);
 
 
  153std::tuple<double, double>
 
  156    double hBs = (heightA == 10) ? heightA : heightB;
 
  157    double hUt = (heightA == 10) ? heightB : heightA;
 
  158    return std::make_tuple(hBs, hUt);
 
 
  173    return 32.45 + 20 * log10(freq / 1e9) + 20 * log10(dist3d);
 
 
  189    if ((elevAngle < 10 && freq > 1e9) || freq >= 10e9)
 
  191        int roundedFreq = round(freq / 10e8);
 
 
  214        loss = 6.22 / (pow(freq / 1e9, 1.5));
 
 
  237                   const std::map<
int, std::vector<float>>* sfcl,
 
  238                   double elevAngleQuantized)
 
 
  255constexpr double M_C = 3.0e8; 
 
 
  266std::function<Ptr<MobilityModel>(Ptr<const MobilityModel>, Ptr<const MobilityModel>)>
 
  273        TypeId(
"ns3::ThreeGppPropagationLossModel")
 
  275            .SetGroupName(
"Propagation")
 
  276            .AddAttribute(
"Frequency",
 
  277                          "The centre frequency in Hz.",
 
  282            .AddAttribute(
"ShadowingEnabled",
 
  283                          "Enable/disable shadowing.",
 
  288                "ChannelConditionModel",
 
  289                "Pointer to the channel condition model.",
 
  294            .AddAttribute(
"EnforceParameterRanges",
 
  295                          "Whether to strictly enforce TR38.901 applicability ranges",
 
  300                "BuildingPenetrationLossesEnabled",
 
  301                "Enable/disable Building Penetration Losses.",
 
 
  362                  "Frequency should be between 0.5 and 100 GHz but is " << f);
 
 
  388    if (a->GetPosition() != c->GetPosition())
 
  390        NS_LOG_DEBUG(
"Prologue function replaced source position " 
  391                     << c->GetPosition() << 
" with position " << a->GetPosition());
 
  401    double rxPow = txPowerDbm;
 
 
  436    switch (cond->GetLosCondition())
 
 
  462    double o2iLossValue = 0;
 
  463    double lowLossTw = 0;
 
  465    double lowlossNormalVariate = 0;
 
  467    double lConcrete = 0;
 
  472    bool notFound = 
false;     
 
  473    bool newCondition = 
false; 
 
  480        newCondition = (it->second.m_condition != cond); 
 
  487        it = 
m_o2iLossMap.insert(it, std::make_pair(key, newItem));
 
  490    if (notFound || newCondition)
 
  502            5 - 10 * log10(0.3 * std::pow(10, -lGlass / 10) + 0.7 * std::pow(10, -lConcrete / 10));
 
  505        lossIn = 0.5 * distance2dIn;
 
  510        o2iLossValue = lowLossTw + lossIn + lowlossNormalVariate;
 
  514        o2iLossValue = it->second.m_o2iLoss;
 
  518    it->second.m_o2iLoss = o2iLossValue;
 
  519    it->second.m_condition = cond;
 
 
  532    double o2iLossValue = 0;
 
  533    double highLossTw = 0;
 
  535    double highlossNormalVariate = 0;
 
  536    double lIIRGlass = 0;
 
  537    double lConcrete = 0;
 
  542    bool notFound = 
false;     
 
  543    bool newCondition = 
false; 
 
  550        newCondition = (it->second.m_condition != cond); 
 
  557        it = 
m_o2iLossMap.insert(it, std::make_pair(key, newItem));
 
  560    if (notFound || newCondition)
 
  573        highLossTw = 5 - 10 * log10(0.7 * std::pow(10, -lIIRGlass / 10) +
 
  574                                    0.3 * std::pow(10, -lConcrete / 10));
 
  577        lossIn = 0.5 * distance2dIn;
 
  582        o2iLossValue = highLossTw + lossIn + highlossNormalVariate;
 
  586        o2iLossValue = it->second.m_o2iLoss;
 
  590    it->second.m_o2iLoss = o2iLossValue;
 
  591    it->second.m_condition = cond;
 
 
  609        NS_ABORT_MSG(
"If we have set the O2I condition, we shouldn't be here");
 
 
  628    double shadowingValue;
 
  633    bool notFound = 
false;          
 
  634    bool newCondition = 
false;      
 
  642        newCondition = (it->second.m_condition != cond); 
 
  653    if (notFound || newCondition)
 
  661        Vector2D displacement(newDistance.x - it->second.m_distance.x,
 
  662                              newDistance.y - it->second.m_distance.y);
 
  664        shadowingValue = R * it->second.m_shadowing + sqrt(1 - R * R) *
 
  670    it->second.m_shadowing = shadowingValue;
 
  671    it->second.m_distance = newDistance; 
 
  673    it->second.m_condition = cond;
 
  675    return shadowingValue;
 
 
  695    double x = a.x - b.x;
 
  696    double y = a.y - b.y;
 
  697    double distance2D = sqrt(x * x + y * y);
 
 
  711    uint32_t key = (((x1 + x2) * (x1 + x2 + 1)) / 2) + x2;
 
 
  724        return b->GetPosition() - a->GetPosition();
 
  728        return a->GetPosition() - b->GetPosition();
 
 
  739    static TypeId tid = 
TypeId(
"ns3::ThreeGppRmaPropagationLossModel")
 
  741                            .SetGroupName(
"Propagation")
 
  743                            .AddAttribute(
"AvgBuildingHeight",
 
  744                                          "The average building height in meters.",
 
  748                            .AddAttribute(
"AvgStreetWidth",
 
  749                                          "The average street width in meters.",
 
 
  780                                                           [[maybe_unused]])
 const 
 
  792                  "RMa scenario is valid for frequencies between 0.5 and 30 GHz.");
 
  794    auto [distance2D, distance3D, hBs, hUt] = GetBsUtDistancesAndHeights(a, b);
 
  797    if (hUt < 1.0 || hUt > 10.0)
 
  801            "The height of the UT should be between 1 and 10 m (see TR 38.901, Table 7.4.1-1)");
 
  804    if (hBs < 10.0 || hBs > 150.0)
 
  808            "The height of the BS should be between 10 and 150 m (see TR 38.901, Table 7.4.1-1)");
 
  822        "Breakpoint distance is zero (divide-by-zero below); are either hBs or hUt = 0?");
 
  825    if (distance2D < 10.0 || distance2D > 10.0e3)
 
  828        NS_LOG_WARN(
"The 2D distance is outside the validity range, the pathloss value may not be " 
  834    if (distance2D <= distanceBp)
 
 
  855                  "RMa scenario is valid for frequencies between 0.5 and 30 GHz.");
 
  857    auto [distance2D, distance3D, hBs, hUt] = GetBsUtDistancesAndHeights(a, b);
 
  860    if (hUt < 1.0 || hUt > 10.0)
 
  864            "The height of the UT should be between 1 and 10 m (see TR 38.901, Table 7.4.1-1)");
 
  867    if (hBs < 10.0 || hBs > 150.0)
 
  871            "The height of the BS should be between 10 and 150 m (see TR 38.901, Table 7.4.1-1)");
 
  882    if (distance2D < 10.0 || distance2D > 5.0e3)
 
  885        NS_LOG_WARN(
"The 2D distance is outside the validity range, the pathloss value may not be " 
  890    double plNlos = 161.04 - 7.1 * log10(
m_w) + 7.5 * log10(
m_h) -
 
  891                    (24.37 - 3.7 * pow((
m_h / hBs), 2)) * log10(hBs) +
 
  892                    (43.42 - 3.1 * log10(hBs)) * (log10(distance3D) - 3.0) +
 
  893                    20.0 * log10(
m_frequency / 1e9) - (3.2 * pow(log10(11.75 * hUt), 2) - 4.97);
 
  895    double loss = std::max(
GetLossLos(a, b), plNlos);
 
 
  918        if (distance2d <= distanceBp)
 
 
  944    double correlationDistance;
 
  949        correlationDistance = 37;
 
  953        correlationDistance = 120;
 
  960    return correlationDistance;
 
 
  966    double loss = 20.0 * log10(40.0 * M_PI * distance3D * frequency / 1e9 / 3.0) +
 
  967                  std::min(0.03 * pow(h, 1.72), 10.0) * log10(distance3D) -
 
  968                  std::min(0.044 * pow(h, 1.72), 14.77) + 0.002 * log10(h) * distance3D;
 
 
  975    double distanceBp = 2.0 * M_PI * hA * hB * frequency / M_C;
 
 
  986    static TypeId tid = 
TypeId(
"ns3::ThreeGppUmaPropagationLossModel")
 
  988                            .SetGroupName(
"Propagation")
 
 
 1014    if (distance2D > 18.0)
 
 1016        g = 5.0 / 4.0 * pow(distance2D / 100.0, 3) * exp(-distance2D / 150.0);
 
 1023        c = pow((hUt - 13.0) / 10.0, 1.5) * g;
 
 1027    double prob = 1.0 / (1.0 + c);
 
 1035        int random = 
m_uniformVar->GetInteger(12, std::max(12, (
int)(hUt - 1.5)));
 
 1036        hE = (
double)floor(random / 3.0) * 3.0;
 
 1040    double distanceBp = 4 * (hBs - hE) * (hUt - hE) * 
m_frequency / M_C;
 
 
 1050    auto [distance2D, distance3D, hBs, hUt] = GetBsUtDistancesAndHeights(a, b);
 
 1053    if (hUt < 1.5 || hUt > 22.5)
 
 1057            "The height of the UT should be between 1.5 and 22.5 m (see TR 38.901, Table 7.4.1-1)");
 
 1063        NS_LOG_WARN(
"The height of the BS should be equal to 25 m (see TR 38.901, Table 7.4.1-1)");
 
 1078    if (distance2D < 10.0 || distance2D > 5.0e3)
 
 1081        NS_LOG_WARN(
"The 2D distance is outside the validity range, the pathloss value may not be " 
 1087    if (distance2D <= distanceBp)
 
 1090        loss = 28.0 + 22.0 * log10(distance3D) + 20.0 * log10(
m_frequency / 1e9);
 
 1095        loss = 28.0 + 40.0 * log10(distance3D) + 20.0 * log10(
m_frequency / 1e9) -
 
 1096               9.0 * log10(pow(distanceBp, 2) + pow(hBs - hUt, 2));
 
 
 1117    auto [distance2D, distance3D, hBs, hUt] = GetBsUtDistancesAndHeights(a, b);
 
 1120    if (hUt < 1.5 || hUt > 22.5)
 
 1124            "The height of the UT should be between 1.5 and 22.5 m (see TR 38.901, Table 7.4.1-1)");
 
 1130        NS_LOG_WARN(
"The height of the BS should be equal to 25 m (see TR 38.901, Table 7.4.1-1)");
 
 1141    if (distance2D < 10.0 || distance2D > 5.0e3)
 
 1144        NS_LOG_WARN(
"The 2D distance is outside the validity range, the pathloss value may not be " 
 1150        13.54 + 39.08 * log10(distance3D) + 20.0 * log10(
m_frequency / 1e9) - 0.6 * (hUt - 1.5);
 
 1151    double loss = std::max(
GetLossLos(a, b), plNlos);
 
 
 1163    double shadowingStd;
 
 1178    return shadowingStd;
 
 
 1186    double correlationDistance;
 
 1191        correlationDistance = 37;
 
 1195        correlationDistance = 50;
 
 1202    return correlationDistance;
 
 
 1222    static TypeId tid = 
TypeId(
"ns3::ThreeGppUmiStreetCanyonPropagationLossModel")
 
 1224                            .SetGroupName(
"Propagation")
 
 
 1254    double distanceBp = 4 * (hBs - hE) * (hUt - hE) * 
m_frequency / M_C;
 
 
 1275    auto [hBs, hUt] = GetBsUtHeightsUmiStreetCanyon(a->GetPosition().z, b->GetPosition().z);
 
 1278    if (hUt < 1.5 || hUt >= 10.0)
 
 1282            "The height of the UT should be between 1.5 and 22.5 m (see TR 38.901, Table 7.4.1-1). " 
 1283            "We further assume hUT < hBS, then hUT is upper bounded by hBS, which should be 10 m");
 
 1289        NS_LOG_WARN(
"The height of the BS should be equal to 10 m (see TR 38.901, Table 7.4.1-1)");
 
 1304    if (distance2D < 10.0 || distance2D > 5.0e3)
 
 1307        NS_LOG_WARN(
"The 2D distance is outside the validity range, the pathloss value may not be " 
 1313    if (distance2D <= distanceBp)
 
 1316        loss = 32.4 + 21.0 * log10(distance3D) + 20.0 * log10(
m_frequency / 1e9);
 
 1321        loss = 32.4 + 40.0 * log10(distance3D) + 20.0 * log10(
m_frequency / 1e9) -
 
 1322               9.5 * log10(pow(distanceBp, 2) + pow(hBs - hUt, 2));
 
 
 1338    auto [hBs, hUt] = GetBsUtHeightsUmiStreetCanyon(a->GetPosition().z, b->GetPosition().z);
 
 1341    if (hUt < 1.5 || hUt >= 10.0)
 
 1345            "The height of the UT should be between 1.5 and 22.5 m (see TR 38.901, Table 7.4.1-1). " 
 1346            "We further assume hUT < hBS, then hUT is upper bounded by hBS, which should be 10 m");
 
 1352        NS_LOG_WARN(
"The height of the BS should be equal to 10 m (see TR 38.901, Table 7.4.1-1)");
 
 1363    if (distance2D < 10.0 || distance2D > 5.0e3)
 
 1366        NS_LOG_WARN(
"The 2D distance is outside the validity range, the pathloss value may not be " 
 1372        22.4 + 35.3 * log10(distance3D) + 21.3 * log10(
m_frequency / 1e9) - 0.3 * (hUt - 1.5);
 
 1373    double loss = std::max(
GetLossLos(a, b), plNlos);
 
 
 1386    double shadowingStd;
 
 1394        shadowingStd = 7.82;
 
 1401    return shadowingStd;
 
 
 1409    double correlationDistance;
 
 1414        correlationDistance = 10;
 
 1418        correlationDistance = 13;
 
 1425    return correlationDistance;
 
 
 1435    static TypeId tid = 
TypeId(
"ns3::ThreeGppIndoorOfficePropagationLossModel")
 
 1437                            .SetGroupName(
"Propagation")
 
 
 1471    if (distance3D < 1.0 || distance3D > 150.0)
 
 1474        NS_LOG_WARN(
"The 3D distance is outside the validity range, the pathloss value may not be " 
 1479    double loss = 32.4 + 17.3 * log10(distance3D) + 20.0 * log10(
m_frequency / 1e9);
 
 
 1495    if (distance3D < 1.0 || distance3D > 150.0)
 
 1498        NS_LOG_WARN(
"The 3D distance is outside the validity range, the pathloss value may not be " 
 1503    double plNlos = 17.3 + 38.3 * log10(distance3D) + 24.9 * log10(
m_frequency / 1e9);
 
 1504    double loss = std::max(
GetLossLos(a, b), plNlos);
 
 
 1518    double shadowingStd;
 
 1526        shadowingStd = 8.03;
 
 1533    return shadowingStd;
 
 
 1543    double correlationDistance;
 
 1547        correlationDistance = 10;
 
 1551        correlationDistance = 6;
 
 1558    return correlationDistance;
 
 
 1566    static TypeId tid = 
TypeId(
"ns3::ThreeGppNTNDenseUrbanPropagationLossModel")
 
 1568                            .SetGroupName(
"Propagation")
 
 
 1575      m_SFCL_DenseUrban(&SFCL_DenseUrban)
 
 
 1598                  "NTN communications are valid for frequencies between 0.5 and 100 GHz.");
 
 1601    auto [elevAngle, elevAngleQuantized] =
 
 1605    double loss = ComputeNtnPathloss(
m_frequency, distance3D);
 
 1608    loss += ComputeAtmosphericAbsorptionLoss(
m_frequency, elevAngle);
 
 1611    loss += ComputeIonosphericPlusTroposphericScintillationLoss(
m_frequency, elevAngleQuantized);
 
 
 1623                  "NTN communications are valid for frequencies between 0.5 and 100 GHz.");
 
 1626    auto [elevAngle, elevAngleQuantized] =
 
 1630    double loss = ComputeNtnPathloss(
m_frequency, distance3D);
 
 1636    loss += ComputeAtmosphericAbsorptionLoss(
m_frequency, elevAngle);
 
 1639    loss += ComputeIonosphericPlusTroposphericScintillationLoss(
m_frequency, elevAngleQuantized);
 
 
 1652    double shadowingStd;
 
 1654    std::string freqBand = (
m_frequency < 13.0e9) ? 
"S" : 
"Ka";
 
 1655    auto [elevAngle, elevAngleQuantized] =
 
 1680    return shadowingStd;
 
 
 1688    double correlationDistance;
 
 1693        correlationDistance = 37;
 
 1697        correlationDistance = 50;
 
 1704    return correlationDistance;
 
 
 1714    static TypeId tid = 
TypeId(
"ns3::ThreeGppNTNUrbanPropagationLossModel")
 
 1716                            .SetGroupName(
"Propagation")
 
 
 1723      m_SFCL_Urban(&SFCL_Urban)
 
 
 1745                  "NTN communications are valid for frequencies between 0.5 and 100 GHz.");
 
 1748    auto [elevAngle, elevAngleQuantized] =
 
 1752    double loss = ComputeNtnPathloss(
m_frequency, distance3D);
 
 1755    loss += ComputeAtmosphericAbsorptionLoss(
m_frequency, elevAngle);
 
 1758    loss += ComputeIonosphericPlusTroposphericScintillationLoss(
m_frequency, elevAngleQuantized);
 
 
 1769                  "NTN communications are valid for frequencies between 0.5 and 100 GHz.");
 
 1772    auto [elevAngle, elevAngleQuantized] =
 
 1776    double loss = ComputeNtnPathloss(
m_frequency, distance3D);
 
 1782    loss += ComputeAtmosphericAbsorptionLoss(
m_frequency, elevAngle);
 
 1785    loss += ComputeIonosphericPlusTroposphericScintillationLoss(
m_frequency, elevAngleQuantized);
 
 
 1798    double shadowingStd;
 
 1800    std::string freqBand = (
m_frequency < 13.0e9) ? 
"S" : 
"Ka";
 
 1801    auto [elevAngle, elevAngleQuantized] =
 
 1826    return shadowingStd;
 
 
 1834    double correlationDistance;
 
 1839        correlationDistance = 37;
 
 1843        correlationDistance = 50;
 
 1850    return correlationDistance;
 
 
 1860    static TypeId tid = 
TypeId(
"ns3::ThreeGppNTNSuburbanPropagationLossModel")
 
 1862                            .SetGroupName(
"Propagation")
 
 
 1869      m_SFCL_SuburbanRural(&SFCL_SuburbanRural)
 
 
 1892                  "NTN communications are valid for frequencies between 0.5 and 100 GHz.");
 
 1895    auto [elevAngle, elevAngleQuantized] =
 
 1899    double loss = ComputeNtnPathloss(
m_frequency, distance3D);
 
 1902    loss += ComputeAtmosphericAbsorptionLoss(
m_frequency, elevAngle);
 
 1905    loss += ComputeIonosphericPlusTroposphericScintillationLoss(
m_frequency, elevAngleQuantized);
 
 
 1918                  "NTN communications are valid for frequencies between 0.5 and 100 GHz.");
 
 1921    auto [elevAngle, elevAngleQuantized] =
 
 1925    double loss = ComputeNtnPathloss(
m_frequency, distance3D);
 
 1931    loss += ComputeAtmosphericAbsorptionLoss(
m_frequency, elevAngle);
 
 1934    loss += ComputeIonosphericPlusTroposphericScintillationLoss(
m_frequency, elevAngleQuantized);
 
 
 1947    double shadowingStd;
 
 1949    std::string freqBand = (
m_frequency < 13.0e9) ? 
"S" : 
"Ka";
 
 1950    auto [elevAngle, elevAngleQuantized] =
 
 1975    return shadowingStd;
 
 
 1983    double correlationDistance;
 
 1988        correlationDistance = 37;
 
 1992        correlationDistance = 50;
 
 1999    return correlationDistance;
 
 
 2009    static TypeId tid = 
TypeId(
"ns3::ThreeGppNTNRuralPropagationLossModel")
 
 2011                            .SetGroupName(
"Propagation")
 
 
 2018      m_SFCL_SuburbanRural(&SFCL_SuburbanRural)
 
 
 2040                  "NTN communications are valid for frequencies between 0.5 and 100 GHz.");
 
 2043    auto [elevAngle, elevAngleQuantized] =
 
 2047    double loss = ComputeNtnPathloss(
m_frequency, distance3D);
 
 2050    loss += ComputeAtmosphericAbsorptionLoss(
m_frequency, elevAngle);
 
 2053    loss += ComputeIonosphericPlusTroposphericScintillationLoss(
m_frequency, elevAngleQuantized);
 
 
 2064                  "NTN communications are valid for frequencies between 0.5 and 100 GHz.");
 
 2067    auto [elevAngle, elevAngleQuantized] =
 
 2071    double loss = ComputeNtnPathloss(
m_frequency, distance3D);
 
 2077    loss += ComputeAtmosphericAbsorptionLoss(
m_frequency, elevAngle);
 
 2080    loss += ComputeIonosphericPlusTroposphericScintillationLoss(
m_frequency, elevAngleQuantized);
 
 
 2093    double shadowingStd;
 
 2095    std::string freqBand = (
m_frequency < 13.0e9) ? 
"S" : 
"Ka";
 
 2096    auto [elevAngle, elevAngleQuantized] =
 
 2121    return shadowingStd;
 
 
 2129    double correlationDistance;
 
 2134        correlationDistance = 37;
 
 2138        correlationDistance = 120;
 
 2145    return correlationDistance;
 
 
AttributeValue implementation for Boolean.
@ 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'.
AttributeValue implementation for Pointer.
Models the propagation loss through a transmission medium.
Smart pointer class similar to boost::intrusive_ptr.
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...
static TypeId GetTypeId()
Get the type ID.
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.
~ThreeGppIndoorOfficePropagationLossModel() override
Destructor.
ThreeGppIndoorOfficePropagationLossModel()
Constructor.
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, Table ???? for the NTN Dense Urban scenario.
~ThreeGppNTNDenseUrbanPropagationLossModel() override
Destructor.
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 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.
const std::map< int, std::vector< float > > * m_SFCL_DenseUrban
The nested map containing the Shadow Fading and Clutter Loss values for the NTN Dense Urban scenario.
static TypeId GetTypeId()
Get the type ID.
double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
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.
ThreeGppNTNDenseUrbanPropagationLossModel()
Constructor.
Implements the pathloss model defined in 3GPP TR 38.811, Table ???? for the NTN Rural scenario.
const std::map< int, std::vector< float > > * m_SFCL_SuburbanRural
The nested map containing the Shadow Fading and Clutter Loss values for the NTN Suburban and Rural sc...
double GetO2iDistance2dIn() const override
Returns the minimum of the two independently generated distances according to the uniform distributio...
static TypeId GetTypeId()
Get the type ID.
ThreeGppNTNRuralPropagationLossModel()
Constructor.
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 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.
~ThreeGppNTNRuralPropagationLossModel() override
Destructor.
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, Table ???? for the NTN Suburban scenario.
ThreeGppNTNSuburbanPropagationLossModel()
Constructor.
double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
const std::map< int, std::vector< float > > * m_SFCL_SuburbanRural
The nested map containing the Shadow Fading and Clutter Loss values for the NTN Suburban and Rural sc...
static TypeId GetTypeId()
Get the type ID.
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.
~ThreeGppNTNSuburbanPropagationLossModel() override
Destructor.
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, Table ???? for the NTN Urban scenario.
ThreeGppNTNUrbanPropagationLossModel()
Constructor.
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.
const std::map< int, std::vector< float > > * m_SFCL_Urban
The nested map containing the Shadow Fading and Clutter Loss values for the NTN Urban scenario.
static TypeId GetTypeId()
Get the type ID.
double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
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.
~ThreeGppNTNUrbanPropagationLossModel() override
Destructor.
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.
Base class for the 3GPP propagation models.
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 GetFrequency() const
Return the current central frequency.
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.
virtual double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const =0
Returns the shadow fading correlation distance.
ThreeGppPropagationLossModel()
Constructor.
Ptr< NormalRandomVariable > m_normRandomVariable
normal random variable
static TypeId GetTypeId()
Get the type ID.
Ptr< ChannelConditionModel > m_channelConditionModel
pointer to the channel condition model
~ThreeGppPropagationLossModel() override
Destructor.
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...
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.
bool IsO2iLowPenetrationLoss(Ptr< const ChannelCondition > cond) const
Return true if the O2I Building Penetration loss corresponds to a low loss condition.
void SetFrequency(double f)
Set the central frequency of the model.
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....
double m_frequency
operating frequency in Hz
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....
static std::function< Ptr< MobilityModel >(Ptr< const MobilityModel >, Ptr< const MobilityModel >)> m_doCalcRxPowerPrologueFunction
Optional prologue function that can be used to implement wraparound models.
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....
bool m_shadowingEnabled
enable/disable shadowing
static Vector GetVectorDifference(Ptr< MobilityModel > a, Ptr< MobilityModel > b)
Get the difference between the node position.
bool m_buildingPenLossesEnabled
enable/disable building penetration losses
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...
ThreeGppRmaPropagationLossModel()
Constructor.
~ThreeGppRmaPropagationLossModel() override
Destructor.
double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
double m_h
average building height in meters
static TypeId GetTypeId()
Get the type ID.
static double GetBpDistance(double frequency, double hA, double hB)
Computes the breakpoint distance for the RMa scenario.
double m_w
average street width in meters
bool DoIsO2iLowPenetrationLoss(Ptr< const ChannelCondition > cond) const override
Indicates the condition of the o2i building penetration loss (defined in 3GPP TR 38....
Implements the pathloss model defined in 3GPP TR 38.901, Table 7.4.1-1 for the UMa scenario.
static TypeId GetTypeId()
Get the type ID.
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.
~ThreeGppUmaPropagationLossModel() override
Destructor.
ThreeGppUmaPropagationLossModel()
Constructor.
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 GetO2iDistance2dIn() const override
Returns the minimum of the two independently generated distances according to the uniform distributio...
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 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...
~ThreeGppUmiStreetCanyonPropagationLossModel() override
Destructor.
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...
ThreeGppUmiStreetCanyonPropagationLossModel()
Constructor.
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.
static TypeId GetTypeId()
Get the type ID.
double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
double GetLength() const
Compute the length (magnitude) of the vector.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeDoubleChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#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.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
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...
constexpr double M_C
propagation velocity in free space
double ComputeIonosphericPlusTroposphericScintillationLoss(double freq, double elevAngleQuantized)
Computes the ionospheric plus tropospheric scintillation loss using the formulas described in 3GPP TR...
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 ComputeNtnPathloss(double freq, double dist3d)
Computes the free-space path loss using the formula described in 3GPP TR 38.811, Table 6....
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.
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...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Define a struct for the m_o2iLossMap entries.
Define a struct for the m_shadowingMap entries.