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-probe.cc
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
#include "ns3/flow-probe.h"
22
#include "ns3/flow-monitor.h"
23
24
namespace
ns3 {
25
26
27
FlowProbe::~FlowProbe
()
28
{
29
}
30
31
32
FlowProbe::FlowProbe
(
Ptr<FlowMonitor>
flowMonitor)
33
: m_flowMonitor (flowMonitor)
34
{
35
m_flowMonitor
->
AddProbe
(
this
);
36
}
37
38
void
39
FlowProbe::DoDispose
(
void
)
40
{
41
m_flowMonitor
= 0;
42
Object::DoDispose
();
43
}
44
45
void
46
FlowProbe::AddPacketStats
(
FlowId
flowId, uint32_t packetSize,
Time
delayFromFirstProbe)
47
{
48
FlowStats
&flow =
m_stats
[flowId];
49
flow.
delayFromFirstProbeSum
+= delayFromFirstProbe;
50
flow.
bytes
+= packetSize;
51
++flow.
packets
;
52
}
53
54
void
55
FlowProbe::AddPacketDropStats
(
FlowId
flowId, uint32_t packetSize, uint32_t reasonCode)
56
{
57
FlowStats
&flow =
m_stats
[flowId];
58
59
if
(flow.
packetsDropped
.size () < reasonCode + 1)
60
{
61
flow.
packetsDropped
.resize (reasonCode + 1, 0);
62
flow.
bytesDropped
.resize (reasonCode + 1, 0);
63
}
64
++flow.
packetsDropped
[reasonCode];
65
flow.
bytesDropped
[reasonCode] += packetSize;
66
}
67
68
FlowProbe::Stats
69
FlowProbe::GetStats
()
const
70
{
71
return
m_stats
;
72
}
73
74
void
75
FlowProbe::SerializeToXmlStream
(std::ostream &os,
int
indent
, uint32_t index)
const
76
{
77
#define INDENT(level) for (int __xpto = 0; __xpto < level; __xpto++) os << ' ';
78
79
INDENT
(indent); os <<
"<FlowProbe index=\""
<< index <<
"\">\n"
;
80
81
indent += 2;
82
83
for
(Stats::const_iterator iter =
m_stats
.begin (); iter !=
m_stats
.end (); iter++)
84
{
85
INDENT
(indent);
86
os <<
"<FlowStats "
87
<<
" flowId=\""
<< iter->first <<
"\""
88
<<
" packets=\""
<< iter->second.packets <<
"\""
89
<<
" bytes=\""
<< iter->second.bytes <<
"\""
90
<<
" delayFromFirstProbeSum=\""
<< iter->second.delayFromFirstProbeSum <<
"\""
91
<<
" >\n"
;
92
indent += 2;
93
for
(uint32_t reasonCode = 0; reasonCode < iter->second.packetsDropped.size (); reasonCode++)
94
{
95
INDENT
(indent);
96
os <<
"<packetsDropped reasonCode=\""
<< reasonCode <<
"\""
97
<<
" number=\""
<< iter->second.packetsDropped[reasonCode]
98
<<
"\" />\n"
;
99
}
100
for
(uint32_t reasonCode = 0; reasonCode < iter->second.bytesDropped.size (); reasonCode++)
101
{
102
INDENT
(indent);
103
os <<
"<bytesDropped reasonCode=\""
<< reasonCode <<
"\""
104
<<
" bytes=\""
<< iter->second.bytesDropped[reasonCode]
105
<<
"\" />\n"
;
106
}
107
indent -= 2;
108
INDENT
(indent); os <<
"</FlowStats>\n"
;
109
}
110
indent -= 2;
111
INDENT
(indent); os <<
"</FlowProbe>\n"
;
112
}
113
114
115
116
}
// namespace ns3
117
118
src
flow-monitor
model
flow-probe.cc
Generated on Tue May 14 2013 11:08:21 for ns-3 by
1.8.1.2