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/mobility-model.h" |
| 26 #include <cmath> |
| 27 #include <ns3/mobility-building-info.h> |
| 28 #include "nist-indoor-propagation-loss-model.h" |
| 29 #include "ns3/simulator.h" |
| 30 |
| 31 NS_LOG_COMPONENT_DEFINE ("NistIndoorPropagationLossModel"); |
| 32 |
| 33 namespace ns3 { |
| 34 |
| 35 NS_OBJECT_ENSURE_REGISTERED (NistIndoorPropagationLossModel); |
| 36 |
| 37 TypeId |
| 38 NistIndoorPropagationLossModel::GetTypeId (void) |
| 39 { |
| 40 static TypeId tid = TypeId ("ns3::NistIndoorPropagationLossModel") |
| 41 .SetParent<PropagationLossModel> () |
| 42 .AddConstructor<NistIndoorPropagationLossModel> () |
| 43 .AddAttribute ("Frequency", |
| 44 "The propagation frequency in Hz", |
| 45 DoubleValue (763e6), |
| 46 MakeDoubleAccessor (&NistIndoorPropagationLossModel::m_frequ
ency), |
| 47 MakeDoubleChecker<double> ()) |
| 48 ; |
| 49 |
| 50 return tid; |
| 51 } |
| 52 |
| 53 NistIndoorPropagationLossModel::NistIndoorPropagationLossModel () |
| 54 : PropagationLossModel () |
| 55 {· |
| 56 m_rand = CreateObject<UniformRandomVariable> (); |
| 57 } |
| 58 |
| 59 NistIndoorPropagationLossModel::~NistIndoorPropagationLossModel () |
| 60 { |
| 61 } |
| 62 |
| 63 // Initialize the static member |
| 64 //Ptr <UniformRandomVariable> NistRandomVariable::s_rand = CreateObject<UniformR
andomVariable> (); |
| 65 |
| 66 std::pair<double, bool>· |
| 67 NistIndoorPropagationLossModel::GetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel
> b) const |
| 68 { |
| 69 bool los = false; |
| 70 double loss = 0.0; |
| 71 double dist = a->GetDistanceFrom (b); |
| 72 // Calculate the pathloss based on 3GPP specifications : 3GPP TR 36.843 V12.0.
1 |
| 73 // The indoor model is defined by 3GPP TR 36.814 V9.0.0, Table A.2.1.1.5-1 |
| 74 |
| 75 // Same building |
| 76 if (a->GetObject<MobilityBuildingInfo> ()->GetBuilding () == b->GetObject<Mobi
lityBuildingInfo> ()->GetBuilding ()) |
| 77 { |
| 78 // Computing the probability of line of sight (LOS) |
| 79 double plos = 0.0; |
| 80 if (dist <= 18) |
| 81 { |
| 82 plos = 1.0; |
| 83 } |
| 84 else if ((dist > 18) and (dist < 37)) |
| 85 { |
| 86 plos = std::exp (-(dist - 18) / 27); |
| 87 } |
| 88 else· |
| 89 { |
| 90 plos = 0.5; |
| 91 } |
| 92 ·· |
| 93 // Generate a random number between 0 and 1 (if it doesn't already exist) to
evaluate the LOS/NLOS situation |
| 94 double r = 0.0; |
| 95 MobilityDuo couple; |
| 96 couple.a = a; |
| 97 couple.b = b; |
| 98 std::map<MobilityDuo, double>::iterator it_a = m_randomMap.find (couple); |
| 99 if (it_a != m_randomMap.end ()) |
| 100 { |
| 101 r = it_a->second; |
| 102 } |
| 103 else |
| 104 { |
| 105 couple.a = b; |
| 106 couple.b = a; |
| 107 std::map<MobilityDuo, double>::iterator it_b = m_randomMap.find (couple); |
| 108 if (it_b != m_randomMap.end ()) |
| 109 { |
| 110 r = it_b->second; |
| 111 } |
| 112 else |
| 113 { |
| 114 m_randomMap[couple] = m_rand->GetValue (0,1); |
| 115 r = m_randomMap[couple]; |
| 116 } |
| 117 } |
| 118 ···· |
| 119 //std::cout << "indoor = " << r << " - "; |
| 120 // Computing the pathloss when the two nodes are in the same building |
| 121 ···· |
| 122 if (r <= plos) |
| 123 { |
| 124 // LOS |
| 125 loss = 89.5 + 16.9 * std::log10 (dist * 1e-3); |
| 126 los = true; |
| 127 NS_LOG_INFO (this << "Indoor (Same building) LOS = " << loss); |
| 128 } |
| 129 else |
| 130 { |
| 131 // NLOS |
| 132 loss = 147.5 + 43.3 * std::log10 (dist * 1e-3); |
| 133 NS_LOG_INFO (this << "Indoor (Same building) NLOS = " << loss); |
| 134 } |
| 135 } |
| 136 |
| 137 // Different buildings |
| 138 else |
| 139 { |
| 140 // Computing the pathloss when the two nodes are in different buildings |
| 141 loss = std::max (131.1 + 42.8 * std::log10 (dist * 1e3), 147.4 + 43.3 * std:
:log10 (dist * 1e3)); |
| 142 NS_LOG_INFO (this << "Indoor (Different buildings) = " << loss); |
| 143 } |
| 144 |
| 145 // Pathloss correction for Public Safety frequency 700 MHz |
| 146 if (((m_frequency / 1e9) >= 0.758) and ((m_frequency / 1e9) <= 0.798)) |
| 147 { |
| 148 loss = loss + 20 * std::log10 (m_frequency / 2e9); |
| 149 } |
| 150 |
| 151 return std::make_pair(std::max (0.0, loss), los); |
| 152 } |
| 153 |
| 154 double· |
| 155 NistIndoorPropagationLossModel::DoCalcRxPower (double txPowerDbm, |
| 156 Ptr<MobilityModel> a, |
| 157 Ptr<MobilityModel> b) const |
| 158 { |
| 159 return (txPowerDbm - GetLoss (a, b).first); |
| 160 } |
| 161 |
| 162 int64_t |
| 163 NistIndoorPropagationLossModel::DoAssignStreams (int64_t stream) |
| 164 { |
| 165 return 0; |
| 166 } |
| 167 |
| 168 |
| 169 } // namespace ns3 |
| 170 |
OLD | NEW |