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
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
onoff-application.h
Go to the documentation of this file.
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
// ns3 - On/Off Data Source Application class
22
// George F. Riley, Georgia Tech, Spring 2007
23
// Adapted from ApplicationOnOff in GTNetS.
24
25
#ifndef ONOFF_APPLICATION_H
26
#define ONOFF_APPLICATION_H
27
28
#include "ns3/address.h"
29
#include "ns3/application.h"
30
#include "ns3/event-id.h"
31
#include "ns3/ptr.h"
32
#include "ns3/data-rate.h"
33
#include "ns3/traced-callback.h"
34
35
namespace
ns3 {
36
37
class
Address;
38
class
RandomVariableStream;
39
class
Socket;
40
86
class
OnOffApplication
:
public
Application
87
{
88
public
:
89
static
TypeId
GetTypeId
(
void
);
90
91
OnOffApplication
();
92
93
virtual
~OnOffApplication
();
94
102
void
SetMaxBytes
(uint32_t maxBytes);
103
107
Ptr<Socket>
GetSocket
(
void
)
const
;
108
117
int64_t
AssignStreams
(int64_t stream);
118
119
protected
:
120
virtual
void
DoDispose
(
void
);
121
private
:
122
// inherited from Application base class.
123
virtual
void
StartApplication
(
void
);
// Called at time specified by Start
124
virtual
void
StopApplication
(
void
);
// Called at time specified by Stop
125
126
//helpers
127
void
CancelEvents
();
128
129
void
Construct
(
Ptr<Node>
n,
130
const
Address
&remote,
131
std::string tid,
132
const
RandomVariable
& ontime,
133
const
RandomVariable
& offtime,
134
uint32_t size);
135
136
137
// Event handlers
138
void
StartSending
();
139
void
StopSending
();
140
void
SendPacket
();
141
142
Ptr<Socket>
m_socket
;
// Associated socket
143
Address
m_peer
;
// Peer address
144
bool
m_connected
;
// True if connected
145
Ptr<RandomVariableStream>
m_onTime
;
// rng for On Time
146
Ptr<RandomVariableStream>
m_offTime
;
// rng for Off Time
147
DataRate
m_cbrRate
;
// Rate that data is generated
148
uint32_t
m_pktSize
;
// Size of packets
149
uint32_t
m_residualBits
;
// Number of generated, but not sent, bits
150
Time
m_lastStartTime
;
// Time last packet sent
151
uint32_t
m_maxBytes
;
// Limit total number of bytes sent
152
uint32_t
m_totBytes
;
// Total bytes sent so far
153
EventId
m_startStopEvent
;
// Event id for next start or stop event
154
EventId
m_sendEvent
;
// Eventid of pending "send packet" event
155
bool
m_sending
;
// True if currently in sending state
156
TypeId
m_tid
;
157
TracedCallback<Ptr<const Packet>
>
m_txTrace
;
158
159
private
:
160
void
ScheduleNextTx
();
161
void
ScheduleStartEvent
();
162
void
ScheduleStopEvent
();
163
void
ConnectionSucceeded
(
Ptr<Socket>
socket);
164
void
ConnectionFailed
(
Ptr<Socket>
socket);
165
};
166
167
}
// namespace ns3
168
169
#endif
/* ONOFF_APPLICATION_H */
src
applications
model
onoff-application.h
Generated on Tue May 14 2013 11:08:16 for ns-3 by
1.8.1.2