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
FlowMonitorHelper::~FlowMonitorHelper
()
39
{
40
if
(
m_flowMonitor
)
41
{
42
m_flowMonitor
->Dispose ();
43
m_flowMonitor
= 0;
44
m_flowClassifier
= 0;
45
}
46
}
47
48
void
49
FlowMonitorHelper::SetMonitorAttribute
(std::string n1,
const
AttributeValue
&v1)
50
{
51
m_monitorFactory
.
Set
(n1, v1);
52
}
53
54
55
Ptr<FlowMonitor>
56
FlowMonitorHelper::GetMonitor
()
57
{
58
if
(!
m_flowMonitor
)
59
{
60
m_flowMonitor
=
m_monitorFactory
.
Create
<
FlowMonitor
> ();
61
m_flowClassifier
= Create<Ipv4FlowClassifier> ();
62
m_flowMonitor
->SetFlowClassifier (m_flowClassifier);
63
}
64
return
m_flowMonitor
;
65
}
66
67
68
Ptr<FlowClassifier>
69
FlowMonitorHelper::GetClassifier
()
70
{
71
if
(!
m_flowClassifier
)
72
{
73
m_flowClassifier
= Create<Ipv4FlowClassifier> ();
74
}
75
return
m_flowClassifier
;
76
}
77
78
79
Ptr<FlowMonitor>
80
FlowMonitorHelper::Install
(
Ptr<Node>
node)
81
{
82
Ptr<FlowMonitor>
monitor =
GetMonitor
();
83
Ptr<FlowClassifier>
classifier =
GetClassifier
();
84
Ptr<Ipv4FlowProbe>
probe = Create<Ipv4FlowProbe> (monitor,
85
DynamicCast<Ipv4FlowClassifier> (classifier),
86
node);
87
return
m_flowMonitor
;
88
}
89
90
91
Ptr<FlowMonitor>
92
FlowMonitorHelper::Install
(
NodeContainer
nodes
)
93
{
94
for
(
NodeContainer::Iterator
i = nodes.
Begin
(); i != nodes.
End
(); ++i)
95
{
96
Ptr<Node>
node = *i;
97
if
(node->
GetObject
<
Ipv4L3Protocol
> ())
98
{
99
Install
(node);
100
}
101
}
102
return
m_flowMonitor
;
103
}
104
105
Ptr<FlowMonitor>
106
FlowMonitorHelper::InstallAll
()
107
{
108
for
(
NodeList::Iterator
i =
NodeList::Begin
(); i !=
NodeList::End
(); ++i)
109
{
110
Ptr<Node>
node = *i;
111
if
(node->
GetObject
<
Ipv4L3Protocol
> ())
112
{
113
Install
(node);
114
}
115
}
116
return
m_flowMonitor
;
117
}
118
119
120
}
// namespace ns3
ns3::FlowMonitorHelper::m_monitorFactory
ObjectFactory m_monitorFactory
Object factory.
Definition:
flow-monitor-helper.h:83
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
ns3::NodeContainer::Iterator
std::vector< Ptr< Node > >::const_iterator Iterator
Definition:
node-container.h:41
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:56
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Definition:
object-factory.cc:41
ns3::NodeContainer::End
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
Definition:
node-container.cc:77
flow-monitor-helper.h
ns3::FlowMonitorHelper::GetMonitor
Ptr< FlowMonitor > GetMonitor()
Retrieve the FlowMonitor object created by the Install* methods.
Definition:
flow-monitor-helper.cc:56
ns3::FlowMonitorHelper::Install
Ptr< FlowMonitor > Install(NodeContainer nodes)
Enable flow monitoring on a set of nodes.
Definition:
flow-monitor-helper.cc:92
first.nodes
tuple nodes
Definition:
first.py:25
ns3::ObjectFactory::Create
Ptr< Object > Create(void) const
Definition:
object-factory.cc:90
ns3::NodeList::End
static Iterator End(void)
Definition:
node-list.cc:188
ns3::FlowMonitorHelper::InstallAll
Ptr< FlowMonitor > InstallAll()
Enable flow monitoring on all nodes.
Definition:
flow-monitor-helper.cc:106
ns3::FlowMonitorHelper::SetMonitorAttribute
void SetMonitorAttribute(std::string n1, const AttributeValue &v1)
Set an attribute for the to-be-created FlowMonitor object.
Definition:
flow-monitor-helper.cc:49
ns3::FlowMonitorHelper::GetClassifier
Ptr< FlowClassifier > GetClassifier()
Retrieve the FlowClassifier object created by the Install* methods.
Definition:
flow-monitor-helper.cc:69
ns3::Ipv4L3Protocol
Implement the Ipv4 layer.
Definition:
ipv4-l3-protocol.h:77
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:38
ns3::NodeList::Iterator
std::vector< Ptr< Node > >::const_iterator Iterator
Definition:
node-list.h:43
ns3::NodeContainer::Begin
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
Definition:
node-container.cc:72
ns3::ObjectFactory::Set
void Set(std::string name, const AttributeValue &value)
Definition:
object-factory.cc:59
ns3::FlowMonitorHelper::FlowMonitorHelper
FlowMonitorHelper()
Definition:
flow-monitor-helper.cc:33
ns3::FlowMonitorHelper::m_flowClassifier
Ptr< FlowClassifier > m_flowClassifier
the FlowClassifier object
Definition:
flow-monitor-helper.h:85
ns3::FlowMonitorHelper::~FlowMonitorHelper
~FlowMonitorHelper()
Definition:
flow-monitor-helper.cc:38
ns3::NodeList::Begin
static Iterator Begin(void)
Definition:
node-list.cc:182
ns3::FlowMonitorHelper::m_flowMonitor
Ptr< FlowMonitor > m_flowMonitor
the FlowMonitor object
Definition:
flow-monitor-helper.h:84
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Definition:
object.h:361
ns3::FlowMonitor
An object that monitors and reports back packet flows observed during a simulation.
Definition:
flow-monitor.h:50
src
flow-monitor
helper
flow-monitor-helper.cc
Generated on Sat Apr 19 2014 14:06:55 for ns-3 by
1.8.6