A Discrete-Event Network Simulator
API
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ns3::Ns2MobilityHelper Class Reference


Helper class which can read ns-2 movement files and configure nodes mobility. More...

#include "ns2-mobility-helper.h"

Classes

class  ObjectStore
 a class to hold input objects internally More...
 

Public Member Functions

 Ns2MobilityHelper (std::string filename)
 
void Install (void) const
 Read the ns2 trace file and configure the movement patterns of all nodes contained in the global ns3::NodeList whose nodeId is matches the nodeId of the nodes in the trace file. More...
 
template<typename T >
void Install (T begin, T end) const
 

Private Member Functions

void ConfigNodesMovements (const ObjectStore &store) const
 Parses ns-2 mobility file to create ns-3 mobility events. More...
 
Ptr< ConstantVelocityMobilityModelGetMobilityModel (std::string idString, const ObjectStore &store) const
 Get or create a ConstantVelocityMobilityModel corresponding to idString. More...
 

Private Attributes

std::string m_filename
 filename of file containing ns-2 mobility trace More...
 

Detailed Description


Helper class which can read ns-2 movement files and configure nodes mobility.

This implementation is based on the ns2 movement documentation of ns2 as described in http://www.isi.edu/nsnam/ns/doc/node172.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

Note that initial position statements may also appear at the end of the mobility file like this:

  $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
  $node set X_ x1
  $node set Y_ y1
  $node set Z_ z1

The following tools are known to support this format:

See usage example in examples/mobility/ns2-mobility-trace.cc

Bug:
Rounding errors may cause movement to diverge from the mobility pattern in ns-2 (using the same trace). See https://www.nsnam.org/bugzilla/show_bug.cgi?id=1316

Definition at line 76 of file ns2-mobility-helper.h.

Constructor & Destructor Documentation

◆ Ns2MobilityHelper()

ns3::Ns2MobilityHelper::Ns2MobilityHelper ( std::string  filename)
Parameters
filenamefilename of file which contains the ns2 movement trace.

Definition at line 185 of file ns2-mobility-helper.cc.

References anonymous_namespace{print-introspected-doxygen.cc}::file, m_filename, and NS_FATAL_ERROR.

Member Function Documentation

◆ ConfigNodesMovements()

void ns3::Ns2MobilityHelper::ConfigNodesMovements ( const ObjectStore store) const
private

◆ GetMobilityModel()

Ptr< ConstantVelocityMobilityModel > ns3::Ns2MobilityHelper::GetMobilityModel ( std::string  idString,
const ObjectStore store 
) const
private

Get or create a ConstantVelocityMobilityModel corresponding to idString.

Parameters
idStringstring name for a node
storeObject store containing ns-3 mobility models
Returns
pointer to a ConstantVelocityMobilityModel

Definition at line 193 of file ns2-mobility-helper.cc.

References ns3::Ns2MobilityHelper::ObjectStore::Get().

Referenced by ConfigNodesMovements().

◆ Install() [1/2]

void ns3::Ns2MobilityHelper::Install ( void  ) const

Read the ns2 trace file and configure the movement patterns of all nodes contained in the global ns3::NodeList whose nodeId is matches the nodeId of the nodes in the trace file.

Definition at line 811 of file ns2-mobility-helper.cc.

References ns3::NodeList::Begin(), and ns3::NodeList::End().

Referenced by VanetRoutingExperiment::SetupAdhocMobilityNodes().

◆ Install() [2/2]

template<typename T >
void ns3::Ns2MobilityHelper::Install ( begin,
end 
) const
Parameters
beginan iterator which points to the start of the input object array.
endan iterator which points to the end of the input object array.

Read the ns2 trace file and configure the movement patterns of all input objects. Each input object is identified by a unique node id which reflects the index of the object in the input array.

Definition at line 142 of file ns2-mobility-helper.h.

References ConfigNodesMovements().

Member Data Documentation

◆ m_filename

std::string ns3::Ns2MobilityHelper::m_filename
private

filename of file containing ns-2 mobility trace

Definition at line 133 of file ns2-mobility-helper.h.

Referenced by ConfigNodesMovements(), and Ns2MobilityHelper().


The documentation for this class was generated from the following files: