LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) | 3 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 NS_LOG_COMPONENT_DEFINE ("BuildingsPathlossTest"); | 39 NS_LOG_COMPONENT_DEFINE ("BuildingsPathlossTest"); |
40 | 40 |
41 /** | 41 /** |
42 * \ingroup buildings-test | 42 * \ingroup buildings-test |
43 * \ingroup tests | 43 * \ingroup tests |
44 * | 44 * |
45 * \brief Test 1.1 BuildingsPathlossModel Pathloss compound test | 45 * \brief Test 1.1 BuildingsPathlossModel Pathloss compound test |
46 * | 46 * |
47 * This TestSuite tests the BuildingPathlossModel by reproducing | 47 * This TestSuite tests the BuildingPathlossModel by reproducing |
48 * several communication scenarios | 48 * several communication scenarios |
49 */ | 49 */ |
50 | 50 |
51 BuildingsPathlossTestSuite::BuildingsPathlossTestSuite () | 51 BuildingsPathlossTestSuite::BuildingsPathlossTestSuite () |
52 : TestSuite ("buildings-pathloss-test", SYSTEM) | 52 : TestSuite ("buildings-pathloss-test", SYSTEM) |
53 { | 53 { |
54 | 54 |
55 LogComponentEnable ("BuildingsPathlossTest", LOG_LEVEL_ALL); | 55 LogComponentEnable ("BuildingsPathlossTest", LOG_LEVEL_ALL); |
56 | 56 |
57 double freq = 869e6; // E_UTRA BAND #5 see table 5.5-1 of 36.101 | 57 double freq = 869e6; // E_UTRA BAND #5 see table 5.5-1 of 36.101 |
58 | 58 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 BuildingsPathlossTestCase::~BuildingsPathlossTestCase () | 152 BuildingsPathlossTestCase::~BuildingsPathlossTestCase () |
153 { | 153 { |
154 } | 154 } |
155 | 155 |
156 void | 156 void |
157 BuildingsPathlossTestCase::DoRun (void) | 157 BuildingsPathlossTestCase::DoRun (void) |
158 { | 158 { |
159 NS_LOG_FUNCTION (this); | 159 NS_LOG_FUNCTION (this); |
160 | 160 |
161 // the building basically occupies the negative x plane, so any node | 161 // the building basically occupies the negative x plane, so any node |
162 // in this area will fall in the building | 162 // in this area will fall in the building |
163 Ptr<Building> building1 = CreateObject<Building> (); | 163 Ptr<Building> building1 = CreateObject<Building> (); |
164 building1->SetBoundaries (Box (-3000, -1, -4000, 4000.0, 0.0, 12)); | 164 building1->SetBoundaries (Box (-3000, -1, -4000, 4000.0, 0.0, 12)); |
165 building1->SetBuildingType (Building::Residential); | 165 building1->SetBuildingType (Building::Residential); |
166 building1->SetExtWallsType (Building::ConcreteWithWindows); | 166 building1->SetExtWallsType (Building::ConcreteWithWindows); |
167 building1->SetNFloors (3); | 167 building1->SetNFloors (3); |
168 | 168 |
169 Ptr<MobilityModel> mma = CreateMobilityModel (m_mobilityModelIndex1); | 169 Ptr<MobilityModel> mma = CreateMobilityModel (m_mobilityModelIndex1); |
170 Ptr<MobilityModel> mmb = CreateMobilityModel (m_mobilityModelIndex2); | 170 Ptr<MobilityModel> mmb = CreateMobilityModel (m_mobilityModelIndex2); |
171 | 171 |
172 Ptr<HybridBuildingsPropagationLossModel> propagationLossModel = CreateObject<H
ybridBuildingsPropagationLossModel> (); | 172 Ptr<HybridBuildingsPropagationLossModel> propagationLossModel = CreateObject<H
ybridBuildingsPropagationLossModel> (); |
173 propagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq)); | 173 propagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq)); |
174 propagationLossModel->SetAttribute ("Environment", EnumValue (m_env)); | 174 propagationLossModel->SetAttribute ("Environment", EnumValue (m_env)); |
175 propagationLossModel->SetAttribute ("CitySize", EnumValue (m_city)); | 175 propagationLossModel->SetAttribute ("CitySize", EnumValue (m_city)); |
176 // cancel shadowing effect | 176 // cancel shadowing effect |
177 propagationLossModel->SetAttribute ("ShadowSigmaOutdoor", DoubleValue (0.0)); | 177 propagationLossModel->SetAttribute ("ShadowSigmaOutdoor", DoubleValue (0.0)); |
178 propagationLossModel->SetAttribute ("ShadowSigmaIndoor", DoubleValue (0.0)); | 178 propagationLossModel->SetAttribute ("ShadowSigmaIndoor", DoubleValue (0.0)); |
179 propagationLossModel->SetAttribute ("ShadowSigmaExtWalls", DoubleValue (0.0)); | 179 propagationLossModel->SetAttribute ("ShadowSigmaExtWalls", DoubleValue (0.0)); |
180 | 180 |
181 double loss = propagationLossModel->GetLoss (mma, mmb); | 181 double loss = propagationLossModel->GetLoss (mma, mmb); |
182 | 182 |
183 NS_LOG_INFO ("Calculated loss: " << loss); | 183 NS_LOG_INFO ("Calculated loss: " << loss); |
184 NS_LOG_INFO ("Theoretical loss: " << m_lossRef); | 184 NS_LOG_INFO ("Theoretical loss: " << m_lossRef); |
185 | 185 |
186 NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss !"); | 186 NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss !"); |
187 Simulator::Destroy (); | 187 Simulator::Destroy (); |
188 } | 188 } |
189 | 189 |
190 Ptr<MobilityModel> | 190 Ptr<MobilityModel> |
191 BuildingsPathlossTestCase::CreateMobilityModel (uint16_t index) | 191 BuildingsPathlossTestCase::CreateMobilityModel (uint16_t index) |
192 { | 192 { |
193 | 193 |
194 /* | 194 /* |
195 * The purpose of this method is to defer the creation of the | 195 * The purpose of this method is to defer the creation of the |
196 * MobilityModel instances to when DoRun() is called. In a previous | 196 * MobilityModel instances to when DoRun() is called. In a previous |
197 * version, MobilityModel instances where created directly in the | 197 * version, MobilityModel instances where created directly in the |
198 * constructor of the test suite, which caused subtle bugs due to | 198 * constructor of the test suite, which caused subtle bugs due to |
199 * "static initialization order fiasco". An example of such a subtle | 199 * "static initialization order fiasco". An example of such a subtle |
200 * bug is that logging via NS_LOG failed for some modules. | 200 * bug is that logging via NS_LOG failed for some modules. |
201 * | 201 * |
202 */ | 202 */ |
203 | 203 |
204 double hm = 1; | 204 double hm = 1; |
205 double hb = 30; | 205 double hb = 30; |
206 double henbHeight = 10.0; | 206 double henbHeight = 10.0; |
207 | 207 |
208 Ptr<MobilityModel> mm; | 208 Ptr<MobilityModel> mm; |
209 | 209 |
210 switch (index) | 210 switch (index) |
211 { | 211 { |
212 case 1: | 212 case 1: |
213 mm = CreateObject<ConstantPositionMobilityModel> (); | 213 mm = CreateObject<ConstantPositionMobilityModel> (); |
214 mm->SetPosition (Vector (0.0, 0.0, hb)); | 214 mm->SetPosition (Vector (0.0, 0.0, hb)); |
215 break; | 215 break; |
216 | 216 |
217 case 2: | 217 case 2: |
218 mm = CreateObject<ConstantPositionMobilityModel> (); | 218 mm = CreateObject<ConstantPositionMobilityModel> (); |
219 mm->SetPosition (Vector (2000, 0.0, hm)); | 219 mm->SetPosition (Vector (2000, 0.0, hm)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 mm = CreateObject<ConstantPositionMobilityModel> (); | 263 mm = CreateObject<ConstantPositionMobilityModel> (); |
264 mm->SetPosition (Vector (-500, 0.0, henbHeight)); | 264 mm->SetPosition (Vector (-500, 0.0, henbHeight)); |
265 break; | 265 break; |
266 | 266 |
267 default: | 267 default: |
268 mm = 0; | 268 mm = 0; |
269 break; | 269 break; |
270 } | 270 } |
271 Ptr<MobilityBuildingInfo> buildingInfo = CreateObject<MobilityBuildingInfo> ()
; | 271 Ptr<MobilityBuildingInfo> buildingInfo = CreateObject<MobilityBuildingInfo> ()
; |
272 mm->AggregateObject (buildingInfo); // operation usually done by BuildingsHelp
er::Install | 272 mm->AggregateObject (buildingInfo); // operation usually done by BuildingsHelp
er::Install |
273 BuildingsHelper::MakeConsistent (mm); | 273 BuildingsHelper::MakeConsistent (mm); |
274 return mm; | 274 return mm; |
275 } | 275 } |
LEFT | RIGHT |