|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/mobility-model.h"
23 #include "ns3/channel-condition-model.h"
24 #include "ns3/double.h"
25 #include "ns3/boolean.h"
26 #include "ns3/pointer.h"
29 #include "ns3/simulator.h"
35 static const double M_C = 3.0e8;
44 static TypeId tid =
TypeId (
"ns3::ThreeGppPropagationLossModel")
46 .SetGroupName (
"Propagation")
47 .AddAttribute (
"Frequency",
"The centre frequency in Hz.",
51 MakeDoubleChecker<double> ())
52 .AddAttribute (
"ShadowingEnabled",
"Enable/disable shadowing.",
56 .AddAttribute (
"ChannelConditionModel",
"Pointer to the channel condition model.",
60 MakePointerChecker<ChannelConditionModel> ())
107 NS_ASSERT_MSG (
f >= 500.0e6 &&
f <= 100.0e9,
"Frequency should be between 0.5 and 100 GHz but is " <<
f);
141 double rxPow = txPowerDbm;
142 rxPow -=
GetLoss (cond, distance2d, distance3d, heights.first, heights.second);
158 if (cond->GetLosCondition () == ChannelCondition::LosConditionValue::LOS)
160 loss =
GetLossLos (distance2d, distance3d, hUt, hBs);
162 else if (cond->GetLosCondition () == ChannelCondition::LosConditionValue::NLOSv)
166 else if (cond->GetLosCondition () == ChannelCondition::LosConditionValue::NLOS)
168 loss =
GetLossNlos (distance2d, distance3d, hUt, hBs);
190 double shadowingValue;
193 uint32_t key =
GetKey (a, b);
195 bool notFound =
false;
196 bool newCondition =
false;
204 newCondition = (it->second.m_condition != cond);
215 if (notFound || newCondition)
223 Vector2D displacement (newDistance.x - it->second.m_distance.x, newDistance.y - it->second.m_distance.y);
229 it->second.m_shadowing = shadowingValue;
230 it->second.m_distance = newDistance;
231 it->second.m_condition = cond;
233 return shadowingValue;
236 std::pair<double, double>
244 return std::pair<double, double> (hUt, hBs);
259 double x = a.x - b.x;
260 double y = a.y - b.y;
261 double distance2D = sqrt (
x *
x + y * y);
275 uint32_t key = (((x1 + x2) * (x1 + x2 + 1)) / 2) + x2;
303 static TypeId tid =
TypeId (
"ns3::ThreeGppRmaPropagationLossModel")
305 .SetGroupName (
"Propagation")
307 .AddAttribute (
"AvgBuildingHeight",
"The average building height in meters.",
310 MakeDoubleChecker<double> (5.0, 50.0))
311 .AddAttribute (
"AvgStreetWidth",
"The average street width in meters.",
314 MakeDoubleChecker<double> (5.0, 50.0))
340 if (hUt < 1.0 || hUt > 10.0)
342 NS_LOG_WARN (
"The height of the UT should be between 1 and 10 m (see TR 38.901, Table 7.4.1-1)");
345 if (hBs < 10.0 || hBs > 150.0)
347 NS_LOG_WARN (
"The height of the BS should be between 10 and 150 m (see TR 38.901, Table 7.4.1-1)");
361 if (distance2D < 10.0 || distance2D > 10.0e3)
363 NS_LOG_WARN (
"The 2D distance is outside the validity range, the pathloss value may not be accurate");
368 if (distance2D <= distanceBp)
391 if (hUt < 1.0 || hUt > 10.0)
393 NS_LOG_WARN (
"The height of the UT should be between 1 and 10 m (see TR 38.901, Table 7.4.1-1)");
396 if (hBs < 10.0 || hBs > 150.0)
398 NS_LOG_WARN (
"The height of the BS should be between 10 and 150 m (see TR 38.901, Table 7.4.1-1)");
409 if (distance2D < 10.0 || distance2D > 5.0e3)
411 NS_LOG_WARN (
"The 2D distance is outside the validity range, the pathloss value may not be accurate");
415 double plNlos = 161.04 - 7.1 * log10 (
m_w) + 7.5 * log10 (
m_h) - (24.37 - 3.7 * pow ((
m_h / hBs), 2)) * log10 (hBs) + (43.42 - 3.1 * log10 (hBs)) * (log10 (distance3D) - 3.0) + 20.0 * log10 (
m_frequency / 1e9) - (3.2 * pow (log10 (11.75 * hUt), 2) - 4.97);
430 if (cond == ChannelCondition::LosConditionValue::LOS)
438 if (distance2d <= distanceBp)
447 else if (cond == ChannelCondition::LosConditionValue::NLOS)
463 double correlationDistance;
466 if (cond == ChannelCondition::LosConditionValue::LOS)
468 correlationDistance = 37;
470 else if (cond == ChannelCondition::LosConditionValue::NLOS)
472 correlationDistance = 120;
479 return correlationDistance;
486 double loss = 20.0 * log10 (40.0 * M_PI * distance3D * frequency / 1e9 / 3.0) +
std::min (0.03 * pow (h, 1.72), 10.0) * log10 (distance3D) -
std::min (0.044 * pow (h, 1.72), 14.77) + 0.002 * log10 (h) * distance3D;
493 double distanceBp = 2.0 * M_PI * hA * hB * frequency /
M_C;
504 static TypeId tid =
TypeId (
"ns3::ThreeGppUmaPropagationLossModel")
506 .SetGroupName (
"Propagation")
534 if (distance2D > 18.0)
536 g = 5.0 / 4.0 * pow (distance2D / 100.0, 3) * exp (-distance2D / 150.0);
543 c = pow ((hUt - 13.0) / 10.0, 1.5) * g;
547 double prob = 1.0 / (1.0 + c);
556 hE = (double)floor (random / 3.0) * 3.0;
560 double distanceBp = 4 * (hBs - hE) * (hUt - hE) *
m_frequency /
M_C;
571 if (hUt < 1.5 || hUt > 22.5)
573 NS_LOG_WARN (
"The height of the UT should be between 1.5 and 22.5 m (see TR 38.901, Table 7.4.1-1)");
578 NS_LOG_WARN (
"The height of the BS should be equal to 25 m (see TR 38.901, Table 7.4.1-1)");
593 if (distance2D < 10.0 || distance2D > 5.0e3)
595 NS_LOG_WARN (
"The 2D distance is outside the validity range, the pathloss value may not be accurate");
600 if (distance2D <= distanceBp)
603 loss = 28.0 + 22.0 * log10 (distance3D) + 20.0 * log10 (
m_frequency / 1e9);
608 loss = 28.0 + 40.0 * log10 (distance3D) + 20.0 * log10 (
m_frequency / 1e9) - 9.0 * log10 (pow (distanceBp, 2) + pow (hBs - hUt, 2));
622 if (hUt < 1.5 || hUt > 22.5)
624 NS_LOG_WARN (
"The height of the UT should be between 1.5 and 22.5 m (see TR 38.901, Table 7.4.1-1)");
629 NS_LOG_WARN (
"The height of the BS should be equal to 25 m (see TR 38.901, Table 7.4.1-1)");
640 if (distance2D < 10.0 || distance2D > 5.0e3)
642 NS_LOG_WARN (
"The 2D distance is outside the validity range, the pathloss value may not be accurate");
646 double plNlos = 13.54 + 39.08 * log10 (distance3D) + 20.0 * log10 (
m_frequency / 1e9) - 0.6 * (hUt - 1.5);
661 if (cond == ChannelCondition::LosConditionValue::LOS)
665 else if (cond == ChannelCondition::LosConditionValue::NLOS)
681 double correlationDistance;
684 if (cond == ChannelCondition::LosConditionValue::LOS)
686 correlationDistance = 37;
688 else if (cond == ChannelCondition::LosConditionValue::NLOS)
690 correlationDistance = 50;
697 return correlationDistance;
717 static TypeId tid =
TypeId (
"ns3::ThreeGppUmiStreetCanyonPropagationLossModel")
719 .SetGroupName (
"Propagation")
748 double distanceBp = 4 * (hBs - hE) * (hUt - hE) *
m_frequency /
M_C;
759 if (hUt < 1.5 || hUt >= 10.0)
761 NS_LOG_WARN (
"The height of the UT should be between 1.5 and 22.5 m (see TR 38.901, Table 7.4.1-1). We further assume hUT < hBS, then hUT is upper bounded by hBS, which should be 10 m");
766 NS_LOG_WARN (
"The height of the BS should be equal to 10 m (see TR 38.901, Table 7.4.1-1)");
781 if (distance2D < 10.0 || distance2D > 5.0e3)
783 NS_LOG_WARN (
"The 2D distance is outside the validity range, the pathloss value may not be accurate");
788 if (distance2D <= distanceBp)
791 loss = 32.4 + 21.0 * log10 (distance3D) + 20.0 * log10 (
m_frequency / 1e9);
796 loss = 32.4 + 40.0 * log10 (distance3D) + 20.0 * log10 (
m_frequency / 1e9) - 9.5 * log10 (pow (distanceBp, 2) + pow (hBs - hUt, 2));
810 if (hUt < 1.5 || hUt >= 10.0)
812 NS_LOG_WARN (
"The height of the UT should be between 1.5 and 22.5 m (see TR 38.901, Table 7.4.1-1). We further assume hUT < hBS, then hUT is upper bounded by hBS, which should be 10 m");
817 NS_LOG_WARN (
"The height of the BS should be equal to 10 m (see TR 38.901, Table 7.4.1-1)");
828 if (distance2D < 10.0 || distance2D > 5.0e3)
830 NS_LOG_WARN (
"The 2D distance is outside the validity range, the pathloss value may not be accurate");
834 double plNlos = 22.4 + 35.3 * log10 (distance3D) + 21.3 * log10 (
m_frequency / 1e9) - 0.3 * (hUt - 1.5);
841 std::pair<double, double>
867 return std::pair<double, double> (hUt, hBs);
878 if (cond == ChannelCondition::LosConditionValue::LOS)
882 else if (cond == ChannelCondition::LosConditionValue::NLOS)
898 double correlationDistance;
901 if (cond == ChannelCondition::LosConditionValue::LOS)
903 correlationDistance = 10;
905 else if (cond == ChannelCondition::LosConditionValue::NLOS)
907 correlationDistance = 13;
914 return correlationDistance;
924 static TypeId tid =
TypeId (
"ns3::ThreeGppIndoorOfficePropagationLossModel")
926 .SetGroupName (
"Propagation")
955 if (distance3D < 1.0 || distance3D > 150.0)
957 NS_LOG_WARN (
"The 3D distance is outside the validity range, the pathloss value may not be accurate");
961 double loss = 32.4 + 17.3 * log10 (distance3D) + 20.0 * log10 (
m_frequency / 1e9);
974 if (distance3D < 1.0 || distance3D > 150.0)
976 NS_LOG_WARN (
"The 3D distance is outside the validity range, the pathloss value may not be accurate");
980 double plNlos = 17.3 + 38.3 * log10 (distance3D) + 24.9 * log10 (
m_frequency / 1e9);
996 if (cond == ChannelCondition::LosConditionValue::LOS)
1000 else if (cond == ChannelCondition::LosConditionValue::NLOS)
1002 shadowingStd = 8.03;
1009 return shadowingStd;
1018 double correlationDistance;
1020 if (cond == ChannelCondition::LosConditionValue::LOS)
1022 correlationDistance = 10;
1024 else if (cond == ChannelCondition::LosConditionValue::NLOS)
1026 correlationDistance = 6;
1033 return correlationDistance;
Ptr< NormalRandomVariable > m_normRandomVariable
normal random variable
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
static double Pl1(double frequency, double distance3D, double h, double w)
Computes the PL1 formula for the RMa scenario.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
AttributeValue implementation for Boolean.
virtual 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....
Implements the pathloss model defined in 3GPP TR 38.901, Table 7.4.1-1 for the RMa scenario.
uint32_t GetId(void) const
ThreeGppIndoorOfficePropagationLossModel()
Constructor.
virtual ~ThreeGppIndoorOfficePropagationLossModel() override
Destructor.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double GetLossLos(double distance2D, double distance3D, double hUt, double hBs) const override
Computes the pathloss between a and b considering that the line of sight is not obstructed.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
virtual ~ThreeGppRmaPropagationLossModel() override
Destructor.
double GetLossNlos(double distance2D, double distance3D, double hUt, double hBs) 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.901, Table 7.4.1-1 for the UMi-Street Canyon scen...
Models the propagation loss through a transmission medium.
virtual double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
Hold objects of type Ptr<T>.
LosConditionValue
Possible values for Line-of-Sight condition.
static TypeId GetTypeId(void)
Get the type ID.
virtual double GetShadowingStd(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading standard deviation.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
double GetLength() const
Compute the length (magnitude) of the vector.
double GetShadowing(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const
Retrieves the shadowing value by looking at m_shadowingMap.
double GetLossLos(double distance2D, double distance3D, double hUt, double hBs) const override
Computes the pathloss between a and b considering that the line of sight is not obstructed.
ThreeGppRmaPropagationLossModel()
Constructor.
virtual double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const =0
Returns the shadow fading correlation distance.
virtual double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
Smart pointer class similar to boost::intrusive_ptr.
Ptr< UniformRandomVariable > m_uniformVar
a uniform random variable used for the computation of the breakpoint distance
static TypeId GetTypeId(void)
Get the type ID.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
double GetBpDistance(double hUt, double hBs, double distance2D) const
Computes the breakpoint distance.
Ptr< ChannelConditionModel > m_channelConditionModel
pointer to the channel condition model
Implements the pathloss model defined in 3GPP TR 38.901, Table 7.4.1-1 for the Indoor Office scenario...
#define NS_UNUSED(x)
Mark a local variable as unused.
static Vector GetVectorDifference(Ptr< MobilityModel > a, Ptr< MobilityModel > b)
Get the difference between the node position.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
virtual double GetLossNlos(double distance2D, double distance3D, double hUt, double hBs) const =0
Computes the pathloss between a and b considering that the line of sight is obstructed.
double CalculateDistance(const Vector3D &a, const Vector3D &b)
virtual double GetLossLos(double distance2D, double distance3D, double hUt, double hBs) const override
Computes the pathloss between a and b considering that the line of sight is not obstructed.
double m_w
average street width in meters
double m_frequency
operating frequency in Hz
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
std::pair< double, double > GetUtAndBsHeights(double za, double zb) const override
Determines hUT and hBS.
double GetLossNlos(double distance2D, double distance3D, double hUt, double hBs) const override
Computes the pathloss between a and b considering that the line of sight is obstructed.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void SetFrequency(double f)
Set the central frequency of the model.
virtual double GetLossNlos(double distance2D, double distance3D, double hUt, double hBs) const override
Computes the pathloss between a and b considering that the line of sight is obstructed.
Ptr< ChannelConditionModel > GetChannelConditionModel(void) const
Returns the associated channel condition model.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual ~ThreeGppUmaPropagationLossModel() override
Destructor.
virtual int64_t DoAssignStreams(int64_t stream) override
If this model uses objects of type RandomVariableStream, set the stream numbers to the integers start...
ThreeGppPropagationLossModel()
Constructor.
double m_h
average building height in meters
static TypeId GetTypeId(void)
Get the type ID.
virtual ~ThreeGppUmiStreetCanyonPropagationLossModel() override
Destructor.
virtual double GetShadowingStd(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const =0
Returns the shadow fading standard deviation.
double GetFrequency(void) const
Return the current central frequency.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
virtual double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
virtual double GetShadowingStd(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading standard deviation.
Implements the pathloss model defined in 3GPP TR 38.901, Table 7.4.1-1 for the UMa scenario.
double f(double x, void *params)
virtual int64_t DoAssignStreams(int64_t stream) override
If this model uses objects of type RandomVariableStream, set the stream numbers to the integers start...
virtual double GetLossLos(double distance2D, double distance3D, double hUt, double hBs) const =0
Computes the pathloss between a and b considering that the line of sight is not obstructed.
static TypeId GetTypeId(void)
Get the type ID.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
ThreeGppUmiStreetCanyonPropagationLossModel()
Constructor.
ThreeGppUmaPropagationLossModel()
Constructor.
bool m_shadowingEnabled
enable/disable shadowing
virtual double GetLossNlosv(double distance2D, double distance3D, double hUt, double hBs) const
Computes the pathloss between a and b considering that the line of sight is obstructed by a vehicle.
static double GetBpDistance(double frequency, double hA, double hB)
Computes the breakpoint distance for the RMa scenario.
Base class for the 3GPP propagation models.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
virtual std::pair< double, double > GetUtAndBsHeights(double za, double zb) const
Determines hUT and hBS.
std::unordered_map< uint32_t, ShadowingMapItem > m_shadowingMap
map to store the shadowing values
virtual void DoDispose() override
Destructor implementation.
double GetLoss(Ptr< ChannelCondition > cond, double distance2D, double distance3D, double hUt, double hBs) const
Computes the pathloss between a and b.
virtual double GetShadowingStd(Ptr< MobilityModel > a, Ptr< MobilityModel > b, ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading standard deviation.
virtual 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.
static TypeId GetTypeId(void)
Get the type ID.
virtual double GetShadowingCorrelationDistance(ChannelCondition::LosConditionValue cond) const override
Returns the shadow fading correlation distance.
virtual ~ThreeGppPropagationLossModel() override
Destructor.
static uint32_t GetKey(Ptr< MobilityModel > a, Ptr< MobilityModel > b)
Returns an unique key for the channel between a and b.
void SetChannelConditionModel(Ptr< ChannelConditionModel > model)
Set the channel condition model used to determine the channel state (e.g., the LOS/NLOS condition)
Vector GetPosition(void) const
Define a struct for the m_shadowingMap entries.
static double Calculate2dDistance(Vector a, Vector b)
Computes the 2D distance between two 3D vectors.
double GetLossLos(double distance2D, double distance3D, double hUt, double hBs) const override
Computes the pathloss between a and b considering that the line of sight is not obstructed.
double GetLossNlos(double distance2D, double distance3D, double hUt, double hBs) const override
Computes the pathloss between a and b considering that the line of sight is obstructed.