21 #include "ns3/boolean.h"
22 #include "ns3/double.h"
24 #include "ns3/mobility-model.h"
26 #include "ns3/simulator.h"
27 #include "ns3/string.h"
147 if (cond == ChannelCondition::LosConditionValue::LOS)
151 else if (cond == ChannelCondition::LosConditionValue::NLOS)
155 else if (cond == ChannelCondition::LosConditionValue::NLOSv)
190 static TypeId tid =
TypeId(
"ns3::AlwaysLosChannelConditionModel")
192 .SetGroupName(
"Propagation")
227 static TypeId tid =
TypeId(
"ns3::NeverLosChannelConditionModel")
229 .SetGroupName(
"Propagation")
264 static TypeId tid =
TypeId(
"ns3::NeverLosVehicleChannelConditionModel")
266 .SetGroupName(
"Propagation")
302 TypeId(
"ns3::ThreeGppChannelConditionModel")
304 .SetGroupName(
"Propagation")
307 "Specifies the time period after which the channel "
308 "condition is recomputed. If set to 0, the channel condition is never updated.",
312 .AddAttribute(
"O2iThreshold",
313 "Specifies what will be the ratio of O2I channel "
314 "conditions. Default value is 0 that corresponds to 0 O2I losses.",
317 MakeDoubleChecker<double>(0, 1))
318 .AddAttribute(
"O2iLowLossThreshold",
319 "Specifies what will be the ratio of O2I "
320 "low - high penetration losses. Default value is 1.0 meaning that"
321 "all losses will be low",
324 MakeDoubleChecker<double>(0, 1))
325 .AddAttribute(
"LinkO2iConditionToAntennaHeight",
326 "Specifies whether the O2I condition will "
327 "be determined based on the UE height, i.e. if the UE height is 1.5 then "
329 "otherwise it is O2I.",
366 uint32_t key =
GetKey(a, b);
368 bool notFound =
false;
376 cond = mapItem->second.m_condition;
394 if (notFound || update)
416 if (
std::min(a->GetPosition().z, b->GetPosition().z) == 1.5)
418 return ChannelCondition::O2iConditionValue::O2O;
422 return ChannelCondition::O2iConditionValue::O2I;
430 return ChannelCondition::O2iConditionValue::O2I;
435 return ChannelCondition::O2iConditionValue::O2O;
454 NS_LOG_DEBUG(
"pRef " << pRef <<
" pLos " << pLos <<
" pNlos " << pNlos);
460 cond->SetLosCondition(ChannelCondition::LosConditionValue::LOS);
462 else if (pRef <= pLos + pNlos)
465 cond->SetLosCondition(ChannelCondition::LosConditionValue::NLOS);
470 cond->SetLosCondition(ChannelCondition::LosConditionValue::NLOSv);
475 if (cond->GetO2iCondition() == ChannelCondition::O2iConditionValue::O2I)
491 cond->SetO2iLowHighCondition(lowHighLossCondition);
519 double x = a.x - b.x;
520 double y = a.y - b.y;
521 double distance2D = sqrt(
x *
x + y * y);
535 uint32_t key = (((x1 + x2) * (x1 + x2 + 1)) / 2) + x2;
547 static TypeId tid =
TypeId(
"ns3::ThreeGppRmaChannelConditionModel")
549 .SetGroupName(
"Propagation")
575 if (distance2D <= 10.0)
581 pLos = exp(-(distance2D - 10.0) / 1000.0);
594 static TypeId tid =
TypeId(
"ns3::ThreeGppUmaChannelConditionModel")
596 .SetGroupName(
"Propagation")
618 double h_UT =
std::min(a->GetPosition().z, b->GetPosition().z);
622 "The height of the UT should be smaller than 23 m (see TR 38.901, Table 7.4.2-1)");
626 double h_BS =
std::max(a->GetPosition().z, b->GetPosition().z);
629 NS_LOG_WARN(
"The LOS probability was derived assuming BS antenna heights of 25 m (see TR "
630 "38.901, Table 7.4.2-1)");
635 if (distance2D <= 18.0)
649 c = pow((h_UT - 13.0) / 10.0, 1.5);
652 pLos = (18.0 / distance2D + exp(-distance2D / 63.0) * (1.0 - 18.0 / distance2D)) *
653 (1.0 + c * 5.0 / 4.0 * pow(distance2D / 100.0, 3.0) * exp(-distance2D / 150.0));
666 static TypeId tid =
TypeId(
"ns3::ThreeGppUmiStreetCanyonChannelConditionModel")
668 .SetGroupName(
"Propagation")
694 if (a->GetPosition().z != 10.0 && b->GetPosition().z != 10.0)
696 NS_LOG_WARN(
"The LOS probability was derived assuming BS antenna heights of 10 m (see TR "
697 "38.901, Table 7.4.2-1)");
702 if (distance2D <= 18.0)
708 pLos = 18.0 / distance2D + exp(-distance2D / 36.0) * (1.0 - 18.0 / distance2D);
721 static TypeId tid =
TypeId(
"ns3::ThreeGppIndoorMixedOfficeChannelConditionModel")
723 .SetGroupName(
"Propagation")
748 double h_BS =
std::max(a->GetPosition().z, b->GetPosition().z);
751 NS_LOG_WARN(
"The LOS probability was derived assuming BS antenna heights of 3 m (see TR "
752 "38.901, Table 7.4.2-1)");
757 if (distance2D <= 1.2)
761 else if (distance2D > 1.2 && distance2D < 6.5)
763 pLos = exp(-(distance2D - 1.2) / 4.7);
767 pLos = exp(-(distance2D - 6.5) / 32.6) * 0.32;
780 static TypeId tid =
TypeId(
"ns3::ThreeGppIndoorOpenOfficeChannelConditionModel")
782 .SetGroupName(
"Propagation")
807 double h_BS =
std::max(a->GetPosition().z, b->GetPosition().z);
810 NS_LOG_WARN(
"The LOS probability was derived assuming BS antenna heights of 3 m (see TR "
811 "38.901, Table 7.4.2-1)");
816 if (distance2D <= 5.0)
820 else if (distance2D > 5.0 && distance2D <= 49.0)
822 pLos = exp(-(distance2D - 5.0) / 70.8);
826 pLos = exp(-(distance2D - 49.0) / 211.7) * 0.54;
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.
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.
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.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
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
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 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.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#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.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
std::ostream & operator<<(std::ostream &os, const Angles &a)
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