A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
service-flow-manager.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007,2008, 2009 INRIA, UDcast
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
* Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19
* Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
20
*/
21
22
#include <stdint.h>
23
#include "ns3/node.h"
24
#include "ns3/simulator.h"
25
#include "ns3/packet.h"
26
#include "
service-flow.h
"
27
#include "
service-flow-manager.h
"
28
#include "ns3/log.h"
29
#include "
wimax-net-device.h
"
30
#include "
bs-net-device.h
"
31
#include "
ss-net-device.h
"
32
#include "
ss-record.h
"
33
#include "ns3/pointer.h"
34
#include "ns3/enum.h"
35
#include "
wimax-connection.h
"
36
#include "
ss-manager.h
"
37
#include "
connection-manager.h
"
38
#include "
bs-uplink-scheduler.h
"
39
#include "
ss-scheduler.h
"
40
#include "ns3/buffer.h"
41
#include "
service-flow-record.h
"
42
43
namespace
ns3
{
44
45
NS_LOG_COMPONENT_DEFINE
(
"ServiceFlowManager"
);
46
47
NS_OBJECT_ENSURE_REGISTERED
(ServiceFlowManager);
48
49
TypeId
ServiceFlowManager::GetTypeId
(
void
)
50
{
51
static
TypeId
tid =
TypeId
(
"ns3::ServiceFlowManager"
)
52
.
SetParent
<
Object
> ()
53
.SetGroupName(
"Wimax"
);
54
return
tid;
55
}
56
57
ServiceFlowManager::ServiceFlowManager
()
58
{
59
m_serviceFlows
=
new
std::vector<ServiceFlow*>;
60
}
61
62
ServiceFlowManager::~ServiceFlowManager
(
void
)
63
{
64
}
65
66
void
67
ServiceFlowManager::DoDispose
(
void
)
68
{
69
for
(std::vector<ServiceFlow*>::iterator iter =
m_serviceFlows
->begin (); iter !=
m_serviceFlows
->end (); ++iter)
70
{
71
delete
(*iter);
72
}
73
m_serviceFlows
->clear ();
74
delete
m_serviceFlows
;
75
}
76
77
void
78
ServiceFlowManager::AddServiceFlow
(
ServiceFlow
*serviceFlow)
79
{
80
m_serviceFlows
->push_back (serviceFlow);
81
}
82
83
ServiceFlow
*
ServiceFlowManager::DoClassify
(
Ipv4Address
srcAddress,
84
Ipv4Address
dstAddress,
85
uint16_t srcPort,
86
uint16_t dstPort,
87
uint8_t proto,
88
ServiceFlow::Direction
dir
)
const
89
{
90
for
(std::vector<ServiceFlow*>::iterator iter =
m_serviceFlows
->begin (); iter !=
m_serviceFlows
->end (); ++iter)
91
{
92
if
((*iter)->GetDirection () ==
dir
)
93
{
94
if
((*iter)->CheckClassifierMatch (srcAddress, dstAddress, srcPort, dstPort, proto))
95
{
96
return
(*iter);
97
}
98
}
99
}
100
return
0;
101
}
102
103
ServiceFlow
*
104
ServiceFlowManager::GetServiceFlow
(uint32_t sfid)
const
105
{
106
for
(std::vector<ServiceFlow*>::iterator iter =
m_serviceFlows
->begin (); iter !=
m_serviceFlows
->end (); ++iter)
107
{
108
if
((*iter)->GetSfid () == sfid)
109
{
110
return
(*iter);
111
}
112
}
113
114
NS_LOG_DEBUG
(
"GetServiceFlow: service flow not found!"
);
115
return
0;
116
}
117
118
ServiceFlow
*
119
ServiceFlowManager::GetServiceFlow
(
Cid
cid)
const
120
{
121
for
(std::vector<ServiceFlow*>::iterator iter =
m_serviceFlows
->begin (); iter !=
m_serviceFlows
->end (); ++iter)
122
{
123
if
((*iter)->GetCid () == cid.
GetIdentifier
())
124
{
125
return
(*iter);
126
}
127
}
128
129
NS_LOG_DEBUG
(
"GetServiceFlow: service flow not found!"
);
130
return
0;
131
}
132
133
std::vector<ServiceFlow*>
134
ServiceFlowManager::GetServiceFlows
(
enum
ServiceFlow::SchedulingType
schedulingType)
const
135
{
136
std::vector<ServiceFlow*> tmpServiceFlows;
137
for
(std::vector<ServiceFlow*>::iterator iter =
m_serviceFlows
->begin (); iter !=
m_serviceFlows
->end (); ++iter)
138
{
139
if
(((*iter)->GetSchedulingType () == schedulingType) || (schedulingType ==
ServiceFlow::SF_TYPE_ALL
))
140
{
141
tmpServiceFlows.push_back ((*iter));
142
}
143
}
144
return
tmpServiceFlows;
145
}
146
147
bool
148
ServiceFlowManager::AreServiceFlowsAllocated
()
149
{
150
return
AreServiceFlowsAllocated
(
m_serviceFlows
);
151
}
152
153
bool
154
ServiceFlowManager::AreServiceFlowsAllocated
(std::vector<ServiceFlow*>* serviceFlowVector)
155
{
156
return
AreServiceFlowsAllocated
(*serviceFlowVector);
157
}
158
159
bool
160
ServiceFlowManager::AreServiceFlowsAllocated
(std::vector<ServiceFlow*> serviceFlowVector)
161
{
162
for
(std::vector<ServiceFlow*>::const_iterator iter = serviceFlowVector.begin (); iter != serviceFlowVector.end (); ++iter)
163
{
164
if
(!(*iter)->GetIsEnabled ())
165
{
166
return
false
;
167
}
168
}
169
return
true
;
170
}
171
172
ServiceFlow
*
173
ServiceFlowManager::GetNextServiceFlowToAllocate
()
174
{
175
std::vector<ServiceFlow*>::iterator iter;
176
for
(iter =
m_serviceFlows
->begin (); iter !=
m_serviceFlows
->end (); ++iter)
177
{
178
if
(!(*iter)->GetIsEnabled ())
179
{
180
return
(*iter);
181
}
182
}
183
return
0;
184
}
185
186
uint32_t
187
ServiceFlowManager::GetNrServiceFlows
(
void
)
const
188
{
189
return
m_serviceFlows
->size ();
190
}
191
192
}
// namespace ns3
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
ns3::Cid
Cid class.
Definition:
cid.h:38
ss-net-device.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::ServiceFlow::Direction
Direction
Direction enumeration.
Definition:
service-flow.h:44
ns3::Cid::GetIdentifier
uint16_t GetIdentifier(void) const
Definition:
cid.cc:45
ns3::ServiceFlowManager::GetNextServiceFlowToAllocate
ServiceFlow * GetNextServiceFlowToAllocate()
Definition:
service-flow-manager.cc:173
ns3::ServiceFlowManager::~ServiceFlowManager
~ServiceFlowManager(void)
Definition:
service-flow-manager.cc:62
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:41
dir
std::string dir
Definition:
tcp-bbr-example.cc:66
ns3::ServiceFlowManager::m_serviceFlows
std::vector< ServiceFlow * > * m_serviceFlows
the service flows
Definition:
service-flow-manager.h:126
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:923
ns3::ServiceFlowManager::GetNrServiceFlows
uint32_t GetNrServiceFlows(void) const
Definition:
service-flow-manager.cc:187
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:88
connection-manager.h
ns3::ServiceFlowManager::GetServiceFlow
ServiceFlow * GetServiceFlow(uint32_t sfid) const
Get service flow by flow id.
Definition:
service-flow-manager.cc:104
wimax-connection.h
ns3::ServiceFlowManager::AreServiceFlowsAllocated
bool AreServiceFlowsAllocated()
Definition:
service-flow-manager.cc:148
service-flow.h
bs-uplink-scheduler.h
wimax-net-device.h
ns3::ServiceFlowManager::DoDispose
void DoDispose(void)
Destructor implementation.
Definition:
service-flow-manager.cc:67
ns3::ServiceFlowManager::GetServiceFlows
std::vector< ServiceFlow * > GetServiceFlows(enum ServiceFlow::SchedulingType schedulingType) const
Get service flows function.
Definition:
service-flow-manager.cc:134
ss-record.h
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition:
log.h:273
ns3::ServiceFlowManager::ServiceFlowManager
ServiceFlowManager()
Definition:
service-flow-manager.cc:57
ns3::ServiceFlow::SchedulingType
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
Definition:
service-flow.h:59
ns3::ServiceFlowManager::AddServiceFlow
void AddServiceFlow(ServiceFlow *serviceFlow)
Add service flow function.
Definition:
service-flow-manager.cc:78
ss-scheduler.h
ns3::ServiceFlow
This class implements service flows as described by the IEEE-802.16 standard.
Definition:
service-flow.h:40
ns3::ServiceFlowManager::DoClassify
ServiceFlow * DoClassify(Ipv4Address SrcAddress, Ipv4Address DstAddress, uint16_t SrcPort, uint16_t DstPort, uint8_t Proto, ServiceFlow::Direction dir) const
Definition:
service-flow-manager.cc:83
ss-manager.h
service-flow-record.h
ns3::ServiceFlow::SF_TYPE_ALL
@ SF_TYPE_ALL
Definition:
service-flow.h:66
service-flow-manager.h
ns3::ServiceFlowManager::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
service-flow-manager.cc:49
bs-net-device.h
src
wimax
model
service-flow-manager.cc
Generated on Fri Oct 1 2021 17:03:54 for ns-3 by
1.8.20