A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 namespace ns3 {
33 
34 NS_LOG_COMPONENT_DEFINE ("OkumuraHataPropagationLossModelTest")
35  ;
36 
37 
39 {
40 public:
41  OkumuraHataPropagationLossModelTestCase (double freq, double dist, double hb, double hm, EnvironmentType env, CitySize city, double refValue, std::string name);
43 
44 private:
45  virtual void DoRun (void);
46  Ptr<MobilityModel> CreateMobilityModel (uint16_t index);
47 
48  double m_freq;
49  double m_dist;
50  double m_hb;
51  double m_hm;
54  double m_lossRef;
55 
56 };
57 
58 OkumuraHataPropagationLossModelTestCase::OkumuraHataPropagationLossModelTestCase (double freq, double dist, double hb, double hm, EnvironmentType env, CitySize city, double refValue, std::string name)
59  : TestCase (name),
60  m_freq (freq),
61  m_dist (dist),
62  m_hb (hb),
63  m_hm (hm),
64  m_env (env),
65  m_city (city),
66  m_lossRef (refValue)
67 {
68 }
69 
71 {
72 }
73 
74 
75 
76 void
78 {
79  NS_LOG_FUNCTION (this);
80 
81 
82  Ptr<MobilityModel> mma = CreateObject<ConstantPositionMobilityModel> ();
83  mma->SetPosition (Vector (0.0, 0.0, m_hb));
84 
85  Ptr<MobilityModel> mmb = CreateObject<ConstantPositionMobilityModel> ();
86  mmb->SetPosition (Vector (m_dist, 0.0, m_hm));
87 
88  Ptr<OkumuraHataPropagationLossModel> propagationLossModel = CreateObject<OkumuraHataPropagationLossModel> ();
89  propagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq));
90  propagationLossModel->SetAttribute ("Environment", EnumValue (m_env));
91  propagationLossModel->SetAttribute ("CitySize", EnumValue (m_city));
92 
93  double loss = propagationLossModel->GetLoss (mma, mmb);
94 
95  NS_LOG_INFO ("Calculated loss: " << loss);
96  NS_LOG_INFO ("Theoretical loss: " << m_lossRef);
97 
98  NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss!");
99 
100 }
101 
102 
103 
105 {
106 public:
108 };
109 
110 
111 
113  : TestSuite ("okumura-hata", SYSTEM)
114 {
115 
116  LogComponentEnable ("OkumuraHataPropagationLossModelTest", LOG_LEVEL_ALL);
117 
118 
119  // reference values obtained with the octave scripts in src/propagation/test/reference/
120 
121 
122  double freq = 869e6; // this will use the original OH model
123 
124  AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, UrbanEnvironment, LargeCity, 137.93, "original OH Urban Large city"), TestCase::QUICK);
125 
126  AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, UrbanEnvironment, SmallCity, 137.88, "original OH Urban small city"), TestCase::QUICK);
127 
128  AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, SubUrbanEnvironment, LargeCity, 128.03, "original OH SubUrban"), TestCase::QUICK);
129 
130  AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, OpenAreasEnvironment, LargeCity, 110.21, "original OH OpenAreas"), TestCase::QUICK);
131 
132 
133  freq = 2.1140e9; // this will use the extended COST231 OH model
134 
135  AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, UrbanEnvironment, LargeCity, 148.55, "COST231 OH Urban Large city"), TestCase::QUICK);
136 
137  AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, UrbanEnvironment, SmallCity, 150.64, "COST231 OH Urban small city and suburban"), TestCase::QUICK);
138 
139 }
140 
141 
142 
144 
145 
146 
147 } // namespace ns3
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
EnvironmentType
The type of propagation environment.
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
#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:326
A suite of tests to run.
Definition: test.h:1025
#define NS_LOG_INFO(msg)
Definition: log.h:298
encapsulates test code
Definition: test.h:849
a 3d vector
Definition: vector.h:31
hold variables of type 'enum'
Definition: enum.h:37
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:173
void SetPosition(const Vector &position)
Fast test.
Definition: test.h:857
CitySize
The size of the city in which propagation takes place.
OkumuraHataPropagationLossModelTestCase(double freq, double dist, double hb, double hm, EnvironmentType env, CitySize city, double refValue, std::string name)
virtual void DoRun(void)
Implementation to actually run this TestCase.
static OkumuraHataPropagationLossModelTestSuite g_okumuraHataTestSuite
Hold a floating point type.
Definition: double.h:41
Ptr< MobilityModel > CreateMobilityModel(uint16_t index)
void LogComponentEnable(char const *name, enum LogLevel level)
Definition: log.cc:311