OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * This software was developed at the National Institute of Standards and |
| 4 * Technology by employees of the Federal Government in the course of |
| 5 * their official duties. Pursuant to titleElement 17 Section 105 of the United |
| 6 * States Code this software is not subject to copyright protection and |
| 7 * is in the public domain. |
| 8 * NIST assumes no responsibility whatsoever for its use by other parties, |
| 9 * and makes no guarantees, expressed or implied, about its quality, |
| 10 * reliability, or any other characteristic. |
| 11 *· |
| 12 * We would appreciate acknowledgement if the software is used. |
| 13 *· |
| 14 * NIST ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION AND |
| 15 * DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING |
| 16 * FROM THE USE OF THIS SOFTWARE. |
| 17 *· |
| 18 * Modified by: NIST |
| 19 * It was tested under ns-3.22 |
| 20 */ |
| 21 |
| 22 #include "ns3/log.h" |
| 23 #include "ns3/double.h" |
| 24 #include "ns3/enum.h" |
| 25 #include "ns3/vector.h" |
| 26 #include "ns3/box.h" |
| 27 #include "ns3/mobility-model.h" |
| 28 #include <cmath> |
| 29 #include "nist-hybrid-propagation-loss-model.h" |
| 30 #include "ns3/mobility-building-info.h" |
| 31 #include "ns3/node.h" |
| 32 #include <ns3/nist-lte-enb-net-device.h> |
| 33 #include <ns3/nist-lte-ue-net-device.h> |
| 34 |
| 35 NS_LOG_COMPONENT_DEFINE ("NistHybridPropagationLossModel"); |
| 36 |
| 37 namespace ns3 { |
| 38 |
| 39 NS_OBJECT_ENSURE_REGISTERED (NistHybridPropagationLossModel); |
| 40 |
| 41 |
| 42 TypeId |
| 43 NistHybridPropagationLossModel::GetTypeId (void) |
| 44 { |
| 45 static TypeId tid = TypeId ("ns3::NistHybridPropagationLossModel") |
| 46 .SetParent<PropagationLossModel> () |
| 47 .AddConstructor<NistHybridPropagationLossModel> () |
| 48 .AddAttribute ("Frequency", |
| 49 "The propagation frequency in Hz", |
| 50 DoubleValue (763e6), |
| 51 MakeDoubleAccessor (&NistHybridPropagationLossModel::m_frequ
ency), |
| 52 MakeDoubleChecker<double> ()) |
| 53 ; |
| 54 |
| 55 return tid; |
| 56 } |
| 57 |
| 58 NistHybridPropagationLossModel::NistHybridPropagationLossModel () |
| 59 : PropagationLossModel () |
| 60 { |
| 61 m_rand = CreateObject<UniformRandomVariable> (); |
| 62 } |
| 63 |
| 64 NistHybridPropagationLossModel::~NistHybridPropagationLossModel () |
| 65 { |
| 66 } |
| 67 |
| 68 double |
| 69 NistHybridPropagationLossModel::GetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel
> b) const |
| 70 { |
| 71 |
| 72 // Pathloss |
| 73 double loss = 0.0; |
| 74 // Frequency in GHz |
| 75 double fc = m_frequency / 1e9;·· |
| 76 // Propagation velocity in free space |
| 77 double c = 3 * std::pow (10, 8); |
| 78 |
| 79 // Actual antenna heights (1.5 m for UEs)·· |
| 80 double hms = a->GetPosition ().z; |
| 81 double hbs = b->GetPosition ().z; |
| 82 // Effective antenna heights (0.7 m for UEs) |
| 83 double hbs1 = hbs - 1; |
| 84 double hms1 = hms - 0.7; |
| 85 |
| 86 double d1 = 4 * hbs1 * hms1 * m_frequency * (1 / c); |
| 87 |
| 88 // Distance between the two nodes |
| 89 double dist = a->GetDistanceFrom (b); |
| 90 // Distance between the outdoor terminal and the point on the wall· |
| 91 // that is the nearest to the indoor terminal |
| 92 double dout = 0; |
| 93 // Distance from the wall to the indoor terminal |
| 94 double din = 0;· |
| 95 |
| 96 // Find the indoor node |
| 97 Ptr<MobilityModel> in; |
| 98 Ptr<MobilityModel> out; |
| 99 |
| 100 if (a->GetObject<MobilityBuildingInfo> ()->IsIndoor ()) |
| 101 { |
| 102 in = a; |
| 103 out = b; |
| 104 } |
| 105 else· |
| 106 { |
| 107 in = b; |
| 108 out = a; |
| 109 } |
| 110 |
| 111 // Get the position vectors of the indoor and outdoor nodes |
| 112 Vector inPosition = in->GetPosition (); |
| 113 Vector outPosition = out->GetPosition (); |
| 114 // Get the boundaries of the building of the indoor node· |
| 115 Box inBox = in->GetObject<MobilityBuildingInfo> ()->GetBuilding ()->GetBoundar
ies (); |
| 116 // Calculate the din and the position of the nearest point on the wall to the
indoor node |
| 117 Vector3D wallPosition; |
| 118 if (inBox.GetClosestSide (inPosition) == Box::LEFT) |
| 119 { |
| 120 din = std::abs (inPosition.x - inBox.xMin); |
| 121 Vector3D wallPosition (inBox.xMin, inPosition.y, inPosition.z); |
| 122 } |
| 123 else if (inBox.GetClosestSide (inPosition) == Box::RIGHT) |
| 124 { |
| 125 din = std::abs (inPosition.x - inBox.xMax); |
| 126 Vector3D wallPosition (inBox.xMax, inPosition.y, inPosition.z); |
| 127 } |
| 128 else if (inBox.GetClosestSide (inPosition) == Box::BOTTOM) |
| 129 { |
| 130 din = std::abs (inPosition.y - inBox.yMin); |
| 131 Vector3D wallPosition (inPosition.x, inBox.yMin, inPosition.z); |
| 132 } |
| 133 else if (inBox.GetClosestSide (inPosition) == Box::TOP) |
| 134 { |
| 135 din = std::abs (inPosition.y - inBox.yMax); |
| 136 Vector3D wallPosition (inPosition.x, inBox.yMax, inPosition.z); |
| 137 } |
| 138 else if (inBox.GetClosestSide (inPosition) == Box::DOWN) |
| 139 { |
| 140 din = std::abs (inPosition.z - inBox.zMin); |
| 141 Vector3D wallPosition (inPosition.x, inPosition.y, inBox.zMin); |
| 142 } |
| 143 else if (inBox.GetClosestSide (inPosition) == Box::UP) |
| 144 { |
| 145 din = std::abs (inPosition.z - inBox.zMax); |
| 146 Vector3D wallPosition (inPosition.x, inPosition.y, inBox.zMax); |
| 147 } |
| 148 // Calculate the dout |
| 149 dout = CalculateDistance (outPosition, wallPosition); |
| 150 |
| 151 // Calculate the pathloss based on 3GPP specifications : 3GPP TR 36.843 V12.0.
1 |
| 152 // WINNER II Channel Models, D1.1.2 V1.2., Equation (4.24) p.43, available at· |
| 153 // http://www.cept.org/files/1050/documents/winner2%20-%20final%20report.pdf |
| 154 double lossFree = 20 * std::log10 (dist) + 46.6 + 20 * std::log10 (fc / 5.0); |
| 155 |
| 156 // Calculate the LOS probability based on 3GPP specifications : 3GPP TR 36.843
V12.0.1 |
| 157 // "Guidelines for evaluation of radio interface technologies for IMT-Advanced
", |
| 158 // Draft new Report ITU-R M.[IMT.EVAL], Document 5/69-E. |
| 159 // for outdoor users only |
| 160 double plos = std::min ((18 / dist), 1.0) * (1 - std::exp (-dist / 36)) + std:
:exp (-dist / 36); |
| 161 ·· |
| 162 // Generate a random number between 0 and 1 (if it doesn't already exist) to e
valuate the LOS/NLOS situation |
| 163 double r = 0.0; |
| 164 |
| 165 MobilityDuo couple; |
| 166 couple.a = a; |
| 167 couple.b = b; |
| 168 std::map<MobilityDuo, double>::iterator it_a = m_randomMap.find (couple); |
| 169 if (it_a != m_randomMap.end ()) |
| 170 { |
| 171 r = it_a->second; |
| 172 } |
| 173 else |
| 174 { |
| 175 couple.a = b; |
| 176 couple.b = a; |
| 177 std::map<MobilityDuo, double>::iterator it_b = m_randomMap.find (couple); |
| 178 if (it_b != m_randomMap.end ()) |
| 179 { |
| 180 r = it_b->second; |
| 181 } |
| 182 else |
| 183 { |
| 184 m_randomMap[couple] = m_rand->GetValue (0,1); |
| 185 r = m_randomMap[couple]; |
| 186 } |
| 187 } |
| 188 |
| 189 //std::cout << "hybrid = " << r << " - "; |
| 190 // LOS offset = LOS loss to add to the computed pathloss |
| 191 double los = 0; |
| 192 // NLOS offset = NLOS loss to add to the computed pathloss |
| 193 double nlos = 5; |
| 194 |
| 195 double lossOut = 0.0; |
| 196 |
| 197 if (r <= plos) |
| 198 { |
| 199 // LOS |
| 200 if (dist <= d1) |
| 201 { |
| 202 lossOut = 22.7 * std::log10 (din + dout) + 27.0 + 20.0 * std::log10 (fc)
+ los;· |
| 203 } |
| 204 else |
| 205 { |
| 206 lossOut = 40 * std::log10 (din + dout) + 7.56 - 17.3 * std::log10 (hbs1)
- 17.3 * std::log10 (hms1) + 2.7 * std::log10 (fc) + los;·· |
| 207 } |
| 208 |
| 209 lossOut = std::max (lossFree, lossOut); |
| 210 |
| 211 loss = lossOut + 20.0 + 0.5 * din; |
| 212 NS_LOG_INFO (this << "Hybrid LOS = " << loss); |
| 213 }· |
| 214 else |
| 215 { |
| 216 // NLOS |
| 217 if ((fc >= 0.758) and (fc <= 0.798)) |
| 218 { |
| 219 // Frequency = 700 MHz for Public Safety |
| 220 lossOut = (44.9 - 6.55 * std::log10 (hbs)) * std::log10 (din + dout) + 5.8
3 * std::log10 (hbs) + 16.33 + 26.16 * std::log10 (fc) + nlos;···· |
| 221 } |
| 222 if ((fc >= 1.92) and (fc <= 2.17)) |
| 223 { |
| 224 // Frequency = 2 GHz for general scenarios |
| 225 lossOut = (44.9 - 6.55 * std::log10 (hbs)) * std::log10 (din + dout) + 5.8
3 * std::log10 (hbs) + 14.78 + 34.97 * std::log10 (fc) + nlos; |
| 226 } |
| 227 ·· |
| 228 lossOut = std::max (lossFree, lossOut); |
| 229 |
| 230 loss = lossOut + 20.0 + 0.5 * din - 0.8 * hms;··· |
| 231 NS_LOG_INFO (this << "Hybrid NLOS = " << loss); |
| 232 } |
| 233 |
| 234 return std::max (0.0, loss); |
| 235 } |
| 236 |
| 237 double· |
| 238 NistHybridPropagationLossModel::DoCalcRxPower (double txPowerDbm, |
| 239 Ptr<MobilityModel> a, |
| 240 Ptr<MobilityModel> b) const |
| 241 { |
| 242 return (txPowerDbm - GetLoss (a, b)); |
| 243 } |
| 244 |
| 245 int64_t |
| 246 NistHybridPropagationLossModel::DoAssignStreams (int64_t stream) |
| 247 { |
| 248 return 0; |
| 249 } |
| 250 |
| 251 |
| 252 } // namespace ns3 |
| 253 |
| 254 |
OLD | NEW |