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 * 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 "node.h"
26
27#include "ns3/log.h"
28#include "ns3/nstime.h"
29#include "ns3/simulator.h"
30
31namespace ns3
32{
33
34NS_LOG_COMPONENT_DEFINE("Application");
35
37
38// Application Methods
39
40TypeId
42{
43 static TypeId tid = TypeId("ns3::Application")
45 .SetGroupName("Network")
46 .AddAttribute("StartTime",
47 "Time at which the application will start",
48 TimeValue(Seconds(0.0)),
51 .AddAttribute("StopTime",
52 "Time at which the application will stop",
53 TimeValue(TimeStep(0)),
56 return tid;
57}
58
59// \brief Application Constructor
61{
62 NS_LOG_FUNCTION(this);
63}
64
65// \brief Application Destructor
67{
68 NS_LOG_FUNCTION(this);
69}
70
71void
73{
74 NS_LOG_FUNCTION(this << start);
75 m_startTime = start;
76}
77
78void
80{
81 NS_LOG_FUNCTION(this << stop);
82 m_stopTime = stop;
83}
84
85void
87{
88 NS_LOG_FUNCTION(this);
89 m_node = nullptr;
93}
94
95void
97{
98 NS_LOG_FUNCTION(this);
100 if (m_stopTime != TimeStep(0))
101 {
103 }
105}
106
109{
110 NS_LOG_FUNCTION(this);
111 return m_node;
112}
113
114void
116{
117 NS_LOG_FUNCTION(this);
118 m_node = node;
119}
120
121// Protected methods
122// StartApp and StopApp will likely be overridden by application subclasses
123void
125{ // Provide null functionality in case subclass is not interested
126 NS_LOG_FUNCTION(this);
127}
128
129void
131{ // Provide null functionality in case subclass is not interested
132 NS_LOG_FUNCTION(this);
133}
134
135int64_t
137{
138 NS_LOG_FUNCTION(this << stream);
139 return 0;
140}
141
142} // namespace ns3
EventId m_startEvent
The event that will fire at m_startTime to start the application.
Definition: application.h:161
void DoInitialize() override
Initialize() implementation.
Definition: application.cc:96
void SetNode(Ptr< Node > node)
Definition: application.cc:115
void DoDispose() override
Destructor implementation.
Definition: application.cc:86
Time m_startTime
The simulation time that the application will start.
Definition: application.h:159
Time m_stopTime
The simulation time that the application will end.
Definition: application.h:160
~Application() override
Definition: application.cc:66
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:79
virtual void StopApplication()
Application specific shutdown code.
Definition: application.cc:130
virtual void StartApplication()
Application specific startup code.
Definition: application.cc:124
void SetStartTime(Time start)
Specify application start time.
Definition: application.cc:72
EventId m_stopEvent
The event that will fire at m_stopTime to end the application.
Definition: application.h:162
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this Application object.
Definition: application.cc:136
static TypeId GetTypeId()
Get the type ID.
Definition: application.cc:41
Ptr< Node > GetNode() const
Definition: application.cc:108
Ptr< Node > m_node
The node that this application is installed on.
Definition: application.h:158
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:451
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:444
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
AttributeValue implementation for Time.
Definition: nstime.h:1413
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition: nstime.h:1434
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1414
#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:46
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
Every class exported by the ns3 library is enclosed in the ns3 namespace.