ns-3
|
Interface to network animator. More...
#include <animation-interface.h>
Public Types | |
typedef void(* | AnimWriteCallback )(const char *str) |
typedef for WriteCallBack used for listening to AnimationInterface write messages | |
Public Member Functions | |
AnimationInterface () | |
Construct the animator interface. No arguments needed. | |
~AnimationInterface () | |
Destructor for the animator interface. | |
AnimationInterface (const std::string filename, bool usingXML=true) | |
Constructor. | |
AnimationInterface (uint16_t port, bool usingXML=true) | |
Constructor. | |
bool | SetOutputFile (const std::string &fn) |
Specify that animation commands are to be written to the specified output file. | |
void | SetXMLOutput () |
Specify that animation commands are to be written in XML format. | |
bool | SetServerPort (uint16_t port) |
(Deprecated) Specify that animation commands are to be written to a socket. | |
void | StartAnimation () |
Writes the topology information and sets up the appropriate animation packet tx callback. | |
void | StopAnimation () |
Closes the interface to the animator. | |
void | SetMobilityPollInterval (Time t) |
Set mobility poll interval:WARNING: setting a low interval can cause slowness. | |
void | SetRandomPosition (bool setRandPos) |
Set random position if a Mobility Model does not exists for the node. | |
void | SetAnimWriteCallback (AnimWriteCallback cb) |
Set a callback function to listen to AnimationInterface write events. | |
void | ResetAnimWriteCallback () |
Reset the write callback function. | |
void | SetConstantPosition (Ptr< Node > n, double x, double y, double z=0) |
Helper function to set Constant Position for a given node. | |
bool | IsStarted (void) |
Is AnimationInterface started. | |
Static Public Member Functions | |
static bool | IsInitialized (void) |
Check if AnimationInterface is initialized. |
Interface to network animator.
Provides functions that facilitate communications with an external or internal network animator.
ns3::AnimationInterface::AnimationInterface | ( | const std::string | filename, |
bool | usingXML = true |
||
) |
Constructor.
filename | The Filename for the trace file used by the Animator |
usingXML | Set to true if XML output traces are required |
References StartAnimation().
ns3::AnimationInterface::AnimationInterface | ( | uint16_t | port, |
bool | usingXML = true |
||
) |
Constructor.
port | Port on which ns-3 should listen to for connection from the external netanim application |
usingXML | Set to true if XML output traces are required |
References StartAnimation().
bool ns3::AnimationInterface::IsInitialized | ( | void | ) | [static] |
Check if AnimationInterface is initialized.
bool ns3::AnimationInterface::IsStarted | ( | void | ) |
Is AnimationInterface started.
Set a callback function to listen to AnimationInterface write events.
cb | Address of callback function |
void ns3::AnimationInterface::SetConstantPosition | ( | Ptr< Node > | n, |
double | x, | ||
double | y, | ||
double | z = 0 |
||
) |
Helper function to set Constant Position for a given node.
n | Ptr to the node |
x | X co-ordinate of the node |
y | Y co-ordinate of the node |
z | Z co-ordinate of the node |
References ns3::Object::AggregateObject(), ns3::Node::GetId(), ns3::Object::GetObject(), NS_ASSERT, and NS_LOG_INFO.
Set mobility poll interval:WARNING: setting a low interval can cause slowness.
t | Time interval between fetching mobility/position information Default: 0.25s |
bool ns3::AnimationInterface::SetOutputFile | ( | const std::string & | fn | ) |
Specify that animation commands are to be written to the specified output file.
This call is used to write the animation information to a text file that can later be used as input to the network animator tool.
fn | The name of the output file. |
References NS_FATAL_ERROR.
Referenced by StartAnimation().
void ns3::AnimationInterface::SetRandomPosition | ( | bool | setRandPos | ) |
Set random position if a Mobility Model does not exists for the node.
setRandPos | True if a random position can be set for a node without a Mobililty model |
bool ns3::AnimationInterface::SetServerPort | ( | uint16_t | port | ) |
(Deprecated) Specify that animation commands are to be written to a socket.
This call is used to set the ns3 process in server mode, waiting for a TCP connection from the animator. This call will not return until the animator connects in, or if the bind to the specified port fails.
port | Port number to bind to. |
References NS_LOG_INFO, and NS_LOG_WARN.
Referenced by StartAnimation().
Specify that animation commands are to be written in XML format.
References NS_LOG_INFO.
Writes the topology information and sets up the appropriate animation packet tx callback.
Writes the topology information to the appropriate output, depending on prior calls to SetOutputFile, SetServerPort, or SetInternalAnimation. Then creates the callbacks needed for the animator to start processing packets.
References ns3::NodeList::Begin(), ns3::NodeList::End(), ns3::NetDevice::GetChannel(), ns3::Channel::GetDevice(), ns3::Node::GetDevice(), ns3::Node::GetId(), ns3::Object::GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::Channel::GetNDevices(), ns3::Node::GetNDevices(), ns3::NodeList::GetNNodes(), ns3::NetDevice::GetNode(), NS_ASSERT, NS_LOG_DEBUG, NS_LOG_INFO, ns3::Simulator::Schedule(), SetOutputFile(), SetServerPort(), ns3::Vector3D::x, and ns3::Vector3D::y.
Referenced by AnimationInterface().