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
queue.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007 University of Washington
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
19
// The queue base class does not have any limit based on the number
20
// of packets or number of bytes. It is, conceptually, infinite
21
// by default. Only subclasses define limitations.
22
// The base class implements tracing and basic statistics calculations.
23
24
#ifndef QUEUE_H
25
#define QUEUE_H
26
27
#include <string>
28
#include <list>
29
#include "ns3/packet.h"
30
#include "ns3/object.h"
31
#include "ns3/traced-callback.h"
32
33
namespace
ns3 {
34
45
class
Queue
:
public
Object
46
{
47
public
:
48
static
TypeId
GetTypeId
(
void
);
49
50
Queue
();
51
virtual
~Queue
();
52
56
bool
IsEmpty
(
void
)
const
;
62
bool
Enqueue
(
Ptr<Packet>
p);
67
Ptr<Packet>
Dequeue
(
void
);
72
Ptr<const Packet>
Peek
(
void
)
const
;
73
77
void
DequeueAll
(
void
);
81
uint32_t
GetNPackets
(
void
)
const
;
85
uint32_t
GetNBytes
(
void
)
const
;
86
93
uint32_t
GetTotalReceivedBytes
(
void
)
const
;
99
uint32_t
GetTotalReceivedPackets
(
void
)
const
;
105
uint32_t
GetTotalDroppedBytes
(
void
)
const
;
111
uint32_t
GetTotalDroppedPackets
(
void
)
const
;
116
void
ResetStatistics
(
void
);
117
122
enum
QueueMode
123
{
124
QUEUE_MODE_PACKETS
,
125
QUEUE_MODE_BYTES
,
126
};
127
128
#if 0
129
// average calculation requires keeping around
130
// a buffer with the date of arrival of past received packets
131
// which are within the average window
132
// so, it is quite costly to do it all the time.
133
// Hence, it is disabled by default and must be explicitely
134
// enabled with this method which specifies the size
135
// of the average window in time units.
136
void
EnableRunningAverage (
Time
averageWindow);
137
void
DisableRunningAverage (
void
);
138
// average
139
double
GetQueueSizeAverage (
void
);
140
double
GetReceivedBytesPerSecondAverage (
void
);
141
double
GetReceivedPacketsPerSecondAverage (
void
);
142
double
GetDroppedBytesPerSecondAverage (
void
);
143
double
GetDroppedPacketsPerSecondAverage (
void
);
144
// variance
145
double
GetQueueSizeVariance (
void
);
146
double
GetReceivedBytesPerSecondVariance (
void
);
147
double
GetReceivedPacketsPerSecondVariance (
void
);
148
double
GetDroppedBytesPerSecondVariance (
void
);
149
double
GetDroppedPacketsPerSecondVariance (
void
);
150
#endif
151
152
private
:
153
154
virtual
bool
DoEnqueue
(
Ptr<Packet>
p) = 0;
155
virtual
Ptr<Packet>
DoDequeue
(
void
) = 0;
156
virtual
Ptr<const Packet>
DoPeek
(
void
)
const
= 0;
157
158
protected
:
159
// called by subclasses to notify parent of packet drops.
160
void
Drop
(
Ptr<Packet>
packet);
161
162
private
:
163
TracedCallback<Ptr<const Packet>
>
m_traceEnqueue
;
164
TracedCallback<Ptr<const Packet>
>
m_traceDequeue
;
165
TracedCallback<Ptr<const Packet>
>
m_traceDrop
;
166
167
uint32_t
m_nBytes
;
168
uint32_t
m_nTotalReceivedBytes
;
169
uint32_t
m_nPackets
;
170
uint32_t
m_nTotalReceivedPackets
;
171
uint32_t
m_nTotalDroppedBytes
;
172
uint32_t
m_nTotalDroppedPackets
;
173
};
174
175
}
// namespace ns3
176
177
#endif
/* QUEUE_H */
src
network
utils
queue.h
Generated on Fri Dec 21 2012 19:00:44 for ns-3 by
1.8.1.2