diff --git a/src/propagation/test/itu-r-1411-los-test-suite.cc b/src/propagation/test/itu-r-1411-los-test-suite.cc new file mode 100644 index 000000000..10f29a627 --- /dev/null +++ b/src/propagation/test/itu-r-1411-los-test-suite.cc @@ -0,0 +1,124 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011,2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Marco Miozzo + * Nicola Baldo + */ + + +#include +#include +#include +#include +#include +#include +#include + + +namespace ns3 { + +NS_LOG_COMPONENT_DEFINE ("ItuR1411LosPropagationLossModelTest"); + + +class ItuR1411LosPropagationLossModelTestCase : public TestCase +{ +public: + ItuR1411LosPropagationLossModelTestCase (double freq, double dist, double hb, double hm, double refValue, std::string name); + virtual ~ItuR1411LosPropagationLossModelTestCase (); + +private: + virtual void DoRun (void); + Ptr CreateMobilityModel (uint16_t index); + + double m_freq; + double m_dist; + double m_hb; + double m_hm; + double m_lossRef; + +}; + +ItuR1411LosPropagationLossModelTestCase::ItuR1411LosPropagationLossModelTestCase (double freq, double dist, double hb, double hm, double refValue, std::string name) + : TestCase (name), + m_freq (freq), + m_dist (dist), + m_hb (hb), + m_hm (hm), + m_lossRef (refValue) +{ +} + +ItuR1411LosPropagationLossModelTestCase::~ItuR1411LosPropagationLossModelTestCase () +{ +} + + + +void +ItuR1411LosPropagationLossModelTestCase::DoRun (void) +{ + NS_LOG_FUNCTION (this); + + + Ptr mma = CreateObject (); + mma->SetPosition (Vector (0.0, 0.0, m_hb)); + + Ptr mmb = CreateObject (); + mmb->SetPosition (Vector (m_dist, 0.0, m_hm)); + + Ptr propagationLossModel = CreateObject (); + propagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq)); + + double loss = propagationLossModel->GetLoss (mma, mmb); + + NS_LOG_INFO ("Calculated loss: " << loss); + NS_LOG_INFO ("Theoretical loss: " << m_lossRef); + + NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss!"); + +} + + + +class ItuR1411LosPropagationLossModelTestSuite : public TestSuite +{ +public: + ItuR1411LosPropagationLossModelTestSuite (); +}; + + + +ItuR1411LosPropagationLossModelTestSuite::ItuR1411LosPropagationLossModelTestSuite () + : TestSuite ("itu-r-1411-los", SYSTEM) +{ + + LogComponentEnable ("ItuR1411LosPropagationLossModelTest", LOG_LEVEL_ALL); + + double freq = 2.1140e9; + + AddTestCase (new ItuR1411LosPropagationLossModelTestCase (freq, 100, 30, 1, 81.00, "freq=2114MHz, dist=100m")); + + +} + + + +static ItuR1411LosPropagationLossModelTestSuite g_ituR1411LosTestSuite; + + + +} // namespace ns3 diff --git a/src/propagation/test/itu-r-1411-nlos-over-rooftop-test-suite.cc b/src/propagation/test/itu-r-1411-nlos-over-rooftop-test-suite.cc new file mode 100644 index 000000000..72bd91c4e --- /dev/null +++ b/src/propagation/test/itu-r-1411-nlos-over-rooftop-test-suite.cc @@ -0,0 +1,127 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011,2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Marco Miozzo + * Nicola Baldo + */ + + +#include +#include +#include +#include +#include +#include +#include + + +namespace ns3 { + +NS_LOG_COMPONENT_DEFINE ("ItuR1411NlosOverRooftopPropagationLossModelTest"); + + +class ItuR1411NlosOverRooftopPropagationLossModelTestCase : public TestCase +{ +public: + ItuR1411NlosOverRooftopPropagationLossModelTestCase (double freq, double dist, double hb, double hm, EnvironmentType env, CitySize city, double refValue, std::string name); + virtual ~ItuR1411NlosOverRooftopPropagationLossModelTestCase (); + +private: + virtual void DoRun (void); + Ptr CreateMobilityModel (uint16_t index); + + double m_freq; + double m_dist; + double m_hb; + double m_hm; + EnvironmentType m_env; + CitySize m_city; + double m_lossRef; + +}; + +ItuR1411NlosOverRooftopPropagationLossModelTestCase::ItuR1411NlosOverRooftopPropagationLossModelTestCase (double freq, double dist, double hb, double hm, EnvironmentType env, CitySize city, double refValue, std::string name) + : TestCase (name), + m_freq (freq), + m_dist (dist), + m_hb (hb), + m_hm (hm), + m_env (env), + m_city (city), + m_lossRef (refValue) +{ +} + +ItuR1411NlosOverRooftopPropagationLossModelTestCase::~ItuR1411NlosOverRooftopPropagationLossModelTestCase () +{ +} + + + +void +ItuR1411NlosOverRooftopPropagationLossModelTestCase::DoRun (void) +{ + NS_LOG_FUNCTION (this); + + + Ptr mma = CreateObject (); + mma->SetPosition (Vector (0.0, 0.0, m_hb)); + + Ptr mmb = CreateObject (); + mmb->SetPosition (Vector (m_dist, 0.0, m_hm)); + + Ptr propagationLossModel = CreateObject (); + propagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq)); + propagationLossModel->SetAttribute ("Environment", EnumValue (m_env)); + propagationLossModel->SetAttribute ("CitySize", EnumValue (m_city)); + + double loss = propagationLossModel->GetLoss (mma, mmb); + + NS_LOG_INFO ("Calculated loss: " << loss); + NS_LOG_INFO ("Theoretical loss: " << m_lossRef); + + NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss!"); + +} + + + +class ItuR1411NlosOverRooftopPropagationLossModelTestSuite : public TestSuite +{ +public: + ItuR1411NlosOverRooftopPropagationLossModelTestSuite (); +}; + + + +ItuR1411NlosOverRooftopPropagationLossModelTestSuite::ItuR1411NlosOverRooftopPropagationLossModelTestSuite () + : TestSuite ("itu-r-1411-nlos-over-rooftop", SYSTEM) +{ + + LogComponentEnable ("ItuR1411NlosOverRooftopPropagationLossModelTest", LOG_LEVEL_ALL); + + AddTestCase (new ItuR1411NlosOverRooftopPropagationLossModelTestCase (2.1140e9, 900, 30, 1, UrbanEnvironment, LargeCity, 143.69, "f=2114Mhz, dist=900, urban large city")); + +} + + + +static ItuR1411NlosOverRooftopPropagationLossModelTestSuite g_ituR1411NlosOverRooftopTestSuite; + + + +} // namespace ns3 diff --git a/src/propagation/test/kun-2600-mhz-test-suite.cc b/src/propagation/test/kun-2600-mhz-test-suite.cc new file mode 100644 index 000000000..034df0719 --- /dev/null +++ b/src/propagation/test/kun-2600-mhz-test-suite.cc @@ -0,0 +1,119 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011,2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Marco Miozzo + * Nicola Baldo + */ + + +#include +#include +#include +#include +#include +#include +#include + + +namespace ns3 { + +NS_LOG_COMPONENT_DEFINE ("Kun2600MhzPropagationLossModelTest"); + + +class Kun2600MhzPropagationLossModelTestCase : public TestCase +{ +public: + Kun2600MhzPropagationLossModelTestCase (double dist, double hb, double hm, double refValue, std::string name); + virtual ~Kun2600MhzPropagationLossModelTestCase (); + +private: + virtual void DoRun (void); + Ptr CreateMobilityModel (uint16_t index); + + double m_dist; + double m_hb; + double m_hm; + double m_lossRef; + +}; + +Kun2600MhzPropagationLossModelTestCase::Kun2600MhzPropagationLossModelTestCase (double dist, double hb, double hm, double refValue, std::string name) + : TestCase (name), + m_dist (dist), + m_hb (hb), + m_hm (hm), + m_lossRef (refValue) +{ +} + +Kun2600MhzPropagationLossModelTestCase::~Kun2600MhzPropagationLossModelTestCase () +{ +} + + + +void +Kun2600MhzPropagationLossModelTestCase::DoRun (void) +{ + NS_LOG_FUNCTION (this); + + + Ptr mma = CreateObject (); + mma->SetPosition (Vector (0.0, 0.0, m_hb)); + + Ptr mmb = CreateObject (); + mmb->SetPosition (Vector (m_dist, 0.0, m_hm)); + + Ptr propagationLossModel = CreateObject (); + + double loss = propagationLossModel->GetLoss (mma, mmb); + + NS_LOG_INFO ("Calculated loss: " << loss); + NS_LOG_INFO ("Theoretical loss: " << m_lossRef); + + NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss!"); + +} + + + +class Kun2600MhzPropagationLossModelTestSuite : public TestSuite +{ +public: + Kun2600MhzPropagationLossModelTestSuite (); +}; + + + +Kun2600MhzPropagationLossModelTestSuite::Kun2600MhzPropagationLossModelTestSuite () + : TestSuite ("kun-2600-mhz", SYSTEM) +{ + + LogComponentEnable ("Kun2600MhzPropagationLossModelTest", LOG_LEVEL_ALL); + + AddTestCase (new Kun2600MhzPropagationLossModelTestCase (2000, 30, 1, 121.83, "dist=2000m")); + + +} + + + +static Kun2600MhzPropagationLossModelTestSuite g_kun2600MhzTestSuite; + + + +} // namespace ns3 diff --git a/src/propagation/test/okumura-hata-test-suite.cc b/src/propagation/test/okumura-hata-test-suite.cc new file mode 100644 index 000000000..985ced9ef --- /dev/null +++ b/src/propagation/test/okumura-hata-test-suite.cc @@ -0,0 +1,142 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011,2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Marco Miozzo + * Nicola Baldo + */ + + +#include +#include +#include +#include +#include +#include +#include + + +namespace ns3 { + +NS_LOG_COMPONENT_DEFINE ("OkumuraHataPropagationLossModelTest"); + + +class OkumuraHataPropagationLossModelTestCase : public TestCase +{ +public: + OkumuraHataPropagationLossModelTestCase (double freq, double dist, double hb, double hm, EnvironmentType env, CitySize city, double refValue, std::string name); + virtual ~OkumuraHataPropagationLossModelTestCase (); + +private: + virtual void DoRun (void); + Ptr CreateMobilityModel (uint16_t index); + + double m_freq; + double m_dist; + double m_hb; + double m_hm; + EnvironmentType m_env; + CitySize m_city; + double m_lossRef; + +}; + +OkumuraHataPropagationLossModelTestCase::OkumuraHataPropagationLossModelTestCase (double freq, double dist, double hb, double hm, EnvironmentType env, CitySize city, double refValue, std::string name) + : TestCase (name), + m_freq (freq), + m_dist (dist), + m_hb (hb), + m_hm (hm), + m_env (env), + m_city (city), + m_lossRef (refValue) +{ +} + +OkumuraHataPropagationLossModelTestCase::~OkumuraHataPropagationLossModelTestCase () +{ +} + + + +void +OkumuraHataPropagationLossModelTestCase::DoRun (void) +{ + NS_LOG_FUNCTION (this); + + + Ptr mma = CreateObject (); + mma->SetPosition (Vector (0.0, 0.0, m_hb)); + + Ptr mmb = CreateObject (); + mmb->SetPosition (Vector (m_dist, 0.0, m_hm)); + + Ptr propagationLossModel = CreateObject (); + propagationLossModel->SetAttribute ("Frequency", DoubleValue (m_freq)); + propagationLossModel->SetAttribute ("Environment", EnumValue (m_env)); + propagationLossModel->SetAttribute ("CitySize", EnumValue (m_city)); + + double loss = propagationLossModel->GetLoss (mma, mmb); + + NS_LOG_INFO ("Calculated loss: " << loss); + NS_LOG_INFO ("Theoretical loss: " << m_lossRef); + + NS_TEST_ASSERT_MSG_EQ_TOL (loss, m_lossRef, 0.1, "Wrong loss!"); + +} + + + +class OkumuraHataPropagationLossModelTestSuite : public TestSuite +{ +public: + OkumuraHataPropagationLossModelTestSuite (); +}; + + + +OkumuraHataPropagationLossModelTestSuite::OkumuraHataPropagationLossModelTestSuite () + : TestSuite ("okumura-hata", SYSTEM) +{ + + LogComponentEnable ("OkumuraHataPropagationLossModelTest", LOG_LEVEL_ALL); + + double freq = 869e6; // this will use the original OH model + + AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, UrbanEnvironment, LargeCity, 137.93, "original OH Urban Large city")); + + AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, UrbanEnvironment, SmallCity, 137.88, "original OH Urban small city")); + + AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, SubUrbanEnvironment, LargeCity, 128.03, "original OH SubUrban")); + + AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, OpenAreasEnvironment, LargeCity, 110.21, "original OH OpenAreas")); + + + freq = 2.1140e9; // this will use the extended COST231 OH model + + AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, UrbanEnvironment, LargeCity, 148.55, "COST231 OH Urban Large city")); + + AddTestCase (new OkumuraHataPropagationLossModelTestCase (freq, 2000, 30, 1, UrbanEnvironment, SmallCity, 150.64, "COST231 OH Urban small city and suburban")); + +} + + + +static OkumuraHataPropagationLossModelTestSuite g_okumuraHataTestSuite; + + + +} // namespace ns3 diff --git a/src/propagation/wscript b/src/propagation/wscript index 8153214cc..f946a4466 100644 --- a/src/propagation/wscript +++ b/src/propagation/wscript @@ -17,6 +17,10 @@ def build(bld): module_test = bld.create_ns3_module_test_library('propagation') module_test.source = [ 'test/propagation-loss-model-test-suite.cc', + 'test/okumura-hata-test-suite.cc', + 'test/itu-r-1411-los-test-suite.cc', + 'test/kun-2600-mhz-test-suite.cc', + 'test/itu-r-1411-nlos-over-rooftop-test-suite.cc', ] headers = bld.new_task_gen(features=['ns3header'])