ns-3
ns3::AnimationInterface Class Reference

Interface to network animator. More...

#include <animation-interface.h>

List of all members.

Public Types

typedef void(* AnimWriteCallback )(const char *str)
 typedef for WriteCallBack used for listening to AnimationInterface write messages

Public Member Functions

 AnimationInterface (const std::string filename, uint64_t maxPktsPerFile=MAX_PKTS_PER_TRACE_FILE, bool usingXML=true)
 Constructor.
 ~AnimationInterface ()
 Destructor for the animator interface.
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.
void SetStartTime (Time t)
 Specify the time at which capture should start.
void SetStopTime (Time t)
 Specify the time at which capture should stop.
void StartAnimation (bool restart=false)
 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.
bool IsStarted (void)
 Is AnimationInterface started.
void ShowAll802_11 (bool showAll)
 Show all 802.11 frames. Default: show only frames accepted by mac layer.
void EnablePacketMetadata (bool enable)
 Enable Packet metadata.
uint64_t GetTracePktCount ()
 Get trace file packet count (This used only for testing)

Static Public Member Functions

static bool IsInitialized (void)
 Check if AnimationInterface is initialized.
static void SetConstantPosition (Ptr< Node > n, double x, double y, double z=0)
 Helper function to set Constant Position for a given node.
static void SetNodeDescription (Ptr< Node > n, std::string descr)
 Helper function to set a brief description for a given node.
static void SetNodeDescription (NodeContainer nc, std::string descr)
 Helper function to set a brief description for nodes in a Node Container.

Detailed Description

Interface to network animator.

Provides functions that facilitate communications with an external or internal network animator.


Constructor & Destructor Documentation

ns3::AnimationInterface::AnimationInterface ( const std::string  filename,
uint64_t  maxPktsPerFile = MAX_PKTS_PER_TRACE_FILE,
bool  usingXML = true 
)

Constructor.

Parameters:
filenameThe Filename for the trace file used by the Animator
maxPktsPerFileThe maximum number of packets per trace file. AnimationInterface will create trace files with the following filenames : filename, filename-1, filename-2..., filename-N where each file contains packet info for 'maxPktPerFile' number of packets
usingXMLSet to true if XML output traces are required

References StartAnimation().


Member Function Documentation

void ns3::AnimationInterface::EnablePacketMetadata ( bool  enable)

Enable Packet metadata.

Parameters:
enableif true enables writing the packet metadata to the XML trace file if false disables writing the packet metadata

References ns3::Packet::EnablePrinting().

uint64_t ns3::AnimationInterface::GetTracePktCount ( )

Get trace file packet count (This used only for testing)

returns Number of packets recorded in the current trace file

bool ns3::AnimationInterface::IsInitialized ( void  )
static

Check if AnimationInterface is initialized.

Returns:
true if AnimationInterface was already initialized
bool ns3::AnimationInterface::IsStarted ( void  )

Is AnimationInterface started.

Returns:
true if AnimationInterface was started
void ns3::AnimationInterface::SetAnimWriteCallback ( AnimWriteCallback  cb)

Set a callback function to listen to AnimationInterface write events.

Parameters:
cbAddress of callback function
void ns3::AnimationInterface::SetConstantPosition ( Ptr< Node n,
double  x,
double  y,
double  z = 0 
)
static

Helper function to set Constant Position for a given node.

Parameters:
nPtr to the node
xX co-ordinate of the node
yY co-ordinate of the node
zZ co-ordinate of the node

References ns3::Object::AggregateObject(), ns3::Node::GetId(), ns3::Object::GetObject(), NS_ASSERT, and NS_LOG_INFO.

void ns3::AnimationInterface::SetMobilityPollInterval ( Time  t)

Set mobility poll interval:WARNING: setting a low interval can cause slowness.

Parameters:
tTime interval between fetching mobility/position information Default: 0.25s
void ns3::AnimationInterface::SetNodeDescription ( Ptr< Node n,
std::string  descr 
)
static

Helper function to set a brief description for a given node.

Parameters:
nPtr to the node
descrA string to briefly describe the node

References ns3::Node::GetId(), and NS_ASSERT.

void ns3::AnimationInterface::SetNodeDescription ( NodeContainer  nc,
std::string  descr 
)
static

Helper function to set a brief description for nodes in a Node Container.

Parameters:
ncNodeContainer containing the nodes
descrA string to briefly describe the nodes

References ns3::NodeContainer::Get(), ns3::Node::GetId(), ns3::NodeContainer::GetN(), and NS_ASSERT.

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.

Parameters:
fnThe name of the output file.
Returns:
true if successful open.

References NS_FATAL_ERROR, and NS_LOG_INFO.

Referenced by StartAnimation().

void ns3::AnimationInterface::SetRandomPosition ( bool  setRandPos)

Set random position if a Mobility Model does not exists for the node.

Parameters:
setRandPosTrue if a random position can be set for a node without a Mobililty model
void ns3::AnimationInterface::SetStartTime ( Time  t)

Specify the time at which capture should start.

Parameters:
tThe time at which AnimationInterface should begin capture of traffic info
Returns:
none
void ns3::AnimationInterface::SetStopTime ( Time  t)

Specify the time at which capture should stop.

Parameters:
tThe time at which AnimationInterface should stop capture of traffic info
Returns:
none
void ns3::AnimationInterface::SetXMLOutput ( )

Specify that animation commands are to be written in XML format.

Returns:
none

References NS_LOG_INFO.

void ns3::AnimationInterface::ShowAll802_11 ( bool  showAll)

Show all 802.11 frames. Default: show only frames accepted by mac layer.

Parameters:
showAllif true shows all 802.11 frames including beacons, association request and acks (very chatty). if false only frames accepted by mac layer
void ns3::AnimationInterface::StartAnimation ( bool  restart = false)

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.

Parameters:
restartTrue when restarting animation

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(), ns3::Vector3D::x, and ns3::Vector3D::y.

Referenced by AnimationInterface().


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