19 #include "ns3/abort.h"
20 #include "ns3/building-position-allocator.h"
21 #include "ns3/building.h"
22 #include "ns3/config.h"
23 #include "ns3/double.h"
26 #include "ns3/mobility-helper.h"
27 #include "ns3/pointer.h"
28 #include "ns3/random-walk-2d-outdoor-mobility-model.h"
29 #include "ns3/simulator.h"
50 void DoRun()
override;
62 :
TestCase(
"Test case for the BuildingsChannelConditionModel"),
74 auto position = model->GetPosition();
79 "Position " << position <<
" is inside");
87 constexpr
double TEST_STEP_S = 10;
88 constexpr
int MAX_CHECKS = 1000;
91 double buildingSizeX = 100;
92 double buildingSizeY = 50;
93 double streetWidth = 25;
94 double buildingHeight = 10;
95 uint32_t numBuildingsX = 20;
96 uint32_t numBuildingsY = 20;
97 double maxAxisX = (buildingSizeX + streetWidth) * numBuildingsX;
98 double maxAxisY = (buildingSizeY + streetWidth) * numBuildingsY;
100 for (uint32_t buildingIdX = 0; buildingIdX < numBuildingsX; ++buildingIdX)
102 for (uint32_t buildingIdY = 0; buildingIdY < numBuildingsY; ++buildingIdY)
105 building = CreateObject<Building>();
107 building->SetBoundaries(
Box(buildingIdX * (buildingSizeX + streetWidth),
108 buildingIdX * (buildingSizeX + streetWidth) + buildingSizeX,
109 buildingIdY * (buildingSizeY + streetWidth),
110 buildingIdY * (buildingSizeY + streetWidth) + buildingSizeY,
113 building->SetNRoomsX(1);
114 building->SetNRoomsY(1);
115 building->SetNFloors(1);
127 "ns3::RandomWalk2dOutdoorMobilityModel",
129 RectangleValue(
Rectangle(-streetWidth, maxAxisX, -streetWidth, maxAxisY)),
131 EnumValue(RandomWalk2dOutdoorMobilityModel::MODE_TIME),
145 mobility.SetPositionAllocator(position);
152 for (
int i = 0; i < MAX_CHECKS; i++)
154 Simulator::Schedule(
Seconds(i * TEST_STEP_S),
160 Simulator::Stop(
Seconds(MAX_CHECKS * TEST_STEP_S + 1));
162 Simulator::Destroy();
178 :
TestSuite(
"outdoor-random-walk-model", UNIT)
Test case for the class OutdoorRandomWalkTestCase.
~OutdoorRandomWalkTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
std::vector< Ptr< Building > > m_buildings
Buildings.
OutdoorRandomWalkTestCase()
void CheckPositionOutdoor(Ptr< RandomWalk2dOutdoorMobilityModel > model)
Check that the position is the expected one.
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'.
Hold variables of type enum.
Helper class used to assign positions and mobility models to nodes.
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 SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Hold objects of type Ptr<T>.
Smart pointer class similar to boost::intrusive_ptr.
2D random walk mobility model which avoids buildings.
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
Static variable for test initialization.