A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
application.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006 Georgia Tech Research Corporation
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: George F. Riley<riley@ece.gatech.edu>
7 */
8
9// Implementation for ns3 Application base class.
10// George F. Riley, Georgia Tech, Fall 2006
11
12#include "application.h"
13
14#include "node.h"
15
16#include "ns3/log.h"
17#include "ns3/nstime.h"
18#include "ns3/simulator.h"
19
20namespace ns3
21{
22
23NS_LOG_COMPONENT_DEFINE("Application");
24
26
27// Application Methods
28
29TypeId
31{
32 static TypeId tid = TypeId("ns3::Application")
34 .SetGroupName("Network")
35 .AddAttribute("StartTime",
36 "Time at which the application will start",
37 TimeValue(Seconds(0.0)),
40 .AddAttribute("StopTime",
41 "Time at which the application will stop",
42 TimeValue(TimeStep(0)),
45 return tid;
46}
47
48// \brief Application Constructor
53
54// \brief Application Destructor
59
60void
62{
63 NS_LOG_FUNCTION(this << start);
64 m_startTime = start;
65}
66
67void
69{
70 NS_LOG_FUNCTION(this << stop);
71 m_stopTime = stop;
72}
73
74void
83
84void
95
98{
99 NS_LOG_FUNCTION(this);
100 return m_node;
101}
102
103void
105{
106 NS_LOG_FUNCTION(this);
107 m_node = node;
108}
109
110// Protected methods
111// StartApp and StopApp will likely be overridden by application subclasses
112void
114{ // Provide null functionality in case subclass is not interested
115 NS_LOG_FUNCTION(this);
116}
117
118void
120{ // Provide null functionality in case subclass is not interested
121 NS_LOG_FUNCTION(this);
122}
123
124int64_t
126{
127 NS_LOG_FUNCTION(this << stream);
128 return 0;
129}
130
131} // namespace ns3
EventId m_startEvent
The event that will fire at m_startTime to start the application.
void DoInitialize() override
Initialize() implementation.
void SetNode(Ptr< Node > node)
void DoDispose() override
Destructor implementation.
Time m_startTime
The simulation time that the application will start.
Time m_stopTime
The simulation time that the application will end.
~Application() override
void SetStopTime(Time stop)
Specify application stop time.
virtual void StopApplication()
Application specific shutdown code.
virtual void StartApplication()
Application specific startup code.
void SetStartTime(Time start)
Specify application start time.
EventId m_stopEvent
The event that will fire at m_stopTime to end the application.
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this Application object.
static TypeId GetTypeId()
Get the type ID.
Ptr< Node > GetNode() const
Ptr< Node > m_node
The node that this application is installed on.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition event-id.cc:44
A base class which provides memory management and object aggregation.
Definition object.h:78
virtual void DoInitialize()
Initialize() implementation.
Definition object.cc:440
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition nstime.h:1396
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1416