42 #include "ns3/simulator.h"
43 #include "ns3/node-list.h"
45 #include "ns3/constant-velocity-mobility-model.h"
47 #include "ns3/node-container.h"
48 #include "ns3/names.h"
49 #include "ns3/config.h"
50 #include "ns3/ns2-mobility-helper.h"
61 if (actual.
x > limit.
x + tol || actual.
x < limit.
x - tol)
65 if (actual.
y > limit.
y + tol || actual.
y < limit.
y - tol)
69 if (actual.
z > limit.
z + tol || actual.
z < limit.
z - tol)
173 std::ostringstream os;
206 Vector pos = mobility->GetPosition ();
207 Vector vel = mobility->GetVelocity ();
276 t->
SetTrace (
"$node_(0) set X_ 1.0\n"
277 "$node_(0) set Y_ 2.0\n"
278 "$node_(0) set Z_ 3.0\n"
287 "$node_(0) set X_ 1.0 # comment \n"
288 "$node_(0) set Y_ 2.0 ### \n"
289 "$node_(0) set Z_ 3.0 # $node_(0) set Z_ 3.0\n"
290 "#$node_(0) set Z_ 100 #"
297 t->
SetTrace (
"$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"");
306 t->
SetTrace (
"$node_(0) set X_ 0.0\n"
307 "$node_(0) set Y_ 0.0\n"
308 "$ns_ at 1.0 \"$node_(0) setdest 5 0 5\"\n"
309 "$ns_ at 2.0 \"$node_(0) setdest 5 5 5\"\n"
310 "$ns_ at 3.0 \"$node_(0) setdest 0 5 5\"\n"
311 "$ns_ at 4.0 \"$node_(0) setdest 0 0 5\"\n"
330 t->
SetTrace (
"$ns_ at 1.0 \"$node_(0) setdest 15 10 5\"\n"
331 "$ns_ at 2.0 \"$node_(0) setdest 15 15 5\"\n"
332 "$ns_ at 3.0 \"$node_(0) setdest 10 15 5\"\n"
333 "$ns_ at 4.0 \"$node_(0) setdest 10 10 5\"\n"
334 "$node_(0) set X_ 10.0\n"
335 "$node_(0) set Y_ 10.0\n"
351 t->
SetTrace (
"$ns_ at 1.0 \"$node_(0) set X_ 10\"\n"
352 "$ns_ at 1.0 \"$node_(0) set Z_ 10\"\n"
353 "$ns_ at 1.0 \"$node_(0) set Y_ 10\"");
362 t->
SetTrace (
"$node() set X_ 1 # node id is not present\n"
363 "$node # incoplete line\"\n"
364 "$node this line is not correct\n"
365 "$node_(0) set X_ 1 # line OK \n"
366 "$node_(0) set Y_ 2 # line OK \n"
367 "$node_(0) set Z_ 3 # line OK \n"
368 "$ns_ at \"$node_(0) setdest 4 4 4\" # time not present\n"
369 "$ns_ at 1 \"$node_(0) setdest 2 2 1 \" # line OK \n");
378 t->
SetTrace (
"$node_(0) set X_ 1 # line OK \n"
379 "$node_(0) set Y_ 2 # line OK \n"
380 "$node_(0) set Z_ 3 # line OK \n"
381 "$node_(-22) set Y_ 3 # node id not correct\n"
382 "$node_(3.3) set Y_ 1111 # node id not correct\n"
383 "$ns_ at sss \"$node_(0) setdest 5 5 5\" # time is not a number\n"
384 "$ns_ at 1 \"$node_(0) setdest 2 2 1\" # line OK \n"
385 "$ns_ at 1 \"$node_(0) setdest 2 2 -1\" # negative speed is not correct\n"
386 "$ns_ at 1 \"$node_(0) setdest 2 2 sdfs\" # speed is not a number\n"
387 "$ns_ at 1 \"$node_(0) setdest 2 2 s232dfs\" # speed is not a number\n"
388 "$ns_ at 1 \"$node_(0) setdest 233 2.. s232dfs\" # more than one non numbers\n"
389 "$ns_ at -12 \"$node_(0) setdest 11 22 33\" # time should not be negative\n");
398 t->
SetTrace (
"$node_(0) set X_ 1.0\n"
399 "$node_(0) set Y_ 2.0\n"
400 "$node_(0) set Z_ 3.0\n"
401 "$ns_ at 1.0 \"$node_(1) setdest 25 0 5\"\n"
402 "$node_(2) set X_ 0.0\n"
403 "$node_(2) set Y_ 0.0\n"
404 "$ns_ at 1.0 \"$node_(2) setdest 5 0 5\"\n"
405 "$ns_ at 2.0 \"$node_(2) setdest 5 5 5\"\n"
406 "$ns_ at 3.0 \"$node_(2) setdest 0 5 5\"\n"
407 "$ns_ at 4.0 \"$node_(2) setdest 0 0 5\"\n");
426 t->
SetTrace (
"$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"\n"
427 "$ns_ at 7.0 \"$node_(0) setdest 11 22 0\"\n");
438 t->
SetTrace (
"$node_(0) set X_ -1.0\n"
439 "$node_(0) set Y_ 0\n"
440 "$ns_ at 1.0 \"$node_(0) setdest 0 0 1\"\n"
441 "$ns_ at 2.0 \"$node_(0) setdest 0 -1 1\"\n");
452 t->
SetTrace (
"$node_(0) set X_ 0.0\n"
453 "$node_(0) set Y_ 0.0\n"
454 "$ns_ at 1.0 \"$node_(0) setdest 1.0e+2 0 1.0e+2\"\n"
455 "$ns_ at 2.0 \"$node_(0) setdest 1.0e+2 1.0e+2 1.0e+2\"\n"
456 "$ns_ at 3.0 \"$node_(0) setdest 0 1.0e+2 1.0e+2\"\n"
457 "$ns_ at 4.0 \"$node_(0) setdest 0 0 1.0e+2\"\n");
470 t->
SetTrace (
"$node_(0) set X_ 0.0\n"
471 "$node_(0) set Y_ 0.0\n"
472 "$ns_ at 1.0 \"$node_(0) setdest 0 10 1\"\n"
473 "$ns_ at 6.0 \"$node_(0) setdest 0 -10 1\"\n"
482 t->
SetTrace (
"$node_(0) set X_ 10.0\r\n"
483 "$node_(0) set Y_ 0.0\r\n"
489 t->
SetTrace (
"$node_(0) set X_ 10.0\n"
490 "$node_(0) set Y_ 0.0\n"
491 "$ns_ at 1.0 \"$node_(0) setdest 10 0 1\"\n"
500 t->
SetTrace (
"$node_(0) set X_ 350.00000000000000\n"
501 "$node_(0) set Y_ 50.00000000000000\n"
502 "$ns_ at 50.00000000000000 \"$node_(0) setdest 400.00000000000000 50.00000000000000 1.00000000000000\"\n"
503 "$ns_ at 150.00000000000000 \"$node_(0) setdest 400.00000000000000 150.00000000000000 4.00000000000000\"\n"
504 "$ns_ at 300.00000000000000 \"$node_(0) setdest 250.00000000000000 150.00000000000000 3.00000000000000\"\n"
505 "$ns_ at 350.00000000000000 \"$node_(0) setdest 250.00000000000000 50.00000000000000 1.00000000000000\"\n"
506 "$ns_ at 600.00000000000000 \"$node_(0) setdest 250.00000000000000 1050.00000000000000 2.00000000000000\"\n"
507 "$ns_ at 900.00000000000000 \"$node_(0) setdest 300.00000000000000 650.00000000000000 2.50000000000000\"\n"
Single record in mobility reference.
Ns2MobilityHelperTest(std::string const &name, Time timeLimit, uint32_t nodes=1)
Create new test case.
double x
x coordinate of vector
void AddReferencePoint(ReferencePoint const &r)
Add next reference point.
keep track of time values and allow control of global simulation resolution
virtual ~Ns2MobilityHelperTest()
Empty.
Every test case is supposed to:
#define NS_ASSERT(condition)
static void Run(void)
Run the simulation until one of:
Vector GetPosition(void) const
size_t m_nextRefPoint
Next reference point to be checked.
void DoTeardown()
Implementation to do any local setup required for this TestCase.
void Connect(std::string path, const CallbackBase &cb)
Vector pos
reference position
#define NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not...
Vector GetVelocity(void) const
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr
Keep track of the current position and velocity of an object.
double GetSeconds(void) const
bool AreVectorsEqual(Vector const &actual, Vector const &limit, double tol)
void Install(void) const
Read the ns2 trace file and configure the movement patterns of all nodes contained in the global ns3:...
static void Clear(void)
Clear the list of objects associated with names.
Ns2MobilityHelperTestSuite()
Helper class which can read ns-2 movement files and configure nodes mobility.
make Callback use a separate empty type
void CourseChange(std::string context, Ptr< const MobilityModel > mobility)
Listen for course change events.
std::string node
node ID as string, e.g. "1"
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
std::string m_traceFile
TMP trace file name.
ns3::Ns2MobilityHelperTestSuite g_ns2TransmobilityHelperTestSuite
Time m_timeLimit
Test time limit.
Vector vel
reference velocity
void CreateNodes()
Create and name nodes.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void DoSetup()
Implementation to do any local setup required for this TestCase.
NS_LOG_COMPONENT_DEFINE("ns2-mobility-helper-test-suite")
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
keep track of a set of node pointers.
bool IsStatusFailure(void) const
double y
y coordinate of vector
static Time Now(void)
Return the "current simulation time".
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
ReferencePoint(std::string const &id, Time t, Vector const &p, Vector const &v)
bool WriteTrace()
Dump NS-2 trace to tmp file.
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
std::string CreateTempDirFilename(std::string filename)
std::string m_trace
Trace as string.
void SetDataDir(std::string directory)
uint32_t m_nodeCount
Number of nodes used in the test.
static std::string FindName(Ptr< Object > object)
Given a pointer to an object, look to see if that object has a name associated with it and...
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
#define NS_LOG_ERROR(msg)
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
#define NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
bool CheckInitialPositions()
Check that all initial positions are correct.
This test suite implements a Unit Test.
bool operator<(ReferencePoint const &o) const
Sort by timestamp.
Ptr< T > GetObject(void) const
void AddReferencePoint(const char *id, double sec, Vector const &p, Vector const &v)
Sugar.
void SetTrace(std::string const &trace)
Set NS-2 trace to read as single large string (don't forget to add \n and quote "'s) ...
#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.
std::vector< ReferencePoint > m_reference
Reference mobility.
double z
z coordinate of vector