A Discrete-Event Network Simulator
qkdnetsim_etsi_014 @ (+)
API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
okumura-hata-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011,2012 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 
23 #include <ns3/log.h>
24 #include <ns3/test.h>
25 #include <ns3/okumura-hata-propagation-loss-model.h>
26 #include <ns3/string.h>
27 #include <ns3/double.h>
28 #include <ns3/constant-position-mobility-model.h>
29 #include <ns3/enum.h>
30 
31 
32 using namespace ns3;
33 
34 NS_LOG_COMPONENT_DEFINE ("OkumuraHataPropagationLossModelTest");
35 
42 {
43 public:
56  OkumuraHataPropagationLossModelTestCase (double freq, double dist, double hb, double hm, EnvironmentType env, CitySize city, double refValue, std::string name);
58 
59 private:
60  virtual void DoRun (void);
61 
68 
69  double m_freq;
70  double m_dist;
71  double m_hb;
72  double m_hm;
75  double m_lossRef;
76 };
77 
78 OkumuraHataPropagationLossModelTestCase::OkumuraHataPropagationLossModelTestCase (double freq, double dist, double hb, double hm, EnvironmentType env, CitySize city, double refValue, std::string name)
79  : TestCase (name),
80  m_freq (freq),
81  m_dist (dist),
82  m_hb (hb),
83  m_hm (hm),
84  m_env (env),
85  m_city (city),
86  m_lossRef (refValue)
87 {
88 }
89 
91 {
92 }
93 
94 
95 
96 void
98 {
99  NS_LOG_FUNCTION (this);
100 
101 
102  Ptr<MobilityModel> mma = CreateObject<ConstantPositionMobilityModel> ();
103  mma->SetPosition (Vector (0.0, 0.0, m_hb));
104 
105  Ptr<MobilityModel> mmb = CreateObject<ConstantPositionMobilityModel> ();
106  mmb->SetPosition (Vector (m_dist, 0.0, m_hm));
107 
108  Ptr<OkumuraHataPropagationLossModel> propagationLossModel = CreateObject<OkumuraHataPropagationLossModel> ();
109  propagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq));
110  propagationLossModel->SetAttribute ("Environment", EnumValue (m_env));
111  propagationLossModel->SetAttribute ("CitySize", EnumValue (m_city));
112 
113  double loss = propagationLossModel->GetLoss (mma, mmb);
114 
115  NS_LOG_INFO ("Calculated loss: " << loss);
116  NS_LOG_INFO ("Theoretical loss: " << m_lossRef);
117 
118  NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss!");
119 
120 }
121 
122 
135 {
136 public:
138 };
139 
141  : TestSuite ("okumura-hata", SYSTEM)
142 {
143  LogComponentEnable ("OkumuraHataPropagationLossModelTest", LOG_LEVEL_ALL);
144  // reference values obtained with the octave scripts in src/propagation/test/reference/
145 
146  double freq = 869e6; // this will use the original OH model
147  AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, UrbanEnvironment, LargeCity, 137.93, "original OH Urban Large city"), TestCase::QUICK);
148  AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, UrbanEnvironment, SmallCity, 137.88, "original OH Urban small city"), TestCase::QUICK);
149  AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, SubUrbanEnvironment, LargeCity, 128.03, "original OH SubUrban"), TestCase::QUICK);
150  AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, OpenAreasEnvironment, LargeCity, 110.21, "original OH OpenAreas"), TestCase::QUICK);
151 
152  freq = 2.1140e9; // this will use the extended COST231 OH model
153  AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, UrbanEnvironment, LargeCity, 148.55, "COST231 OH Urban Large city"), TestCase::QUICK);
154  AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, UrbanEnvironment, SmallCity, 150.64, "COST231 OH Urban small city and suburban"), TestCase::QUICK);
155 }
156 
157 
OkumuraHataPropagationLossModel Test Case.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
Create a MobilityModel.
OkumuraHataPropagationLossModelTestCase(double freq, double dist, double hb, double hm, EnvironmentType env, CitySize city, double refValue, std::string name)
Constructor.
double m_dist
2D distance between UT and BS in meters
OkumuraHataPropagationLossModel TestSuite.
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)
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
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
static OkumuraHataPropagationLossModelTestSuite g_okumuraHataTestSuite
Static variable for test initialization.