22 #include "ns3/double.h"
23 #include "ns3/mobility-model.h"
26 #include "ns3/simulator.h"
27 #include "ns3/string.h"
40 .SetGroupName (
"Propagation")
127 if (cond == ChannelCondition::LosConditionValue::LOS)
131 else if (cond == ChannelCondition::LosConditionValue::NLOS)
135 else if (cond == ChannelCondition::LosConditionValue::NLOSv)
149 static TypeId tid =
TypeId (
"ns3::ChannelConditionModel")
151 .SetGroupName (
"Propagation")
169 static TypeId tid =
TypeId (
"ns3::AlwaysLosChannelConditionModel")
171 .SetGroupName (
"Propagation")
205 static TypeId tid =
TypeId (
"ns3::NeverLosChannelConditionModel")
207 .SetGroupName (
"Propagation")
241 static TypeId tid =
TypeId (
"ns3::NeverLosVehicleChannelConditionModel")
243 .SetGroupName (
"Propagation")
278 static TypeId tid =
TypeId (
"ns3::ThreeGppChannelConditionModel")
280 .SetGroupName (
"Propagation")
281 .AddAttribute (
"UpdatePeriod",
"Specifies the time period after which the channel condition is recomputed. If set to 0, the channel condition is never updated.",
313 uint32_t key =
GetKey (a, b);
315 bool notFound =
false;
322 NS_LOG_DEBUG (
"found the channel condition in the map");
323 cond = mapItem->second.m_condition;
340 if (notFound || update)
368 NS_LOG_DEBUG (
"pRef " << pRef <<
" pLos " << pLos <<
" pNlos " << pNlos);
374 cond->SetLosCondition (ChannelCondition::LosConditionValue::LOS);
376 else if (pRef <= pLos + pNlos)
379 cond->SetLosCondition (ChannelCondition::LosConditionValue::NLOS);
384 cond->SetLosCondition (ChannelCondition::LosConditionValue::NLOSv);
409 double x = a.x - b.x;
410 double y = a.y - b.y;
411 double distance2D = sqrt (
x *
x + y * y);
425 uint32_t key = (((x1 + x2) * (x1 + x2 + 1)) / 2) + x2;
437 static TypeId tid =
TypeId (
"ns3::ThreeGppRmaChannelConditionModel")
439 .SetGroupName (
"Propagation")
464 if (distance2D <= 10.0)
470 pLos = exp (-(distance2D - 10.0) / 1000.0);
483 static TypeId tid =
TypeId (
"ns3::ThreeGppUmaChannelConditionModel")
485 .SetGroupName (
"Propagation")
506 double h_UT =
std::min (a->GetPosition ().z, b->GetPosition ().z);
509 NS_LOG_WARN (
"The height of the UT should be smaller than 23 m (see TR 38.901, Table 7.4.2-1)");
513 double h_BS =
std::max (a->GetPosition ().z, b->GetPosition ().z);
516 NS_LOG_WARN (
"The LOS probability was derived assuming BS antenna heights of 25 m (see TR 38.901, Table 7.4.2-1)");
521 if (distance2D <= 18.0)
535 c = pow ((h_UT - 13.0) / 10.0, 1.5);
538 pLos = (18.0 / distance2D + exp (-distance2D / 63.0) * (1.0 - 18.0 / distance2D)) * (1.0 + c * 5.0 / 4.0 * pow (distance2D / 100.0, 3.0) * exp (-distance2D / 150.0));
551 static TypeId tid =
TypeId (
"ns3::ThreeGppUmiStreetCanyonChannelConditionModel")
553 .SetGroupName (
"Propagation")
578 if (a->GetPosition ().z != 10.0 && b->GetPosition ().z != 10.0)
580 NS_LOG_WARN (
"The LOS probability was derived assuming BS antenna heights of 10 m (see TR 38.901, Table 7.4.2-1)");
585 if (distance2D <= 18.0)
591 pLos = 18.0 / distance2D + exp (-distance2D / 36.0) * (1.0 - 18.0 / distance2D);
604 static TypeId tid =
TypeId (
"ns3::ThreeGppIndoorMixedOfficeChannelConditionModel")
606 .SetGroupName (
"Propagation")
630 double h_BS =
std::max (a->GetPosition ().z, b->GetPosition ().z);
633 NS_LOG_WARN (
"The LOS probability was derived assuming BS antenna heights of 3 m (see TR 38.901, Table 7.4.2-1)");
638 if (distance2D <= 1.2)
642 else if (distance2D > 1.2 && distance2D < 6.5)
644 pLos = exp (-(distance2D - 1.2) / 4.7);
648 pLos = exp (-(distance2D - 6.5) / 32.6) * 0.32;
661 static TypeId tid =
TypeId (
"ns3::ThreeGppIndoorOpenOfficeChannelConditionModel")
663 .SetGroupName (
"Propagation")
687 double h_BS =
std::max (a->GetPosition ().z, b->GetPosition ().z);
690 NS_LOG_WARN (
"The LOS probability was derived assuming BS antenna heights of 3 m (see TR 38.901, Table 7.4.2-1)");
695 if (distance2D <= 5.0)
699 else if (distance2D > 5.0 && distance2D <= 49.0)
701 pLos = exp (-(distance2D - 5.0) / 70.8);
705 pLos = exp (-(distance2D - 49.0) / 211.7) * 0.54;
Models an always in-LoS condition model.
virtual int64_t AssignStreams(int64_t stream) override
If this model uses objects of type RandomVariableStream, set the stream numbers to the integers start...
virtual ~AlwaysLosChannelConditionModel()
Destructor.
AlwaysLosChannelConditionModel()
Constructor.
static TypeId GetTypeId(void)
Get the type ID.
virtual 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
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 contaning 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 contaning the information about the O2I state of the channel.
static TypeId GetTypeId(void)
Get the type ID.
bool IsO2o() const
Return true if the channel is outdoor-to-outdoor.
bool IsI2i() const
Return true if the channel is indoor-to-indoor.
virtual ~ChannelCondition()
Destructor for the ChannelCondition class.
O2iConditionValue
Possible values for Outdoor to Indoor condition.
O2iConditionValue GetO2iCondition() const
Get the O2iConditionValue contaning 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.
ChannelConditionModel()
Constructor for the ChannelConditionModel class.
static TypeId GetTypeId(void)
Get the type ID.
virtual ~ChannelConditionModel()
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.
virtual ~NeverLosChannelConditionModel()
Destructor.
virtual 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.
virtual 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(void)
Get the type ID.
Models a never in-LoS condition model caused by a blocking vehicle.
static TypeId GetTypeId(void)
Get the type ID.
virtual int64_t AssignStreams(int64_t stream) override
If this model uses objects of type RandomVariableStream, set the stream numbers to the integers start...
virtual ~NeverLosVehicleChannelConditionModel()
Destructor.
virtual 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()
Constructor.
uint32_t GetId(void) const
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(void)
Return the current simulation virtual time.
Base class for the 3GPP channel condition models.
virtual int64_t AssignStreams(int64_t stream) override
If this model uses objects of type RandomVariableStream, set the stream numbers to the integers start...
virtual void DoDispose() override
Destructor implementation.
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.
virtual Ptr< ChannelCondition > GetChannelCondition(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b) const override
Retrieve the condition of the channel between a and b.
virtual ~ThreeGppChannelConditionModel() override
Destructor for the ThreeGppRmaChannelConditionModel class.
static TypeId GetTypeId(void)
Get the type ID.
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.
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...
Time m_updatePeriod
the update period for the channel condition
Computes the channel condition for the Indoor Mixed Office scenario.
static TypeId GetTypeId(void)
Get the type ID.
ThreeGppIndoorMixedOfficeChannelConditionModel()
Constructor for the ThreeGppIndoorMixedOfficeChannelConditionModel class.
virtual ~ThreeGppIndoorMixedOfficeChannelConditionModel() override
Destructor for the ThreeGppIndoorMixedOfficeChannelConditionModel class.
virtual 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(void)
Get the type ID.
virtual 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...
virtual ~ThreeGppIndoorOpenOfficeChannelConditionModel() override
Destructor for the ThreeGppIndoorOpenOfficeChannelConditionModel class.
Computes the channel condition for the RMa scenario.
virtual ~ThreeGppRmaChannelConditionModel() override
Destructor for the ThreeGppRmaChannelConditionModel class.
virtual 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(void)
Get the type ID.
Computes the channel condition for the UMa scenario.
static TypeId GetTypeId(void)
Get the type ID.
ThreeGppUmaChannelConditionModel()
Constructor for the ThreeGppUmaChannelConditionModel class.
virtual 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.
virtual ~ThreeGppUmaChannelConditionModel() override
Destructor for the ThreeGppUmaChannelConditionModel class.
Computes the channel condition for the UMi-Street canyon scenario.
ThreeGppUmiStreetCanyonChannelConditionModel()
Constructor for the ThreeGppUmiStreetCanyonChannelConditionModel class.
virtual ~ThreeGppUmiStreetCanyonChannelConditionModel() override
Destructor for the ThreeGppUmiStreetCanyonChannelConditionModel class.
virtual 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...
static TypeId GetTypeId(void)
Get the type ID.
bool IsZero(void) const
Exactly equivalent to t == 0.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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_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 > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
std::ostream & operator<<(std::ostream &os, const Angles &a)
list x
Random number samples.
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