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::AddPacketStats
(
FlowId
flowId, uint32_t packetSize,
Time
delayFromFirstProbe)
40
{
41
FlowStats
&flow =
m_stats
[flowId];
42
flow.
delayFromFirstProbeSum
+= delayFromFirstProbe;
43
flow.
bytes
+= packetSize;
44
++flow.
packets
;
45
}
46
47
void
48
FlowProbe::AddPacketDropStats
(
FlowId
flowId, uint32_t packetSize, uint32_t reasonCode)
49
{
50
FlowStats
&flow =
m_stats
[flowId];
51
52
if
(flow.
packetsDropped
.size () < reasonCode + 1)
53
{
54
flow.
packetsDropped
.resize (reasonCode + 1, 0);
55
flow.
bytesDropped
.resize (reasonCode + 1, 0);
56
}
57
++flow.
packetsDropped
[reasonCode];
58
flow.
bytesDropped
[reasonCode] += packetSize;
59
}
60
61
FlowProbe::Stats
62
FlowProbe::GetStats
()
const
63
{
64
return
m_stats
;
65
}
66
67
void
68
FlowProbe::SerializeToXmlStream
(std::ostream &os,
int
indent
, uint32_t index)
const
69
{
70
#define INDENT(level) for (int __xpto = 0; __xpto < level; __xpto++) os << ' ';
71
72
INDENT
(indent); os <<
"<FlowProbe index=\""
<< index <<
"\">\n"
;
73
74
indent += 2;
75
76
for
(Stats::const_iterator iter =
m_stats
.begin (); iter !=
m_stats
.end (); iter++)
77
{
78
INDENT
(indent);
79
os <<
"<FlowStats "
80
<<
" flowId=\""
<< iter->first <<
"\""
81
<<
" packets=\""
<< iter->second.packets <<
"\""
82
<<
" bytes=\""
<< iter->second.bytes <<
"\""
83
<<
" delayFromFirstProbeSum=\""
<< iter->second.delayFromFirstProbeSum <<
"\""
84
<<
" >\n"
;
85
indent += 2;
86
for
(uint32_t reasonCode = 0; reasonCode < iter->second.packetsDropped.size (); reasonCode++)
87
{
88
INDENT
(indent);
89
os <<
"<packetsDropped reasonCode=\""
<< reasonCode <<
"\""
90
<<
" number=\""
<< iter->second.packetsDropped[reasonCode]
91
<<
"\" />\n"
;
92
}
93
for
(uint32_t reasonCode = 0; reasonCode < iter->second.bytesDropped.size (); reasonCode++)
94
{
95
INDENT
(indent);
96
os <<
"<bytesDropped reasonCode=\""
<< reasonCode <<
"\""
97
<<
" bytes=\""
<< iter->second.bytesDropped[reasonCode]
98
<<
"\" />\n"
;
99
}
100
indent -= 2;
101
INDENT
(indent); os <<
"</FlowStats>\n"
;
102
}
103
indent -= 2;
104
INDENT
(indent); os <<
"</FlowProbe>\n"
;
105
}
106
107
108
109
}
// namespace ns3
110
111
src
flow-monitor
model
flow-probe.cc
Generated on Tue Nov 13 2012 10:32:13 for ns-3 by
1.8.1.2