merge
This commit is contained in:
@@ -19,8 +19,6 @@
|
||||
*/
|
||||
#include "log.h"
|
||||
|
||||
#ifdef NS3_LOG_ENABLE
|
||||
|
||||
#include <list>
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
@@ -381,35 +379,3 @@ ParameterLogger::ParameterLogger (std::ostream &os)
|
||||
{}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#else // NS3_LOG_ENABLE
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
void
|
||||
LogComponentEnable (char const *name, enum LogLevel level)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
LogComponentEnableAll (enum LogLevel level)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
LogComponentDisable (char const *name, enum LogLevel level)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
LogComponentDisableAll (enum LogLevel level)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif
|
||||
|
||||
@@ -323,8 +323,22 @@ void LogComponentDisableAll (enum LogLevel level);
|
||||
} \
|
||||
while (false)
|
||||
|
||||
namespace ns3 {
|
||||
#else /* LOG_ENABLE */
|
||||
|
||||
#define NS_LOG_COMPONENT_DEFINE(component)
|
||||
#define NS_LOG(level, msg)
|
||||
#define NS_LOG_ERROR(msg)
|
||||
#define NS_LOG_WARN(msg)
|
||||
#define NS_LOG_DEBUG(msg)
|
||||
#define NS_LOG_INFO(msg)
|
||||
#define NS_LOG_FUNCTION_NOARGS()
|
||||
#define NS_LOG_FUNCTION(msg)
|
||||
#define NS_LOG_LOGIC(msg)
|
||||
#define NS_LOG_UNCOND(msg)
|
||||
|
||||
#endif /* LOG_ENABLE */
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \ingroup logging
|
||||
@@ -385,27 +399,5 @@ public:
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#else /* LOG_ENABLE */
|
||||
|
||||
#define NS_LOG_COMPONENT_DEFINE(component)
|
||||
#define NS_LOG(level, msg)
|
||||
#define NS_LOG_ERROR(msg)
|
||||
#define NS_LOG_WARN(msg)
|
||||
#define NS_LOG_DEBUG(msg)
|
||||
#define NS_LOG_INFO(msg)
|
||||
#define NS_LOG_FUNCTION_NOARGS()
|
||||
#define NS_LOG_FUNCTION(msg)
|
||||
#define NS_LOG_LOGIC(msg)
|
||||
#define NS_LOG_UNCOND(msg)
|
||||
|
||||
#define LogComponentPrintList
|
||||
#define LogRegisterTimePrinter(printer)
|
||||
|
||||
#define LogSetTimePrinter(printer)
|
||||
#define LogGetTimePrinter
|
||||
#define LogSetNodePrinter(printer)
|
||||
#define LogGetNodePrinter
|
||||
|
||||
#endif /* LOG_ENABLE */
|
||||
|
||||
#endif // __LOG_H__
|
||||
|
||||
@@ -51,14 +51,6 @@ GlobalValue g_schedTypeImpl = GlobalValue ("SchedulerType",
|
||||
TypeIdValue (MapScheduler::GetTypeId ()),
|
||||
MakeTypeIdChecker ());
|
||||
|
||||
|
||||
#ifdef NS3_LOG_ENABLE
|
||||
|
||||
//
|
||||
// Note: Calls that take TimePrinter as a parameter are defined as nothing
|
||||
// in the logging module if NS3_LOG_ENABLE is not defined.
|
||||
//
|
||||
|
||||
static void
|
||||
TimePrinter (std::ostream &os)
|
||||
{
|
||||
@@ -78,8 +70,6 @@ NodePrinter (std::ostream &os)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* NS3_LOG_ENABLE */
|
||||
|
||||
static SimulatorImpl **PeekImpl (void)
|
||||
{
|
||||
static SimulatorImpl *impl = 0;
|
||||
|
||||
@@ -217,7 +217,7 @@ public:
|
||||
};
|
||||
|
||||
CommandLineTestSuite::CommandLineTestSuite ()
|
||||
: TestSuite ("command-line", BVT)
|
||||
: TestSuite ("command-line", UNIT)
|
||||
{
|
||||
AddTestCase (new CommandLineBooleanTestCase);
|
||||
AddTestCase (new CommandLineIntTestCase);
|
||||
|
||||
@@ -605,7 +605,7 @@ public:
|
||||
};
|
||||
|
||||
ConfigTestSuite::ConfigTestSuite ()
|
||||
: TestSuite ("config", BVT)
|
||||
: TestSuite ("config", UNIT)
|
||||
{
|
||||
AddTestCase (new RootNamespaceConfigTestCase);
|
||||
AddTestCase (new UnderRootNamespaceConfigTestCase);
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
};
|
||||
|
||||
GlobalValueTestSuite::GlobalValueTestSuite ()
|
||||
: TestSuite ("global-value", BVT)
|
||||
: TestSuite ("global-value", UNIT)
|
||||
{
|
||||
AddTestCase (new GlobalValueTestCase);
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ public:
|
||||
};
|
||||
|
||||
ObjectTestSuite::ObjectTestSuite ()
|
||||
: TestSuite ("object", BVT)
|
||||
: TestSuite ("object", UNIT)
|
||||
{
|
||||
AddTestCase (new CreateObjectTestCase);
|
||||
AddTestCase (new AggregateObjectTestCase);
|
||||
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
};
|
||||
|
||||
BasicRandomNumberTestSuite::BasicRandomNumberTestSuite ()
|
||||
: TestSuite ("basic-random-number", BVT)
|
||||
: TestSuite ("basic-random-number", UNIT)
|
||||
{
|
||||
AddTestCase (new BasicRandomNumberTestCase);
|
||||
AddTestCase (new RandomNumberSerializationTestCase);
|
||||
|
||||
@@ -41,16 +41,11 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/node-list.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/constant-velocity-mobility-model.h"
|
||||
#include "ns3/test.h"
|
||||
#include "ns3/node-container.h"
|
||||
#include "ns3/names.h"
|
||||
#include "ns3/config.h"
|
||||
#include "ns2-mobility-helper.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("Ns2MobilityHelper");
|
||||
@@ -663,367 +658,4 @@ Ns2MobilityHelper::Install (void) const
|
||||
Install (NodeList::Begin (), NodeList::End ());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Testing
|
||||
// -----------------------------------------------------------------------------
|
||||
bool operator== (Vector const & a, Vector const & b)
|
||||
{
|
||||
return (a.x == b.x && a.y == b.y && a.z == b.z);
|
||||
}
|
||||
/**
|
||||
* Every test case is supposed to:
|
||||
* 1. Generate short mobility trace file
|
||||
* 2. Read it back using Ns2MobilityHelper
|
||||
* 3. Check initial node positions and speeds.
|
||||
* 4. Run simulation listening for all CourseChange events and compare actual mobility with the reference
|
||||
*/
|
||||
class Ns2MobilityHelperTest : public TestCase
|
||||
{
|
||||
public:
|
||||
/// Single record in mobility reference
|
||||
struct ReferencePoint
|
||||
{
|
||||
std::string node; ///< node ID as string, e.g. "1"
|
||||
Time time; ///< timestamp
|
||||
Vector pos; ///< reference position
|
||||
Vector vel; ///< reference velocity
|
||||
|
||||
ReferencePoint (std::string const & id, Time t, Vector const & p, Vector const & v)
|
||||
: node (id),
|
||||
time (t),
|
||||
pos (p),
|
||||
vel (v)
|
||||
{
|
||||
}
|
||||
/// Sort by timestamp
|
||||
bool operator< (ReferencePoint const & o) const
|
||||
{
|
||||
return (time < o.time);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Create new test case. To make it useful SetTrace () and AddReferencePoint () must be called
|
||||
*
|
||||
* \param name Short description
|
||||
* \param nodes Number of nodes used in the test trace, 1 by default
|
||||
*/
|
||||
Ns2MobilityHelperTest (std::string const & name, Time timeLimit, uint32_t nodes = 1)
|
||||
: TestCase (name),
|
||||
m_timeLimit (timeLimit),
|
||||
m_nodeCount (nodes),
|
||||
m_nextRefPoint (0)
|
||||
{
|
||||
}
|
||||
/// Empty
|
||||
virtual ~Ns2MobilityHelperTest ()
|
||||
{
|
||||
}
|
||||
/// Set NS-2 trace to read as single large string (don't forget to add \n and quote ")
|
||||
void SetTrace (std::string const & trace)
|
||||
{
|
||||
m_trace = trace;
|
||||
}
|
||||
/// Add next reference point
|
||||
void AddReferencePoint (ReferencePoint const & r)
|
||||
{
|
||||
m_reference.push_back (r);
|
||||
}
|
||||
/// Sugar
|
||||
void AddReferencePoint (const char * id, double sec, Vector const & p, Vector const & v)
|
||||
{
|
||||
AddReferencePoint (ReferencePoint (id, Seconds (sec), p, v));
|
||||
}
|
||||
|
||||
private:
|
||||
/// Test time limit
|
||||
Time m_timeLimit;
|
||||
/// Number of nodes used in the test
|
||||
uint32_t m_nodeCount;
|
||||
/// Trace as string
|
||||
std::string m_trace;
|
||||
/// Reference mobility
|
||||
std::vector<ReferencePoint> m_reference;
|
||||
/// Next reference point to be checked
|
||||
size_t m_nextRefPoint;
|
||||
/// TMP trace file name
|
||||
std::string m_traceFile;
|
||||
|
||||
private:
|
||||
/// Dump NS-2 trace to tmp file
|
||||
bool WriteTrace ()
|
||||
{
|
||||
m_traceFile = GetTempDir () + "Ns2MobilityHelperTest.tcl";
|
||||
std::ofstream of (m_traceFile.c_str ());
|
||||
NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (of.is_open (), true, "Need to write tmp. file");
|
||||
of << m_trace;
|
||||
of.close ();
|
||||
return false; // no errors
|
||||
}
|
||||
/// Create and name nodes
|
||||
void CreateNodes ()
|
||||
{
|
||||
NodeContainer nodes;
|
||||
nodes.Create (m_nodeCount);
|
||||
for (uint32_t i = 0; i < m_nodeCount; ++i)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << i;
|
||||
Names::Add (os.str (), nodes.Get (i));
|
||||
}
|
||||
}
|
||||
/// Check that all initial positions are correct
|
||||
bool CheckInitialPositions ()
|
||||
{
|
||||
std::stable_sort (m_reference.begin (), m_reference.end ());
|
||||
while (m_nextRefPoint < m_reference.size () && m_reference[m_nextRefPoint].time == Seconds (0))
|
||||
{
|
||||
ReferencePoint const & rp = m_reference[m_nextRefPoint];
|
||||
Ptr<Node> node = Names::Find<Node> (rp.node);
|
||||
NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL (node, 0, "Can't find node with id " << rp.node);
|
||||
Ptr<MobilityModel> mob = node->GetObject<MobilityModel> ();
|
||||
NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL (mob, 0, "Can't find mobility for node " << rp.node);
|
||||
|
||||
NS_TEST_EXPECT_MSG_EQ (rp.pos, mob->GetPosition (), "Initial position mismatch for node " << rp.node);
|
||||
NS_TEST_EXPECT_MSG_EQ (rp.vel, mob->GetVelocity (), "Initial velocity mismatch for node " << rp.node);
|
||||
|
||||
m_nextRefPoint++;
|
||||
}
|
||||
return GetErrorStatus ();
|
||||
}
|
||||
/// Listen for course change events
|
||||
void CourseChange (std::string context, Ptr<const MobilityModel> mobility)
|
||||
{
|
||||
Time time = Simulator::Now ();
|
||||
Ptr<Node> node = mobility->GetObject<Node> ();
|
||||
NS_ASSERT (node);
|
||||
std::string id = Names::FindName (node);
|
||||
NS_ASSERT (!id.empty ());
|
||||
Vector pos = mobility->GetPosition ();
|
||||
Vector vel = mobility->GetVelocity ();
|
||||
|
||||
NS_TEST_EXPECT_MSG_LT (m_nextRefPoint, m_reference.size (), "Not enough reference points");
|
||||
if (m_nextRefPoint >= m_reference.size ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ReferencePoint const & ref = m_reference [m_nextRefPoint++];
|
||||
NS_TEST_EXPECT_MSG_EQ (time, ref.time, "Time mismatch");
|
||||
NS_TEST_EXPECT_MSG_EQ (id, ref.node, "Node ID mismatch at time " << time.GetSeconds () << " s");
|
||||
NS_TEST_EXPECT_MSG_EQ (pos, ref.pos, "Position mismatch at time " << time.GetSeconds () << " s for node " << id);
|
||||
NS_TEST_EXPECT_MSG_EQ (vel, ref.vel, "Velocity mismatch at time " << time.GetSeconds () << " s for node " << id);
|
||||
}
|
||||
/// Go
|
||||
void DoRun ()
|
||||
{
|
||||
NS_TEST_ASSERT_MSG_EQ (m_trace.empty (), false, "Need trace");
|
||||
NS_TEST_ASSERT_MSG_EQ (m_reference.empty (), false, "Need reference");
|
||||
|
||||
if (WriteTrace ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
CreateNodes ();
|
||||
Ns2MobilityHelper mobility (m_traceFile);
|
||||
mobility.Install ();
|
||||
if (CheckInitialPositions ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
|
||||
MakeCallback (&Ns2MobilityHelperTest::CourseChange, this));
|
||||
Simulator::Stop (m_timeLimit);
|
||||
Simulator::Run ();
|
||||
Names::Clear ();
|
||||
std::remove (m_traceFile.c_str ());
|
||||
Simulator::Destroy ();
|
||||
}
|
||||
};
|
||||
|
||||
/// The test suite
|
||||
class Ns2MobilityHelperTestSuite : public TestSuite
|
||||
{
|
||||
public:
|
||||
Ns2MobilityHelperTestSuite () : TestSuite ("mobility-ns2-trace-helper", UNIT)
|
||||
{
|
||||
// to be used as temporary variable for test cases.
|
||||
// Note that test suite takes care of deleting all test cases.
|
||||
Ns2MobilityHelperTest * t (0);
|
||||
|
||||
// Initial position
|
||||
t = new Ns2MobilityHelperTest ("initial position", Seconds (1));
|
||||
t->SetTrace ("$node_(0) set X_ 1.0\n"
|
||||
"$node_(0) set Y_ 2.0\n"
|
||||
"$node_(0) set Z_ 3.0\n"
|
||||
);
|
||||
t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Check parsing comments, empty lines and no EOF at the end of file
|
||||
t = new Ns2MobilityHelperTest ("comments", Seconds (1));
|
||||
t->SetTrace ("# comment\n"
|
||||
"\n\n" // empty lines
|
||||
"$node_(0) set X_ 1.0 # comment \n"
|
||||
"$node_(0) set Y_ 2.0 ### \n"
|
||||
"$node_(0) set Z_ 3.0 # $node_(0) set Z_ 3.0\n"
|
||||
"#$node_(0) set Z_ 100 #"
|
||||
);
|
||||
t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Simple setdest. Arguments are interpreted as x, y, speed by default
|
||||
t = new Ns2MobilityHelperTest ("simple setdest", Seconds (10));
|
||||
t->SetTrace ("$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5, 0, 0));
|
||||
t->AddReferencePoint ("0", 6, Vector (25, 0, 0), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Several set and setdest. Arguments are interpreted as x, y, speed by default
|
||||
t = new Ns2MobilityHelperTest ("square setdest", Seconds (6));
|
||||
t->SetTrace ("$node_(0) set X_ 0.0\n"
|
||||
"$node_(0) set Y_ 0.0\n"
|
||||
"$ns_ at 1.0 \"$node_(0) setdest 5 0 5\"\n"
|
||||
"$ns_ at 2.0 \"$node_(0) setdest 5 5 5\"\n"
|
||||
"$ns_ at 3.0 \"$node_(0) setdest 0 5 5\"\n"
|
||||
"$ns_ at 4.0 \"$node_(0) setdest 0 0 5\"\n"
|
||||
);
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (5, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (5, 0, 0), Vector (0, 5, 0));
|
||||
t->AddReferencePoint ("0", 3, Vector (5, 5, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 3, Vector (5, 5, 0), Vector (-5, 0, 0));
|
||||
t->AddReferencePoint ("0", 4, Vector (0, 5, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 4, Vector (0, 5, 0), Vector (0, -5, 0));
|
||||
t->AddReferencePoint ("0", 5, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Scheduled set position
|
||||
t = new Ns2MobilityHelperTest ("scheduled set position", Seconds (2));
|
||||
t->SetTrace ("$ns_ at 1.0 \"$node_(0) set X_ 10\"\n"
|
||||
"$ns_ at 1.0 \"$node_(0) set Z_ 10\"\n"
|
||||
"$ns_ at 1.0 \"$node_(0) set Y_ 10\"");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 1, Vector (10, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (10, 0, 10), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (10, 10, 10), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Malformed lines
|
||||
t = new Ns2MobilityHelperTest ("malformed lines", Seconds (2));
|
||||
t->SetTrace ("$node() set X_ 1 # node id is not present\n"
|
||||
"$node # incoplete line\"\n"
|
||||
"$node this line is not correct\n"
|
||||
"$node_(0) set X_ 1 # line OK \n"
|
||||
"$node_(0) set Y_ 2 # line OK \n"
|
||||
"$node_(0) set Z_ 3 # line OK \n"
|
||||
"$ns_ at \"$node_(0) setdest 4 4 4\" # time not present\n"
|
||||
"$ns_ at 1 \"$node_(0) setdest 2 2 1 \" # line OK \n");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (1, 2, 3), Vector (1, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (2, 2, 3), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Non possible values
|
||||
t = new Ns2MobilityHelperTest ("non possible values", Seconds (2));
|
||||
t->SetTrace ("$node_(0) set X_ 1 # line OK \n"
|
||||
"$node_(0) set Y_ 2 # line OK \n"
|
||||
"$node_(0) set Z_ 3 # line OK \n"
|
||||
"$node_(-22) set Y_ 3 # node id not correct\n"
|
||||
"$node_(3.3) set Y_ 1111 # node id not correct\n"
|
||||
"$ns_ at sss \"$node_(0) setdest 5 5 5\" # time is not a number\n"
|
||||
"$ns_ at 1 \"$node_(0) setdest 2 2 1\" # line OK \n"
|
||||
"$ns_ at 1 \"$node_(0) setdest 2 2 -1\" # negative speed is not correct\n"
|
||||
"$ns_ at 1 \"$node_(0) setdest 2 2 sdfs\" # speed is not a number\n"
|
||||
"$ns_ at 1 \"$node_(0) setdest 2 2 s232dfs\" # speed is not a number\n"
|
||||
"$ns_ at 1 \"$node_(0) setdest 233 2.. s232dfs\" # more than one non numbers\n"
|
||||
"$ns_ at -12 \"$node_(0) setdest 11 22 33\" # time should not be negative\n");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (1, 2, 3), Vector (1, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (2, 2, 3), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// More than one node
|
||||
t = new Ns2MobilityHelperTest ("few nodes, combinations of set and setdest", Seconds (10), 3);
|
||||
t->SetTrace ("$node_(0) set X_ 1.0\n"
|
||||
"$node_(0) set Y_ 2.0\n"
|
||||
"$node_(0) set Z_ 3.0\n"
|
||||
"$ns_ at 1.0 \"$node_(1) setdest 25 0 5\"\n"
|
||||
"$node_(2) set X_ 0.0\n"
|
||||
"$node_(2) set Y_ 0.0\n"
|
||||
"$ns_ at 1.0 \"$node_(2) setdest 5 0 5\"\n"
|
||||
"$ns_ at 2.0 \"$node_(2) setdest 5 5 5\"\n"
|
||||
"$ns_ at 3.0 \"$node_(2) setdest 0 5 5\"\n"
|
||||
"$ns_ at 4.0 \"$node_(2) setdest 0 0 5\"\n");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("1", 0, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("1", 1, Vector (0, 0, 0), Vector (5, 0, 0));
|
||||
t->AddReferencePoint ("1", 6, Vector (25, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("2", 0, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("2", 1, Vector (0, 0, 0), Vector (5, 0, 0));
|
||||
t->AddReferencePoint ("2", 2, Vector (5, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("2", 2, Vector (5, 0, 0), Vector (0, 5, 0));
|
||||
t->AddReferencePoint ("2", 3, Vector (5, 5, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("2", 3, Vector (5, 5, 0), Vector (-5, 0, 0));
|
||||
t->AddReferencePoint ("2", 4, Vector (0, 5, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("2", 4, Vector (0, 5, 0), Vector (0, -5, 0));
|
||||
t->AddReferencePoint ("2", 5, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Test for Speed == 0, that acts as stop the node.
|
||||
t = new Ns2MobilityHelperTest ("setdest with speed cero", Seconds (10));
|
||||
t->SetTrace ("$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"\n"
|
||||
"$ns_ at 7.0 \"$node_(0) setdest 11 22 0\"\n");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5, 0, 0));
|
||||
t->AddReferencePoint ("0", 6, Vector (25, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 7, Vector (25, 0, 0), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
|
||||
// Test negative positions
|
||||
t = new Ns2MobilityHelperTest ("test negative positions", Seconds (10));
|
||||
t->SetTrace ("$node_(0) set X_ -1.0\n"
|
||||
"$node_(0) set Y_ 0\n"
|
||||
"$ns_ at 1.0 \"$node_(0) setdest 0 0 1\"\n"
|
||||
"$ns_ at 2.0 \"$node_(0) setdest 0 -1 1\"\n");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (-1, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (-1, 0, 0), Vector (1, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (0, 0, 0), Vector (0, -1, 0));
|
||||
t->AddReferencePoint ("0", 3, Vector (0, -1, 0), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Sqare setdest with values in the form 1.0e+2
|
||||
t = new Ns2MobilityHelperTest ("Foalt numbers in 1.0e+2 format", Seconds (6));
|
||||
t->SetTrace ("$node_(0) set X_ 0.0\n"
|
||||
"$node_(0) set Y_ 0.0\n"
|
||||
"$ns_ at 1.0 \"$node_(0) setdest 1.0e+2 0 1.0e+2\"\n"
|
||||
"$ns_ at 2.0 \"$node_(0) setdest 1.0e+2 1.0e+2 1.0e+2\"\n"
|
||||
"$ns_ at 3.0 \"$node_(0) setdest 0 1.0e+2 1.0e+2\"\n"
|
||||
"$ns_ at 4.0 \"$node_(0) setdest 0 0 1.0e+2\"\n");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (100, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (100, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (100, 0, 0), Vector (0, 100, 0));
|
||||
t->AddReferencePoint ("0", 3, Vector (100, 100, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 3, Vector (100, 100, 0), Vector (-100, 0, 0));
|
||||
t->AddReferencePoint ("0", 4, Vector (0, 100, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 4, Vector (0, 100, 0), Vector (0, -100, 0));
|
||||
t->AddReferencePoint ("0", 5, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
}
|
||||
} g_ns2TransmobilityHelperTestSuite;
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
417
src/mobility/test/ns2-mobility-helper-test-suite.cc
Normal file
417
src/mobility/test/ns2-mobility-helper-test-suite.cc
Normal file
@@ -0,0 +1,417 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
* 2009,2010 Contributors
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
* Contributors: Thomas Waldecker <twaldecker@rocketmail.com>
|
||||
* Martín Giachino <martin.giachino@gmail.com>
|
||||
*
|
||||
* Brief description: Implementation of a ns2 movement trace file reader.
|
||||
*
|
||||
* This implementation is based on the ns2 movement documentation of ns2
|
||||
* as described in http://www.isi.edu/nsnam/ns/doc/node174.html
|
||||
*
|
||||
* Valid trace files use the following ns2 statements:
|
||||
*
|
||||
* $node set X_ x1
|
||||
* $node set Y_ y1
|
||||
* $node set Z_ z1
|
||||
* $ns at $time $node setdest x2 y2 speed
|
||||
* $ns at $time $node set X_ x1
|
||||
* $ns at $time $node set Y_ Y1
|
||||
* $ns at $time $node set Z_ Z1
|
||||
*
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/node-list.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/constant-velocity-mobility-model.h"
|
||||
#include "ns3/test.h"
|
||||
#include "ns3/node-container.h"
|
||||
#include "ns3/names.h"
|
||||
#include "ns3/config.h"
|
||||
#include "ns3/ns2-mobility-helper.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Testing
|
||||
// -----------------------------------------------------------------------------
|
||||
bool operator== (Vector const & a, Vector const & b)
|
||||
{
|
||||
return (a.x == b.x && a.y == b.y && a.z == b.z);
|
||||
}
|
||||
/**
|
||||
* Every test case is supposed to:
|
||||
* 1. Generate short mobility trace file
|
||||
* 2. Read it back using Ns2MobilityHelper
|
||||
* 3. Check initial node positions and speeds.
|
||||
* 4. Run simulation listening for all CourseChange events and compare actual mobility with the reference
|
||||
*/
|
||||
class Ns2MobilityHelperTest : public TestCase
|
||||
{
|
||||
public:
|
||||
/// Single record in mobility reference
|
||||
struct ReferencePoint
|
||||
{
|
||||
std::string node; ///< node ID as string, e.g. "1"
|
||||
Time time; ///< timestamp
|
||||
Vector pos; ///< reference position
|
||||
Vector vel; ///< reference velocity
|
||||
|
||||
ReferencePoint (std::string const & id, Time t, Vector const & p, Vector const & v)
|
||||
: node (id),
|
||||
time (t),
|
||||
pos (p),
|
||||
vel (v)
|
||||
{
|
||||
}
|
||||
/// Sort by timestamp
|
||||
bool operator< (ReferencePoint const & o) const
|
||||
{
|
||||
return (time < o.time);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Create new test case. To make it useful SetTrace () and AddReferencePoint () must be called
|
||||
*
|
||||
* \param name Short description
|
||||
* \param nodes Number of nodes used in the test trace, 1 by default
|
||||
*/
|
||||
Ns2MobilityHelperTest (std::string const & name, Time timeLimit, uint32_t nodes = 1)
|
||||
: TestCase (name),
|
||||
m_timeLimit (timeLimit),
|
||||
m_nodeCount (nodes),
|
||||
m_nextRefPoint (0)
|
||||
{
|
||||
}
|
||||
/// Empty
|
||||
virtual ~Ns2MobilityHelperTest ()
|
||||
{
|
||||
}
|
||||
/// Set NS-2 trace to read as single large string (don't forget to add \n and quote ")
|
||||
void SetTrace (std::string const & trace)
|
||||
{
|
||||
m_trace = trace;
|
||||
}
|
||||
/// Add next reference point
|
||||
void AddReferencePoint (ReferencePoint const & r)
|
||||
{
|
||||
m_reference.push_back (r);
|
||||
}
|
||||
/// Sugar
|
||||
void AddReferencePoint (const char * id, double sec, Vector const & p, Vector const & v)
|
||||
{
|
||||
AddReferencePoint (ReferencePoint (id, Seconds (sec), p, v));
|
||||
}
|
||||
|
||||
private:
|
||||
/// Test time limit
|
||||
Time m_timeLimit;
|
||||
/// Number of nodes used in the test
|
||||
uint32_t m_nodeCount;
|
||||
/// Trace as string
|
||||
std::string m_trace;
|
||||
/// Reference mobility
|
||||
std::vector<ReferencePoint> m_reference;
|
||||
/// Next reference point to be checked
|
||||
size_t m_nextRefPoint;
|
||||
/// TMP trace file name
|
||||
std::string m_traceFile;
|
||||
|
||||
private:
|
||||
/// Dump NS-2 trace to tmp file
|
||||
bool WriteTrace ()
|
||||
{
|
||||
m_traceFile = GetTempDir () + "Ns2MobilityHelperTest.tcl";
|
||||
std::ofstream of (m_traceFile.c_str ());
|
||||
NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (of.is_open (), true, "Need to write tmp. file");
|
||||
of << m_trace;
|
||||
of.close ();
|
||||
return false; // no errors
|
||||
}
|
||||
/// Create and name nodes
|
||||
void CreateNodes ()
|
||||
{
|
||||
NodeContainer nodes;
|
||||
nodes.Create (m_nodeCount);
|
||||
for (uint32_t i = 0; i < m_nodeCount; ++i)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << i;
|
||||
Names::Add (os.str (), nodes.Get (i));
|
||||
}
|
||||
}
|
||||
/// Check that all initial positions are correct
|
||||
bool CheckInitialPositions ()
|
||||
{
|
||||
std::stable_sort (m_reference.begin (), m_reference.end ());
|
||||
while (m_nextRefPoint < m_reference.size () && m_reference[m_nextRefPoint].time == Seconds (0))
|
||||
{
|
||||
ReferencePoint const & rp = m_reference[m_nextRefPoint];
|
||||
Ptr<Node> node = Names::Find<Node> (rp.node);
|
||||
NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL (node, 0, "Can't find node with id " << rp.node);
|
||||
Ptr<MobilityModel> mob = node->GetObject<MobilityModel> ();
|
||||
NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL (mob, 0, "Can't find mobility for node " << rp.node);
|
||||
|
||||
NS_TEST_EXPECT_MSG_EQ (rp.pos, mob->GetPosition (), "Initial position mismatch for node " << rp.node);
|
||||
NS_TEST_EXPECT_MSG_EQ (rp.vel, mob->GetVelocity (), "Initial velocity mismatch for node " << rp.node);
|
||||
|
||||
m_nextRefPoint++;
|
||||
}
|
||||
return GetErrorStatus ();
|
||||
}
|
||||
/// Listen for course change events
|
||||
void CourseChange (std::string context, Ptr<const MobilityModel> mobility)
|
||||
{
|
||||
Time time = Simulator::Now ();
|
||||
Ptr<Node> node = mobility->GetObject<Node> ();
|
||||
NS_ASSERT (node);
|
||||
std::string id = Names::FindName (node);
|
||||
NS_ASSERT (!id.empty ());
|
||||
Vector pos = mobility->GetPosition ();
|
||||
Vector vel = mobility->GetVelocity ();
|
||||
|
||||
NS_TEST_EXPECT_MSG_LT (m_nextRefPoint, m_reference.size (), "Not enough reference points");
|
||||
if (m_nextRefPoint >= m_reference.size ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ReferencePoint const & ref = m_reference [m_nextRefPoint++];
|
||||
NS_TEST_EXPECT_MSG_EQ (time, ref.time, "Time mismatch");
|
||||
NS_TEST_EXPECT_MSG_EQ (id, ref.node, "Node ID mismatch at time " << time.GetSeconds () << " s");
|
||||
NS_TEST_EXPECT_MSG_EQ (pos, ref.pos, "Position mismatch at time " << time.GetSeconds () << " s for node " << id);
|
||||
NS_TEST_EXPECT_MSG_EQ (vel, ref.vel, "Velocity mismatch at time " << time.GetSeconds () << " s for node " << id);
|
||||
}
|
||||
/// Go
|
||||
void DoRun ()
|
||||
{
|
||||
NS_TEST_ASSERT_MSG_EQ (m_trace.empty (), false, "Need trace");
|
||||
NS_TEST_ASSERT_MSG_EQ (m_reference.empty (), false, "Need reference");
|
||||
|
||||
if (WriteTrace ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
CreateNodes ();
|
||||
Ns2MobilityHelper mobility (m_traceFile);
|
||||
mobility.Install ();
|
||||
if (CheckInitialPositions ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
|
||||
MakeCallback (&Ns2MobilityHelperTest::CourseChange, this));
|
||||
Simulator::Stop (m_timeLimit);
|
||||
Simulator::Run ();
|
||||
Names::Clear ();
|
||||
std::remove (m_traceFile.c_str ());
|
||||
Simulator::Destroy ();
|
||||
}
|
||||
};
|
||||
|
||||
/// The test suite
|
||||
class Ns2MobilityHelperTestSuite : public TestSuite
|
||||
{
|
||||
public:
|
||||
Ns2MobilityHelperTestSuite () : TestSuite ("mobility-ns2-trace-helper", UNIT)
|
||||
{
|
||||
// to be used as temporary variable for test cases.
|
||||
// Note that test suite takes care of deleting all test cases.
|
||||
Ns2MobilityHelperTest * t (0);
|
||||
|
||||
// Initial position
|
||||
t = new Ns2MobilityHelperTest ("initial position", Seconds (1));
|
||||
t->SetTrace ("$node_(0) set X_ 1.0\n"
|
||||
"$node_(0) set Y_ 2.0\n"
|
||||
"$node_(0) set Z_ 3.0\n"
|
||||
);
|
||||
t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Check parsing comments, empty lines and no EOF at the end of file
|
||||
t = new Ns2MobilityHelperTest ("comments", Seconds (1));
|
||||
t->SetTrace ("# comment\n"
|
||||
"\n\n" // empty lines
|
||||
"$node_(0) set X_ 1.0 # comment \n"
|
||||
"$node_(0) set Y_ 2.0 ### \n"
|
||||
"$node_(0) set Z_ 3.0 # $node_(0) set Z_ 3.0\n"
|
||||
"#$node_(0) set Z_ 100 #"
|
||||
);
|
||||
t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Simple setdest. Arguments are interpreted as x, y, speed by default
|
||||
t = new Ns2MobilityHelperTest ("simple setdest", Seconds (10));
|
||||
t->SetTrace ("$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5, 0, 0));
|
||||
t->AddReferencePoint ("0", 6, Vector (25, 0, 0), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Several set and setdest. Arguments are interpreted as x, y, speed by default
|
||||
t = new Ns2MobilityHelperTest ("square setdest", Seconds (6));
|
||||
t->SetTrace ("$node_(0) set X_ 0.0\n"
|
||||
"$node_(0) set Y_ 0.0\n"
|
||||
"$ns_ at 1.0 \"$node_(0) setdest 5 0 5\"\n"
|
||||
"$ns_ at 2.0 \"$node_(0) setdest 5 5 5\"\n"
|
||||
"$ns_ at 3.0 \"$node_(0) setdest 0 5 5\"\n"
|
||||
"$ns_ at 4.0 \"$node_(0) setdest 0 0 5\"\n"
|
||||
);
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (5, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (5, 0, 0), Vector (0, 5, 0));
|
||||
t->AddReferencePoint ("0", 3, Vector (5, 5, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 3, Vector (5, 5, 0), Vector (-5, 0, 0));
|
||||
t->AddReferencePoint ("0", 4, Vector (0, 5, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 4, Vector (0, 5, 0), Vector (0, -5, 0));
|
||||
t->AddReferencePoint ("0", 5, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Scheduled set position
|
||||
t = new Ns2MobilityHelperTest ("scheduled set position", Seconds (2));
|
||||
t->SetTrace ("$ns_ at 1.0 \"$node_(0) set X_ 10\"\n"
|
||||
"$ns_ at 1.0 \"$node_(0) set Z_ 10\"\n"
|
||||
"$ns_ at 1.0 \"$node_(0) set Y_ 10\"");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 1, Vector (10, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (10, 0, 10), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (10, 10, 10), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Malformed lines
|
||||
t = new Ns2MobilityHelperTest ("malformed lines", Seconds (2));
|
||||
t->SetTrace ("$node() set X_ 1 # node id is not present\n"
|
||||
"$node # incoplete line\"\n"
|
||||
"$node this line is not correct\n"
|
||||
"$node_(0) set X_ 1 # line OK \n"
|
||||
"$node_(0) set Y_ 2 # line OK \n"
|
||||
"$node_(0) set Z_ 3 # line OK \n"
|
||||
"$ns_ at \"$node_(0) setdest 4 4 4\" # time not present\n"
|
||||
"$ns_ at 1 \"$node_(0) setdest 2 2 1 \" # line OK \n");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (1, 2, 3), Vector (1, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (2, 2, 3), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Non possible values
|
||||
t = new Ns2MobilityHelperTest ("non possible values", Seconds (2));
|
||||
t->SetTrace ("$node_(0) set X_ 1 # line OK \n"
|
||||
"$node_(0) set Y_ 2 # line OK \n"
|
||||
"$node_(0) set Z_ 3 # line OK \n"
|
||||
"$node_(-22) set Y_ 3 # node id not correct\n"
|
||||
"$node_(3.3) set Y_ 1111 # node id not correct\n"
|
||||
"$ns_ at sss \"$node_(0) setdest 5 5 5\" # time is not a number\n"
|
||||
"$ns_ at 1 \"$node_(0) setdest 2 2 1\" # line OK \n"
|
||||
"$ns_ at 1 \"$node_(0) setdest 2 2 -1\" # negative speed is not correct\n"
|
||||
"$ns_ at 1 \"$node_(0) setdest 2 2 sdfs\" # speed is not a number\n"
|
||||
"$ns_ at 1 \"$node_(0) setdest 2 2 s232dfs\" # speed is not a number\n"
|
||||
"$ns_ at 1 \"$node_(0) setdest 233 2.. s232dfs\" # more than one non numbers\n"
|
||||
"$ns_ at -12 \"$node_(0) setdest 11 22 33\" # time should not be negative\n");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (1, 2, 3), Vector (1, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (2, 2, 3), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// More than one node
|
||||
t = new Ns2MobilityHelperTest ("few nodes, combinations of set and setdest", Seconds (10), 3);
|
||||
t->SetTrace ("$node_(0) set X_ 1.0\n"
|
||||
"$node_(0) set Y_ 2.0\n"
|
||||
"$node_(0) set Z_ 3.0\n"
|
||||
"$ns_ at 1.0 \"$node_(1) setdest 25 0 5\"\n"
|
||||
"$node_(2) set X_ 0.0\n"
|
||||
"$node_(2) set Y_ 0.0\n"
|
||||
"$ns_ at 1.0 \"$node_(2) setdest 5 0 5\"\n"
|
||||
"$ns_ at 2.0 \"$node_(2) setdest 5 5 5\"\n"
|
||||
"$ns_ at 3.0 \"$node_(2) setdest 0 5 5\"\n"
|
||||
"$ns_ at 4.0 \"$node_(2) setdest 0 0 5\"\n");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (1, 2, 3), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("1", 0, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("1", 1, Vector (0, 0, 0), Vector (5, 0, 0));
|
||||
t->AddReferencePoint ("1", 6, Vector (25, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("2", 0, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("2", 1, Vector (0, 0, 0), Vector (5, 0, 0));
|
||||
t->AddReferencePoint ("2", 2, Vector (5, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("2", 2, Vector (5, 0, 0), Vector (0, 5, 0));
|
||||
t->AddReferencePoint ("2", 3, Vector (5, 5, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("2", 3, Vector (5, 5, 0), Vector (-5, 0, 0));
|
||||
t->AddReferencePoint ("2", 4, Vector (0, 5, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("2", 4, Vector (0, 5, 0), Vector (0, -5, 0));
|
||||
t->AddReferencePoint ("2", 5, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Test for Speed == 0, that acts as stop the node.
|
||||
t = new Ns2MobilityHelperTest ("setdest with speed cero", Seconds (10));
|
||||
t->SetTrace ("$ns_ at 1.0 \"$node_(0) setdest 25 0 5\"\n"
|
||||
"$ns_ at 7.0 \"$node_(0) setdest 11 22 0\"\n");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (5, 0, 0));
|
||||
t->AddReferencePoint ("0", 6, Vector (25, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 7, Vector (25, 0, 0), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
|
||||
// Test negative positions
|
||||
t = new Ns2MobilityHelperTest ("test negative positions", Seconds (10));
|
||||
t->SetTrace ("$node_(0) set X_ -1.0\n"
|
||||
"$node_(0) set Y_ 0\n"
|
||||
"$ns_ at 1.0 \"$node_(0) setdest 0 0 1\"\n"
|
||||
"$ns_ at 2.0 \"$node_(0) setdest 0 -1 1\"\n");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (-1, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (-1, 0, 0), Vector (1, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (0, 0, 0), Vector (0, -1, 0));
|
||||
t->AddReferencePoint ("0", 3, Vector (0, -1, 0), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
// Sqare setdest with values in the form 1.0e+2
|
||||
t = new Ns2MobilityHelperTest ("Foalt numbers in 1.0e+2 format", Seconds (6));
|
||||
t->SetTrace ("$node_(0) set X_ 0.0\n"
|
||||
"$node_(0) set Y_ 0.0\n"
|
||||
"$ns_ at 1.0 \"$node_(0) setdest 1.0e+2 0 1.0e+2\"\n"
|
||||
"$ns_ at 2.0 \"$node_(0) setdest 1.0e+2 1.0e+2 1.0e+2\"\n"
|
||||
"$ns_ at 3.0 \"$node_(0) setdest 0 1.0e+2 1.0e+2\"\n"
|
||||
"$ns_ at 4.0 \"$node_(0) setdest 0 0 1.0e+2\"\n");
|
||||
// id t position velocity
|
||||
t->AddReferencePoint ("0", 0, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 1, Vector (0, 0, 0), Vector (100, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (100, 0, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 2, Vector (100, 0, 0), Vector (0, 100, 0));
|
||||
t->AddReferencePoint ("0", 3, Vector (100, 100, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 3, Vector (100, 100, 0), Vector (-100, 0, 0));
|
||||
t->AddReferencePoint ("0", 4, Vector (0, 100, 0), Vector (0, 0, 0));
|
||||
t->AddReferencePoint ("0", 4, Vector (0, 100, 0), Vector (0, -100, 0));
|
||||
t->AddReferencePoint ("0", 5, Vector (0, 0, 0), Vector (0, 0, 0));
|
||||
AddTestCase (t);
|
||||
|
||||
}
|
||||
} g_ns2TransmobilityHelperTestSuite;
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
@@ -25,6 +25,7 @@ def build(bld):
|
||||
|
||||
mobility_test = bld.create_ns3_module_test_library('mobility')
|
||||
mobility_test.source = [
|
||||
'test/ns2-mobility-helper-test-suite.cc',
|
||||
'test/steady-state-random-waypoint-mobility-model-test.cc',
|
||||
'test/waypoint-mobility-model-test.cc',
|
||||
]
|
||||
|
||||
@@ -167,8 +167,7 @@ public:
|
||||
* encapsulated in an abstract Address to avoid dependencies on the exact
|
||||
* MAC address format.
|
||||
*
|
||||
* A default implementation of GetMulticast is provided, but this
|
||||
* method simply NS_ASSERTS. In the case of net devices that do not support
|
||||
* In the case of net devices that do not support
|
||||
* multicast, clients are expected to test NetDevice::IsMulticast and avoid
|
||||
* attempting to map multicast packets. Subclasses of NetDevice that do
|
||||
* support multicasting are expected to override this method and provide an
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
* Author: Nicola Baldo <nbaldo@cttc.es>
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <ns3/spectrum-model.h>
|
||||
#include <math.h>
|
||||
#include <ns3/log.h>
|
||||
#include <ns3/assert.h>
|
||||
|
||||
|
||||
@@ -1094,7 +1094,7 @@ public:
|
||||
};
|
||||
|
||||
CsmaSystemTestSuite::CsmaSystemTestSuite ()
|
||||
: TestSuite ("csma-system", BVT)
|
||||
: TestSuite ("csma-system", UNIT)
|
||||
{
|
||||
AddTestCase (new CsmaBridgeTestCase);
|
||||
AddTestCase (new CsmaBroadcastTestCase);
|
||||
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
};
|
||||
|
||||
ErrorModelTestSuite::ErrorModelTestSuite ()
|
||||
: TestSuite ("error-model", BVT)
|
||||
: TestSuite ("error-model", UNIT)
|
||||
{
|
||||
AddTestCase (new ErrorModelSimple);
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ public:
|
||||
};
|
||||
|
||||
GlobalRoutingTestSuite::GlobalRoutingTestSuite ()
|
||||
: TestSuite ("global-routing", BVT)
|
||||
: TestSuite ("global-routing", UNIT)
|
||||
{
|
||||
AddTestCase (new DynamicGlobalRoutingTestCase);
|
||||
AddTestCase (new GlobalRoutingSlash32TestCase);
|
||||
|
||||
@@ -361,7 +361,7 @@ public:
|
||||
};
|
||||
|
||||
MobilityTestSuite::MobilityTestSuite ()
|
||||
: TestSuite ("mobility", BVT)
|
||||
: TestSuite ("mobility", UNIT)
|
||||
{
|
||||
AddTestCase (new WaypointLazyNotifyFalse);
|
||||
AddTestCase (new WaypointLazyNotifyTrue);
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
};
|
||||
|
||||
SampleTestSuite::SampleTestSuite ()
|
||||
: TestSuite ("sample", BVT)
|
||||
: TestSuite ("sample", UNIT)
|
||||
{
|
||||
AddTestCase (new SampleTestCase1);
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public:
|
||||
};
|
||||
|
||||
StaticRoutingTestSuite::StaticRoutingTestSuite ()
|
||||
: TestSuite ("static-routing", BVT)
|
||||
: TestSuite ("static-routing", UNIT)
|
||||
{
|
||||
AddTestCase (new StaticRoutingSlash32TestCase);
|
||||
}
|
||||
|
||||
@@ -278,16 +278,31 @@ PcapSniffTxEvent (
|
||||
header.SetFrameFlags (frameFlags);
|
||||
header.SetRate (rate);
|
||||
|
||||
uint16_t channelFlags = 0;
|
||||
switch (rate)
|
||||
{
|
||||
case 2: // 1Mbps
|
||||
case 4: // 2Mbps
|
||||
case 10: // 5Mbps
|
||||
case 22: // 11Mbps
|
||||
channelFlags |= RadiotapHeader::CHANNEL_FLAG_CCK;
|
||||
break;
|
||||
|
||||
default:
|
||||
channelFlags |= RadiotapHeader::CHANNEL_FLAG_OFDM;
|
||||
break;
|
||||
}
|
||||
|
||||
if (channelFreqMhz < 2500)
|
||||
{
|
||||
header.SetChannelFrequencyAndFlags (channelFreqMhz,
|
||||
RadiotapHeader::CHANNEL_FLAG_SPECTRUM_2GHZ | RadiotapHeader::CHANNEL_FLAG_CCK);
|
||||
channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_2GHZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
header.SetChannelFrequencyAndFlags (channelFreqMhz,
|
||||
RadiotapHeader::CHANNEL_FLAG_SPECTRUM_5GHZ | RadiotapHeader::CHANNEL_FLAG_OFDM);
|
||||
channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_5GHZ;
|
||||
}
|
||||
|
||||
header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags);
|
||||
|
||||
p->AddHeader (header);
|
||||
file->Write (Simulator::Now (), p);
|
||||
@@ -339,16 +354,31 @@ PcapSniffRxEvent (
|
||||
header.SetFrameFlags (frameFlags);
|
||||
header.SetRate (rate);
|
||||
|
||||
uint16_t channelFlags = 0;
|
||||
switch (rate)
|
||||
{
|
||||
case 2: // 1Mbps
|
||||
case 4: // 2Mbps
|
||||
case 10: // 5Mbps
|
||||
case 22: // 11Mbps
|
||||
channelFlags |= RadiotapHeader::CHANNEL_FLAG_CCK;
|
||||
break;
|
||||
|
||||
default:
|
||||
channelFlags |= RadiotapHeader::CHANNEL_FLAG_OFDM;
|
||||
break;
|
||||
}
|
||||
|
||||
if (channelFreqMhz < 2500)
|
||||
{
|
||||
header.SetChannelFrequencyAndFlags (channelFreqMhz,
|
||||
RadiotapHeader::CHANNEL_FLAG_SPECTRUM_2GHZ | RadiotapHeader::CHANNEL_FLAG_CCK);
|
||||
channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_2GHZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
header.SetChannelFrequencyAndFlags (channelFreqMhz,
|
||||
RadiotapHeader::CHANNEL_FLAG_SPECTRUM_5GHZ | RadiotapHeader::CHANNEL_FLAG_OFDM);
|
||||
channelFlags |= RadiotapHeader::CHANNEL_FLAG_SPECTRUM_5GHZ;
|
||||
}
|
||||
|
||||
header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags);
|
||||
|
||||
header.SetAntennaSignalPower (signalDbm);
|
||||
header.SetAntennaNoisePower (noiseDbm);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/uinteger.h"
|
||||
#include "ns3/pointer.h"
|
||||
|
||||
#include "dca-txop.h"
|
||||
#include "dcf-manager.h"
|
||||
@@ -102,6 +103,10 @@ DcaTxop::GetTypeId (void)
|
||||
static TypeId tid = TypeId ("ns3::DcaTxop")
|
||||
.SetParent (ns3::Dcf::GetTypeId ())
|
||||
.AddConstructor<DcaTxop> ()
|
||||
.AddAttribute ("Queue", "The WifiMacQueue object",
|
||||
PointerValue (),
|
||||
MakePointerAccessor (&DcaTxop::GetQueue),
|
||||
MakePointerChecker<WifiMacQueue> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
@@ -171,18 +176,13 @@ DcaTxop::SetTxFailedCallback (TxFailed callback)
|
||||
m_txFailedCallback = callback;
|
||||
}
|
||||
|
||||
void
|
||||
DcaTxop::SetMaxQueueSize (uint32_t size)
|
||||
Ptr<WifiMacQueue >
|
||||
DcaTxop::GetQueue () const
|
||||
{
|
||||
NS_LOG_FUNCTION (this << size);
|
||||
m_queue->SetMaxSize (size);
|
||||
}
|
||||
void
|
||||
DcaTxop::SetMaxQueueDelay (Time delay)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << delay);
|
||||
m_queue->SetMaxDelay (delay);
|
||||
NS_LOG_FUNCTION (this);
|
||||
return m_queue;
|
||||
}
|
||||
|
||||
void
|
||||
DcaTxop::SetMinCw (uint32_t minCw)
|
||||
{
|
||||
|
||||
@@ -89,8 +89,7 @@ public:
|
||||
*/
|
||||
void SetTxFailedCallback (TxFailed callback);
|
||||
|
||||
void SetMaxQueueSize (uint32_t size);
|
||||
void SetMaxQueueDelay (Time delay);
|
||||
Ptr<WifiMacQueue > GetQueue () const;
|
||||
virtual void SetMinCw (uint32_t minCw);
|
||||
virtual void SetMaxCw (uint32_t maxCw);
|
||||
virtual void SetAifsn (uint32_t aifsn);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/pointer.h"
|
||||
|
||||
#include "edca-txop-n.h"
|
||||
#include "mac-low.h"
|
||||
@@ -138,6 +139,10 @@ EdcaTxopN::GetTypeId (void)
|
||||
UintegerValue(0),
|
||||
MakeUintegerAccessor (&EdcaTxopN::SetBlockAckInactivityTimeout),
|
||||
MakeUintegerChecker<uint16_t> ())
|
||||
.AddAttribute ("Queue", "The WifiMacQueue object",
|
||||
PointerValue (),
|
||||
MakePointerAccessor (&EdcaTxopN::GetQueue),
|
||||
MakePointerChecker<WifiMacQueue> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
@@ -230,18 +235,11 @@ EdcaTxopN::GetTypeOfStation (void) const
|
||||
return m_typeOfStation;
|
||||
}
|
||||
|
||||
void
|
||||
EdcaTxopN::SetMaxQueueSize (uint32_t size)
|
||||
Ptr<WifiMacQueue >
|
||||
EdcaTxopN::GetQueue () const
|
||||
{
|
||||
NS_LOG_FUNCTION (this << size);
|
||||
m_queue->SetMaxSize (size);
|
||||
}
|
||||
|
||||
void
|
||||
EdcaTxopN::SetMaxQueueDelay (Time delay)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << delay);
|
||||
m_queue->SetMaxDelay (delay);
|
||||
NS_LOG_FUNCTION (this);
|
||||
return m_queue;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -93,8 +93,7 @@ public:
|
||||
void SetTypeOfStation (enum TypeOfStation type);
|
||||
enum TypeOfStation GetTypeOfStation (void) const;
|
||||
|
||||
void SetMaxQueueSize (uint32_t size);
|
||||
void SetMaxQueueDelay (Time delay);
|
||||
Ptr<WifiMacQueue > GetQueue () const;
|
||||
virtual void SetMinCw (uint32_t minCw);
|
||||
virtual void SetMaxCw (uint32_t maxCw);
|
||||
virtual void SetAifsn (uint32_t aifsn);
|
||||
|
||||
@@ -423,7 +423,18 @@ RegularWifiMac::Receive (Ptr<Packet> packet, const WifiMacHeader *hdr)
|
||||
Mac48Address to = hdr->GetAddr1 ();
|
||||
Mac48Address from = hdr->GetAddr2 ();
|
||||
|
||||
if (hdr->IsMgt () && hdr->IsAction () && to == GetAddress ())
|
||||
// We don't know how to deal with any frame that is not addressed to
|
||||
// us (and odds are there is nothing sensible we could do anyway),
|
||||
// so we ignore such frames.
|
||||
//
|
||||
// The derived class may also do some such filtering, but it doesn't
|
||||
// hurt to have it here too as a backstop.
|
||||
if (to != GetAddress ())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (hdr->IsMgt () && hdr->IsAction ())
|
||||
{
|
||||
// There is currently only any reason for Management Action
|
||||
// frames to be flying about if we are a QoS STA.
|
||||
|
||||
103
src/wscript
103
src/wscript
@@ -95,12 +95,16 @@ def configure(conf):
|
||||
conf.env['NS3_MODULES'] = ['ns3-' + module.split('/')[-1] for module in all_modules]
|
||||
|
||||
|
||||
def create_ns3_module(bld, name, dependencies=()):
|
||||
def create_ns3_module(bld, name, dependencies=(), test=False):
|
||||
# Create a separate library for this module.
|
||||
if bld.env['ENABLE_STATIC_NS3']:
|
||||
module = bld.new_task_gen('cxx', 'cstaticlib')
|
||||
else:
|
||||
module = bld.new_task_gen('cxx', 'cshlib')
|
||||
if not test:
|
||||
pcfile = bld.new_task_gen('ns3pcfile')
|
||||
pcfile.module = module
|
||||
|
||||
module.is_ns3_module = True
|
||||
module.name = 'ns3-' + name
|
||||
# Add the proper path to the module's name.
|
||||
@@ -136,7 +140,7 @@ def create_ns3_module_test_library(bld, name):
|
||||
# Create an ns3 module for the test library that depends only on
|
||||
# the module being tested.
|
||||
library_name = name + "-test"
|
||||
library = bld.create_ns3_module(library_name, [name])
|
||||
library = bld.create_ns3_module(library_name, [name], test = True)
|
||||
|
||||
# Modify attributes for the test library that are different from a
|
||||
# normal module.
|
||||
@@ -276,6 +280,100 @@ def build(bld):
|
||||
modheader = bld.new_task_gen('ns3moduleheader')
|
||||
modheader.module = module.split('/')[-1]
|
||||
|
||||
class ns3pcfile_task(Task.Task):
|
||||
after = 'cc cxx'
|
||||
def __str__(self):
|
||||
"string to display to the user"
|
||||
tgt_str = ' '.join([a.nice_path(self.env) for a in self.outputs])
|
||||
return 'pcfile: %s\n' % (tgt_str)
|
||||
def runnable_status(self):
|
||||
return super(ns3pcfile_task, self).runnable_status()
|
||||
def _self_libs(self, env, name, libdir):
|
||||
if env['ENABLE_STATIC_NS3']:
|
||||
path_st = 'STATICLIBPATH_ST'
|
||||
lib_st = 'STATICLIB_ST'
|
||||
lib_marker = 'STATICLIB_MARKER'
|
||||
else:
|
||||
path_st = 'LIBPATH_ST'
|
||||
lib_st = 'LIB_ST'
|
||||
lib_marker = 'SHLIB_MARKER'
|
||||
return [env[path_st] % libdir,
|
||||
env[lib_marker],
|
||||
env[lib_st] % name]
|
||||
def _lib(self, env, dep):
|
||||
libpath = env['LIBPATH_%s' % dep]
|
||||
linkflags = env['LINKFLAGS_%s' % dep]
|
||||
libs = env['LIB_%s' % dep]
|
||||
retval = []
|
||||
for path in libpath:
|
||||
retval.append(env['LIBPATH_ST'] % path)
|
||||
retval = retval + linkflags
|
||||
for lib in libs:
|
||||
retval.append(env['LIB_ST'] % lib)
|
||||
return retval
|
||||
def _listify(self, v):
|
||||
if isinstance(v, list):
|
||||
return v
|
||||
else:
|
||||
return [v]
|
||||
def _cflags(self, dep):
|
||||
flags = self.env['CFLAGS_%s' % dep]
|
||||
return self._listify(flags)
|
||||
def _cxxflags(self, dep):
|
||||
return self._listify(self.env['CXXFLAGS_%s' % dep])
|
||||
def _defines(self, dep):
|
||||
defines = self.env['CCDEFINES_%s' % dep] + self.env['CXXDEFINES_%s' % dep]
|
||||
return [self.env['CCDEFINES_ST'] % define for define in self.env['CCDEFINES_%s' % dep]] + \
|
||||
[self.env['CXXDEFINES_ST'] % define for define in self.env['CXXDEFINES_%s' % dep]]
|
||||
def _includes(self, dep):
|
||||
includes = self.env['CPPPATH_%s' % dep]
|
||||
return [self.env['CPPPATH_ST'] % include for include in includes]
|
||||
|
||||
def _generate_pcfile(self, name, use, uselib_local, prefix, outfilename):
|
||||
outfile = open(outfilename, 'w')
|
||||
includedir = os.path.join(prefix, 'include')
|
||||
libdir = os.path.join(prefix, 'lib')
|
||||
libs = self._self_libs(self.env, name, '%{libdir}')
|
||||
for dep in use:
|
||||
libs = libs + self._lib(self.env, dep)
|
||||
for dep in uselib_local:
|
||||
libs = libs + [self.env['LIB_ST'] % dep]
|
||||
cflags = [self.env['CPPPATH_ST'] % '${includedir}']
|
||||
for dep in use:
|
||||
cflags = cflags + self._cflags(dep) + self._cxxflags(dep) + \
|
||||
self._defines(dep) + self._includes(dep)
|
||||
print >> outfile, """
|
||||
prefix=%s
|
||||
libdir=%s
|
||||
includedir=%s
|
||||
|
||||
Name: lib%s
|
||||
Description: ns-3 module %s
|
||||
Version: devel
|
||||
Libs: %s
|
||||
Cflags: %s
|
||||
""" % (prefix, libdir, includedir,
|
||||
name, name, ' '.join(libs), ' '.join(cflags))
|
||||
outfile.close()
|
||||
|
||||
def run(self):
|
||||
output_filename = self.outputs[0].bldpath(self.env)
|
||||
self._generate_pcfile(self.module.name, self.module.uselib,
|
||||
self.module.uselib_local,
|
||||
self.env['PREFIX'], output_filename)
|
||||
|
||||
class ns3pcfile_taskgen(TaskGen.task_gen):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ns3pcfile_taskgen, self).__init__(*args, **kwargs)
|
||||
def apply(self):
|
||||
output_filename = os.path.join('pkgconfig', 'lib%s.pc' % self.module.name)
|
||||
output_node = self.bld.path.find_or_declare(output_filename)
|
||||
task = self.create_task('ns3pcfile', env=self.env)
|
||||
self.bld.install_files(os.path.join('${PREFIX}', 'lib', 'pkgconfig'),
|
||||
output_filename)
|
||||
task.set_outputs([output_node])
|
||||
task.module = self.module
|
||||
|
||||
|
||||
class ns3header_taskgen(TaskGen.task_gen):
|
||||
"""A set of NS-3 header files"""
|
||||
@@ -359,7 +457,6 @@ class ns3header_task(Task.Task):
|
||||
if ex.errno != 2:
|
||||
raise
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
class gen_ns3_module_header_task(Task.Task):
|
||||
|
||||
@@ -87,7 +87,6 @@ sp_after_semi_for=Add
|
||||
sp_arith=Add
|
||||
sp_assign=Add
|
||||
sp_compare=Add
|
||||
sp_cmt_cpp_start=Add
|
||||
sp_func_class_paren=Add
|
||||
sp_after_type=Add
|
||||
sp_type_func=Add
|
||||
|
||||
Reference in New Issue
Block a user