21 #include "ns3/simulator.h"
22 #include "ns3/boolean.h"
23 #include "ns3/double.h"
25 #include "ns3/config.h"
26 #include "ns3/steady-state-random-waypoint-mobility-model.h"
27 #include "ns3/rng-seed-manager.h"
35 :
TestCase (
"Check steady-state rwp mobility model velocity and position distributions") {}
39 std::vector<Ptr<MobilityModel> > mobilityStack;
42 virtual void DoRun (
void);
44 void DistribCompare ();
50 mobilityStack.clear();
59 double totalTime = 1000;
62 mobilityFactory.
SetTypeId (
"ns3::SteadyStateRandomWaypointMobilityModel");
74 for (uint32_t i = 0; i < count; i++)
80 mobilityStack.push_back (model);
92 SteadyStateRandomWaypointTest::DistribCompare ()
98 std::vector<Ptr<MobilityModel> >::iterator i;
100 for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
108 double mean_x = sum_x / count;
109 double mean_y = sum_y / count;
110 double mean_v = sum_v / count;
112 NS_TEST_EXPECT_MSG_EQ_TOL (mean_x, 500, 25.0,
"Got unexpected x-position mean value");
113 NS_TEST_EXPECT_MSG_EQ_TOL (mean_y, 300, 15.0,
"Got unexpected y-position mean value");
114 NS_TEST_EXPECT_MSG_EQ_TOL (mean_v, 2.6, 0.13,
"Got unexpected velocity mean value");
120 for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i)
128 tmp = velocity - mean_v;
131 double dev_x = std::sqrt (sum_x / (count - 1));
132 double dev_y = std::sqrt (sum_y / (count - 1));
133 double dev_v = std::sqrt (sum_v / (count - 1));
135 NS_TEST_EXPECT_MSG_EQ_TOL (dev_x, 230, 10.0,
"Got unexpected x-position standard deviation");
136 NS_TEST_EXPECT_MSG_EQ_TOL (dev_y, 140, 7.0,
"Got unexpected y-position standard deviation");
137 NS_TEST_EXPECT_MSG_EQ_TOL (dev_v, 4.4, 0.22,
"Got unexpected velocity standard deviation");
146 } g_steadyStateRandomWaypointTestSuite;
void SetTypeId(TypeId tid)
Vector GetPosition(void) const
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
TestSuite(std::string name, Type type=UNIT)
Constuct a new test suite.
Vector GetVelocity(void) const
Keep track of the current position and velocity of an object.
Ptr< Object > Create(void) const
TestCase(std::string name)
static void Destroy(void)
void Set(std::string name, const AttributeValue &value)
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
static void SetSeed(uint32_t seed)
set the seed it will duplicate the seed value 6 times
virtual void DoRun(void)
Implementation to actually run this test case.
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case.
instantiate subclasses of ns3::Object.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Hold an floating point type.
Ptr< T > GetObject(void) const