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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
7 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
8 */
9
11
12#include "bs-net-device.h"
13#include "bs-uplink-scheduler.h"
14#include "connection-manager.h"
15#include "service-flow-record.h"
16#include "service-flow.h"
17#include "ss-manager.h"
18#include "ss-net-device.h"
19#include "ss-record.h"
20#include "ss-scheduler.h"
21#include "wimax-connection.h"
22#include "wimax-net-device.h"
23
24#include "ns3/buffer.h"
25#include "ns3/enum.h"
26#include "ns3/log.h"
27#include "ns3/node.h"
28#include "ns3/packet.h"
29#include "ns3/pointer.h"
30#include "ns3/simulator.h"
31
32#include <stdint.h>
33
34namespace ns3
35{
36
37NS_LOG_COMPONENT_DEFINE("ServiceFlowManager");
38
39NS_OBJECT_ENSURE_REGISTERED(ServiceFlowManager);
40
41TypeId
43{
44 static TypeId tid = TypeId("ns3::ServiceFlowManager").SetParent<Object>().SetGroupName("Wimax");
45 return tid;
46}
47
49{
50 m_serviceFlows = new std::vector<ServiceFlow*>;
51}
52
56
57void
59{
60 for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter)
61 {
62 delete (*iter);
63 }
64 m_serviceFlows->clear();
65 delete m_serviceFlows;
66}
67
68void
70{
71 m_serviceFlows->push_back(serviceFlow);
72}
73
76 Ipv4Address dstAddress,
77 uint16_t srcPort,
78 uint16_t dstPort,
79 uint8_t proto,
81{
82 for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter)
83 {
84 if ((*iter)->GetDirection() == dir)
85 {
86 if ((*iter)->CheckClassifierMatch(srcAddress, dstAddress, srcPort, dstPort, proto))
87 {
88 return *iter;
89 }
90 }
91 }
92 return nullptr;
93}
94
97{
98 for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter)
99 {
100 if ((*iter)->GetSfid() == sfid)
101 {
102 return *iter;
103 }
104 }
105
106 NS_LOG_DEBUG("GetServiceFlow: service flow not found!");
107 return nullptr;
108}
109
112{
113 for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter)
114 {
115 if ((*iter)->GetCid() == cid.GetIdentifier())
116 {
117 return *iter;
118 }
119 }
120
121 NS_LOG_DEBUG("GetServiceFlow: service flow not found!");
122 return nullptr;
123}
124
125std::vector<ServiceFlow*>
127{
128 std::vector<ServiceFlow*> tmpServiceFlows;
129 for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter)
130 {
131 if (((*iter)->GetSchedulingType() == schedulingType) ||
132 (schedulingType == ServiceFlow::SF_TYPE_ALL))
133 {
134 tmpServiceFlows.push_back(*iter);
135 }
136 }
137 return tmpServiceFlows;
138}
139
140bool
145
146bool
147ServiceFlowManager::AreServiceFlowsAllocated(std::vector<ServiceFlow*>* serviceFlowVector)
148{
149 return AreServiceFlowsAllocated(*serviceFlowVector);
150}
151
152bool
153ServiceFlowManager::AreServiceFlowsAllocated(std::vector<ServiceFlow*> serviceFlowVector)
154{
155 for (auto iter = serviceFlowVector.begin(); iter != serviceFlowVector.end(); ++iter)
156 {
157 if (!(*iter)->GetIsEnabled())
158 {
159 return false;
160 }
161 }
162 return true;
163}
164
167{
168 for (auto iter = m_serviceFlows->begin(); iter != m_serviceFlows->end(); ++iter)
169 {
170 if (!(*iter)->GetIsEnabled())
171 {
172 return *iter;
173 }
174 }
175 return nullptr;
176}
177
180{
181 return m_serviceFlows->size();
182}
183
184} // namespace ns3
Cid class.
Definition cid.h:26
uint16_t GetIdentifier() const
Definition cid.cc:34
Ipv4 addresses are stored in host order in this class.
A base class which provides memory management and object aggregation.
Definition object.h:78
This class implements service flows as described by the IEEE-802.16 standard.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
Direction
Direction enumeration.
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.
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:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string dir