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"
50 virtual void DoRun (
void);
62 :
TestCase (
"Test case for the BuildingsChannelConditionModel"), m_buildings ()
71 auto position = model->GetPosition ();
74 NS_TEST_ASSERT_MSG_EQ (building->IsInside (position),
false,
"Position " << position <<
" is inside");
82 double buildingSizeX = 100;
83 double buildingSizeY = 50;
84 double streetWidth = 25;
85 double buildingHeight = 10;
86 uint32_t numBuildingsX = 20;
87 uint32_t numBuildingsY = 20;
88 double maxAxisX = (buildingSizeX + streetWidth) * numBuildingsX;
89 double maxAxisY = (buildingSizeY + streetWidth) * numBuildingsY;
91 for (uint32_t buildingIdX = 0; buildingIdX < numBuildingsX; ++buildingIdX)
93 for (uint32_t buildingIdY = 0; buildingIdY < numBuildingsY; ++buildingIdY)
96 building = CreateObject<Building> ();
98 building->SetBoundaries (
Box (buildingIdX * (buildingSizeX + streetWidth),
99 buildingIdX * (buildingSizeX + streetWidth) + buildingSizeX,
100 buildingIdY * (buildingSizeY + streetWidth),
101 buildingIdY * (buildingSizeY + streetWidth) + buildingSizeY,
102 0.0, buildingHeight));
103 building->SetNRoomsX (1);
104 building->SetNRoomsY (1);
105 building->SetNFloors (1);
116 mobility.SetMobilityModel (
"ns3::RandomWalk2dOutdoorMobilityModel",
118 Rectangle (-streetWidth, maxAxisX, -streetWidth, maxAxisY)));
129 mobility.SetPositionAllocator (position);
136 double testStep = 10;
137 int maxChecks = 1000;
138 for (
int i = 0; i < maxChecks; ++i)
140 Simulator::Schedule (
Seconds (i * testStep),
144 Simulator::Stop (
Seconds (maxChecks * testStep + 1));
146 Simulator::Destroy ();
162 :
TestSuite (
"outdoor-random-walk-model", UNIT)
Test case for the class OutdoorRandomWalkTestCase.
std::vector< Ptr< Building > > m_buildings
Buildings.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~OutdoorRandomWalkTestCase()
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'.
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
Static variable for test initialization.