19 #include "ns3/boolean.h"
20 #include "ns3/config.h"
21 #include "ns3/double.h"
22 #include "ns3/rng-seed-manager.h"
23 #include "ns3/simulator.h"
24 #include "ns3/steady-state-random-waypoint-mobility-model.h"
40 :
TestCase(
"Check steady-state rwp mobility model velocity and position distributions")
52 void DoRun()
override;
53 void DoTeardown()
override;
55 void DistribCompare();
61 mobilityStack.clear();
70 double totalTime = 1000;
73 mobilityFactory.
SetTypeId(
"ns3::SteadyStateRandomWaypointMobilityModel");
85 for (uint32_t i = 0; i < count; i++)
91 mobilityStack.push_back(model);
109 for (
auto i = mobilityStack.begin(); i != mobilityStack.end(); ++i)
113 std::sqrt(std::pow(model->GetVelocity().x, 2) + std::pow(model->GetVelocity().y, 2));
114 sum_x += model->GetPosition().x;
115 sum_y += model->GetPosition().y;
118 double mean_x = sum_x / count;
119 double mean_y = sum_y / count;
120 double mean_v = sum_v / count;
130 for (
auto i = mobilityStack.begin(); i != mobilityStack.end(); ++i)
134 std::sqrt(std::pow(model->GetVelocity().x, 2) + std::pow(model->GetVelocity().y, 2));
135 tmp = model->GetPosition().x - mean_x;
137 tmp = model->GetPosition().y - mean_y;
139 tmp = velocity - mean_v;
142 double dev_x = std::sqrt(sum_x / (count - 1));
143 double dev_y = std::sqrt(sum_y / (count - 1));
144 double dev_v = std::sqrt(sum_v / (count - 1));
159 :
TestSuite(
"steady-state-rwp-mobility-model", UNIT)
Steady State Random Waypoint Test.
~SteadyStateRandomWaypointTest() override
std::vector< Ptr< MobilityModel > > mobilityStack
modility model
void DoRun() override
Implementation to actually run this TestCase.
SteadyStateRandomWaypointTest()
void DistribCompare()
Distribution compare function.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Keep track of the current position and velocity of an object.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
void Initialize()
Invoke DoInitialize on all Objects aggregated to this one.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
static void SetSeed(uint32_t seed)
Set the seed.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
SteadyStateRandomWaypointTestSuite g_steadyStateRandomWaypointTestSuite
the test suite
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if ...
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Steady State Random Waypoint Test Suite.
SteadyStateRandomWaypointTestSuite()