A Discrete-Event Network Simulator
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 
50 {
51  static TypeId tid = TypeId ("ns3::ServiceFlowManager")
52  .SetParent<Object> ()
53  .SetGroupName("Wimax");
54  return tid;
55 }
56 
58 {
59  m_serviceFlows = new std::vector<ServiceFlow*>;
60 }
61 
63 {
64 }
65 
66 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
79 {
80  m_serviceFlows->push_back (serviceFlow);
81 }
82 
84  Ipv4Address dstAddress,
85  uint16_t srcPort,
86  uint16_t dstPort,
87  uint8_t proto,
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 
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 
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*>
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
149 {
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 
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
188 {
189  return m_serviceFlows->size ();
190 }
191 
192 } // namespace ns3
static TypeId GetTypeId(void)
Get the type ID.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
ServiceFlow * DoClassify(Ipv4Address SrcAddress, Ipv4Address DstAddress, uint16_t SrcPort, uint16_t DstPort, uint8_t Proto, ServiceFlow::Direction dir) const
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ServiceFlow * GetNextServiceFlowToAllocate()
uint32_t GetNrServiceFlows(void) const
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
Definition: service-flow.h:58
ServiceFlow * GetServiceFlow(uint32_t sfid) const
Get service flow by flow id.
Direction
Direction enumeration.
Definition: service-flow.h:43
std::string dir
void DoDispose(void)
Destructor implementation.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Cid class.
Definition: cid.h:37
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
std::vector< ServiceFlow * > * m_serviceFlows
the service flows
void AddServiceFlow(ServiceFlow *serviceFlow)
Add service flow function.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
std::vector< ServiceFlow * > GetServiceFlows(enum ServiceFlow::SchedulingType schedulingType) const
Get service flows function.
A base class which provides memory management and object aggregation.
Definition: object.h:87
uint16_t GetIdentifier(void) const
Definition: cid.cc:45
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923