A Discrete-Event Network Simulator
API
application.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006 Georgia Tech Research Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: George F. Riley<riley@ece.gatech.edu>
18 */
19
20// Implementation for ns3 Application base class.
21// George F. Riley, Georgia Tech, Fall 2006
22
23#include "application.h"
24
25#include "ns3/log.h"
26#include "ns3/node.h"
27#include "ns3/nstime.h"
28#include "ns3/simulator.h"
29
30namespace ns3
31{
32
33NS_LOG_COMPONENT_DEFINE("Application");
34
36
37// Application Methods
38
39TypeId
41{
42 static TypeId tid = TypeId("ns3::Application")
44 .SetGroupName("Network")
45 .AddAttribute("StartTime",
46 "Time at which the application will start",
47 TimeValue(Seconds(0.0)),
50 .AddAttribute("StopTime",
51 "Time at which the application will stop",
52 TimeValue(TimeStep(0)),
55 return tid;
56}
57
58// \brief Application Constructor
60{
61 NS_LOG_FUNCTION(this);
62}
63
64// \brief Application Destructor
66{
67 NS_LOG_FUNCTION(this);
68}
69
70void
72{
73 NS_LOG_FUNCTION(this << start);
75}
76
77void
79{
80 NS_LOG_FUNCTION(this << stop);
81 m_stopTime = stop;
82}
83
84void
86{
87 NS_LOG_FUNCTION(this);
88 m_node = nullptr;
92}
93
94void
96{
97 NS_LOG_FUNCTION(this);
99 if (m_stopTime != TimeStep(0))
100 {
102 }
104}
105
108{
109 NS_LOG_FUNCTION(this);
110 return m_node;
111}
112
113void
115{
116 NS_LOG_FUNCTION(this);
117 m_node = node;
118}
119
120// Protected methods
121// StartApp and StopApp will likely be overridden by application subclasses
122void
124{ // Provide null functionality in case subclass is not interested
125 NS_LOG_FUNCTION(this);
126}
127
128void
130{ // Provide null functionality in case subclass is not interested
131 NS_LOG_FUNCTION(this);
132}
133
134} // namespace ns3
EventId m_startEvent
The event that will fire at m_startTime to start the application.
Definition: application.h:151
void DoInitialize() override
Initialize() implementation.
Definition: application.cc:95
void SetNode(Ptr< Node > node)
Definition: application.cc:114
void DoDispose() override
Destructor implementation.
Definition: application.cc:85
Time m_startTime
The simulation time that the application will start.
Definition: application.h:149
Time m_stopTime
The simulation time that the application will end.
Definition: application.h:150
~Application() override
Definition: application.cc:65
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:78
virtual void StopApplication()
Application specific shutdown code.
Definition: application.cc:129
virtual void StartApplication()
Application specific startup code.
Definition: application.cc:123
void SetStartTime(Time start)
Specify application start time.
Definition: application.cc:71
EventId m_stopEvent
The event that will fire at m_stopTime to end the application.
Definition: application.h:152
static TypeId GetTypeId()
Get the type ID.
Definition: application.cc:40
Ptr< Node > GetNode() const
Definition: application.cc:107
Ptr< Node > m_node
The node that this application is installed on.
Definition: application.h:148
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:55
A base class which provides memory management and object aggregation.
Definition: object.h:89
virtual void DoInitialize()
Initialize() implementation.
Definition: object.cc:360
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:353
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:568
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
AttributeValue implementation for Time.
Definition: nstime.h:1425
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1426
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:45
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:535
def start()
Definition: core.py:1861