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-helper.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 "
flow-monitor-helper.h
"
22
23
#include "ns3/flow-monitor.h"
24
#include "ns3/ipv4-flow-classifier.h"
25
#include "ns3/ipv4-flow-probe.h"
26
#include "ns3/ipv4-l3-protocol.h"
27
#include "ns3/node.h"
28
#include "ns3/node-list.h"
29
30
31
namespace
ns3 {
32
33
FlowMonitorHelper::FlowMonitorHelper
()
34
{
35
m_monitorFactory
.
SetTypeId
(
"ns3::FlowMonitor"
);
36
}
37
38
void
39
FlowMonitorHelper::SetMonitorAttribute
(std::string n1,
const
AttributeValue
&v1)
40
{
41
m_monitorFactory
.
Set
(n1, v1);
42
}
43
44
45
Ptr<FlowMonitor>
46
FlowMonitorHelper::GetMonitor
()
47
{
48
if
(!
m_flowMonitor
)
49
{
50
m_flowMonitor
=
m_monitorFactory
.
Create
<
FlowMonitor
> ();
51
m_flowClassifier
= Create<Ipv4FlowClassifier> ();
52
m_flowMonitor
->
SetFlowClassifier
(m_flowClassifier);
53
}
54
return
m_flowMonitor
;
55
}
56
57
58
Ptr<FlowClassifier>
59
FlowMonitorHelper::GetClassifier
()
60
{
61
if
(!
m_flowClassifier
)
62
{
63
m_flowClassifier
= Create<Ipv4FlowClassifier> ();
64
}
65
return
m_flowClassifier
;
66
}
67
68
69
Ptr<FlowMonitor>
70
FlowMonitorHelper::Install
(
Ptr<Node>
node)
71
{
72
Ptr<FlowMonitor>
monitor =
GetMonitor
();
73
Ptr<FlowClassifier>
classifier =
GetClassifier
();
74
Ptr<Ipv4FlowProbe>
probe = Create<Ipv4FlowProbe> (monitor,
75
DynamicCast<Ipv4FlowClassifier> (classifier),
76
node);
77
return
m_flowMonitor
;
78
}
79
80
81
Ptr<FlowMonitor>
82
FlowMonitorHelper::Install
(
NodeContainer
nodes)
83
{
84
for
(
NodeContainer::Iterator
i = nodes.
Begin
(); i != nodes.
End
(); ++i)
85
{
86
Ptr<Node>
node = *i;
87
if
(node->
GetObject
<
Ipv4L3Protocol
> ())
88
{
89
Install
(node);
90
}
91
}
92
return
m_flowMonitor
;
93
}
94
95
Ptr<FlowMonitor>
96
FlowMonitorHelper::InstallAll
()
97
{
98
for
(
NodeList::Iterator
i =
NodeList::Begin
(); i !=
NodeList::End
(); ++i)
99
{
100
Ptr<Node>
node = *i;
101
if
(node->
GetObject
<
Ipv4L3Protocol
> ())
102
{
103
Install
(node);
104
}
105
}
106
return
m_flowMonitor
;
107
}
108
109
110
}
// namespace ns3
src
flow-monitor
helper
flow-monitor-helper.cc
Generated on Tue Oct 9 2012 16:45:37 for ns-3 by
1.8.1.2