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 (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. |
Interface to network animator.
Provides functions that facilitate communications with an external or internal network animator.
ns3::AnimationInterface::AnimationInterface | ( | const std::string | filename, |
uint64_t | maxPktsPerFile = MAX_PKTS_PER_TRACE_FILE , |
||
bool | usingXML = true |
||
) |
Constructor.
filename | The Filename for the trace file used by the Animator |
maxPktsPerFile | The 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 |
usingXML | Set to true if XML output traces are required |
References StartAnimation().
void ns3::AnimationInterface::EnablePacketMetadata | ( | bool | enable | ) |
Enable Packet metadata.
enable | if 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
|
static |
Check if AnimationInterface is initialized.
bool ns3::AnimationInterface::IsStarted | ( | void | ) |
Is AnimationInterface started.
void ns3::AnimationInterface::SetAnimWriteCallback | ( | AnimWriteCallback | cb | ) |
Set a callback function to listen to AnimationInterface write events.
cb | Address of callback function |
|
static |
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.
void ns3::AnimationInterface::SetMobilityPollInterval | ( | Time | t | ) |
Set mobility poll interval:WARNING: setting a low interval can cause slowness.
t | Time interval between fetching mobility/position information Default: 0.25s |
Helper function to set a brief description for a given node.
n | Ptr to the node |
descr | A string to briefly describe the node |
References ns3::Node::GetId(), and NS_ASSERT.
|
static |
Helper function to set a brief description for nodes in a Node Container.
nc | NodeContainer containing the nodes |
descr | A 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.
fn | The name of the output file. |
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.
setRandPos | True 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.
t | The time at which AnimationInterface should begin capture of traffic info |
void ns3::AnimationInterface::SetStopTime | ( | Time | t | ) |
Specify the time at which capture should stop.
t | The time at which AnimationInterface should stop capture of traffic info |
void ns3::AnimationInterface::SetXMLOutput | ( | ) |
Specify that animation commands are to be written in XML format.
References NS_LOG_INFO.
void ns3::AnimationInterface::ShowAll802_11 | ( | bool | showAll | ) |
Show all 802.11 frames. Default: show only frames accepted by mac layer.
showAll | if 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.
restart | True 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().