A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::MobilityHelper Class Reference

Helper class used to assign positions and mobility models to nodes. More...

#include "mobility-helper.h"

+ Collaboration diagram for ns3::MobilityHelper:

Public Member Functions

 MobilityHelper ()
 Construct a Mobility Helper which is used to make life easier when working with mobility models.
 
 ~MobilityHelper ()
 Destroy a Mobility Helper.
 
int64_t AssignStreams (NodeContainer c, int64_t stream)
 Assign a fixed random variable stream number to the random variables used by the mobility models on these nodes.
 
std::string GetMobilityModelType () const
 
void Install (NodeContainer container) const
 Layout a collection of nodes according to the current position allocator type.
 
void Install (Ptr< Node > node) const
 "Layout" a single node according to the current position allocator type.
 
void Install (std::string nodeName) const
 "Layout" a single node according to the current position allocator type.
 
void InstallAll () const
 Perform the work of MobilityHelper::Install on all nodes which exist in the simulation.
 
void PopReferenceMobilityModel ()
 Remove the top item from the top of the stack of "reference mobility models".
 
void PushReferenceMobilityModel (Ptr< Object > reference)
 
void PushReferenceMobilityModel (std::string referenceName)
 
template<typename... Ts>
void SetMobilityModel (std::string type, Ts &&... args)
 
void SetPositionAllocator (Ptr< PositionAllocator > allocator)
 Set the position allocator which will be used to allocate the initial position of every node initialized during MobilityModel::Install.
 
template<typename... Ts>
void SetPositionAllocator (std::string type, Ts &&... args)
 

Static Public Member Functions

static void EnableAscii (Ptr< OutputStreamWrapper > stream, NodeContainer n)
 
static void EnableAscii (Ptr< OutputStreamWrapper > stream, uint32_t nodeid)
 
static void EnableAsciiAll (Ptr< OutputStreamWrapper > stream)
 
static double GetDistanceSquaredBetween (Ptr< Node > n1, Ptr< Node > n2)
 

Static Private Member Functions

static void CourseChanged (Ptr< OutputStreamWrapper > stream, Ptr< const MobilityModel > mobility)
 Output course change events from mobility model to output stream.
 

Private Attributes

ObjectFactory m_mobility
 Object factory to create mobility objects.
 
std::vector< Ptr< MobilityModel > > m_mobilityStack
 Internal stack of mobility models.
 
Ptr< PositionAllocatorm_position
 Position allocator for use in hierarchical mobility model.
 

Detailed Description

Helper class used to assign positions and mobility models to nodes.

MobilityHelper::Install is the most important method here.

Definition at line 32 of file mobility-helper.h.

Constructor & Destructor Documentation

◆ MobilityHelper()

ns3::MobilityHelper::MobilityHelper ( )

Construct a Mobility Helper which is used to make life easier when working with mobility models.

Definition at line 27 of file mobility-helper.cc.

References ns3::CreateObjectWithAttributes(), m_mobility, m_position, and ns3::ObjectFactory::SetTypeId().

+ Here is the call graph for this function:

◆ ~MobilityHelper()

ns3::MobilityHelper::~MobilityHelper ( )

Destroy a Mobility Helper.

Definition at line 37 of file mobility-helper.cc.

Member Function Documentation

◆ AssignStreams()

int64_t ns3::MobilityHelper::AssignStreams ( NodeContainer c,
int64_t stream )

Assign a fixed random variable stream number to the random variables used by the mobility models on these nodes.

Return the number of streams (possibly zero) that have been assigned. The Install() method should have previously been called by the user.

Note
If the PositionAllocator used contains random variables, they will not be affected by this call to AssignStreams because they are used earlier during Install() time. If the user needs to assign a fixed stream number to a PositionAllocator used with this helper, the user should instantiate it outside of the helper, call AssignStreams() on it, and then pass the pointer of it to this helper.
Parameters
cNodeContainer of the set of nodes for which the MobilityModels should be modified to use a fixed stream
streamfirst stream index to use
Returns
the number of stream indices assigned by this helper

Definition at line 206 of file mobility-helper.cc.

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

Referenced by RoutingExperiment::Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CourseChanged()

void ns3::MobilityHelper::CourseChanged ( Ptr< OutputStreamWrapper > stream,
Ptr< const MobilityModel > mobility )
staticprivate

Output course change events from mobility model to output stream.

Parameters
streamoutput stream
mobilitymobility model

Definition at line 158 of file mobility-helper.cc.

References ns3::DoRound(), and ns3::Simulator::Now().

Referenced by EnableAscii().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EnableAscii() [1/2]

void ns3::MobilityHelper::EnableAscii ( Ptr< OutputStreamWrapper > stream,
NodeContainer n )
static
Parameters
streaman output stream wrapper
nnode container

Enable ascii output to record course changes from the mobility models associated to the the nodes in the input container and dump that to the specified output stream. Nodes that do not have a MobilityModel aggregated will not result in any output.

Definition at line 191 of file mobility-helper.cc.

References ns3::NodeContainer::Begin(), EnableAscii(), and ns3::NodeContainer::End().

+ Here is the call graph for this function:

◆ EnableAscii() [2/2]

void ns3::MobilityHelper::EnableAscii ( Ptr< OutputStreamWrapper > stream,
uint32_t nodeid )
static
Parameters
streaman output stream wrapper
nodeidthe id of the node to generate ascii output for.

Enable ascii output to record course changes from the mobility model associated with the specified nodeid and dump that to the specified output stream. If the Node does not have a MobilityModel aggregated, this method will not produce any output.

Definition at line 181 of file mobility-helper.cc.

References ns3::Config::ConnectWithoutContextFailSafe(), CourseChanged(), and ns3::MakeBoundCallback().

Referenced by EnableAscii(), and EnableAsciiAll().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EnableAsciiAll()

void ns3::MobilityHelper::EnableAsciiAll ( Ptr< OutputStreamWrapper > stream)
static
Parameters
streaman output stream wrapper

Enable ascii output to record course changes from the mobility models associated to every node in the system and dump that to the specified output stream. Nodes that do not have a MobilityModel aggregated will not result in any output.

Definition at line 200 of file mobility-helper.cc.

References EnableAscii(), and ns3::NodeContainer::GetGlobal().

Referenced by MobilityTraceTestCase::DoRun(), and RoutingExperiment::Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDistanceSquaredBetween()

double ns3::MobilityHelper::GetDistanceSquaredBetween ( Ptr< Node > n1,
Ptr< Node > n2 )
static
Parameters
n1node 1
n2node 2
Returns
the distance (squared), in meters, between two nodes

Definition at line 224 of file mobility-helper.cc.

References NS_ASSERT, and NS_LOG_FUNCTION_NOARGS.

◆ GetMobilityModelType()

std::string ns3::MobilityHelper::GetMobilityModelType ( ) const
Returns
a string which contains the TypeId of the currently-selected mobility model.

Definition at line 68 of file mobility-helper.cc.

References ns3::TypeId::GetName(), ns3::ObjectFactory::GetTypeId(), and m_mobility.

+ Here is the call graph for this function:

◆ Install() [1/3]

void ns3::MobilityHelper::Install ( NodeContainer container) const

Layout a collection of nodes according to the current position allocator type.

For each node in the provided NodeContainer, this method creates an instance of a ns3::MobilityModel subclass (the type of which was set with MobilityHelper::SetMobilityModel), aggregates it to the node, and sets an initial position based on the current position allocator (set through MobilityHelper::SetPositionAllocator).

Parameters
containerThe set of nodes to layout.

Definition at line 116 of file mobility-helper.cc.

References ns3::NodeContainer::Begin(), ns3::NodeContainer::End(), and Install().

+ Here is the call graph for this function:

◆ Install() [2/3]

void ns3::MobilityHelper::Install ( Ptr< Node > node) const

"Layout" a single node according to the current position allocator type.

This method creates an instance of a ns3::MobilityModel subclass (the type of which was set with MobilityHelper::SetMobilityModel), aggregates it to the provided node, and sets an initial position based on the current position allocator (set through MobilityHelper::SetPositionAllocator).

Parameters
nodeThe node to "layout."

Definition at line 74 of file mobility-helper.cc.

References ns3::ObjectFactory::Create(), ns3::CreateObjectWithAttributes(), ns3::TypeId::GetName(), ns3::Object::GetObject(), ns3::ObjectFactory::GetTypeId(), m_mobility, m_mobilityStack, m_position, NS_FATAL_ERROR, and NS_LOG_DEBUG.

Referenced by LteEpcE2eDataTestCase::DoRun(), LteHandoverDelayTestCase::DoRun(), LteHandoverFailureTestCase::DoRun(), LteHandoverTargetTestCase::DoRun(), LteX2HandoverMeasuresTestCase::DoRun(), WaypointMobilityModelViaHelper::DoRun(), Install(), Install(), InstallAll(), Experiment::Run(), RoutingExperiment::Run(), and UanExperiment::SetupPositions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Install() [3/3]

void ns3::MobilityHelper::Install ( std::string nodeName) const

"Layout" a single node according to the current position allocator type.

This method creates an instance of a ns3::MobilityModel subclass (the type of which was set with MobilityHelper::SetMobilityModel), aggregates it to the provided node, and sets an initial position based on the current position allocator (set through MobilityHelper::SetPositionAllocator).

Parameters
nodeNameThe name of the node to "layout."

Definition at line 109 of file mobility-helper.cc.

References ns3::Names::Find(), and Install().

+ Here is the call graph for this function:

◆ InstallAll()

void ns3::MobilityHelper::InstallAll ( ) const

Perform the work of MobilityHelper::Install on all nodes which exist in the simulation.

Definition at line 125 of file mobility-helper.cc.

References ns3::NodeContainer::GetGlobal(), and Install().

+ Here is the call graph for this function:

◆ PopReferenceMobilityModel()

void ns3::MobilityHelper::PopReferenceMobilityModel ( )

Remove the top item from the top of the stack of "reference mobility models".

Definition at line 62 of file mobility-helper.cc.

References m_mobilityStack.

◆ PushReferenceMobilityModel() [1/2]

void ns3::MobilityHelper::PushReferenceMobilityModel ( Ptr< Object > reference)
Parameters
referenceitem to push.

Push an item on the top of the stack of "reference mobility models". The input item should be a node instance to which a mobility model has already been aggregated (usually by a call to Install).

If this stack is not empty when MobilityHelper::Install is called, the model from the top of the stack is used to create a ns3::HierarchicalMobilityModel to make the newly-created models define their positions relative to that of the parent mobility model.

This method is typically used to create hierarchical mobility patterns and positions by starting with the large-scale mobility features, and, then, defining the smaller-scale movements relative to a few reference points in the large-scale model.

Definition at line 48 of file mobility-helper.cc.

References m_mobilityStack.

◆ PushReferenceMobilityModel() [2/2]

void ns3::MobilityHelper::PushReferenceMobilityModel ( std::string referenceName)
Parameters
referenceNamenamed item to push.

Push an item on the top of the stack of "reference mobility models". The input item should be a node instance to which a mobility model has already been aggregated (usually by a call to Install).

If this stack is not empty when MobilityHelper::Install is called, the model from the top of the stack is used to create a ns3::HierarchicalMobilityModel to make the newly-created models define their positions relative to that of the parent mobility model.

This method is typically used to create hierarchical mobility patterns and positions by starting with the large-scale mobility features, and, then, defining the smaller-scale movements relative to a few reference points in the large-scale model.

Definition at line 55 of file mobility-helper.cc.

References ns3::Names::Find(), and m_mobilityStack.

+ Here is the call graph for this function:

◆ SetMobilityModel()

template<typename... Ts>
void ns3::MobilityHelper::SetMobilityModel ( std::string type,
Ts &&... args )
Template Parameters
Ts[deduced] Argument types
Parameters
typethe type of mobility model to use.
[in]argsName and AttributeValue pairs to set.

Calls to MobilityHelper::Install will create an instance of a matching mobility model for each node.

Definition at line 248 of file mobility-helper.h.

References m_mobility, ns3::ObjectFactory::Set(), and ns3::ObjectFactory::SetTypeId().

Referenced by LteEpcE2eDataTestCase::DoRun(), LteHandoverDelayTestCase::DoRun(), LteHandoverFailureTestCase::DoRun(), LteHandoverTargetTestCase::DoRun(), LteX2HandoverMeasuresTestCase::DoRun(), WaypointMobilityModelViaHelper::DoRun(), Experiment::Run(), RoutingExperiment::Run(), and UanExperiment::SetupPositions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetPositionAllocator() [1/2]

void ns3::MobilityHelper::SetPositionAllocator ( Ptr< PositionAllocator > allocator)

Set the position allocator which will be used to allocate the initial position of every node initialized during MobilityModel::Install.

Parameters
allocatorallocate initial node positions

Definition at line 42 of file mobility-helper.cc.

References m_position.

Referenced by LteEpcE2eDataTestCase::DoRun(), LteHandoverDelayTestCase::DoRun(), LteHandoverFailureTestCase::DoRun(), LteHandoverTargetTestCase::DoRun(), LteX2HandoverMeasuresTestCase::DoRun(), WaypointMobilityModelViaHelper::DoRun(), Experiment::Run(), and RoutingExperiment::Run().

+ Here is the caller graph for this function:

◆ SetPositionAllocator() [2/2]

template<typename... Ts>
void ns3::MobilityHelper::SetPositionAllocator ( std::string type,
Ts &&... args )
Template Parameters
Ts[deduced] Argument types
Parameters
typethe type of mobility model to use.
[in]argsName and AttributeValue pairs to set.

Definition at line 240 of file mobility-helper.h.

References ns3::ObjectFactory::Create(), ns3::Object::GetObject(), and m_position.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_mobility

ObjectFactory ns3::MobilityHelper::m_mobility
private

Object factory to create mobility objects.

Definition at line 229 of file mobility-helper.h.

Referenced by MobilityHelper(), GetMobilityModelType(), Install(), and SetMobilityModel().

◆ m_mobilityStack

std::vector<Ptr<MobilityModel> > ns3::MobilityHelper::m_mobilityStack
private

Internal stack of mobility models.

Definition at line 228 of file mobility-helper.h.

Referenced by Install(), PopReferenceMobilityModel(), PushReferenceMobilityModel(), and PushReferenceMobilityModel().

◆ m_position

Ptr<PositionAllocator> ns3::MobilityHelper::m_position
private

Position allocator for use in hierarchical mobility model.

Definition at line 231 of file mobility-helper.h.

Referenced by MobilityHelper(), Install(), SetPositionAllocator(), and SetPositionAllocator().


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