A Discrete-Event Network Simulator
API
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 Types

typedef void(* DelayAddressCallback) (const Time &delay, const Address &from)
 Common callback signature for packet delay and address. More...
 
typedef void(* StateTransitionCallback) (const std::string &oldState, const std::string &newState)
 Common signature used by callbacks to application's state transition trace source. More...
 

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 ()
 Constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together. More...
 
void Dispose (void)
 Dispose of this Object. More...
 
AggregateIterator GetAggregateIterator (void) const
 Get an iterator to the Objects aggregated to this one. More...
 
virtual TypeId GetInstanceTypeId (void) const
 Get the most derived TypeId for this Object. More...
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId. More...
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object. More...
 
template<typename T >
Ptr< T > GetObject (void) const
 Get a pointer to the requested aggregated Object. More...
 
void Initialize (void)
 Invoke DoInitialize on all Objects aggregated to this one. More...
 
bool IsInitialized (void) const
 Check if the object has been initialized. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o[[maybe_unused]])
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= ([[maybe_unused]] const SimpleRefCount &o)
 Assignment operator. 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
 Get the value of an attribute, raising fatal errors if unsuccessful. More...
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising erros. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful. More...
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors. More...
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context. More...
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context. More...
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context. More...
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context. More...
 

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::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Protected Member Functions

virtual void DoDispose (void)
 Destructor implementation. More...
 
virtual void DoInitialize (void)
 Initialize() implementation. More...
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object. More...
 
virtual void NotifyNewAggregate (void)
 Notify all Objects aggregated to this one of a new Object being aggregated. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes. More...
 
virtual void NotifyConstructionCompleted (void)
 Notifier called once the ObjectBase is fully constructed. 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...
 

Additional Inherited Members

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 +9.22337e+18ns:+9.22337e+18ns
    • Initial value: +0ns
    • Flags: construct write read
  • StopTime: Time at which the application will stop
    • Set with class: ns3::TimeValue
    • Underlying type: Time +9.22337e+18ns:+9.22337e+18ns
    • Initial value: +0ns
    • Flags: construct write read

No TraceSources are defined for this type.
Size of this type is 104 bytes (on a 64-bit architecture).

Definition at line 60 of file application.h.

Member Typedef Documentation

◆ DelayAddressCallback

typedef void(* ns3::Application::DelayAddressCallback) (const Time &delay, const Address &from)

Common callback signature for packet delay and address.

Parameters
delayThe packet delay.
fromThe source socket address associated with the packet, indicating the packet's origin.

Definition at line 114 of file application.h.

◆ StateTransitionCallback

typedef void(* ns3::Application::StateTransitionCallback) (const std::string &oldState, const std::string &newState)

Common signature used by callbacks to application's state transition trace source.

Parameters
oldStateThe name of the previous state.
newStateThe name of the current state.

Definition at line 123 of file application.h.

Constructor & Destructor Documentation

◆ Application()

ns3::Application::Application ( )

Definition at line 57 of file application.cc.

References NS_LOG_FUNCTION.

◆ ~Application()

ns3::Application::~Application ( )
virtual

Definition at line 63 of file application.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ DoDispose()

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

Destructor implementation.

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

Subclasses are expected to implement their real destruction code in an overridden 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::BsmApplication, ns3::PacketSocketServer, ns3::PacketSocketClient, EpsBearerTagUdpClient, ns3::EpcEnbApplication, ns3::V4TraceRoute, ns3::V4Ping, ns3::DhcpServer, ns3::DhcpClient, ns3::UdpTraceClient, ns3::UdpServer, ns3::UdpEchoServer, ns3::UdpEchoClient, ns3::UdpClient, ns3::QKDSDNController, ns3::QKDPostprocessingApplication, ns3::QKDKeyManagerSystemApplication, ns3::PacketSink, ns3::OnOffApplication, ns3::BulkSendApplication, Receiver, Sender, ns3::EpcSgwApplication, ns3::EpcPgwApplication, ns3::EpcMmeApplication, ns3::Radvd, ns3::Ping6, ns3::ThreeGppHttpServer, and ns3::ThreeGppHttpClient.

Definition at line 83 of file application.cc.

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

Referenced by ns3::ThreeGppHttpClient::DoDispose(), ns3::ThreeGppHttpServer::DoDispose(), ns3::Ping6::DoDispose(), ns3::Radvd::DoDispose(), Sender::DoDispose(), ns3::BulkSendApplication::DoDispose(), ns3::OnOffApplication::DoDispose(), ns3::PacketSink::DoDispose(), ns3::QKDKeyManagerSystemApplication::DoDispose(), ns3::QKDPostprocessingApplication::DoDispose(), ns3::QKDSDNController::DoDispose(), ns3::UdpClient::DoDispose(), ns3::UdpEchoClient::DoDispose(), ns3::UdpEchoServer::DoDispose(), ns3::UdpServer::DoDispose(), ns3::UdpTraceClient::DoDispose(), ns3::DhcpClient::DoDispose(), ns3::DhcpServer::DoDispose(), ns3::V4Ping::DoDispose(), ns3::V4TraceRoute::DoDispose(), ns3::PacketSocketClient::DoDispose(), ns3::PacketSocketServer::DoDispose(), and ns3::BsmApplication::DoDispose().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoInitialize()

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

Initialize() implementation.

This method is called only once by Initialize(). If the user calls 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 93 of file application.cc.

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

+ Here is the call graph for this function:

◆ GetNode()

Ptr< Node > ns3::Application::GetNode ( void  ) const
Returns
the Node to which this Application object is attached.

Definition at line 104 of file application.cc.

References m_node, and NS_LOG_FUNCTION.

Referenced by ns3::DhcpClient::AcceptAck(), ns3::BsmApplication::GenerateWaveTraffic(), ns3::V4Ping::GetApplicationId(), ns3::V4TraceRoute::GetApplicationId(), ns3::Radvd::HandleRead(), ns3::DhcpClient::LinkStateHandler(), ns3::DhcpServer::NetHandler(), ns3::ThreeGppHttpClient::OpenConnection(), ns3::QKDApp004::PrepareSendSocketToApp(), ns3::QKDApp014::PrepareSendSocketToApp(), ns3::QKDApp004::PrepareSendSocketToKMS(), ns3::QKDApp014::PrepareSendSocketToKMS(), ns3::QKDApp004::PrepareSinkSocketFromApp(), ns3::QKDApp014::PrepareSinkSocketFromApp(), ns3::QKDApp004::PrepareSinkSocketFromKMS(), ns3::QKDApp014::PrepareSinkSocketFromKMS(), ns3::V4Ping::Receive(), ns3::BsmApplication::ReceiveWavePacket(), ns3::DhcpClient::RemoveAndStart(), ns3::Ping6::Send(), ns3::V4Ping::Send(), ns3::Radvd::Send(), ns3::DhcpServer::SendOffer(), ns3::ThreeGppHttpServer::StartApplication(), ns3::Ping6::StartApplication(), ns3::Radvd::StartApplication(), Receiver::StartApplication(), ns3::BulkSendApplication::StartApplication(), ns3::OnOffApplication::StartApplication(), ns3::PacketSink::StartApplication(), ns3::QKDPostprocessingApplication::StartApplication(), ns3::UdpClient::StartApplication(), ns3::UdpEchoClient::StartApplication(), ns3::UdpEchoServer::StartApplication(), ns3::UdpServer::StartApplication(), ns3::UdpTraceClient::StartApplication(), ns3::DhcpClient::StartApplication(), ns3::DhcpServer::StartApplication(), ns3::V4Ping::StartApplication(), ns3::V4TraceRoute::StartApplication(), EpsBearerTagUdpClient::StartApplication(), ns3::PacketSocketClient::StartApplication(), ns3::PacketSocketServer::StartApplication(), ns3::BsmApplication::StartApplication(), and ns3::DhcpClient::StopApplication().

+ Here is the caller graph for this function:

◆ GetTypeId()

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::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::Seconds(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ SetNode()

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

Definition at line 111 of file application.cc.

References m_node, and NS_LOG_FUNCTION.

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

+ Here is the caller graph for this function:

◆ SetStartTime()

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 69 of file application.cc.

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

Referenced by ns3::ApplicationContainer::Start(), and ns3::ApplicationContainer::StartWithJitter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetStopTime()

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 75 of file application.cc.

References m_stopTime, and NS_LOG_FUNCTION.

Referenced by ns3::ApplicationContainer::Stop().

+ Here is the caller graph for this function:

◆ StartApplication()

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

◆ StopApplication()

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

Member Data Documentation

◆ m_node

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

The node that this application is installed on.

Definition at line 148 of file application.h.

Referenced by DoDispose(), GetNode(), SetNode(), and ns3::Ping6::StartApplication().

◆ m_startEvent

EventId ns3::Application::m_startEvent
protected

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

Definition at line 151 of file application.h.

Referenced by DoDispose(), and DoInitialize().

◆ m_startTime

Time ns3::Application::m_startTime
protected

The simulation time that the application will start.

Definition at line 149 of file application.h.

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

◆ m_stopEvent

EventId ns3::Application::m_stopEvent
protected

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

Definition at line 152 of file application.h.

Referenced by DoDispose(), and DoInitialize().

◆ m_stopTime

Time ns3::Application::m_stopTime
protected

The simulation time that the application will end.

Definition at line 150 of file application.h.

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


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