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 (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter)
72 {
73 delete (*iter);
74 }
75 m_serviceFlows->clear();
76 delete m_serviceFlows;
77}
78
79void
81{
82 m_serviceFlows->push_back(serviceFlow);
83}
84
87 Ipv4Address dstAddress,
88 uint16_t srcPort,
89 uint16_t dstPort,
90 uint8_t proto,
92{
93 for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter)
94 {
95 if ((*iter)->GetDirection() == dir)
96 {
97 if ((*iter)->CheckClassifierMatch(srcAddress, dstAddress, srcPort, dstPort, proto))
98 {
99 return *iter;
100 }
101 }
102 }
103 return nullptr;
104}
105
108{
109 for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter)
110 {
111 if ((*iter)->GetSfid() == sfid)
112 {
113 return *iter;
114 }
115 }
116
117 NS_LOG_DEBUG("GetServiceFlow: service flow not found!");
118 return nullptr;
119}
120
123{
124 for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter)
125 {
126 if ((*iter)->GetCid() == cid.GetIdentifier())
127 {
128 return *iter;
129 }
130 }
131
132 NS_LOG_DEBUG("GetServiceFlow: service flow not found!");
133 return nullptr;
134}
135
136std::vector<ServiceFlow*>
138{
139 std::vector<ServiceFlow*> tmpServiceFlows;
140 for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter)
141 {
142 if (((*iter)->GetSchedulingType() == schedulingType) ||
143 (schedulingType == ServiceFlow::SF_TYPE_ALL))
144 {
145 tmpServiceFlows.push_back(*iter);
146 }
147 }
148 return tmpServiceFlows;
149}
150
151bool
153{
155}
156
157bool
158ServiceFlowManager::AreServiceFlowsAllocated(std::vector<ServiceFlow*>* serviceFlowVector)
159{
160 return AreServiceFlowsAllocated(*serviceFlowVector);
161}
162
163bool
164ServiceFlowManager::AreServiceFlowsAllocated(std::vector<ServiceFlow*> serviceFlowVector)
165{
166 for (auto iter = serviceFlowVector.begin(); iter != serviceFlowVector.end(); ++iter)
167 {
168 if (!(*iter)->GetIsEnabled())
169 {
170 return false;
171 }
172 }
173 return true;
174}
175
178{
179 for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter)
180 {
181 if (!(*iter)->GetIsEnabled())
182 {
183 return *iter;
184 }
185 }
186 return nullptr;
187}
188
191{
192 return m_serviceFlows->size();
193}
194
195} // 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:932
#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