10#include "ns3/boolean.h"
11#include "ns3/double.h"
12#include "ns3/geocentric-constant-position-mobility-model.h"
14#include "ns3/mobility-model.h"
16#include "ns3/pointer.h"
17#include "ns3/simulator.h"
18#include "ns3/string.h"
225 static TypeId tid =
TypeId(
"ns3::AlwaysLosChannelConditionModel")
227 .SetGroupName(
"Propagation")
262 static TypeId tid =
TypeId(
"ns3::NeverLosChannelConditionModel")
264 .SetGroupName(
"Propagation")
299 static TypeId tid =
TypeId(
"ns3::NeverLosVehicleChannelConditionModel")
301 .SetGroupName(
"Propagation")
337 TypeId(
"ns3::ThreeGppChannelConditionModel")
339 .SetGroupName(
"Propagation")
342 "Specifies the time period after which the channel "
343 "condition is recomputed. If set to 0, the channel condition is never updated.",
347 .AddAttribute(
"O2iThreshold",
348 "Specifies what will be the ratio of O2I channel "
349 "conditions. Default value is 0 that corresponds to 0 O2I losses.",
353 .AddAttribute(
"O2iLowLossThreshold",
354 "Specifies what will be the ratio of O2I "
355 "low - high penetration losses. Default value is 1.0 meaning that"
356 "all losses will be low",
360 .AddAttribute(
"LinkO2iConditionToAntennaHeight",
361 "Specifies whether the O2I condition will "
362 "be determined based on the UE height, i.e. if the UE height is 1.5 then "
364 "otherwise it is O2I.",
403 bool notFound =
false;
411 cond = mapItem->second.m_condition;
429 if (notFound || update)
451 if (std::min(a->GetPosition().z, b->GetPosition().z) == 1.5)
489 NS_LOG_DEBUG(
"pRef " << pRef <<
" pLos " << pLos <<
" pNlos " << pNlos);
497 else if (pRef <= pLos + pNlos)
526 cond->SetO2iLowHighCondition(lowHighLossCondition);
554 double x = a.x - b.x;
555 double y = a.y - b.y;
556 double distance2D = sqrt(x * x + y * y);
570 uint32_t key = (((x1 + x2) * (x1 + x2 + 1)) / 2) + x2;
575std::tuple<double, double>
586 "Mobility Models need to be of type Geocentric for NTN scenarios");
588 double elevAngle = aNTNMob->GetElevationAngle(bNTNMob);
591 int elevAngleQuantized = (elevAngle < 10) ? 10 : round(elevAngle / 10) * 10;
592 NS_ASSERT_MSG((elevAngleQuantized >= 10) && (elevAngleQuantized <= 90),
593 "Invalid elevation angle!");
595 return std::make_tuple(elevAngle, elevAngleQuantized);
605 static TypeId tid =
TypeId(
"ns3::ThreeGppRmaChannelConditionModel")
607 .SetGroupName(
"Propagation")
633 if (distance2D <= 10.0)
639 pLos = exp(-(distance2D - 10.0) / 1000.0);
652 static TypeId tid =
TypeId(
"ns3::ThreeGppUmaChannelConditionModel")
654 .SetGroupName(
"Propagation")
676 double h_UT = std::min(a->GetPosition().z, b->GetPosition().z);
680 "The height of the UT should be smaller than 23 m (see TR 38.901, Table 7.4.2-1)");
684 double h_BS = std::max(a->GetPosition().z, b->GetPosition().z);
687 NS_LOG_WARN(
"The LOS probability was derived assuming BS antenna heights of 25 m (see TR "
688 "38.901, Table 7.4.2-1)");
693 if (distance2D <= 18.0)
707 c = pow((h_UT - 13.0) / 10.0, 1.5);
710 pLos = (18.0 / distance2D + exp(-distance2D / 63.0) * (1.0 - 18.0 / distance2D)) *
711 (1.0 + c * 5.0 / 4.0 * pow(distance2D / 100.0, 3.0) * exp(-distance2D / 150.0));
724 static TypeId tid =
TypeId(
"ns3::ThreeGppUmiStreetCanyonChannelConditionModel")
726 .SetGroupName(
"Propagation")
752 if (a->GetPosition().z != 10.0 && b->GetPosition().z != 10.0)
754 NS_LOG_WARN(
"The LOS probability was derived assuming BS antenna heights of 10 m (see TR "
755 "38.901, Table 7.4.2-1)");
760 if (distance2D <= 18.0)
766 pLos = 18.0 / distance2D + exp(-distance2D / 36.0) * (1.0 - 18.0 / distance2D);
779 static TypeId tid =
TypeId(
"ns3::ThreeGppIndoorMixedOfficeChannelConditionModel")
781 .SetGroupName(
"Propagation")
806 double h_BS = std::max(a->GetPosition().z, b->GetPosition().z);
809 NS_LOG_WARN(
"The LOS probability was derived assuming BS antenna heights of 3 m (see TR "
810 "38.901, Table 7.4.2-1)");
815 if (distance2D <= 1.2)
819 else if (distance2D > 1.2 && distance2D < 6.5)
821 pLos = exp(-(distance2D - 1.2) / 4.7);
825 pLos = exp(-(distance2D - 6.5) / 32.6) * 0.32;
838 static TypeId tid =
TypeId(
"ns3::ThreeGppIndoorOpenOfficeChannelConditionModel")
840 .SetGroupName(
"Propagation")
865 double h_BS = std::max(a->GetPosition().z, b->GetPosition().z);
868 NS_LOG_WARN(
"The LOS probability was derived assuming BS antenna heights of 3 m (see TR "
869 "38.901, Table 7.4.2-1)");
874 if (distance2D <= 5.0)
878 else if (distance2D > 5.0 && distance2D <= 49.0)
880 pLos = exp(-(distance2D - 5.0) / 70.8);
884 pLos = exp(-(distance2D - 49.0) / 211.7) * 0.54;
897 static TypeId tid =
TypeId(
"ns3::ThreeGppNTNDenseUrbanChannelConditionModel")
899 .SetGroupName(
"Propagation")
911 return DenseUrbanLOSProb.at(quantizedElevAngle);
921 static TypeId tid =
TypeId(
"ns3::ThreeGppNTNUrbanChannelConditionModel")
923 .SetGroupName(
"Propagation")
935 return UrbanLOSProb.at(quantizedElevAngle);
945 static TypeId tid =
TypeId(
"ns3::ThreeGppNTNSuburbanChannelConditionModel")
947 .SetGroupName(
"Propagation")
959 return SuburbanRuralLOSProb.at(quantizedElevAngle);
969 static TypeId tid =
TypeId(
"ns3::ThreeGppNTNRuralChannelConditionModel")
971 .SetGroupName(
"Propagation")
983 return SuburbanRuralLOSProb.at(quantizedElevAngle);
Models an always in-LoS condition model.
~AlwaysLosChannelConditionModel() override
Destructor.
int64_t AssignStreams(int64_t stream) override
If this model uses objects of type RandomVariableStream, set the stream numbers to the integers start...
static TypeId GetTypeId()
Get the type ID.
AlwaysLosChannelConditionModel()
Constructor.
Ptr< ChannelCondition > GetChannelCondition(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Computes the condition of the channel between a and b, that will be always LoS.
AttributeValue implementation for Boolean.
LosConditionValue m_losCondition
contains the information about the LOS state of the channel
O2iLowHighConditionValue m_o2iLowHighCondition
contains the information about the O2I low-high building penetration losses
bool IsO2i() const
Return true if the channel is outdoor-to-indoor.
ChannelCondition()
Constructor for the ChannelCondition class.
void SetLosCondition(LosConditionValue losCondition)
Set the LosConditionValue with the information about the LOS/NLOS state of the channel.
LosConditionValue GetLosCondition() const
Get the LosConditionValue containing the information about the LOS/NLOS state of the channel.
bool IsNlos() const
Return true if the channel condition is NLOS.
bool IsEqual(LosConditionValue losCondition, O2iConditionValue o2iCondition) const
Return true if this instance is equivalent to the one passed as argument.
O2iConditionValue m_o2iCondition
contains the information about the O2I state of the channel
bool IsNlosv() const
Return true if the channel condition is NLOSv.
bool IsLos() const
Return true if the channel condition is LOS.
void SetO2iCondition(O2iConditionValue o2iCondition)
Set the O2iConditionValue containing the information about the O2I state of the channel.
~ChannelCondition() override
Destructor for the ChannelCondition class.
O2iLowHighConditionValue GetO2iLowHighCondition() const
Get the O2iLowHighConditionValue containing the information about the O2I building penetration losses...
bool IsO2o() const
Return true if the channel is outdoor-to-outdoor.
bool IsI2i() const
Return true if the channel is indoor-to-indoor.
static TypeId GetTypeId()
Get the type ID.
O2iConditionValue
Possible values for Outdoor to Indoor condition.
O2iLowHighConditionValue
Possible values for Low-High Penetration Loss condition.
@ LOW
Low Penetration Losses.
@ HIGH
High Penetration Losses.
void SetO2iLowHighCondition(O2iLowHighConditionValue o2iLowHighCondition)
Set the O2iLowHighConditionValue containing the information about the O2I building penetration losses...
O2iConditionValue GetO2iCondition() const
Get the O2iConditionValue containing the information about the O2I state of the channel.
LosConditionValue
Possible values for Line-of-Sight condition.
@ NLOSv
Non Line of Sight due to a vehicle.
Models the channel condition.
static TypeId GetTypeId()
Get the type ID.
ChannelConditionModel()
Constructor for the ChannelConditionModel class.
~ChannelConditionModel() override
Destructor for the ChannelConditionModel class.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Models a never in-LoS condition model.
static TypeId GetTypeId()
Get the type ID.
~NeverLosChannelConditionModel() override
Destructor.
Ptr< ChannelCondition > GetChannelCondition(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Computes the condition of the channel between a and b, that will be always non-LoS.
NeverLosChannelConditionModel()
Constructor.
int64_t AssignStreams(int64_t stream) override
If this model uses objects of type RandomVariableStream, set the stream numbers to the integers start...
Models a never in-LoS condition model caused by a blocking vehicle.
int64_t AssignStreams(int64_t stream) override
If this model uses objects of type RandomVariableStream, set the stream numbers to the integers start...
static TypeId GetTypeId()
Get the type ID.
Ptr< ChannelCondition > GetChannelCondition(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Computes the condition of the channel between a and b, that will be always NLOSv.
~NeverLosVehicleChannelConditionModel() override
Destructor.
NeverLosVehicleChannelConditionModel()
Constructor.
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Base class for the 3GPP channel condition models.
int64_t AssignStreams(int64_t stream) override
If this model uses objects of type RandomVariableStream, set the stream numbers to the integers start...
void DoDispose() override
Destructor implementation.
Ptr< UniformRandomVariable > m_uniformVarO2i
uniform random variable that is used for the generation of the O2i conditions
virtual ChannelCondition::O2iConditionValue ComputeO2i(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const
Determines whether the channel condition is O2I or O2O.
static uint32_t GetKey(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b)
Returns a unique and reciprocal key for the channel between a and b.
Ptr< ChannelCondition > GetChannelCondition(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Retrieve the condition of the channel between a and b.
~ThreeGppChannelConditionModel() override
Destructor for the ThreeGppRmaChannelConditionModel class.
Ptr< UniformRandomVariable > m_uniformO2iLowHighLossVar
a uniform random variable for the calculation of the low/high losses, see TR38.901 Table 7....
double m_o2iLowLossThreshold
the threshold for determining what is the ratio of low - high O2I building penetration losses
static double Calculate2dDistance(const Vector &a, const Vector &b)
Computes the 2D distance between two 3D vectors.
virtual double ComputePnlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const
Compute the NLOS probability.
double m_o2iThreshold
the threshold for determining what is the ratio of channels with O2I
virtual double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const =0
Compute the LOS probability.
std::unordered_map< uint32_t, Item > m_channelConditionMap
map to store the channel conditions
Ptr< UniformRandomVariable > m_uniformVar
uniform random variable
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].
ThreeGppChannelConditionModel()
Constructor for the ThreeGppRmaChannelConditionModel class.
Ptr< ChannelCondition > ComputeChannelCondition(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const
This method computes the channel condition based on a probabilistic model that is specific for the sc...
bool m_linkO2iConditionToAntennaHeight
the indicator that determines whether the O2I/O2O condition is determined based on the UE height
Time m_updatePeriod
the update period for the channel condition
static TypeId GetTypeId()
Get the type ID.
Computes the channel condition for the Indoor Mixed Office scenario.
static TypeId GetTypeId()
Get the type ID.
ThreeGppIndoorMixedOfficeChannelConditionModel()
Constructor for the ThreeGppIndoorMixedOfficeChannelConditionModel class.
~ThreeGppIndoorMixedOfficeChannelConditionModel() override
Destructor for the ThreeGppIndoorMixedOfficeChannelConditionModel class.
double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability as specified in Table 7.4.2-1 of 3GPP TR 38.901 for the Indoor Mixed Offi...
Computes the channel condition for the Indoor Open Office scenario.
ThreeGppIndoorOpenOfficeChannelConditionModel()
Constructor for the ThreeGppIndoorOpenOfficeChannelConditionModel class.
static TypeId GetTypeId()
Get the type ID.
double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability as specified in Table 7.4.2-1 of 3GPP TR 38.901 for the Indoor Open Offic...
~ThreeGppIndoorOpenOfficeChannelConditionModel() override
Destructor for the ThreeGppIndoorOpenOfficeChannelConditionModel class.
Computes the channel condition for the NTN Dense Urban Scenario.
static TypeId GetTypeId()
Register this type.
double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability.
Computes the channel condition for the NTN Rural Scenario.
double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability.
static TypeId GetTypeId()
Register this type.
Computes the channel condition for the NTN Suburban Scenario.
double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability.
static TypeId GetTypeId()
Register this type.
Computes the channel condition for the NTN Urban Scenario.
static TypeId GetTypeId()
Register this type.
double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability.
Computes the channel condition for the RMa scenario.
~ThreeGppRmaChannelConditionModel() override
Destructor for the ThreeGppRmaChannelConditionModel class.
double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability as specified in Table 7.4.2-1 of 3GPP TR 38.901 for the RMa scenario.
ThreeGppRmaChannelConditionModel()
Constructor for the ThreeGppRmaChannelConditionModel class.
static TypeId GetTypeId()
Get the type ID.
Computes the channel condition for the UMa scenario.
static TypeId GetTypeId()
Get the type ID.
ThreeGppUmaChannelConditionModel()
Constructor for the ThreeGppUmaChannelConditionModel class.
double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability as specified in Table 7.4.2-1 of 3GPP TR 38.901 for the UMa scenario.
~ThreeGppUmaChannelConditionModel() override
Destructor for the ThreeGppUmaChannelConditionModel class.
Computes the channel condition for the UMi-Street canyon scenario.
ThreeGppUmiStreetCanyonChannelConditionModel()
Constructor for the ThreeGppUmiStreetCanyonChannelConditionModel class.
static TypeId GetTypeId()
Get the type ID.
~ThreeGppUmiStreetCanyonChannelConditionModel() override
Destructor for the ThreeGppUmiStreetCanyonChannelConditionModel class.
double ComputePlos(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Compute the LOS probability as specified in Table 7.4.2-1 of 3GPP TR 38.901 for the UMi-Street Canyon...
bool IsZero() const
Exactly equivalent to t == 0.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#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 > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
#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.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
const std::map< int, double > SuburbanRuralLOSProb
NTN Suburban LOS probabilities from table 6.6.1-1 of 3GPP 38.811.
const std::map< int, double > UrbanLOSProb
NTN Urban LOS probabilities from table 6.6.1-1 of 3GPP 38.811.
const std::map< int, double > DenseUrbanLOSProb
NTN Dense Urban LOS probabilities from table 6.6.1-1 of 3GPP 38.811.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Ptr< T1 > ConstCast(const Ptr< T2 > &p)
Cast a Ptr.
Struct to store the channel condition in the m_channelConditionMap.
Ptr< ChannelCondition > m_condition
the channel condition
Time m_generatedTime
the time when the condition was generated