A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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.
 
typedef void(* StateTransitionCallback) (const std::string &oldState, const std::string &newState)
 Common signature used by callbacks to application's state transition trace source.
 

Public Member Functions

 Application ()
 
 ~Application () override
 
virtual int64_t AssignStreams (int64_t stream)
 Assign a fixed random variable stream number to the random variables used by this Application object.
 
Ptr< NodeGetNode () const
 
void SetNode (Ptr< Node > node)
 
void SetStartTime (Time start)
 Specify application start time.
 
void SetStopTime (Time stop)
 Specify application stop time.
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
virtual TypeId GetInstanceTypeId () const =0
 Get the most derived TypeId for this Object.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Protected Member Functions

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

Protected Attributes

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

Private Member Functions

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

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: constructwriteread
  • 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: constructwriteread

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

Definition at line 61 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 124 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 132 of file application.h.

Constructor & Destructor Documentation

◆ Application()

ns3::Application::Application ( )

Definition at line 60 of file application.cc.

References NS_LOG_FUNCTION.

◆ ~Application()

ns3::Application::~Application ( )
override

Definition at line 66 of file application.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ AssignStreams()

int64_t ns3::Application::AssignStreams ( int64_t  stream)
virtual

Assign a fixed random variable stream number to the random variables used by this Application object.

Parameters
streamfirst stream index to use
Returns
the number of stream indices assigned by this Application object

Reimplemented in ns3::OnOffApplication, ns3::DhcpClient, and ns3::Radvd.

Definition at line 136 of file application.cc.

References NS_LOG_FUNCTION.

◆ DoDispose()

void ns3::Application::DoDispose ( )
overrideprotectedvirtual

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::PacketSocketClient, and ns3::PacketSocketServer.

Definition at line 86 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(), Receiver::DoDispose(), ns3::BulkSendApplication::DoDispose(), ns3::OnOffApplication::DoDispose(), ns3::PacketSink::DoDispose(), ns3::ThreeGppHttpClient::DoDispose(), ns3::ThreeGppHttpServer::DoDispose(), ns3::DhcpClient::DoDispose(), ns3::DhcpServer::DoDispose(), ns3::Ping::DoDispose(), ns3::Radvd::DoDispose(), ns3::V4TraceRoute::DoDispose(), EpsBearerTagUdpClient::DoDispose(), ns3::PacketSocketClient::DoDispose(), and ns3::PacketSocketServer::DoDispose().

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

◆ DoInitialize()

void ns3::Application::DoInitialize ( )
overrideprotectedvirtual

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 96 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()

◆ GetTypeId()

TypeId ns3::Application::GetTypeId ( )
static

Get the type ID.

Returns
the object TypeId

Definition at line 41 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 115 of file application.cc.

References m_node, and NS_LOG_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. This 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 72 of file application.cc.

References m_startTime, and NS_LOG_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. This 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 79 of file application.cc.

References m_stopTime, and NS_LOG_FUNCTION.

◆ StartApplication()

void ns3::Application::StartApplication ( )
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 Sender, Receiver, ns3::TutorialApp, ns3::BulkSendApplication, ns3::OnOffApplication, ns3::PacketSink, ns3::ThreeGppHttpClient, ns3::ThreeGppHttpServer, ns3::UdpClient, ns3::UdpEchoClient, ns3::UdpEchoServer, ns3::UdpServer, ns3::UdpTraceClient, ns3::DhcpClient, ns3::DhcpServer, ns3::Ping, ns3::Radvd, ns3::V4TraceRoute, EpsBearerTagUdpClient, ns3::PacketSocketClient, ns3::PacketSocketServer, and ns3::SocketWriter.

Definition at line 124 of file application.cc.

References NS_LOG_FUNCTION.

Referenced by DoInitialize().

+ Here is the caller graph for this function:

◆ StopApplication()

void ns3::Application::StopApplication ( )
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 Sender, Receiver, ns3::TutorialApp, ns3::BulkSendApplication, ns3::OnOffApplication, ns3::PacketSink, ns3::ThreeGppHttpClient, ns3::ThreeGppHttpServer, ns3::UdpClient, ns3::UdpEchoClient, ns3::UdpEchoServer, ns3::UdpServer, ns3::UdpTraceClient, ns3::DhcpClient, ns3::DhcpServer, ns3::Ping, ns3::Radvd, ns3::V4TraceRoute, EpsBearerTagUdpClient, ns3::PacketSocketClient, ns3::PacketSocketServer, and ns3::SocketWriter.

Definition at line 130 of file application.cc.

References NS_LOG_FUNCTION.

Referenced by DoInitialize().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_node

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

The node that this application is installed on.

Definition at line 158 of file application.h.

Referenced by DoDispose(), GetNode(), ns3::Ping::Receive(), and SetNode().

◆ m_startEvent

EventId ns3::Application::m_startEvent
protected

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

Definition at line 161 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 159 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 162 of file application.h.

Referenced by DoDispose(), DoInitialize(), and ns3::Ping::StopApplication().

◆ m_stopTime

Time ns3::Application::m_stopTime
protected

The simulation time that the application will end.

Definition at line 160 of file application.h.

Referenced by DoInitialize(), GetTypeId(), SetStopTime(), and ns3::Ping::StartApplication().


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