A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::Application Class Reference

The base class for all ns3 applications. More...

#include <application.h>

+ Inheritance diagram for ns3::Application:
+ Collaboration diagram for ns3::Application:

Public Member Functions

 Application ()
 
virtual ~Application ()
 
Ptr< NodeGetNode () const
 
void SetNode (Ptr< Node > node)
 
void SetStartTime (Time start)
 Specify application start time. More...
 
void SetStopTime (Time stop)
 Specify application stop time. More...
 
- Public Member Functions inherited from ns3::Object
 Object ()
 
virtual ~Object ()
 
void AggregateObject (Ptr< Object > other)
 
void Dispose (void)
 Run the DoDispose methods of this object and all the objects aggregated to it. More...
 
AggregateIterator GetAggregateIterator (void) const
 
virtual TypeId GetInstanceTypeId (void) const
 
template<typename T >
Ptr< T > GetObject (void) const
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 
void Initialize (void)
 This method calls the virtual DoInitialize method on all the objects aggregated to this object. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 
bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const
 
void SetAttribute (std::string name, const AttributeValue &value)
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 

Static Public Member Functions

static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
static void Cleanup (void)
 Noop. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Protected Member Functions

virtual void DoDispose (void)
 This method is called by Object::Dispose or by the object's destructor, whichever comes first. More...
 
virtual void DoInitialize (void)
 This method is called only once by Object::Initialize. More...
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 
virtual void NotifyNewAggregate (void)
 This method is invoked whenever two sets of objects are aggregated together. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 
virtual void NotifyConstructionCompleted (void)
 This method is invoked once all member attributes have been initialized. More...
 

Protected Attributes

Ptr< Nodem_node
 The node that this application is installed on. More...
 
EventId m_startEvent
 The event that will fire at m_startTime to start the application. More...
 
Time m_startTime
 The simulation time that the application will start. More...
 
EventId m_stopEvent
 The event that will fire at m_stopTime to end the application. More...
 
Time m_stopTime
 The simulation time that the application will end. More...
 

Private Member Functions

virtual void StartApplication (void)
 Application specific startup code. More...
 
virtual void StopApplication (void)
 Application specific shutdown code. More...
 

Detailed Description

The base class for all ns3 applications.

Config Paths

ns3::Application is accessible through the following paths with Config::Set and Config::Connect:

  • /NodeList/[i]/ApplicationList/[i]

Attributes

  • StartTime: Time at which the application will start
    • Set with class: ns3::TimeValue
    • Underlying type: Time –9223372036854775808.0ns:+9223372036854775807.0ns
    • Initial value: +0.0ns
    • Flags: construct write read
  • StopTime: Time at which the application will stop
    • Set with class: ns3::TimeValue
    • Underlying type: Time –9223372036854775808.0ns:+9223372036854775807.0ns
    • Initial value: +0.0ns
    • Flags: construct write read

No TraceSources are defined for this type.

Definition at line 60 of file application.h.

Constructor & Destructor Documentation

ns3::Application::Application ( )

Definition at line 56 of file application.cc.

References NS_LOG_FUNCTION.

ns3::Application::~Application ( )
virtual

Definition at line 62 of file application.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

void ns3::Application::DoDispose ( void  )
protectedvirtual

This method is called by Object::Dispose or by the object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.

It is safe to call GetObject from within this method.

Reimplemented from ns3::Object.

Reimplemented in ns3::UdpEchoClient, ns3::OnOffApplication, ns3::UdpTraceClient, ns3::BulkSendApplication, ns3::PacketSink, ns3::Ping6, ns3::Radvd, EpsBearerTagUdpClient, Receiver, ns3::UdpServer, ns3::V4Ping, ns3::UdpClient, ns3::EpcEnbApplication, ns3::EpcSgwPgwApplication, ns3::UdpEchoServer, and Sender.

Definition at line 82 of file application.cc.

References ns3::EventId::Cancel(), ns3::Object::DoDispose(), m_node, m_startEvent, m_stopEvent, and NS_LOG_FUNCTION.

Referenced by Sender::DoDispose(), ns3::UdpEchoServer::DoDispose(), ns3::UdpClient::DoDispose(), ns3::V4Ping::DoDispose(), ns3::UdpServer::DoDispose(), ns3::Radvd::DoDispose(), ns3::Ping6::DoDispose(), ns3::PacketSink::DoDispose(), ns3::BulkSendApplication::DoDispose(), ns3::UdpTraceClient::DoDispose(), ns3::OnOffApplication::DoDispose(), and ns3::UdpEchoClient::DoDispose().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::Application::DoInitialize ( void  )
protectedvirtual

This method is called only once by Object::Initialize.

If the user calls Object::Initialize multiple times, DoInitialize is called only the first time.

Subclasses are expected to override this method and chain up to their parent's implementation once they are done. It is safe to call GetObject and AggregateObject from within this method.

Reimplemented from ns3::Object.

Definition at line 92 of file application.cc.

References ns3::Object::DoInitialize(), m_startEvent, m_startTime, m_stopEvent, m_stopTime, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), StartApplication(), StopApplication(), and ns3::TimeStep().

+ Here is the call graph for this function:

TypeId ns3::Application::GetTypeId ( void  )
static

Get the type ID.

Returns
the object TypeId

Definition at line 39 of file application.cc.

References m_startTime, m_stopTime, ns3::MakeTimeChecker(), ns3::TypeId::SetParent(), and ns3::TimeStep().

+ Here is the call graph for this function:

void ns3::Application::SetNode ( Ptr< Node node)
Parameters
nodethe node to which this Application object is attached.

Definition at line 110 of file application.cc.

References m_node, and NS_LOG_FUNCTION.

Referenced by ns3::Node::AddApplication().

+ Here is the caller graph for this function:

void ns3::Application::SetStartTime ( Time  start)

Specify application start time.

Parameters
startStart time for this application, relative to the current simulation time.

Applications start at various times in the simulation scenario. The Start method specifies when the application should be started. The application subclasses should override the private "StartApplication" method defined below, which is called at the time specified, to cause the application to begin.

Definition at line 68 of file application.cc.

References m_startTime, NS_LOG_FUNCTION, and visualizer.core::start().

Referenced by Ns3TcpNoDelayTestCase::DoRun(), Ns3TcpSocketTestCase1::DoRun(), NscTcpLossTestCase1::DoRun(), Ns3TcpSocketTestCase2::DoRun(), NscTcpLossTestCase2::DoRun(), Ns3TcpCwndTestCase1::DoRun(), Ns3TcpCwndTestCase2::DoRun(), main(), and ns3::ApplicationContainer::Start().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::Application::SetStopTime ( Time  stop)

Specify application stop time.

Parameters
stopStop time for this application, relative to the current simulation time.

Once an application has started, it is sometimes useful to stop the application. The Stop method specifies when an application is to stop. The application subclasses should override the private StopApplication method, to be notified when that time has come.

Definition at line 74 of file application.cc.

References m_stopTime, and NS_LOG_FUNCTION.

Referenced by Ns3TcpNoDelayTestCase::DoRun(), Ns3TcpSocketTestCase1::DoRun(), NscTcpLossTestCase1::DoRun(), Ns3TcpSocketTestCase2::DoRun(), NscTcpLossTestCase2::DoRun(), Ns3TcpCwndTestCase1::DoRun(), Ns3TcpCwndTestCase2::DoRun(), main(), and ns3::ApplicationContainer::Stop().

+ Here is the caller graph for this function:

void ns3::Application::StartApplication ( void  )
privatevirtual

Application specific startup code.

The StartApplication method is called at the start time specified by Start This method should be overridden by all or most application subclasses.

Reimplemented in ns3::UdpEchoClient, ns3::UdpTraceClient, ns3::OnOffApplication, ns3::Radvd, ns3::BulkSendApplication, ns3::Ping6, ns3::PacketSink, EpsBearerTagUdpClient, Receiver, ns3::UdpServer, SimpleSource, ns3::UdpClient, ns3::V4Ping, MyApp, MyApp, MyApp, ns3::UdpEchoServer, Sender, and ns3::SocketWriter.

Definition at line 118 of file application.cc.

References NS_LOG_FUNCTION.

Referenced by DoInitialize().

+ Here is the caller graph for this function:

void ns3::Application::StopApplication ( void  )
privatevirtual

Application specific shutdown code.

The StopApplication method is called at the stop time specified by Stop This method should be overridden by all or most application subclasses.

Reimplemented in ns3::UdpEchoClient, ns3::UdpTraceClient, ns3::OnOffApplication, ns3::Radvd, ns3::BulkSendApplication, ns3::Ping6, ns3::PacketSink, EpsBearerTagUdpClient, Receiver, ns3::UdpServer, SimpleSource, ns3::UdpClient, ns3::V4Ping, MyApp, MyApp, MyApp, ns3::UdpEchoServer, Sender, and ns3::SocketWriter.

Definition at line 123 of file application.cc.

References NS_LOG_FUNCTION.

Referenced by DoInitialize().

+ Here is the caller graph for this function:

Member Data Documentation

Ptr<Node> ns3::Application::m_node
protected

The node that this application is installed on.

Definition at line 129 of file application.h.

Referenced by DoDispose(), GetNode(), and SetNode().

EventId ns3::Application::m_startEvent
protected

The event that will fire at m_startTime to start the application.

Definition at line 132 of file application.h.

Referenced by DoDispose(), and DoInitialize().

Time ns3::Application::m_startTime
protected

The simulation time that the application will start.

Definition at line 130 of file application.h.

Referenced by DoInitialize(), GetTypeId(), and SetStartTime().

EventId ns3::Application::m_stopEvent
protected

The event that will fire at m_stopTime to end the application.

Definition at line 133 of file application.h.

Referenced by DoDispose(), and DoInitialize().

Time ns3::Application::m_stopTime
protected

The simulation time that the application will end.

Definition at line 131 of file application.h.

Referenced by DoInitialize(), GetTypeId(), and SetStopTime().


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