39#include "ns3/config.h" 
   40#include "ns3/constant-velocity-mobility-model.h" 
   43#include "ns3/node-container.h" 
   44#include "ns3/node-list.h" 
   46#include "ns3/ns2-mobility-helper.h" 
   47#include "ns3/simulator.h" 
   62    if (actual.x > limit.x + tol || actual.x < limit.x - tol)
 
   66    if (actual.y > limit.y + tol || actual.y < limit.y - tol)
 
   70    if (actual.z > limit.z + tol || actual.z < limit.z - tol)
 
  212            std::ostringstream os;
 
  232                                               "Can't find node with id " << rp.
node);
 
  236                                               "Can't find mobility for node " << rp.
node);
 
  241                                  "Initial position mismatch for node " << rp.
node);
 
  244                                  "Initial velocity mismatch for node " << rp.
node);
 
  261        std::string 
id = Names::FindName(node);
 
  263        Vector pos = 
mobility->GetPosition();
 
  264        Vector vel = 
mobility->GetVelocity();
 
  276                              "Node ID mismatch at time " << time.
GetSeconds() << 
" s");
 
  281                              "Position mismatch at time " << time.
GetSeconds() << 
" s for node " 
  285                              "Velocity mismatch at time " << time.
GetSeconds() << 
" s for node " 
  297        Simulator::Destroy();
 
  343        t->
SetTrace(
"$node_(0) set X_ 1.0\n" 
  344                    "$node_(0) set Y_ 2.0\n" 
  345                    "$node_(0) set Z_ 3.0\n");
 
  353                    "$node_(0) set X_ 1.0 # comment \n" 
  354                    "$node_(0) set Y_ 2.0 ### \n" 
  355                    "$node_(0) set Z_ 3.0 # $node_(0) set Z_ 3.0\n" 
  356                    "#$node_(0) set Z_ 100 #");
 
  362        t->
SetTrace(
"$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"");
 
  371        t->
SetTrace(
"$node_(0) set X_ 0.0\n" 
  372                    "$node_(0) set Y_ 0.0\n" 
  373                    "$ns_ at 1.0 \"$node_(0) setdest 5  0  5\"\n" 
  374                    "$ns_ at 2.0 \"$node_(0) setdest 5  5  5\"\n" 
  375                    "$ns_ at 3.0 \"$node_(0) setdest 0  5  5\"\n" 
  376                    "$ns_ at 4.0 \"$node_(0) setdest 0  0  5\"\n");
 
  394        t->
SetTrace(
"$ns_ at 1.0 \"$node_(0) setdest 15  10  5\"\n" 
  395                    "$ns_ at 2.0 \"$node_(0) setdest 15  15  5\"\n" 
  396                    "$ns_ at 3.0 \"$node_(0) setdest 10  15  5\"\n" 
  397                    "$ns_ at 4.0 \"$node_(0) setdest 10  10  5\"\n" 
  398                    "$node_(0) set X_ 10.0\n" 
  399                    "$node_(0) set Y_ 10.0\n");
 
  414        t->
SetTrace(
"$ns_ at 1.0 \"$node_(0) set X_ 10\"\n" 
  415                    "$ns_ at 1.0 \"$node_(0) set Z_ 10\"\n" 
  416                    "$ns_ at 1.0 \"$node_(0) set Y_ 10\"");
 
  425        t->
SetTrace(
"$node() set X_ 1 # node id is not present\n" 
  426                    "$node # incoplete line\"\n" 
  427                    "$node this line is not correct\n" 
  428                    "$node_(0) set X_ 1 # line OK \n" 
  429                    "$node_(0) set Y_ 2 # line OK \n" 
  430                    "$node_(0) set Z_ 3 # line OK \n" 
  431                    "$ns_ at  \"$node_(0) setdest 4 4 4\" # time not present\n" 
  432                    "$ns_ at 1 \"$node_(0) setdest 2 2 1   \" # line OK \n");
 
  442            "$node_(0) set X_ 1 # line OK \n" 
  443            "$node_(0) set Y_ 2 # line OK \n" 
  444            "$node_(0) set Z_ 3 # line OK \n" 
  445            "$node_(-22) set Y_ 3 # node id not correct\n" 
  446            "$node_(3.3) set Y_ 1111 # node id not correct\n" 
  447            "$ns_ at sss \"$node_(0) setdest 5 5 5\" # time is not a number\n" 
  448            "$ns_ at 1 \"$node_(0) setdest 2 2 1\" # line OK \n" 
  449            "$ns_ at 1 \"$node_(0) setdest 2 2 -1\" # negative speed is not correct\n" 
  450            "$ns_ at 1 \"$node_(0) setdest 2 2 sdfs\"    # speed is not a number\n" 
  451            "$ns_ at 1 \"$node_(0) setdest 2 2 s232dfs\" # speed is not a number\n" 
  452            "$ns_ at 1 \"$node_(0) setdest 233 2.. s232dfs\"   # more than one non numbers\n" 
  453            "$ns_ at -12 \"$node_(0) setdest 11 22 33\" # time should not be negative\n");
 
  462        t->
SetTrace(
"$node_(0) set X_ 1.0\n" 
  463                    "$node_(0) set Y_ 2.0\n" 
  464                    "$node_(0) set Z_ 3.0\n" 
  465                    "$ns_ at 1.0 \"$node_(1) setdest 25 0 5\"\n" 
  466                    "$node_(2) set X_ 0.0\n" 
  467                    "$node_(2) set Y_ 0.0\n" 
  468                    "$ns_ at 1.0 \"$node_(2) setdest 5  0  5\"\n" 
  469                    "$ns_ at 2.0 \"$node_(2) setdest 5  5  5\"\n" 
  470                    "$ns_ at 3.0 \"$node_(2) setdest 0  5  5\"\n" 
  471                    "$ns_ at 4.0 \"$node_(2) setdest 0  0  5\"\n");
 
  490        t->
SetTrace(
"$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"\n" 
  491                    "$ns_ at 7.0 \"$node_(0) setdest 11  22  0\"\n");
 
  501        t->
SetTrace(
"$node_(0) set X_ -1.0\n" 
  502                    "$node_(0) set Y_ 0\n" 
  503                    "$ns_ at 1.0 \"$node_(0) setdest 0 0 1\"\n" 
  504                    "$ns_ at 2.0 \"$node_(0) setdest 0  -1  1\"\n");
 
  515        t->
SetTrace(
"$node_(0) set X_ 0.0\n" 
  516                    "$node_(0) set Y_ 0.0\n" 
  517                    "$ns_ at 1.0 \"$node_(0) setdest 1.0e+2  0       1.0e+2\"\n" 
  518                    "$ns_ at 2.0 \"$node_(0) setdest 1.0e+2  1.0e+2  1.0e+2\"\n" 
  519                    "$ns_ at 3.0 \"$node_(0) setdest 0       1.0e+2  1.0e+2\"\n" 
  520                    "$ns_ at 4.0 \"$node_(0) setdest 0       0       1.0e+2\"\n");
 
  533        t->
SetTrace(
"$node_(0) set X_ 0.0\n" 
  534                    "$node_(0) set Y_ 0.0\n" 
  535                    "$ns_ at 1.0 \"$node_(0) setdest 0  10       1\"\n" 
  536                    "$ns_ at 6.0 \"$node_(0) setdest 0  -10       1\"\n");
 
  544        t->
SetTrace(
"$node_(0) set X_ 10.0\r\n" 
  545                    "$node_(0) set Y_ 0.0\r\n");
 
  550        t->
SetTrace(
"$node_(0) set X_ 10.0\n" 
  551                    "$node_(0) set Y_ 0.0\n" 
  552                    "$ns_ at 1.0 \"$node_(0) setdest 10  0       1\"\n");
 
  560        t->
SetTrace(
"$node_(0) set X_ 350.00000000000000\n" 
  561                    "$node_(0) set Y_ 50.00000000000000\n" 
  562                    "$ns_ at 50.00000000000000  \"$node_(0) setdest 400.00000000000000 " 
  563                    "50.00000000000000 1.00000000000000\"\n" 
  564                    "$ns_ at 150.00000000000000 \"$node_(0) setdest 400.00000000000000 " 
  565                    "150.00000000000000 4.00000000000000\"\n" 
  566                    "$ns_ at 300.00000000000000 \"$node_(0) setdest 250.00000000000000 " 
  567                    "150.00000000000000 3.00000000000000\"\n" 
  568                    "$ns_ at 350.00000000000000 \"$node_(0) setdest 250.00000000000000 " 
  569                    "50.00000000000000 1.00000000000000\"\n" 
  570                    "$ns_ at 600.00000000000000 \"$node_(0) setdest 250.00000000000000 " 
  571                    "1050.00000000000000 2.00000000000000\"\n" 
  572                    "$ns_ at 900.00000000000000 \"$node_(0) setdest 300.00000000000000 " 
  573                    "650.00000000000000 2.50000000000000\"\n");
 
  576                             Vector(350.000, 50.000, 0.000),
 
  577                             Vector(0.000, 0.000, 0.000));
 
  580                             Vector(350.000, 50.000, 0.000),
 
  581                             Vector(1.000, 0.000, 0.000));
 
  584                             Vector(400.000, 50.000, 0.000),
 
  585                             Vector(0.000, 0.000, 0.000));
 
  588                             Vector(400.000, 50.000, 0.000),
 
  589                             Vector(0.000, 4.000, 0.000));
 
  592                             Vector(400.000, 150.000, 0.000),
 
  593                             Vector(0.000, 0.000, 0.000));
 
  596                             Vector(400.000, 150.000, 0.000),
 
  597                             Vector(-3.000, 0.000, 0.000));
 
  600                             Vector(250.000, 150.000, 0.000),
 
  601                             Vector(0.000, 0.000, 0.000));
 
  604                             Vector(250.000, 150.000, 0.000),
 
  605                             Vector(0.000, -1.000, 0.000));
 
  608                             Vector(250.000, 50.000, 0.000),
 
  609                             Vector(0.000, 0.000, 0.000));
 
  612                             Vector(250.000, 50.000, 0.000),
 
  613                             Vector(0.000, 2.000, 0.000));
 
  616                             Vector(250.000, 650.000, 0.000),
 
  617                             Vector(2.500, 0.000, 0.000));
 
  620                             Vector(300.000, 650.000, 0.000),
 
  621                             Vector(0.000, 0.000, 0.000));
 
Every test case is supposed to:
std::string m_traceFile
TMP trace file name.
bool CheckInitialPositions()
Check that all initial positions are correct.
void AddReferencePoint(const char *id, double sec, const Vector &p, const Vector &v)
Add next reference point.
void CourseChange(std::string context, Ptr< const MobilityModel > mobility)
Listen for course change events.
void AddReferencePoint(const ReferencePoint &r)
Add next reference point.
bool WriteTrace()
Dump NS-2 trace to tmp file.
std::string m_trace
Trace as string.
size_t m_nextRefPoint
Next reference point to be checked.
Time m_timeLimit
Test time limit.
std::vector< ReferencePoint > m_reference
Reference mobility.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void CreateNodes()
Create and name nodes.
~Ns2MobilityHelperTest() override
Empty.
void SetTrace(const std::string &trace)
Set NS-2 trace to read as single large string (don't forget to add \n and quote "'s)
Ns2MobilityHelperTest(const std::string &name, Time timeLimit, uint32_t nodes=1)
Create new test case.
uint32_t m_nodeCount
Number of nodes used in the test.
Ns2MobilityHelperTestSuite()
Keep track of the current position and velocity of an object.
Vector GetVelocity() const
Vector GetPosition() const
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Helper class which can read ns-2 movement files and configure nodes mobility.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
bool IsStatusFailure() const
Check if any tests failed.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
void SetDataDir(std::string directory)
Set the data directory where reference trace files can be found.
@ UNIT
This test suite implements a Unit Test.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
Empty class, used as a default parent class for SimpleRefCount.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void Connect(std::string path, const CallbackBase &cb)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time Now()
create an ns3::Time instance which contains the current simulation time.
#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.
#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.
#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_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
#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.
Ns2MobilityHelperTestSuite g_ns2TransmobilityHelperTestSuite
the test suite
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
bool AreVectorsEqual(const Vector &actual, const Vector &limit, double tol)
Single record in mobility reference.
std::string node
node ID as string, e.g. "1"
Vector pos
reference position
ReferencePoint(const std::string &id, Time t, const Vector &p, const Vector &v)
Constructor.
Vector vel
reference velocity
bool operator<(const ReferencePoint &o) const
Less-than operator - used to sort by timestamp.