A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
application.cc
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2006 Georgia Tech Research Corporation
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: George F. Riley<riley@ece.gatech.edu>
19
*/
20
21
// Implementation for ns3 Application base class.
22
// George F. Riley, Georgia Tech, Fall 2006
23
24
#include "application.h"
25
#include "ns3/log.h"
26
#include "ns3/node.h"
27
#include "ns3/nstime.h"
28
#include "ns3/simulator.h"
29
30
NS_LOG_COMPONENT_DEFINE
(
"Application"
);
31
32
namespace
ns3 {
33
34
NS_OBJECT_ENSURE_REGISTERED (Application);
35
36
// Application Methods
37
38
TypeId
39
Application::GetTypeId (
void
)
40
{
41
static
TypeId tid = TypeId (
"ns3::Application"
)
42
.SetParent<Object> ()
43
.AddAttribute (
"StartTime"
,
"Time at which the application will start"
,
44
TimeValue (
Seconds
(0.0)),
45
MakeTimeAccessor (&Application::m_startTime),
46
MakeTimeChecker ())
47
.AddAttribute (
"StopTime"
,
"Time at which the application will stop"
,
48
TimeValue (TimeStep (0)),
49
MakeTimeAccessor (&Application::m_stopTime),
50
MakeTimeChecker ())
51
;
52
return
tid;
53
}
54
55
// \brief Application Constructor
56
Application::Application()
57
{
58
NS_LOG_FUNCTION
(
this
);
59
}
60
61
// \brief Application Destructor
62
Application::~Application()
63
{
64
NS_LOG_FUNCTION
(
this
);
65
}
66
67
void
68
Application::SetStartTime
(
Time
start)
69
{
70
NS_LOG_FUNCTION
(
this
<< start);
71
m_startTime = start;
72
}
73
void
74
Application::SetStopTime
(
Time
stop)
75
{
76
NS_LOG_FUNCTION
(
this
<< stop);
77
m_stopTime = stop;
78
}
79
80
81
void
82
Application::DoDispose
(
void
)
83
{
84
NS_LOG_FUNCTION
(
this
);
85
m_node = 0;
86
m_startEvent.
Cancel
();
87
m_stopEvent.
Cancel
();
88
Object::DoDispose
();
89
}
90
91
void
92
Application::DoInitialize
(
void
)
93
{
94
NS_LOG_FUNCTION
(
this
);
95
m_startEvent =
Simulator::Schedule
(m_startTime, &
Application::StartApplication
,
this
);
96
if
(m_stopTime != TimeStep (0))
97
{
98
m_stopEvent =
Simulator::Schedule
(m_stopTime, &
Application::StopApplication
,
this
);
99
}
100
Object::DoInitialize
();
101
}
102
103
Ptr<Node>
Application::GetNode
()
const
104
{
105
NS_LOG_FUNCTION
(
this
);
106
return
m_node;
107
}
108
109
void
110
Application::SetNode
(
Ptr<Node>
node)
111
{
112
NS_LOG_FUNCTION
(
this
);
113
m_node = node;
114
}
115
116
// Protected methods
117
// StartApp and StopApp will likely be overridden by application subclasses
118
void
Application::StartApplication
()
119
{
// Provide null functionality in case subclass is not interested
120
NS_LOG_FUNCTION
(
this
);
121
}
122
123
void
Application::StopApplication
()
124
{
// Provide null functionality in case subclass is not interested
125
NS_LOG_FUNCTION
(
this
);
126
}
127
128
}
// namespace ns3
129
130
ns3::Application::SetStopTime
void SetStopTime(Time stop)
Specify application stop time.
Definition:
application.cc:74
ns3::Time
keep track of time unit.
Definition:
nstime.h:149
ns3::Ptr< Node >
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:311
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Definition:
log.h:122
ns3::Object::DoDispose
virtual void DoDispose(void)
Definition:
object.cc:335
ns3::Simulator::Schedule
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Definition:
simulator.h:820
ns3::Application::DoInitialize
virtual void DoInitialize(void)
Definition:
application.cc:92
ns3::Application::StartApplication
virtual void StartApplication(void)
Application specific startup code.
Definition:
application.cc:118
ns3::Application::GetNode
Ptr< Node > GetNode() const
Definition:
application.cc:103
ns3::Application::DoDispose
virtual void DoDispose(void)
Definition:
application.cc:82
ns3::Application::SetNode
void SetNode(Ptr< Node > node)
Definition:
application.cc:110
ns3::Application::StopApplication
virtual void StopApplication(void)
Application specific shutdown code.
Definition:
application.cc:123
ns3::Seconds
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Definition:
nstime.h:586
ns3::EventId::Cancel
void Cancel(void)
Definition:
event-id.cc:47
ns3::Application::SetStartTime
void SetStartTime(Time start)
Specify application start time.
Definition:
application.cc:68
ns3::Object::DoInitialize
virtual void DoInitialize(void)
Definition:
object.cc:342
src
network
model
application.cc
Generated on Sun Mar 16 2014 11:25:09 for ns-3 by
1.8.6