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
flow-monitor.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
//
3
// Copyright (c) 2009 INESC Porto
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: Gustavo J. A. M. Carneiro <gjc@inescporto.pt> <gjcarneiro@gmail.com>
19
//
20
21
#ifndef FLOW_MONITOR_H
22
#define FLOW_MONITOR_H
23
24
#include <vector>
25
#include <map>
26
27
#include "ns3/ptr.h"
28
#include "ns3/object.h"
29
#include "ns3/flow-probe.h"
30
#include "ns3/flow-classifier.h"
31
#include "ns3/histogram.h"
32
#include "ns3/nstime.h"
33
#include "ns3/event-id.h"
34
35
namespace
ns3 {
36
41
class
FlowMonitor
:
public
Object
42
{
43
public
:
44
46
struct
FlowStats
47
{
51
Time
timeFirstTxPacket
;
52
56
Time
timeFirstRxPacket
;
57
61
Time
timeLastTxPacket
;
62
65
Time
timeLastRxPacket
;
66
69
Time
delaySum
;
// delayCount == rxPackets
70
78
Time
jitterSum
;
// jitterCount == rxPackets - 1
79
80
Time
lastDelay
;
81
83
uint64_t
txBytes
;
85
uint64_t
rxBytes
;
87
uint32_t
txPackets
;
89
uint32_t
rxPackets
;
90
96
uint32_t
lostPackets
;
97
100
uint32_t
timesForwarded
;
101
103
Histogram
delayHistogram
;
105
Histogram
jitterHistogram
;
107
Histogram
packetSizeHistogram
;
108
121
std::vector<uint32_t>
packetsDropped
;
// packetsDropped[reasonCode] => number of dropped packets
122
125
std::vector<uint64_t>
bytesDropped
;
// bytesDropped[reasonCode] => number of dropped bytes
126
Histogram
flowInterruptionsHistogram
;
// histogram of durations of flow interruptions
127
};
128
129
// --- basic methods ---
130
static
TypeId
GetTypeId
();
131
TypeId
GetInstanceTypeId
()
const
;
132
FlowMonitor
();
133
135
void
SetFlowClassifier
(
Ptr<FlowClassifier>
classifier);
136
138
void
Start
(
const
Time
&time);
140
void
Stop
(
const
Time
&time);
142
void
StartRightNow
();
144
void
StopRightNow
();
145
146
// --- methods to be used by the FlowMonitorProbe's only ---
150
void
AddProbe
(
Ptr<FlowProbe>
probe);
151
156
void
ReportFirstTx
(
Ptr<FlowProbe>
probe,
FlowId
flowId,
FlowPacketId
packetId, uint32_t packetSize);
159
void
ReportForwarding
(
Ptr<FlowProbe>
probe,
FlowId
flowId,
FlowPacketId
packetId, uint32_t packetSize);
162
void
ReportLastRx
(
Ptr<FlowProbe>
probe,
FlowId
flowId,
FlowPacketId
packetId, uint32_t packetSize);
165
void
ReportDrop
(
Ptr<FlowProbe>
probe,
FlowId
flowId,
FlowPacketId
packetId,
166
uint32_t packetSize, uint32_t reasonCode);
167
169
void
CheckForLostPackets
();
170
174
void
CheckForLostPackets
(
Time
maxDelay);
175
176
// --- methods to get the results ---
181
std::map<FlowId, FlowStats>
GetFlowStats
()
const
;
182
184
std::vector< Ptr<FlowProbe> >
GetAllProbes
()
const
;
185
191
void
SerializeToXmlStream
(std::ostream &os,
int
indent
,
bool
enableHistograms,
bool
enableProbes);
197
std::string
SerializeToXmlString
(
int
indent
,
bool
enableHistograms,
bool
enableProbes);
202
void
SerializeToXmlFile
(std::string fileName,
bool
enableHistograms,
bool
enableProbes);
203
204
205
protected
:
206
207
virtual
void
NotifyConstructionCompleted
();
208
209
private
:
210
211
struct
TrackedPacket
212
{
213
Time
firstSeenTime
;
// absolute time when the packet was first seen by a probe
214
Time
lastSeenTime
;
// absolute time when the packet was last seen by a probe
215
uint32_t
timesForwarded
;
// number of times the packet was reportedly forwarded
216
};
217
218
// FlowId --> FlowStats
219
std::map<FlowId, FlowStats>
m_flowStats
;
220
221
// (FlowId,PacketId) --> TrackedPacket
222
typedef
std::map< std::pair<FlowId, FlowPacketId>,
TrackedPacket
>
TrackedPacketMap
;
223
TrackedPacketMap
m_trackedPackets
;
224
Time
m_maxPerHopDelay
;
225
std::vector< Ptr<FlowProbe> >
m_flowProbes
;
226
227
// note: this is needed only for serialization
228
Ptr<FlowClassifier>
m_classifier
;
229
230
EventId
m_startEvent
;
231
EventId
m_stopEvent
;
232
bool
m_enabled
;
233
double
m_delayBinWidth
;
234
double
m_jitterBinWidth
;
235
double
m_packetSizeBinWidth
;
236
double
m_flowInterruptionsBinWidth
;
237
Time
m_flowInterruptionsMinTime
;
238
239
FlowStats
&
GetStatsForFlow
(
FlowId
flowId);
240
void
PeriodicCheckForLostPackets
();
241
};
242
243
244
}
// namespace ns3
245
246
#endif
/* FLOW_MONITOR_H */
247
src
flow-monitor
model
flow-monitor.h
Generated on Tue Nov 13 2012 10:32:13 for ns-3 by
1.8.1.2