A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
buildings-pathloss-test.cc
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 
32 #include "buildings-pathloss-test.h"
33 
34 
35 NS_LOG_COMPONENT_DEFINE ("BuildingsPathlossTest");
36 
37 namespace ns3 {
38 
39 
51  : TestSuite ("buildings-pathloss-test", SYSTEM)
52 {
53 
54  LogComponentEnable ("BuildingsPathlossTest", LOG_LEVEL_ALL);
55 
56  double freq = 869e6; // E_UTRA BAND #5 see table 5.5-1 of 36.101
57 
58  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, LargeCity, 137.93, "OH Urban Large city"), TestCase::QUICK);
59 
60  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, SmallCity, 137.88, "OH Urban small city"), TestCase::QUICK);
61 
62  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, SubUrbanEnvironment, LargeCity, 128.03, "loss OH SubUrban"), TestCase::QUICK);
63 
64  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, OpenAreasEnvironment, LargeCity, 110.21, "loss OH OpenAreas"), TestCase::QUICK);
65 
66  // Test #2 COST231 Model (1500 < freq < 2000~2170 MHz) (Macro<->UE)
67 
68  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
69 
70  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, LargeCity, 148.55, "COST231 Urban Large city"), TestCase::QUICK);
71 
72  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, SmallCity, 150.64, "COST231 Urban small city and suburban"), TestCase::QUICK);
73 
74  // Test #3 2.6 GHz model (Macro<->UE)
75 
76  freq = 2.620e9; // E_UTRA BAND #7 see table 5.5-1 of 36.101
77 
78  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 2, UrbanEnvironment, SmallCity, 121.83, "2.6GHz model"), TestCase::QUICK);
79 
80  // Test #4 ITU1411 LOS model (Macro<->UE)
81 
82  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
83  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 3, UrbanEnvironment, LargeCity, 81.00, "ITU1411 LOS"), TestCase::QUICK);
84 
85  // Test #5 ITU1411 NLOS model (Macro<->UE)
86 
87  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
88 
89  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 4, UrbanEnvironment, LargeCity, 143.69, "ITU1411 NLOS"), TestCase::QUICK);
90 
91  // Test #6 ITUP1238 (HeNB <-> UE)
92 
93  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
94  AddTestCase (new BuildingsPathlossTestCase (freq, 5, 6, UrbanEnvironment, LargeCity, 88.3855, "ITUP1238"), TestCase::QUICK);
95 
96  // Test #7 Outdoor -> Indoor OkumuraHata (Macro<->UE)
97 
98  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
99  // The loss is as in test #2 (large city) plus the building penetration loss
100  // which for ConcreteWithWindows is equal to 7 dB -> 148.55 + 7 = 155.55
101  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 7, UrbanEnvironment, LargeCity, 155.55, "Okumura Hata Outdoor -> Indoor"), TestCase::QUICK);
102 
103  // Test #8 Outdoor -> Indoor ITU1411 (Macro<->UE)
104  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
105  // The loss is as in test #4 plus the building penetration loss
106  // which for ConcreteWithWindows is equal to 7 dB -> 81.000 + 7 = 88.000
107  AddTestCase (new BuildingsPathlossTestCase (freq, 1, 8, UrbanEnvironment, LargeCity, 88.000, "ITU1411 LOS Outdoor -> Indoor"), TestCase::QUICK);
108 
109  // Test #9 Indoor -> Outdoor LOS (HeNB <-> UE)
110 
111  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
112  // The loss is similar of test #4 plus the building penetration loss
113  // which for ConcreteWithWindows is equal to 7 dB and the height gain
114  // (2 floors x 2 dB/floor = 4) -> 81.838 + 7 - 4 = 84.838
115  AddTestCase (new BuildingsPathlossTestCase (freq, 9, 10, UrbanEnvironment, LargeCity, 84.838, "ITU1411 LOS Indoor -> Outdoor"), TestCase::QUICK);
116 
117  // Test #10 Indoor -> Outdoor NLOS (HeNB <-> UE)
118 
119  freq = 2.1140e9; // E_UTRA BAND #1 see table 5.5-1 of 36.101
120  // The loss is similar as in test #4 plus the building penetration loss
121  // which for ConcreteWithWindows is equal to 7 dB and the height gain
122  // (2 floors x 2 dB/floor = 4) -> 180.90 + 7 - 4 = 183.90
123  AddTestCase (new BuildingsPathlossTestCase (freq, 9, 11, UrbanEnvironment, LargeCity, 183.90, "ITU1411 NLOS Indoor -> Outdoor"), TestCase::QUICK);
124 
125 
126 }
127 
128 
129 
130 static BuildingsPathlossTestSuite buildingsPathlossTestSuite;
131 
132 
137 BuildingsPathlossTestCase::BuildingsPathlossTestCase (double freq, uint16_t m1, uint16_t m2, EnvironmentType env, CitySize city, double refValue, std::string name)
138  : TestCase ("LOSS calculation: " + name),
139  m_freq (freq),
140  m_mobilityModelIndex1 (m1),
141  m_mobilityModelIndex2 (m2),
142  m_env (env),
143  m_city (city),
144  m_lossRef (refValue)
145 {
146 }
147 
148 BuildingsPathlossTestCase::~BuildingsPathlossTestCase ()
149 {
150 }
151 
152 void
154 {
155  NS_LOG_FUNCTION (this);
156 
157  // the building basically occupies the negative x plane, so any node
158  // in this area will fall in the building
159  Ptr<Building> building1 = CreateObject<Building> ();
160  building1->SetBoundaries (Box (-3000, -1, -4000, 4000.0, 0.0, 12));
161  building1->SetBuildingType (Building::Residential);
162  building1->SetExtWallsType (Building::ConcreteWithWindows);
163  building1->SetNFloors (3);
164 
165  Ptr<MobilityModel> mma = CreateMobilityModel (m_mobilityModelIndex1);
166  Ptr<MobilityModel> mmb = CreateMobilityModel (m_mobilityModelIndex2);
167 
168  Ptr<HybridBuildingsPropagationLossModel> propagationLossModel = CreateObject<HybridBuildingsPropagationLossModel> ();
169  propagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq));
170  propagationLossModel->SetAttribute ("Environment", EnumValue (m_env));
171  propagationLossModel->SetAttribute ("CitySize", EnumValue (m_city));
172  // cancel shadowing effect
173  propagationLossModel->SetAttribute ("ShadowSigmaOutdoor", DoubleValue (0.0));
174  propagationLossModel->SetAttribute ("ShadowSigmaIndoor", DoubleValue (0.0));
175  propagationLossModel->SetAttribute ("ShadowSigmaExtWalls", DoubleValue (0.0));
176 
177  double loss = propagationLossModel->GetLoss (mma, mmb);
178 
179  NS_LOG_INFO ("Calculated loss: " << loss);
180  NS_LOG_INFO ("Theoretical loss: " << m_lossRef);
181 
182  NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss !");
184 }
185 
187 BuildingsPathlossTestCase::CreateMobilityModel (uint16_t index)
188 {
189 
190  /*
191  * The purpose of this method is to defer the creation of the
192  * MobilityModel instances to when DoRun() is called. In a previous
193  * version, MobilityModel instances where created directly in the
194  * constructor of the test suite, which caused subtle bugs due to
195  * "static initialization order fiasco". An example of such a subtle
196  * bug is that logging via NS_LOG failed for some modules.
197  *
198  */
199 
200  double hm = 1;
201  double hb = 30;
202  double henbHeight = 10.0;
203 
205 
206  switch (index)
207  {
208  case 1:
209  mm = CreateObject<BuildingsMobilityModel> ();
210  mm->SetPosition (Vector (0.0, 0.0, hb));
211  break;
212 
213  case 2:
214  mm = CreateObject<BuildingsMobilityModel> ();
215  mm->SetPosition (Vector (2000, 0.0, hm));
216  break;
217 
218  case 3:
219  mm = CreateObject<BuildingsMobilityModel> ();
220  mm->SetPosition (Vector (100, 0.0, hm));
221  break;
222 
223  case 4:
224  mm = CreateObject<BuildingsMobilityModel> ();
225  mm->SetPosition (Vector (900, 0.0, hm));
226  break;
227 
228  case 5:
229  mm = CreateObject<BuildingsMobilityModel> ();
230  mm->SetPosition (Vector (-5, 0.0, hm));
231  break;
232 
233  case 6:
234  mm = CreateObject<BuildingsMobilityModel> ();
235  mm->SetPosition (Vector (-5, 30, henbHeight));
236  break;
237 
238  case 7:
239  mm = CreateObject<BuildingsMobilityModel> ();
240  mm->SetPosition (Vector (-2000, 0.0, hm));
241  break;
242 
243  case 8:
244  mm = CreateObject<BuildingsMobilityModel> ();
245  mm->SetPosition (Vector (-100, 0.0, hm));
246  break;
247 
248  case 9:
249  mm = CreateObject<BuildingsMobilityModel> ();
250  mm->SetPosition (Vector (0, 0.0, hm));
251  break;
252 
253  case 10:
254  mm = CreateObject<BuildingsMobilityModel> ();
255  mm->SetPosition (Vector (-100, 0.0, henbHeight));
256  break;
257 
258  case 11:
259  mm = CreateObject<BuildingsMobilityModel> ();
260  mm->SetPosition (Vector (-500, 0.0, henbHeight));
261  break;
262 
263  default:
264  mm = 0;
265  break;
266  }
267  BuildingsHelper::MakeConsistent (mm);
268  return mm;
269 }
270 
271 
272 
273 } // namespace ns3
BuildingsPathlossTestCase(double freq, uint16_t m1, uint16_t m2, EnvironmentType env, CitySize city, double refValue, std::string name)
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:311
A suite of tests to run.
Definition: test.h:962
#define NS_LOG_COMPONENT_DEFINE(name)
Definition: log.h:122
#define NS_LOG_INFO(msg)
Definition: log.h:264
encapsulates test code
Definition: test.h:834
a 3d vector
Definition: vector.h:31
a 3d box
Definition: box.h:33
hold variables of type 'enum'
Definition: enum.h:37
static void Destroy(void)
Definition: simulator.cc:121
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
Definition: test.cc:172
Hold an floating point type.
Definition: double.h:41
void LogComponentEnable(char const *name, enum LogLevel level)
Definition: log.cc:311
virtual void DoRun(void)
Implementation to actually run this test case.