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. More... | |
~AnimationInterface () | |
Destructor for the animator interface. | |
AnimationInterface & | AddSourceDestination (uint32_t fromNodeId, std::string destinationIpv4Address) |
Helper function to print the routing path from a source node to destination IP. More... | |
int64_t | AssignStreams (int64_t stream) |
AnimationInterface & | EnableIpv4RouteTracking (std::string fileName, Time startTime, Time stopTime, Time pollInterval=Seconds(5)) |
Enable tracking of the Ipv4 routing table for all Nodes. More... | |
AnimationInterface & | EnableIpv4RouteTracking (std::string fileName, Time startTime, Time stopTime, NodeContainer nc, Time pollInterval=Seconds(5)) |
Enable tracking of the Ipv4 routing table for a set of Nodes. More... | |
void | EnablePacketMetadata (bool enable) |
Enable Packet metadata. More... | |
uint64_t | GetTracePktCount () |
Get trace file packet count (This used only for testing) More... | |
bool | IsStarted (void) |
Is AnimationInterface started. More... | |
void | ResetAnimWriteCallback () |
Reset the write callback function. | |
void | SetAnimWriteCallback (AnimWriteCallback cb) |
Set a callback function to listen to AnimationInterface write events. More... | |
void | SetMobilityPollInterval (Time t) |
Set mobility poll interval:WARNING: setting a low interval can cause slowness. More... | |
void | SetRandomPosition (bool setRandPos) |
Set random position if a Mobility Model does not exists for the node. More... | |
void | SetStartTime (Time t) |
Specify the time at which capture should start. More... | |
void | SetStopTime (Time t) |
Specify the time at which capture should stop. More... | |
void | ShowNode (uint32_t nodeId, bool show=true) |
Helper function to show/hide a node. More... | |
void | ShowNode (Ptr< Node > n, bool show=true) |
Helper function to show/hide a node. More... | |
void | UpdateLinkDescription (uint32_t fromNode, uint32_t toNode, std::string linkDescription) |
Helper function to update the description for a link. More... | |
void | UpdateLinkDescription (Ptr< Node > fromNode, Ptr< Node > toNode, std::string linkDescription) |
Helper function to update the description for a link. More... | |
void | UpdateNodeColor (Ptr< Node > n, uint8_t r, uint8_t g, uint8_t b) |
Helper function to update the node color. More... | |
void | UpdateNodeColor (uint32_t nodeId, uint8_t r, uint8_t g, uint8_t b) |
Helper function to update the node color. More... | |
void | UpdateNodeDescription (Ptr< Node > n, std::string descr) |
Helper function to update the description for a given node. More... | |
void | UpdateNodeDescription (uint32_t nodeId, std::string descr) |
Helper function to update the description for a given node. More... | |
Static Public Member Functions | |
static bool | IsInitialized (void) |
Check if AnimationInterface is initialized. More... | |
static void | SetConstantPosition (Ptr< Node > n, double x, double y, double z=0) |
Helper function to set Constant Position for a given node. More... | |
static void | SetLinkDescription (uint32_t fromNode, uint32_t toNode, std::string linkDescription, std::string fromNodeDescription="", std::string toNodeDescription="") |
Helper function to set the description for a link. More... | |
static void | SetLinkDescription (Ptr< Node > fromNode, Ptr< Node > toNode, std::string linkDescription, std::string fromNodeDescription="", std::string toNodeDescription="") |
Helper function to set the description for a link. More... | |
static void | SetNodeColor (Ptr< Node > n, uint8_t r, uint8_t g, uint8_t b) |
Helper function to set the node color. More... | |
static void | SetNodeColor (NodeContainer nc, uint8_t r, uint8_t g, uint8_t b) |
Helper function to set the color of nodes in a container. More... | |
static void | SetNodeDescription (Ptr< Node > n, std::string descr) |
Helper function to set a brief description for a given node. More... | |
static void | SetNodeDescription (NodeContainer nc, std::string descr) |
Helper function to set a brief description for nodes in a Node Container. More... | |
Private Types | |
typedef std::vector < Ipv4RoutePathElement > | Ipv4RoutePathElements |
Private Member Functions | |
void | AddPendingCsmaPacket (uint64_t AnimUid, AnimPacketInfo &) |
void | AddPendingLtePacket (uint64_t AnimUid, AnimPacketInfo &) |
void | AddPendingUanPacket (uint64_t AnimUid, AnimPacketInfo &) |
void | AddPendingWifiPacket (uint64_t AnimUid, AnimPacketInfo &) |
void | AddPendingWimaxPacket (uint64_t AnimUid, AnimPacketInfo &) |
void | AddToIpv4AddressNodeIdTable (std::string, uint32_t) |
void | ConnectCallbacks () |
void | ConnectLte () |
void | ConnectLteEnb (Ptr< Node > n, Ptr< LteEnbNetDevice > nd, uint32_t devIndex) |
void | ConnectLteUe (Ptr< Node > n, Ptr< LteUeNetDevice > nd, uint32_t devIndex) |
void | CsmaMacRxTrace (std::string context, Ptr< const Packet > p) |
bool | CsmaPacketIsPending (uint64_t AnimUid) |
void | CsmaPhyRxEndTrace (std::string context, Ptr< const Packet > p) |
void | CsmaPhyTxBeginTrace (std::string context, Ptr< const Packet > p) |
void | CsmaPhyTxEndTrace (std::string context, Ptr< const Packet > p) |
void | DevTxTrace (std::string context, Ptr< const Packet > p, Ptr< NetDevice > tx, Ptr< NetDevice > rx, Time txTime, Time rxTime) |
uint64_t | GetAnimUidFromPacket (Ptr< const Packet >) |
std::vector< std::string > | GetElementsFromContext (std::string context) |
std::string | GetIpv4Address (Ptr< NetDevice > nd) |
std::string | GetIpv4RoutingTable (Ptr< Node > n) |
std::string | GetMacAddress (Ptr< NetDevice > nd) |
std::string | GetNetAnimVersion () |
Ptr< NetDevice > | GetNetDeviceFromContext (std::string context) |
std::string | GetPacketMetadata (Ptr< const Packet > p) |
Vector | GetPosition (Ptr< Node > n) |
std::string | GetPreamble (void) |
std::string | GetXMLClose (std::string name) |
std::string | GetXMLOpen_anim (uint32_t lp) |
std::string | GetXMLOpen_packet (uint32_t fromLp, uint32_t fromId, double fbTx, double lbTx, std::string auxInfo="") |
std::string | GetXMLOpen_topology (double minX, double minY, double maxX, double maxY) |
std::string | GetXMLOpen_wpacket (uint32_t fromLp, uint32_t fromId, double fbTx, double lbTx, double range) |
std::string | GetXMLOpenClose_link (uint32_t fromLp, uint32_t fromId, uint32_t toLp, uint32_t toId) |
std::string | GetXMLOpenClose_linkupdate (uint32_t fromId, uint32_t toId, std::string) |
std::string | GetXMLOpenClose_meta (std::string metaInfo) |
std::string | GetXMLOpenClose_node (uint32_t lp, uint32_t id, double locX, double locY) |
std::string | GetXMLOpenClose_node (uint32_t lp, uint32_t id, double locX, double locY, struct Rgb rgb) |
std::string | GetXMLOpenClose_nodeupdate (uint32_t id, bool visible=true) |
std::string | GetXMLOpenClose_NonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType) |
std::string | GetXMLOpenClose_p (std::string pktType, uint32_t fId, double fbTx, double lbTx, uint32_t tId, double fbRx, double lbRx, std::string metaInfo="", std::string auxInfo="") |
std::string | GetXMLOpenClose_routing (uint32_t id, std::string routingInfo) |
std::string | GetXMLOpenClose_rp (uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements) |
std::string | GetXMLOpenClose_rx (uint32_t toLp, uint32_t toId, double fbRx, double lbRx) |
bool | IsInTimeWindow () |
bool | LtePacketIsPending (uint64_t AnimUid) |
void | LteRxTrace (std::string context, Ptr< const Packet > p, const Mac48Address &) |
void | LteSpectrumPhyRxStart (std::string context, Ptr< const PacketBurst > pb) |
void | LteSpectrumPhyTxStart (std::string context, Ptr< const PacketBurst > pb) |
void | LteTxTrace (std::string context, Ptr< const Packet > p, const Mac48Address &) |
void | MobilityAutoCheck () |
void | MobilityCourseChangeTrace (Ptr< const MobilityModel > mob) |
bool | NodeHasMoved (Ptr< Node > n, Vector newLocation) |
void | OutputCsmaPacket (Ptr< const Packet > p, AnimPacketInfo &pktInfo, AnimRxInfo pktrxInfo) |
void | OutputWirelessPacket (Ptr< const Packet > p, AnimPacketInfo &pktInfo, AnimRxInfo pktrxInfo) |
void | PurgePendingCsma () |
void | PurgePendingLte () |
void | PurgePendingWifi () |
void | PurgePendingWimax () |
void | RecalcTopoBounds (Vector v) |
std::vector< Ptr< Node > > | RecalcTopoBounds () |
void | RecursiveIpv4RoutePathSearch (std::string fromIpv4, std::string toIpv4, Ipv4RoutePathElements &) |
bool | SetOutputFile (const std::string &fn) |
Specify that animation commands are to be written to the specified output file. More... | |
bool | SetRoutingOutputFile (const std::string &fn) |
void | SetXMLOutput () |
Specify that animation commands are to be written in XML format. More... | |
void | StartAnimation (bool restart=false) |
Writes the topology information and sets up the appropriate animation packet tx callback. More... | |
void | StartNewTraceFile () |
void | StopAnimation (bool onlyAnimation=false) |
Closes the interface to the animator. | |
void | TrackIpv4Route () |
void | TrackIpv4RoutePaths () |
bool | UanPacketIsPending (uint64_t AnimUid) |
void | UanPhyGenRxTrace (std::string context, Ptr< const Packet >) |
void | UanPhyGenTxTrace (std::string context, Ptr< const Packet >) |
Vector | UpdatePosition (Ptr< Node > n) |
Vector | UpdatePosition (Ptr< Node > n, Vector v) |
void | WifiMacRxTrace (std::string context, Ptr< const Packet > p) |
bool | WifiPacketIsPending (uint64_t AnimUid) |
void | WifiPhyRxBeginTrace (std::string context, Ptr< const Packet > p) |
void | WifiPhyRxDropTrace (std::string context, Ptr< const Packet > p) |
void | WifiPhyRxEndTrace (std::string context, Ptr< const Packet > p) |
void | WifiPhyTxBeginTrace (std::string context, Ptr< const Packet > p) |
void | WifiPhyTxDropTrace (std::string context, Ptr< const Packet > p) |
void | WifiPhyTxEndTrace (std::string context, Ptr< const Packet > p) |
bool | WimaxPacketIsPending (uint64_t AnimUid) |
void | WimaxRxTrace (std::string context, Ptr< const Packet > p, const Mac48Address &) |
void | WimaxTxTrace (std::string context, Ptr< const Packet > p, const Mac48Address &) |
void | WriteDummyPacket () |
int | WriteN (const char *, uint32_t, FILE *f) |
int | WriteN (const std::string &, FILE *f) |
void | WriteNonP2pLinkProperties (uint32_t id, std::string ipv4Address, std::string channelType) |
void | WriteRoutePath (uint32_t nodeId, std::string destination, Ipv4RoutePathElements rpElements) |
Private Attributes | |
uint64_t | gAnimUid |
uint64_t | m_currentPktCount |
bool | m_enablePacketMetadata |
FILE * | m_f |
std::vector < Ipv4RouteTrackElement > | m_ipv4RouteTrackElements |
std::map< std::string, uint32_t > | m_ipv4ToNodeIdMap |
std::map< std::string, uint32_t > | m_macToNodeIdMap |
uint64_t | m_maxPktsPerFile |
Time | m_mobilityPollInterval |
std::map< uint32_t, Vector > | m_nodeLocation |
std::string | m_originalFileName |
std::string | m_outputFileName |
bool | m_outputFileSet |
std::map< uint64_t, AnimPacketInfo > | m_pendingCsmaPackets |
std::map< uint64_t, AnimPacketInfo > | m_pendingLtePackets |
std::map< uint64_t, AnimPacketInfo > | m_pendingUanPackets |
std::map< uint64_t, AnimPacketInfo > | m_pendingWifiPackets |
std::map< uint64_t, AnimPacketInfo > | m_pendingWimaxPackets |
bool | m_randomPosition |
FILE * | m_routingF |
std::string | m_routingFileName |
NodeContainer | m_routingNc |
Time | m_routingPollInterval |
Time | m_routingStopTime |
bool | m_started |
Time | m_startTime |
Time | m_stopTime |
double | m_topoMaxX |
double | m_topoMaxY |
double | m_topoMinX |
double | m_topoMinY |
Ptr< UniformRandomVariable > | m_uniformRandomVariable |
Provides uniform random variables. | |
AnimWriteCallback | m_writeCallback |
bool | m_xml |
Static Private Attributes | |
static std::map < P2pLinkNodeIdPair, LinkProperties, LinkPairCompare > | linkProperties |
static std::map< uint32_t, Rgb > | nodeColors |
static std::map< uint32_t, std::string > | nodeDescriptions |
Interface to network animator.
Provides functions that facilitate communications with an external or internal network animator.
Definition at line 104 of file animation-interface.h.
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 |
Definition at line 64 of file animation-interface.cc.
References m_uniformRandomVariable, and StartAnimation().
AnimationInterface & ns3::AnimationInterface::AddSourceDestination | ( | uint32_t | fromNodeId, |
std::string | destinationIpv4Address | ||
) |
Helper function to print the routing path from a source node to destination IP.
Definition at line 728 of file animation-interface.cc.
int64_t ns3::AnimationInterface::AssignStreams | ( | int64_t | stream | ) |
Assign a fixed random variable stream number to the random variables used by this model. Return the number of streams (possibly zero) that have been assigned.
stream | first stream index to use |
Definition at line 1578 of file animation-interface.cc.
References m_uniformRandomVariable, NS_LOG_FUNCTION, and ns3::RandomVariableStream::SetStream().
AnimationInterface & ns3::AnimationInterface::EnableIpv4RouteTracking | ( | std::string | fileName, |
Time | startTime, | ||
Time | stopTime, | ||
Time | pollInterval = Seconds(5) |
||
) |
Enable tracking of the Ipv4 routing table for all Nodes.
fileName | Trace file for storing routing table information |
startTime | Start time for capture |
stopTime | End time for capture |
pollInterval | The periodic interval at which routing table information is polled Default: 5s |
Definition at line 84 of file animation-interface.cc.
References ns3::Simulator::Schedule().
Referenced by EnableIpv4RouteTracking().
AnimationInterface & ns3::AnimationInterface::EnableIpv4RouteTracking | ( | std::string | fileName, |
Time | startTime, | ||
Time | stopTime, | ||
NodeContainer | nc, | ||
Time | pollInterval = Seconds(5) |
||
) |
Enable tracking of the Ipv4 routing table for a set of Nodes.
fileName | Trace file for storing routing table information |
startTime | Start time for capture |
stopTime | End time for capture |
nc | A NodeContainer containing nodes for which Routing table has to be tracked |
pollInterval | The periodic interval at which routing table information is polled Default: 5s |
Definition at line 95 of file animation-interface.cc.
References EnableIpv4RouteTracking().
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 |
Definition at line 356 of file animation-interface.cc.
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
Definition at line 1572 of file animation-interface.cc.
|
static |
Check if AnimationInterface is initialized.
Definition at line 363 of file animation-interface.cc.
bool ns3::AnimationInterface::IsStarted | ( | void | ) |
Is AnimationInterface started.
Definition at line 368 of file animation-interface.cc.
void ns3::AnimationInterface::SetAnimWriteCallback | ( | AnimWriteCallback | cb | ) |
Set a callback function to listen to AnimationInterface write events.
cb | Address of callback function |
Definition at line 374 of file animation-interface.cc.
|
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 |
Definition at line 1679 of file animation-interface.cc.
References ns3::Object::AggregateObject(), ns3::Node::GetId(), ns3::Object::GetObject(), NS_ASSERT, and NS_LOG_INFO.
Referenced by ns3::AnimationInterfaceTestCase::DoRun().
|
static |
Helper function to set the description for a link.
fromNode | Node Id of the "from Node" of the p2p link |
toNode | Node Id of the "to Node" of the p2p link |
linkDescription | Description of the link such as link bandwidth |
fromNodeDescription | Description at the "from Node" end such as IP address |
toNodeDescription | Description at the "to Node" end such as Ip address |
Definition at line 1766 of file animation-interface.cc.
Referenced by SetLinkDescription(), and StartAnimation().
|
static |
Helper function to set the description for a link.
fromNode | Ptr to the "from Node" of the p2p link |
toNode | Ptr the "to Node" of the p2p link |
linkDescription | Description of the link such as link bandwidth |
fromNodeDescription | Description at the "from Node" end such as IP address |
toNodeDescription | Description at the "to Node" end such as Ip address |
Definition at line 1790 of file animation-interface.cc.
References ns3::Node::GetId(), NS_ASSERT, and SetLinkDescription().
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 |
Definition at line 419 of file animation-interface.cc.
|
static |
Helper function to set the node color.
n | Ptr to the node |
r | Red component value (0-255) |
g | Green component value (0-255) |
b | Blue component value (0-255) |
Definition at line 1694 of file animation-interface.cc.
References ns3::Node::GetId(), NS_ASSERT, NS_FATAL_ERROR, and NS_LOG_INFO.
Referenced by SetNodeColor().
|
static |
Helper function to set the color of nodes in a container.
n | Ptr to the node |
r | Red component value (0-255) |
g | Green component value (0-255) |
b | Blue component value (0-255) |
Definition at line 1737 of file animation-interface.cc.
References ns3::NodeContainer::Get(), ns3::NodeContainer::GetN(), NS_ASSERT, and SetNodeColor().
Helper function to set a brief description for a given node.
Definition at line 1801 of file animation-interface.cc.
References ns3::Node::GetId(), NS_ASSERT, and NS_FATAL_ERROR.
|
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 |
Definition at line 1825 of file animation-interface.cc.
References ns3::NodeContainer::Get(), ns3::Node::GetId(), ns3::NodeContainer::GetN(), NS_ASSERT, and NS_FATAL_ERROR.
|
private |
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. |
Definition at line 322 of file animation-interface.cc.
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 |
Definition at line 424 of file animation-interface.cc.
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 |
Definition at line 312 of file animation-interface.cc.
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 |
Definition at line 317 of file animation-interface.cc.
|
private |
Specify that animation commands are to be written in XML format.
Definition at line 283 of file animation-interface.cc.
References NS_LOG_INFO.
void ns3::AnimationInterface::ShowNode | ( | uint32_t | nodeId, |
bool | show = true |
||
) |
Helper function to show/hide a node.
nodeId | Id of the node |
show | Set to true to show node, set to false to hide |
Definition at line 1704 of file animation-interface.cc.
References ns3::NodeList::GetNode(), NS_ASSERT, and NS_LOG_INFO.
Referenced by ShowNode().
Helper function to show/hide a node.
n | Ptr to the node |
show | Set to true to show node, set to false to hide |
Definition at line 1714 of file animation-interface.cc.
References ShowNode().
|
private |
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 |
Definition at line 606 of file animation-interface.cc.
References ns3::NodeList::Begin(), ns3::NodeList::End(), ns3::Node::GetDevice(), ns3::Node::GetId(), ns3::Node::GetNDevices(), ns3::NodeList::GetNNodes(), NS_ASSERT, NS_LOG_DEBUG, NS_LOG_INFO, ns3::Simulator::Schedule(), SetLinkDescription(), SetOutputFile(), ns3::Vector3D::x, and ns3::Vector3D::y.
Referenced by AnimationInterface().
void ns3::AnimationInterface::UpdateLinkDescription | ( | uint32_t | fromNode, |
uint32_t | toNode, | ||
std::string | linkDescription | ||
) |
Helper function to update the description for a link.
fromNode | Node Id of the "from Node" of the p2p link |
toNode | Node Id of the "to Node" of the p2p link |
linkDescription | Description of the link such as link bandwidth |
Definition at line 1748 of file animation-interface.cc.
void ns3::AnimationInterface::UpdateLinkDescription | ( | Ptr< Node > | fromNode, |
Ptr< Node > | toNode, | ||
std::string | linkDescription | ||
) |
Helper function to update the description for a link.
fromNode | Ptr to the "from Node" of the p2p link |
toNode | Ptr to the "to Node" of the p2p link |
linkDescription | Description of the link such as link bandwidth |
Definition at line 1756 of file animation-interface.cc.
References ns3::Node::GetId(), and NS_ASSERT.
Helper function to update the node color.
n | Ptr to the node |
r | Red component value (0-255) |
g | Green component value (0-255) |
b | Blue component value (0-255) |
Definition at line 1719 of file animation-interface.cc.
References ns3::Node::GetId().
void ns3::AnimationInterface::UpdateNodeColor | ( | uint32_t | nodeId, |
uint8_t | r, | ||
uint8_t | g, | ||
uint8_t | b | ||
) |
Helper function to update the node color.
nodeId | Id of the node |
r | Red component value (0-255) |
g | Green component value (0-255) |
b | Blue component value (0-255) |
Definition at line 1724 of file animation-interface.cc.
References ns3::NodeList::GetNode(), NS_ASSERT, and NS_LOG_INFO.
Helper function to update the description for a given node.
Definition at line 1809 of file animation-interface.cc.
References ns3::Node::GetId().
void ns3::AnimationInterface::UpdateNodeDescription | ( | uint32_t | nodeId, |
std::string | descr | ||
) |
Helper function to update the description for a given node.
nodeId | Id of the node |
descr | A string to briefly describe the node |
Definition at line 1814 of file animation-interface.cc.
References ns3::NodeList::GetNode(), and NS_ASSERT.