A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
bs-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
10#include "bs-net-device.h"
11#include "bs-uplink-scheduler.h"
12#include "connection-manager.h"
14#include "service-flow-record.h"
15#include "service-flow.h"
16#include "ss-manager.h"
17#include "ss-record.h"
18#include "ss-scheduler.h"
19#include "wimax-connection.h"
20
21#include "ns3/buffer.h"
22#include "ns3/enum.h"
23#include "ns3/log.h"
24#include "ns3/node.h"
25#include "ns3/packet.h"
26#include "ns3/pointer.h"
27#include "ns3/simulator.h"
28
29#include <stdint.h>
30
31namespace ns3
32{
33
34NS_LOG_COMPONENT_DEFINE("BsServiceFlowManager");
35
37 : m_device(device),
38 m_sfidIndex(100),
39 m_maxDsaRspRetries(100) // default value
40{
42}
43
47
48/* static */
51{
52 static TypeId tid =
53 TypeId("ns3::BsServiceFlowManager").SetParent<ServiceFlowManager>().SetGroupName("Wifi")
54 // No AddConstructor because this class has no default constructor.
55 ;
56 return tid;
57}
58
59void
64
65void
70
71uint8_t
76
82
83void
88
94
100
101std::vector<ServiceFlow*>
106
107DsaRsp
109{
112 dsaRsp.SetServiceFlow(*serviceFlow);
113 // assuming SS can supports all of the service flow parameters
114 dsaRsp.SetConfirmationCode(CONFIRMATION_CODE_SUCCESS);
115
116 return dsaRsp;
117}
118
119void
121{
123
124 SSRecord* ssRecord = bs->GetSSManager()->GetSSRecord(cid);
125 if (ssRecord == nullptr)
126 {
127 NS_LOG_INFO("SS not registered with the BS CID:" << cid);
128 return;
129 }
130
131 serviceFlow->SetIsEnabled(true);
133 ssRecord->AddServiceFlow(serviceFlow);
134
135 bs->GetUplinkScheduler()->SetupServiceFlow(ssRecord, serviceFlow);
136
139
140 if (ssRecord->GetDsaRspRetries() == 0)
141 {
142 dsaRsp = CreateDsaRsp(serviceFlow, ssRecord->GetSfTransactionId());
143 p->AddHeader(dsaRsp);
144 ssRecord->SetDsaRsp(dsaRsp);
145 }
146 else
147 {
148 if (ssRecord->GetDsaRspRetries() < m_maxDsaRspRetries)
149 {
150 p->AddHeader(ssRecord->GetDsaRsp());
151 }
152 else
153 {
154 NS_LOG_DEBUG("Service flows could not be initialized!");
155 }
156 }
157
158 ssRecord->IncrementDsaRspRetries();
160
162 {
164 }
165
167
170 this,
172 cid);
173 m_device->Enqueue(p, MacHeaderType(), bs->GetConnection(ssRecord->GetPrimaryCid()));
174}
175
178{
181 SSRecord* ssRecord = bs->GetSSManager()->GetSSRecord(cid);
182
183 NS_LOG_INFO("BsServiceFlowManager: Processing DSA-REQ...");
184 if (ssRecord->GetSfTransactionId() != 0)
185 {
186 // had already received DSA-REQ. DSA-RSP was lost
188 dsaReq.GetTransactionId() == ssRecord->GetSfTransactionId(),
189 "Error while processing DSA request:the received transaction ID is not expected");
190 serviceFlow = GetServiceFlow(ssRecord->GetDsaRsp().GetSfid());
191 }
192 else
193 {
194 ServiceFlow sf = dsaReq.GetServiceFlow();
196 Ptr<ConnectionManager> BsConManager = bs->GetConnectionManager();
198 serviceFlow = new ServiceFlow(m_sfidIndex++, sf.GetDirection(), transportConnection);
199 transportConnection->SetServiceFlow(serviceFlow);
200 serviceFlow->CopyParametersFrom(sf);
201 serviceFlow->SetUnsolicitedGrantInterval(1);
202 serviceFlow->SetUnsolicitedPollingInterval(1);
203 serviceFlow->SetConvergenceSublayerParam(sf.GetConvergenceSublayerParam());
205 ssRecord->SetSfTransactionId(dsaReq.GetTransactionId());
206 NS_LOG_INFO("BsServiceFlowManager: Creating a new Service flow: SFID = "
207 << serviceFlow->GetSfid() << " CID = " << serviceFlow->GetCid());
208 }
209 return serviceFlow;
210}
211
212void
214{
215 auto serviceFlow = new ServiceFlow();
216 serviceFlow->CopyParametersFrom(sf);
219 bs->GetConnectionManager()->CreateConnection(Cid::MULTICAST);
220 serviceFlow->SetConnection(multicastConnection);
222 serviceFlow->SetIsEnabled(true);
224 serviceFlow->SetIsMulticast(true);
225 serviceFlow->SetModulation(modulation);
226 bs->GetUplinkScheduler()->SetupServiceFlow(nullptr, serviceFlow);
227}
228
229void
231{
233 if (serviceFlow)
234 {
236 }
237 else
238 {
239 NS_LOG_INFO("No service Flow. Could not connect.");
240 }
241}
242
243void
245{
247 SSRecord* ssRecord = bs->GetSSManager()->GetSSRecord(cid);
248
249 if (dsaAck.GetTransactionId() != ssRecord->GetSfTransactionId())
250 {
251 return;
252 }
253
255 ssRecord->SetSfTransactionId(0);
256
257 // check if all service flow have been initiated
259 {
260 ssRecord->SetAreServiceFlowsAllocated(true);
261 }
262}
263} // namespace ns3
BaseStation NetDevice.
ServiceFlow * GetServiceFlow(uint32_t sfid) const
uint8_t m_maxDsaRspRetries
maximum number of DSA response retries
void AllocateServiceFlows(const DsaReq &dsaReq, Cid cid)
allocate service flows
void DoDispose() override
Destructor implementation.
Cid m_inuseScheduleDsaRspCid
in use schedule DSA response CID
void AddMulticastServiceFlow(ServiceFlow sf, WimaxPhy::ModulationType modulation)
add a multicast service flow
Ptr< WimaxNetDevice > m_device
the device
void ScheduleDsaRsp(ServiceFlow *serviceFlow, Cid cid)
Create DSA response function.
void ProcessDsaAck(const DsaAck &dsaAck, Cid cid)
process a DSA-ACK message
std::vector< ServiceFlow * > GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const
static TypeId GetTypeId()
Register this type.
void AddServiceFlow(ServiceFlow *serviceFlow)
Add a new service flow.
void SetMaxDsaRspRetries(uint8_t maxDsaRspRetries)
set the maximum Dynamic ServiceFlow Add (DSA) retries
DsaRsp CreateDsaRsp(const ServiceFlow *serviceFlow, uint16_t transactionId)
Create DSA response function.
EventId m_dsaAckTimeoutEvent
DSA ack timeout event.
BsServiceFlowManager(Ptr< BaseStationNetDevice > device)
Constructor.
ServiceFlow * ProcessDsaReq(const DsaReq &dsaReq, Cid cid)
process a DSA-Req message
Cid class.
Definition cid.h:26
@ TRANSPORT
Definition cid.h:35
@ MULTICAST
Definition cid.h:36
static Cid InitialRanging()
Definition cid.cc:76
This class implements the DSA-ACK message described by "IEEE Standard for Local and metropolitan area...
This class implements the DSA-REQ message described by "IEEE Standard for Local and metropolitan area...
This class implements the DSA-RSP message described by "IEEE Standard for Local and metropolitan area...
void SetTransactionId(uint16_t transactionId)
set the transaction ID
An identifier for simulation events.
Definition event-id.h:45
bool IsPending() const
This method is syntactic sugar for !IsExpired().
Definition event-id.cc:65
This class Represents the HT (Header Type) field of generic MAC and bandwidth request headers.
Mac Management messages Section 6.3.2.3 MAC Management messages page 42, Table 14 page 43.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
This class is used by the base station to store some information related to subscriber station in the...
Definition ss-record.h:35
void SetDsaRspRetries(uint8_t dsaRspRetries)
Set DSA response retries.
Definition ss-record.cc:313
This class implements service flows as described by the IEEE-802.16 standard.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
The same service flow manager class serves both for BS and SS though some functions are exclusive to ...
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.
void DoDispose() override
Destructor implementation.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
Definition simulator.cc:274
a unique identifier for an interface.
Definition type-id.h:49
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
ModulationType
ModulationType enumeration.
Definition wimax-phy.h:43
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
#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_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Every class exported by the ns3 library is enclosed in the ns3 namespace.