A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
buildings-channel-condition-model-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 SIGNET Lab, Department of Information Engineering,
3 * University of Padova
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
19#include "ns3/abort.h"
20#include "ns3/buildings-channel-condition-model.h"
21#include "ns3/buildings-module.h"
22#include "ns3/config.h"
23#include "ns3/constant-position-mobility-model.h"
24#include "ns3/log.h"
25#include "ns3/simulator.h"
26#include "ns3/test.h"
27
28using namespace ns3;
29
30NS_LOG_COMPONENT_DEFINE("BuildingsChannelConditionModelsTest");
31
41{
42 public:
47
52
53 private:
57 void DoRun() override;
58
63 {
64 Vector m_positionA;
65 Vector m_positionB;
67 };
68
70};
71
73 : TestCase("Test case for the BuildingsChannelConditionModel"),
74 m_testVectors()
75{
76}
77
79{
80}
81
82void
84{
85 TestVector testVector;
86
87 testVector.m_positionA = Vector(0.0, 5.0, 1.5);
88 testVector.m_positionB = Vector(20.0, 5.0, 1.5);
89 testVector.m_losCond = ChannelCondition::LosConditionValue::NLOS;
90 m_testVectors.Add(testVector);
91
92 testVector.m_positionA = Vector(0.0, 11.0, 1.5);
93 testVector.m_positionB = Vector(20.0, 11.0, 1.5);
94 testVector.m_losCond = ChannelCondition::LosConditionValue::LOS;
95 m_testVectors.Add(testVector);
96
97 testVector.m_positionA = Vector(5.0, 5.0, 1.5);
98 testVector.m_positionB = Vector(20.0, 5.0, 1.5);
99 testVector.m_losCond = ChannelCondition::LosConditionValue::NLOS;
100 m_testVectors.Add(testVector);
101
102 testVector.m_positionA = Vector(4.0, 5.0, 1.5);
103 testVector.m_positionB = Vector(5.0, 5.0, 1.5);
104 testVector.m_losCond = ChannelCondition::LosConditionValue::LOS;
105 m_testVectors.Add(testVector);
106
107 // Deploy nodes and building and get the channel condition
109 nodes.Create(2);
110
111 Ptr<MobilityModel> a = CreateObject<ConstantPositionMobilityModel>();
113
114 Ptr<MobilityModel> b = CreateObject<ConstantPositionMobilityModel>();
116
117 Ptr<BuildingsChannelConditionModel> condModel = CreateObject<BuildingsChannelConditionModel>();
118
119 Ptr<Building> building = Create<Building>();
120 building->SetNRoomsX(1);
121 building->SetNRoomsY(1);
122 building->SetNFloors(1);
123 building->SetBoundaries(Box(0.0, 10.0, 0.0, 10.0, 0.0, 5.0));
124 building->SetExtWallsType(Building::ExtWallsType_t::Wood);
125
127
128 for (uint32_t i = 0; i < m_testVectors.GetN(); ++i)
129 {
130 testVector = m_testVectors.Get(i);
131 a->SetPosition(testVector.m_positionA);
132 b->SetPosition(testVector.m_positionB);
133 Ptr<MobilityBuildingInfo> buildingInfoA = a->GetObject<MobilityBuildingInfo>();
134 buildingInfoA->MakeConsistent(a);
135 Ptr<MobilityBuildingInfo> buildingInfoB = b->GetObject<MobilityBuildingInfo>();
136 buildingInfoA->MakeConsistent(b);
137 Ptr<ChannelCondition> cond = condModel->GetChannelCondition(a, b);
138
139 NS_LOG_DEBUG("Got " << cond->GetLosCondition() << " expected condition "
140 << testVector.m_losCond);
141 NS_TEST_ASSERT_MSG_EQ(cond->GetLosCondition(),
142 testVector.m_losCond,
143 " Got unexpected channel condition");
144 }
145
147}
148
155{
156 public:
158};
159
161 : TestSuite("buildings-channel-condition-model", UNIT)
162{
164}
165
Test case for the class BuildingsChannelConditionModel.
void DoRun() override
Builds the simulation scenario and perform the tests.
TestVectors< TestVector > m_testVectors
array containing all the test vectors
Test suite for the buildings channel condition model.
a 3d box
Definition: box.h:35
static void Install(Ptr< Node > node)
Install the MobilityBuildingInfo to a node.
LosConditionValue
Possible values for Line-of-Sight condition.
mobility buildings information (to be used by mobility models)
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:259
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:140
encapsulates test code
Definition: test.h:1060
@ QUICK
Fast test.
Definition: test.h:1065
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
A simple way to store test vectors (for stimulus or from responses)
Definition: test.h:1319
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:144
NodeContainer nodes
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ChannelCondition::LosConditionValue m_losCond
the correct channel condition