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 ()
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> ();
102 buildingIdX * (buildingSizeX + streetWidth) + buildingSizeX,
103 buildingIdY * (buildingSizeY + streetWidth),
104 buildingIdY * (buildingSizeY + streetWidth) + buildingSizeY,
105 0.0, buildingHeight));
119 mobility.SetMobilityModel (
"ns3::RandomWalk2dOutdoorMobilityModel",
121 Rectangle (-streetWidth, maxAxisX, -streetWidth, maxAxisY)));
126 xPos->SetAttribute (
"Max",
DoubleValue (maxAxisX));
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)
Smart pointer class similar to boost::intrusive_ptr.
void SetNRoomsY(uint16_t nroomy)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Test suite for the buildings channel condition model.
AttributeValue implementation for Rectangle.
OutdoorRandomWalkTestSuite()
virtual void DoRun(void)
Builds the simulation scenario and perform the tests.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
void CheckPositionOutdoor(Ptr< RandomWalk2dOutdoorMobilityModel > model)
void SetNFloors(uint16_t nfloors)
#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.
2D random walk mobility model which avoids buildings.
Test case for the class OutdoorRandomWalkTestCase.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr<T>.
std::vector< Ptr< Building > > m_buildings
Vector GetPosition(void) const
static OutdoorRandomWalkTestSuite OutdoorRandomWalkTestSuite
Helper class used to assign positions and mobility models to nodes.
virtual ~OutdoorRandomWalkTestCase()
Destructor.
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetNRoomsX(uint16_t nroomx)
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
OutdoorRandomWalkTestCase()
Constructor.
void SetBoundaries(Box box)
Set the boundaries of the building.