20 #include "ns3/abort.h"
22 #include "ns3/config.h"
23 #include "ns3/building.h"
24 #include "ns3/building-position-allocator.h"
25 #include "ns3/random-walk-2d-outdoor-mobility-model.h"
26 #include "ns3/mobility-helper.h"
28 #include "ns3/simulator.h"
29 #include "ns3/double.h"
30 #include "ns3/pointer.h"
57 virtual void DoRun (
void);
65 :
TestCase (
"Test case for the BuildingsChannelConditionModel"), m_buildings ()
74 auto position = model->GetPosition ();
77 NS_TEST_ASSERT_MSG_EQ (building->IsInside (position),
false,
"Position " << position <<
" is inside");
85 double buildingSizeX = 100;
86 double buildingSizeY = 50;
87 double streetWidth = 25;
88 double buildingHeight = 10;
89 uint32_t numBuildingsX = 20;
90 uint32_t numBuildingsY = 20;
91 double maxAxisX = (buildingSizeX + streetWidth) * numBuildingsX;
92 double maxAxisY = (buildingSizeY + streetWidth) * numBuildingsY;
94 for (uint32_t buildingIdX = 0; buildingIdX < numBuildingsX; ++buildingIdX)
96 for (uint32_t buildingIdY = 0; buildingIdY < numBuildingsY; ++buildingIdY)
99 building = CreateObject<Building> ();
101 building->SetBoundaries (
Box (buildingIdX * (buildingSizeX + streetWidth),
102 buildingIdX * (buildingSizeX + streetWidth) + buildingSizeX,
103 buildingIdY * (buildingSizeY + streetWidth),
104 buildingIdY * (buildingSizeY + streetWidth) + buildingSizeY,
105 0.0, buildingHeight));
106 building->SetNRoomsX (1);
107 building->SetNRoomsY (1);
108 building->SetNFloors (1);
119 mobility.SetMobilityModel (
"ns3::RandomWalk2dOutdoorMobilityModel",
121 Rectangle (-streetWidth, maxAxisX, -streetWidth, maxAxisY)));
132 mobility.SetPositionAllocator (position);
139 double testStep = 10;
140 int maxChecks = 1000;
141 for (
int i = 0; i < maxChecks; ++i)
143 Simulator::Schedule (
Seconds (i * testStep),
147 Simulator::Stop (
Seconds (maxChecks * testStep + 1));
149 Simulator::Destroy ();
162 :
TestSuite (
"outdoor-random-walk-model", UNIT)
Test case for the class OutdoorRandomWalkTestCase.
std::vector< Ptr< Building > > m_buildings
virtual void DoRun(void)
Builds the simulation scenario and perform the tests.
virtual ~OutdoorRandomWalkTestCase()
Destructor.
OutdoorRandomWalkTestCase()
Constructor.
void CheckPositionOutdoor(Ptr< RandomWalk2dOutdoorMobilityModel > model)
Test suite for the buildings channel condition model.
OutdoorRandomWalkTestSuite()
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Helper class used to assign positions and mobility models to nodes.
keep track of a set of node pointers.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Hold objects of type Ptr<T>.
Smart pointer class similar to boost::intrusive_ptr.
2D random walk mobility model which avoids buildings.
AttributeValue implementation for Rectangle.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static OutdoorRandomWalkTestSuite OutdoorRandomWalkTestSuite