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 
41 /*
42  * Test 1.1 BuildingsPathlossModel Pathloss compound test
43  *
44  * This TestSuite tests the BuildingPathlossModel by reproducing
45  * several communication scenarios
46  */
48  : TestSuite ("buildings-pathloss-test", SYSTEM)
49 {
50 
51  LogComponentEnable ("BuildingsPathlossTest", LOG_LEVEL_ALL);
52 
53  double freq = 869e6; // E_UTRA BAND #5 see table 5.5-1 of 36.101
54 
55  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, LargeCity, 137.93, "OH Urban Large city"), TestCase::QUICK);
56 
57  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, SmallCity, 137.88, "OH Urban small city"), TestCase::QUICK);
58 
59  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, SubUrbanEnvironment, LargeCity, 128.03, "loss OH SubUrban"), TestCase::QUICK);
60 
61  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, OpenAreasEnvironment, LargeCity, 110.21, "loss OH OpenAreas"), TestCase::QUICK);
62 
63  // Test #2 COST231 Model (1500 < freq < 2000~2170 MHz) (Macro<->UE)
64 
65  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
66 
67  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, LargeCity, 148.55, "COST231 Urban Large city"), TestCase::QUICK);
68 
69  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, SmallCity, 150.64, "COST231 Urban small city and suburban"), TestCase::QUICK);
70 
71  // Test #3 2.6 GHz model (Macro<->UE)
72 
73  freq = 2.620e9; // E_UTRA BAND #7 see table 5.5-1 of 36.101
74 
75  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, SmallCity, 121.83, "2.6GHz model"), TestCase::QUICK);
76 
77  // Test #4 ITU1411 LOS model (Macro<->UE)
78 
79  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
80  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 3, UrbanEnvironment, LargeCity, 81.00, "ITU1411 LOS"), TestCase::QUICK);
81 
82  // Test #5 ITU1411 NLOS model (Macro<->UE)
83 
84  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
85 
86  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 4, UrbanEnvironment, LargeCity, 143.69, "ITU1411 NLOS"), TestCase::QUICK);
87 
88  // Test #6 ITUP1238 (HeNB <-> UE)
89 
90  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
91  AddTestCase (new BuildingsPathlossTestCase (freq, 5, 6, UrbanEnvironment, LargeCity, 88.3855, "ITUP1238"), TestCase::QUICK);
92 
93  // Test #7 Outdoor -> Indoor OkumuraHata (Macro<->UE)
94 
95  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
96  // The loss is as in test #2 (large city) plus the building penetration loss
97  // which for ConcreteWithWindows is equal to 7 dB -> 148.55 + 7 = 155.55
98  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 7, UrbanEnvironment, LargeCity, 155.55, "Okumura Hata Outdoor -> Indoor"), TestCase::QUICK);
99 
100  // Test #8 Outdoor -> Indoor ITU1411 (Macro<->UE)
101  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
102  // The loss is as in test #4 plus the building penetration loss
103  // which for ConcreteWithWindows is equal to 7 dB -> 81.000 + 7 = 88.000
104  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 8, UrbanEnvironment, LargeCity, 88.000, "ITU1411 LOS Outdoor -> Indoor"), TestCase::QUICK);
105 
106  // Test #9 Indoor -> Outdoor LOS (HeNB <-> UE)
107 
108  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
109  // The loss is similar of test #4 plus the building penetration loss
110  // which for ConcreteWithWindows is equal to 7 dB and the height gain
111  // (2 floors x 2 dB/floor = 4) -> 81.838 + 7 - 4 = 84.838
112  AddTestCase (new BuildingsPathlossTestCase (freq, 9, 10, UrbanEnvironment, LargeCity, 84.838, "ITU1411 LOS Indoor -> Outdoor"), TestCase::QUICK);
113 
114  // Test #10 Indoor -> Outdoor NLOS (HeNB <-> UE)
115 
116  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
117  // The loss is similar as in test #4 plus the building penetration loss
118  // which for ConcreteWithWindows is equal to 7 dB and the height gain
119  // (2 floors x 2 dB/floor = 4) -> 180.90 + 7 - 4 = 183.90
120  AddTestCase (new BuildingsPathlossTestCase (freq, 9, 11, UrbanEnvironment, LargeCity, 183.90, "ITU1411 NLOS Indoor -> Outdoor"), TestCase::QUICK);
121 
122 
123 }
124 
125 
128 
129 
130 /*
131  * TestCase
132  */
133 
134 BuildingsPathlossTestCase::BuildingsPathlossTestCase (double freq, uint16_t m1, uint16_t m2, EnvironmentType env, CitySize city, double refValue, std::string name)
135  : TestCase ("LOSS calculation: " + name),
136  m_freq (freq),
137  m_mobilityModelIndex1 (m1),
138  m_mobilityModelIndex2 (m2),
139  m_env (env),
140  m_city (city),
141  m_lossRef (refValue)
142 {
143 }
144 
146 {
147 }
148 
149 void
151 {
152  NS_LOG_FUNCTION (this);
153 
154  // the building basically occupies the negative x plane, so any node
155  // in this area will fall in the building
156  Ptr<Building> building1 = CreateObject<Building> ();
157  building1->SetBoundaries (Box (-3000, -1, -4000, 4000.0, 0.0, 12));
158  building1->SetBuildingType (Building::Residential);
159  building1->SetExtWallsType (Building::ConcreteWithWindows);
160  building1->SetNFloors (3);
161 
164 
165  Ptr<HybridBuildingsPropagationLossModel> propagationLossModel = CreateObject<HybridBuildingsPropagationLossModel> ();
166  propagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq));
167  propagationLossModel->SetAttribute ("Environment", EnumValue (m_env));
168  propagationLossModel->SetAttribute ("CitySize", EnumValue (m_city));
169  // cancel shadowing effect
170  propagationLossModel->SetAttribute ("ShadowSigmaOutdoor", DoubleValue (0.0));
171  propagationLossModel->SetAttribute ("ShadowSigmaIndoor", DoubleValue (0.0));
172  propagationLossModel->SetAttribute ("ShadowSigmaExtWalls", DoubleValue (0.0));
173 
174  double loss = propagationLossModel->GetLoss (mma, mmb);
175 
176  NS_LOG_INFO ("Calculated loss: " << loss);
177  NS_LOG_INFO ("Theoretical loss: " << m_lossRef);
178 
179  NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss !");
180  Simulator::Destroy ();
181 }
182 
185 {
186 
187  /*
188  * The purpose of this method is to defer the creation of the
189  * MobilityModel instances to when DoRun() is called. In a previous
190  * version, MobilityModel instances where created directly in the
191  * constructor of the test suite, which caused subtle bugs due to
192  * "static initialization order fiasco". An example of such a subtle
193  * bug is that logging via NS_LOG failed for some modules.
194  *
195  */
196 
197  double hm = 1;
198  double hb = 30;
199  double henbHeight = 10.0;
200 
202 
203  switch (index)
204  {
205  case 1:
206  mm = CreateObject<ConstantPositionMobilityModel> ();
207  mm->SetPosition (Vector (0.0, 0.0, hb));
208  break;
209 
210  case 2:
211  mm = CreateObject<ConstantPositionMobilityModel> ();
212  mm->SetPosition (Vector (2000, 0.0, hm));
213  break;
214 
215  case 3:
216  mm = CreateObject<ConstantPositionMobilityModel> ();
217  mm->SetPosition (Vector (100, 0.0, hm));
218  break;
219 
220  case 4:
221  mm = CreateObject<ConstantPositionMobilityModel> ();
222  mm->SetPosition (Vector (900, 0.0, hm));
223  break;
224 
225  case 5:
226  mm = CreateObject<ConstantPositionMobilityModel> ();
227  mm->SetPosition (Vector (-5, 0.0, hm));
228  break;
229 
230  case 6:
231  mm = CreateObject<ConstantPositionMobilityModel> ();
232  mm->SetPosition (Vector (-5, 30, henbHeight));
233  break;
234 
235  case 7:
236  mm = CreateObject<ConstantPositionMobilityModel> ();
237  mm->SetPosition (Vector (-2000, 0.0, hm));
238  break;
239 
240  case 8:
241  mm = CreateObject<ConstantPositionMobilityModel> ();
242  mm->SetPosition (Vector (-100, 0.0, hm));
243  break;
244 
245  case 9:
246  mm = CreateObject<ConstantPositionMobilityModel> ();
247  mm->SetPosition (Vector (0, 0.0, hm));
248  break;
249 
250  case 10:
251  mm = CreateObject<ConstantPositionMobilityModel> ();
252  mm->SetPosition (Vector (-100, 0.0, henbHeight));
253  break;
254 
255  case 11:
256  mm = CreateObject<ConstantPositionMobilityModel> ();
257  mm->SetPosition (Vector (-500, 0.0, henbHeight));
258  break;
259 
260  default:
261  mm = 0;
262  break;
263  }
264  Ptr<MobilityBuildingInfo> buildingInfo = CreateObject<MobilityBuildingInfo> ();
265  mm->AggregateObject (buildingInfo); // operation usually done by BuildingsHelper::Install
266  buildingInfo->MakeConsistent (mm);
267  return mm;
268 }
static BuildingsPathlossTestSuite buildingsPathlossTestSuite
Static variable for test initialization.
Test 1.1 BuildingsPathlossModel Pathloss test.
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
Create a mobility model based on its index.
uint16_t m_mobilityModelIndex2
Second MobilityModel Index.
double m_lossRef
Theoretical loss.
virtual void DoRun(void)
Implementation to actually run this TestCase.
double m_freq
Communication frequency.
EnvironmentType m_env
Enviroment type.
uint16_t m_mobilityModelIndex1
First MobilityModel Index.
BuildingsPathlossTestCase(double freq, uint16_t m1, uint16_t m2, EnvironmentType env, CitySize city, double refValue, std::string name)
Constructor.
Test 1.1 BuildingsPathlossModel Pathloss compound test.
a 3d box
Definition: box.h:35
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
Hold variables of type enum.
Definition: enum.h:55
void SetPosition(const Vector &position)
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:252
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
EnvironmentType
The type of propagation environment.
CitySize
The size of the city in which propagation takes place.
#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:323
const double m1
First component modulus, 232 - 209.
Definition: rng-stream.cc:58
const double m2
Second component modulus, 232 - 22853.
Definition: rng-stream.cc:61
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ LOG_LEVEL_ALL
Print everything.
Definition: log.h:116
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:361