A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
cost231-propagation-loss-model.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008, 2009 INRIA, UDcast
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
7 * <amine.ismail@udcast.com>
8 */
9
11
13
14#include "ns3/double.h"
15#include "ns3/log.h"
16#include "ns3/mobility-model.h"
17#include "ns3/pointer.h"
18
19#include <cmath>
20
21namespace ns3
22{
23
24NS_LOG_COMPONENT_DEFINE("Cost231PropagationLossModel");
25
26NS_OBJECT_ENSURE_REGISTERED(Cost231PropagationLossModel);
27
28TypeId
30{
31 static TypeId tid =
32 TypeId("ns3::Cost231PropagationLossModel")
34 .SetGroupName("Propagation")
35 .AddConstructor<Cost231PropagationLossModel>()
36 .AddAttribute("Lambda",
37 "The wavelength (default is 2.3 GHz at 300 000 km/s).",
38 DoubleValue(300000000.0 / 2.3e9),
41 .AddAttribute("Frequency",
42 "The Frequency (default is 2.3 GHz).",
43 DoubleValue(2.3e9),
46 .AddAttribute("BSAntennaHeight",
47 "BS Antenna Height (default is 50m).",
48 DoubleValue(50.0),
51 .AddAttribute("SSAntennaHeight",
52 "SS Antenna Height (default is 3m).",
53 DoubleValue(3),
56 .AddAttribute(
57 "MinDistance",
58 "The distance under which the propagation model refuses to give results (m).",
59 DoubleValue(0.5),
63 return tid;
64}
65
70
71void
72Cost231PropagationLossModel::SetLambda(double frequency, double speed)
73{
74 m_lambda = speed / frequency;
75 m_frequency = frequency;
76}
77
78double
83
84void
86{
87 m_shadowing = shadowing;
88}
89
90void
92{
93 m_lambda = lambda;
94 m_frequency = 300000000 / lambda;
95}
96
97double
102
103void
105{
106 m_minDistance = minDistance;
107}
108
109double
114
115void
120
121double
126
127void
132
133double
138
139double
141{
142 double distance = a->GetDistanceFrom(b);
143 if (distance <= m_minDistance)
144 {
145 return 0.0;
146 }
147
148 double logFrequencyMhz = std::log10(m_frequency * 1e-6);
149 double logDistanceKm = std::log10(distance * 1e-3);
150 double logBSAntennaHeight = std::log10(m_BSAntennaHeight);
151
152 double C_H =
153 0.8 + ((1.11 * logFrequencyMhz) - 0.7) * m_SSAntennaHeight - (1.56 * logFrequencyMhz);
154
155 // from the COST231 wiki entry
156 // See also http://www.lx.it.pt/cost231/final_report.htm
157 // Ch. 4, eq. 4.4.3, pg. 135
158
159 double loss_in_db = 46.3 + (33.9 * logFrequencyMhz) - (13.82 * logBSAntennaHeight) - C_H +
160 ((44.9 - 6.55 * logBSAntennaHeight) * logDistanceKm) + m_shadowing;
161
162 NS_LOG_DEBUG("dist =" << distance << ", Path Loss = " << loss_in_db);
163
164 return (0 - loss_in_db);
165}
166
167double
170 Ptr<MobilityModel> b) const
171{
172 return txPowerDbm + GetLoss(a, b);
173}
174
175int64_t
177{
178 return 0;
179}
180
181} // namespace ns3
The COST-Hata-Model is the most often cited of the COST 231 models.
double GetShadowing() const
Get the shadowing value.
void SetShadowing(double shadowing)
Set the shadowing value.
double GetLambda() const
Get the wavelength.
void SetBSAntennaHeight(double height)
Set the BS antenna height.
int64_t DoAssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
double GetBSAntennaHeight() const
Get the BS antenna height.
double GetSSAntennaHeight() const
Get the SS antenna height.
double GetMinDistance() const
Get the minimum model distance.
void SetSSAntennaHeight(double height)
Set the SS antenna height.
void SetLambda(double lambda)
Set the wavelength.
void SetMinDistance(double minDistance)
Set the minimum model distance.
double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Get the propagation loss.
double DoCalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const override
PropagationLossModel.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Models the propagation loss through a transmission medium.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32