A Discrete-Event Network Simulator
API
buildings-pathloss-test.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Marco Miozzo <marco.miozzo@cttc.es>
19  * Nicola Baldo <nbaldo@cttc.es>
20  */
21 
22 #include <ns3/simulator.h>
23 
24 #include <ns3/log.h>
25 
26 #include <ns3/buildings-helper.h>
27 #include <ns3/string.h>
28 #include <ns3/double.h>
29 #include <ns3/building.h>
30 #include <ns3/enum.h>
31 #include <ns3/constant-position-mobility-model.h>
32 #include <ns3/mobility-building-info.h>
34 
35 
36 
37 using namespace ns3;
38 
39 NS_LOG_COMPONENT_DEFINE ("BuildingsPathlossTest");
40 
52  : TestSuite ("buildings-pathloss-test", SYSTEM)
53 {
54 
55  LogComponentEnable ("BuildingsPathlossTest", LOG_LEVEL_ALL);
56 
57  double freq = 869e6; // E_UTRA BAND #5 see table 5.5-1 of 36.101
58 
59  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, LargeCity, 137.93, "OH Urban Large city"), TestCase::QUICK);
60 
61  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, SmallCity, 137.88, "OH Urban small city"), TestCase::QUICK);
62 
63  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, SubUrbanEnvironment, LargeCity, 128.03, "loss OH SubUrban"), TestCase::QUICK);
64 
65  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, OpenAreasEnvironment, LargeCity, 110.21, "loss OH OpenAreas"), TestCase::QUICK);
66 
67  // Test #2 COST231 Model (1500 < freq < 2000~2170 MHz) (Macro<->UE)
68 
69  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
70 
71  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, LargeCity, 148.55, "COST231 Urban Large city"), TestCase::QUICK);
72 
73  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, SmallCity, 150.64, "COST231 Urban small city and suburban"), TestCase::QUICK);
74 
75  // Test #3 2.6 GHz model (Macro<->UE)
76 
77  freq = 2.620e9; // E_UTRA BAND #7 see table 5.5-1 of 36.101
78 
79  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, SmallCity, 121.83, "2.6GHz model"), TestCase::QUICK);
80 
81  // Test #4 ITU1411 LOS model (Macro<->UE)
82 
83  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
84  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 3, UrbanEnvironment, LargeCity, 81.00, "ITU1411 LOS"), TestCase::QUICK);
85 
86  // Test #5 ITU1411 NLOS model (Macro<->UE)
87 
88  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
89 
90  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 4, UrbanEnvironment, LargeCity, 143.69, "ITU1411 NLOS"), TestCase::QUICK);
91 
92  // Test #6 ITUP1238 (HeNB <-> UE)
93 
94  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
95  AddTestCase (new BuildingsPathlossTestCase (freq, 5, 6, UrbanEnvironment, LargeCity, 88.3855, "ITUP1238"), TestCase::QUICK);
96 
97  // Test #7 Outdoor -> Indoor OkumuraHata (Macro<->UE)
98 
99  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
100  // The loss is as in test #2 (large city) plus the building penetration loss
101  // which for ConcreteWithWindows is equal to 7 dB -> 148.55 + 7 = 155.55
102  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 7, UrbanEnvironment, LargeCity, 155.55, "Okumura Hata Outdoor -> Indoor"), TestCase::QUICK);
103 
104  // Test #8 Outdoor -> Indoor ITU1411 (Macro<->UE)
105  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
106  // The loss is as in test #4 plus the building penetration loss
107  // which for ConcreteWithWindows is equal to 7 dB -> 81.000 + 7 = 88.000
108  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 8, UrbanEnvironment, LargeCity, 88.000, "ITU1411 LOS Outdoor -> Indoor"), TestCase::QUICK);
109 
110  // Test #9 Indoor -> Outdoor LOS (HeNB <-> UE)
111 
112  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
113  // The loss is similar of test #4 plus the building penetration loss
114  // which for ConcreteWithWindows is equal to 7 dB and the height gain
115  // (2 floors x 2 dB/floor = 4) -> 81.838 + 7 - 4 = 84.838
116  AddTestCase (new BuildingsPathlossTestCase (freq, 9, 10, UrbanEnvironment, LargeCity, 84.838, "ITU1411 LOS Indoor -> Outdoor"), TestCase::QUICK);
117 
118  // Test #10 Indoor -> Outdoor NLOS (HeNB <-> UE)
119 
120  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
121  // The loss is similar as in test #4 plus the building penetration loss
122  // which for ConcreteWithWindows is equal to 7 dB and the height gain
123  // (2 floors x 2 dB/floor = 4) -> 180.90 + 7 - 4 = 183.90
124  AddTestCase (new BuildingsPathlossTestCase (freq, 9, 11, UrbanEnvironment, LargeCity, 183.90, "ITU1411 NLOS Indoor -> Outdoor"), TestCase::QUICK);
125 
126 
127 }
128 
129 
130 
132 
133 
138 BuildingsPathlossTestCase::BuildingsPathlossTestCase (double freq, uint16_t m1, uint16_t m2, EnvironmentType env, CitySize city, double refValue, std::string name)
139  : TestCase ("LOSS calculation: " + name),
140  m_freq (freq),
141  m_mobilityModelIndex1 (m1),
142  m_mobilityModelIndex2 (m2),
143  m_env (env),
144  m_city (city),
145  m_lossRef (refValue)
146 {
147 }
148 
150 {
151 }
152 
153 void
155 {
156  NS_LOG_FUNCTION (this);
157 
158  // the building basically occupies the negative x plane, so any node
159  // in this area will fall in the building
160  Ptr<Building> building1 = CreateObject<Building> ();
161  building1->SetBoundaries (Box (-3000, -1, -4000, 4000.0, 0.0, 12));
162  building1->SetBuildingType (Building::Residential);
163  building1->SetExtWallsType (Building::ConcreteWithWindows);
164  building1->SetNFloors (3);
165 
168 
169  Ptr<HybridBuildingsPropagationLossModel> propagationLossModel = CreateObject<HybridBuildingsPropagationLossModel> ();
170  propagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq));
171  propagationLossModel->SetAttribute ("Environment", EnumValue (m_env));
172  propagationLossModel->SetAttribute ("CitySize", EnumValue (m_city));
173  // cancel shadowing effect
174  propagationLossModel->SetAttribute ("ShadowSigmaOutdoor", DoubleValue (0.0));
175  propagationLossModel->SetAttribute ("ShadowSigmaIndoor", DoubleValue (0.0));
176  propagationLossModel->SetAttribute ("ShadowSigmaExtWalls", DoubleValue (0.0));
177 
178  double loss = propagationLossModel->GetLoss (mma, mmb);
179 
180  NS_LOG_INFO ("Calculated loss: " << loss);
181  NS_LOG_INFO ("Theoretical loss: " << m_lossRef);
182 
183  NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss !");
184  Simulator::Destroy ();
185 }
186 
189 {
190 
191  /*
192  * The purpose of this method is to defer the creation of the
193  * MobilityModel instances to when DoRun() is called. In a previous
194  * version, MobilityModel instances where created directly in the
195  * constructor of the test suite, which caused subtle bugs due to
196  * "static initialization order fiasco". An example of such a subtle
197  * bug is that logging via NS_LOG failed for some modules.
198  *
199  */
200 
201  double hm = 1;
202  double hb = 30;
203  double henbHeight = 10.0;
204 
206 
207  switch (index)
208  {
209  case 1:
210  mm = CreateObject<ConstantPositionMobilityModel> ();
211  mm->SetPosition (Vector (0.0, 0.0, hb));
212  break;
213 
214  case 2:
215  mm = CreateObject<ConstantPositionMobilityModel> ();
216  mm->SetPosition (Vector (2000, 0.0, hm));
217  break;
218 
219  case 3:
220  mm = CreateObject<ConstantPositionMobilityModel> ();
221  mm->SetPosition (Vector (100, 0.0, hm));
222  break;
223 
224  case 4:
225  mm = CreateObject<ConstantPositionMobilityModel> ();
226  mm->SetPosition (Vector (900, 0.0, hm));
227  break;
228 
229  case 5:
230  mm = CreateObject<ConstantPositionMobilityModel> ();
231  mm->SetPosition (Vector (-5, 0.0, hm));
232  break;
233 
234  case 6:
235  mm = CreateObject<ConstantPositionMobilityModel> ();
236  mm->SetPosition (Vector (-5, 30, henbHeight));
237  break;
238 
239  case 7:
240  mm = CreateObject<ConstantPositionMobilityModel> ();
241  mm->SetPosition (Vector (-2000, 0.0, hm));
242  break;
243 
244  case 8:
245  mm = CreateObject<ConstantPositionMobilityModel> ();
246  mm->SetPosition (Vector (-100, 0.0, hm));
247  break;
248 
249  case 9:
250  mm = CreateObject<ConstantPositionMobilityModel> ();
251  mm->SetPosition (Vector (0, 0.0, hm));
252  break;
253 
254  case 10:
255  mm = CreateObject<ConstantPositionMobilityModel> ();
256  mm->SetPosition (Vector (-100, 0.0, henbHeight));
257  break;
258 
259  case 11:
260  mm = CreateObject<ConstantPositionMobilityModel> ();
261  mm->SetPosition (Vector (-500, 0.0, henbHeight));
262  break;
263 
264  default:
265  mm = 0;
266  break;
267  }
268  Ptr<MobilityBuildingInfo> buildingInfo = CreateObject<MobilityBuildingInfo> ();
269  mm->AggregateObject (buildingInfo); // operation usually done by BuildingsHelper::Install
270  buildingInfo->MakeConsistent (mm);
271  return mm;
272 }
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
EnvironmentType
The type of propagation environment.
A suite of tests to run.
Definition: test.h:1343
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
BuildingsPathlossTestSuite()
Test 1.1 BuildingsPathlossModel Pathloss compound test.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
const double m1
First component modulus, 232 - 209.
Definition: rng-stream.cc:58
encapsulates test code
Definition: test.h:1153
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
a 3d box
Definition: box.h:34
virtual double GetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:361
Hold variables of type enum.
Definition: enum.h:54
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
void SetNFloors(uint16_t nfloors)
Definition: building.cc:160
Test 1.1 pathloss calculation.
BuildingsPathlossTestCase(double freq, uint16_t m1, uint16_t m2, EnvironmentType env, CitySize city, double refValue, std::string name)
TestCase.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Definition: test.h:378
void SetExtWallsType(Building::ExtWallsType_t t)
Definition: building.cc:153
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetPosition(const Vector &position)
static BuildingsPathlossTestSuite buildingsPathlossTestSuite
CitySize
The size of the city in which propagation takes place.
Print everything.
Definition: log.h:116
const double m2
Second component modulus, 232 - 22853.
Definition: rng-stream.cc:61
void MakeConsistent(Ptr< MobilityModel > mm)
Make the given mobility model consistent, by determining whether its position falls inside any of the...
virtual void DoRun(void)
Implementation to actually run this TestCase.
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
void SetBoundaries(Box box)
Set the boundaries of the building.
Definition: building.cc:139
void SetBuildingType(Building::BuildingType_t t)
Definition: building.cc:146