A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
service-flow-manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008, 2009 INRIA, UDcast
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
18 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19 */
20
22
23#include "bs-net-device.h"
24#include "bs-uplink-scheduler.h"
25#include "connection-manager.h"
26#include "service-flow-record.h"
27#include "service-flow.h"
28#include "ss-manager.h"
29#include "ss-net-device.h"
30#include "ss-record.h"
31#include "ss-scheduler.h"
32#include "wimax-connection.h"
33#include "wimax-net-device.h"
34
35#include "ns3/buffer.h"
36#include "ns3/enum.h"
37#include "ns3/log.h"
38#include "ns3/node.h"
39#include "ns3/packet.h"
40#include "ns3/pointer.h"
41#include "ns3/simulator.h"
42
43#include <stdint.h>
44
45namespace ns3
46{
47
48NS_LOG_COMPONENT_DEFINE("ServiceFlowManager");
49
50NS_OBJECT_ENSURE_REGISTERED(ServiceFlowManager);
51
52TypeId
54{
55 static TypeId tid = TypeId("ns3::ServiceFlowManager").SetParent<Object>().SetGroupName("Wimax");
56 return tid;
57}
58
60{
61 m_serviceFlows = new std::vector<ServiceFlow*>;
62}
63
65{
66}
67
68void
70{
71 for (std::vector<ServiceFlow*>::iterator iter = m_serviceFlows->begin();
72 iter != m_serviceFlows->end();
73 ++iter)
74 {
75 delete (*iter);
76 }
77 m_serviceFlows->clear();
78 delete m_serviceFlows;
79}
80
81void
83{
84 m_serviceFlows->push_back(serviceFlow);
85}
86
89 Ipv4Address dstAddress,
90 uint16_t srcPort,
91 uint16_t dstPort,
92 uint8_t proto,
94{
95 for (std::vector<ServiceFlow*>::iterator iter = m_serviceFlows->begin();
96 iter != m_serviceFlows->end();
97 ++iter)
98 {
99 if ((*iter)->GetDirection() == dir)
100 {
101 if ((*iter)->CheckClassifierMatch(srcAddress, dstAddress, srcPort, dstPort, proto))
102 {
103 return (*iter);
104 }
105 }
106 }
107 return nullptr;
108}
109
112{
113 for (std::vector<ServiceFlow*>::iterator iter = m_serviceFlows->begin();
114 iter != m_serviceFlows->end();
115 ++iter)
116 {
117 if ((*iter)->GetSfid() == sfid)
118 {
119 return (*iter);
120 }
121 }
122
123 NS_LOG_DEBUG("GetServiceFlow: service flow not found!");
124 return nullptr;
125}
126
129{
130 for (std::vector<ServiceFlow*>::iterator iter = m_serviceFlows->begin();
131 iter != m_serviceFlows->end();
132 ++iter)
133 {
134 if ((*iter)->GetCid() == cid.GetIdentifier())
135 {
136 return (*iter);
137 }
138 }
139
140 NS_LOG_DEBUG("GetServiceFlow: service flow not found!");
141 return nullptr;
142}
143
144std::vector<ServiceFlow*>
146{
147 std::vector<ServiceFlow*> tmpServiceFlows;
148 for (std::vector<ServiceFlow*>::iterator iter = m_serviceFlows->begin();
149 iter != m_serviceFlows->end();
150 ++iter)
151 {
152 if (((*iter)->GetSchedulingType() == schedulingType) ||
153 (schedulingType == ServiceFlow::SF_TYPE_ALL))
154 {
155 tmpServiceFlows.push_back((*iter));
156 }
157 }
158 return tmpServiceFlows;
159}
160
161bool
163{
165}
166
167bool
168ServiceFlowManager::AreServiceFlowsAllocated(std::vector<ServiceFlow*>* serviceFlowVector)
169{
170 return AreServiceFlowsAllocated(*serviceFlowVector);
171}
172
173bool
174ServiceFlowManager::AreServiceFlowsAllocated(std::vector<ServiceFlow*> serviceFlowVector)
175{
176 for (std::vector<ServiceFlow*>::const_iterator iter = serviceFlowVector.begin();
177 iter != serviceFlowVector.end();
178 ++iter)
179 {
180 if (!(*iter)->GetIsEnabled())
181 {
182 return false;
183 }
184 }
185 return true;
186}
187
190{
191 std::vector<ServiceFlow*>::iterator iter;
192 for (iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter)
193 {
194 if (!(*iter)->GetIsEnabled())
195 {
196 return (*iter);
197 }
198 }
199 return nullptr;
200}
201
204{
205 return m_serviceFlows->size();
206}
207
208} // namespace ns3
Cid class.
Definition: cid.h:37
uint16_t GetIdentifier() const
Definition: cid.cc:45
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
A base class which provides memory management and object aggregation.
Definition: object.h:89
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:43
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
Definition: service-flow.h:62
Direction
Direction enumeration.
Definition: service-flow.h:47
ServiceFlow * GetNextServiceFlowToAllocate()
ServiceFlow * DoClassify(Ipv4Address SrcAddress, Ipv4Address DstAddress, uint16_t SrcPort, uint16_t DstPort, uint8_t Proto, ServiceFlow::Direction dir) const
void AddServiceFlow(ServiceFlow *serviceFlow)
Add service flow function.
ServiceFlow * GetServiceFlow(uint32_t sfid) const
Get service flow by flow id.
std::vector< ServiceFlow * > GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const
Get service flows function.
uint32_t GetNrServiceFlows() const
static TypeId GetTypeId()
Get the type ID.
void DoDispose() override
Destructor implementation.
std::vector< ServiceFlow * > * m_serviceFlows
the service flows
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:936
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string dir