23 #include "ns3/propagation-loss-model.h"
25 #include "ns3/mobility-model.h"
26 #include "ns3/double.h"
27 #include "ns3/pointer.h"
29 #include "buildings-propagation-loss-model.h"
30 #include "ns3/buildings-mobility-model.h"
38 NS_OBJECT_ENSURE_REGISTERED (BuildingsPropagationLossModel);
40 BuildingsPropagationLossModel::ShadowingLoss::ShadowingLoss ()
44 BuildingsPropagationLossModel::ShadowingLoss::ShadowingLoss (
double shadowingValue, Ptr<MobilityModel> receiver)
45 : m_shadowingValue (shadowingValue), m_receiver (receiver)
47 NS_LOG_INFO (
this <<
" New Shadowing value " << m_shadowingValue);
51 BuildingsPropagationLossModel::ShadowingLoss::GetLoss ()
const
53 return (m_shadowingValue);
57 BuildingsPropagationLossModel::ShadowingLoss::GetReceiver ()
const
63 BuildingsPropagationLossModel::GetTypeId (
void)
65 static TypeId tid = TypeId (
"ns3::BuildingsPropagationLossModel")
67 .SetParent<PropagationLossModel> ()
70 .AddAttribute (
"ShadowSigmaOutdoor",
71 "Standard deviation of the normal distribution used for calculate the shadowing for outdoor nodes",
73 MakeDoubleAccessor (&BuildingsPropagationLossModel::m_shadowingSigmaOutdoor),
74 MakeDoubleChecker<double> ())
76 .AddAttribute (
"ShadowSigmaIndoor",
77 "Standard deviation of the normal distribution used for calculate the shadowing for indoor nodes ",
79 MakeDoubleAccessor (&BuildingsPropagationLossModel::m_shadowingSigmaIndoor),
80 MakeDoubleChecker<double> ())
81 .AddAttribute (
"ShadowSigmaExtWalls",
82 "Standard deviation of the normal distribution used for calculate the shadowing due to ext walls ",
84 MakeDoubleAccessor (&BuildingsPropagationLossModel::m_shadowingSigmaExtWalls),
85 MakeDoubleChecker<double> ())
87 .AddAttribute (
"InternalWallLoss",
88 "Additional loss for each internal wall [dB]",
90 MakeDoubleAccessor (&BuildingsPropagationLossModel::m_lossInternalWall),
91 MakeDoubleChecker<double> ());
97 BuildingsPropagationLossModel::BuildingsPropagationLossModel ()
99 m_randVariable = CreateObject<NormalRandomVariable> ();
103 BuildingsPropagationLossModel::ExternalWallLoss (Ptr<BuildingsMobilityModel> a)
const
106 Ptr<Building> aBuilding = a->GetBuilding ();
107 if (aBuilding->GetExtWallsType () == Building::Wood)
111 else if (aBuilding->GetExtWallsType () == Building::ConcreteWithWindows)
115 else if (aBuilding->GetExtWallsType () == Building::ConcreteWithoutWindows)
119 else if (aBuilding->GetExtWallsType () == Building::StoneBlocks)
127 BuildingsPropagationLossModel::HeightLoss (Ptr<BuildingsMobilityModel> node)
const
131 int nfloors = node->GetFloorNumber () - 1;
132 loss = -2 * (nfloors);
137 BuildingsPropagationLossModel::InternalWallsLoss (Ptr<BuildingsMobilityModel> a, Ptr<BuildingsMobilityModel>b)
const
140 double dx = std::abs (a->GetRoomNumberX () - b->GetRoomNumberX ());
141 double dy = std::abs (a->GetRoomNumberY () - b->GetRoomNumberY ());
142 return m_lossInternalWall * (dx+dy);
148 BuildingsPropagationLossModel::GetShadowing (Ptr<MobilityModel> a, Ptr<MobilityModel> b)
151 Ptr<BuildingsMobilityModel> a1 = DynamicCast<BuildingsMobilityModel> (a);
152 Ptr<BuildingsMobilityModel> b1 = DynamicCast<BuildingsMobilityModel> (b);
153 NS_ASSERT_MSG ((a1 != 0) && (b1 != 0),
"BuildingsPropagationLossModel only works with BuildingsMobilityModel");
155 std::map<Ptr<MobilityModel>, std::map<Ptr<MobilityModel>, ShadowingLoss> >::iterator ait = m_shadowingLossMap.find (a);
156 if (ait != m_shadowingLossMap.end ())
158 std::map<Ptr<MobilityModel>, ShadowingLoss>::iterator bit = ait->second.find (b);
159 if (bit != ait->second.end ())
161 return (bit->second.GetLoss ());
165 double sigma = EvaluateSigma (a1, b1);
168 double shadowingValue = m_randVariable->GetValue (0.0, (sigma*sigma));
169 ait->second[b] = ShadowingLoss (shadowingValue, b);
170 return (ait->second[b].GetLoss ());
175 double sigma = EvaluateSigma (a1, b1);
178 double shadowingValue = m_randVariable->GetValue (0.0, (sigma*sigma));
179 m_shadowingLossMap[a][b] = ShadowingLoss (shadowingValue, b);
180 return (m_shadowingLossMap[a][b].
GetLoss ());
187 BuildingsPropagationLossModel::EvaluateSigma (Ptr<BuildingsMobilityModel> a, Ptr<BuildingsMobilityModel> b)
194 return (m_shadowingSigmaOutdoor);
198 double sigma = std::sqrt ((m_shadowingSigmaOutdoor * m_shadowingSigmaOutdoor) + (m_shadowingSigmaExtWalls * m_shadowingSigmaExtWalls));
205 return (m_shadowingSigmaIndoor);
209 double sigma = std::sqrt ((m_shadowingSigmaOutdoor * m_shadowingSigmaOutdoor) + (m_shadowingSigmaExtWalls * m_shadowingSigmaExtWalls));
216 BuildingsPropagationLossModel::DoCalcRxPower (
double txPowerDbm, Ptr<MobilityModel> a, Ptr<MobilityModel> b)
const
218 return txPowerDbm -
GetLoss (a, b) - GetShadowing (a, b);
224 m_randVariable->SetStream (stream);
#define NS_LOG_COMPONENT_DEFINE(name)
virtual double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const =0
#define NS_ASSERT_MSG(condition, message)
virtual int64_t DoAssignStreams(int64_t stream)