A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ss-service-flow-manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 INRIA, UDcast
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
7 */
8
9#include "bs-net-device.h"
10#include "bs-uplink-scheduler.h"
11#include "connection-manager.h"
13#include "service-flow-record.h"
14#include "service-flow.h"
15#include "ss-manager.h"
16#include "ss-net-device.h"
17#include "ss-record.h"
18#include "ss-scheduler.h"
19#include "wimax-connection.h"
20#include "wimax-net-device.h"
21
22#include "ns3/buffer.h"
23#include "ns3/enum.h"
24#include "ns3/log.h"
25#include "ns3/node.h"
26#include "ns3/packet.h"
27#include "ns3/pointer.h"
28#include "ns3/simulator.h"
29
30#include <stdint.h>
31
32namespace ns3
33{
34
35NS_LOG_COMPONENT_DEFINE("SsServiceFlowManager");
36
38 : m_device(device),
39 m_maxDsaReqRetries(100),
40 m_dsaReq(DsaReq()),
41 m_dsaAck(DsaAck()),
42 m_currentTransactionId(0),
43 m_transactionIdIndex(1),
44 m_dsaReqRetries(0),
45 m_pendingServiceFlow(nullptr)
46{
47}
48
52
53/* static */
56{
57 static TypeId tid =
58 TypeId("ns3::SsServiceFlowManager").SetParent<ServiceFlowManager>().SetGroupName("Wimax")
59 // No AddConstructor because this is an abstract class.
60 ;
61 return tid;
62}
63
64void
69
70void
72{
73 m_maxDsaReqRetries = maxDsaReqRetries;
74}
75
76uint8_t
81
87
93
94void
96{
97 auto sf = new ServiceFlow();
98 sf->CopyParametersFrom(serviceFlow);
100}
101
102void
107
108void
110{
113 serviceFlow != nullptr,
114 "Error while initiating a new service flow: All service flows have been initiated");
115 m_pendingServiceFlow = serviceFlow;
117}
118
119DsaReq
121{
122 DsaReq dsaReq;
125
126 /*as it is SS-initiated DSA therefore SFID and CID will
127 not be included, see 6.3.2.3.10.1 and 6.3.2.3.11.1*/
128 dsaReq.SetServiceFlow(*serviceFlow);
129 // dsaReq.SetParameterSet (*serviceFlow->GetParameterSet ());
130 return dsaReq;
131}
132
145
146void
148{
150 DsaReq dsaReq;
152
153 if (m_dsaReqRetries == 0)
154 {
155 dsaReq = CreateDsaReq(serviceFlow);
156 p->AddHeader(dsaReq);
157 m_dsaReq = dsaReq;
158 }
159 else
160 {
162 {
163 p->AddHeader(m_dsaReq);
164 }
165 else
166 {
167 NS_LOG_DEBUG("Service flows could not be initialized!");
168 }
169 }
170
173
175 {
177 }
178
179 m_dsaRspTimeoutEvent = Simulator::Schedule(ss->GetIntervalT7(),
181 this,
182 serviceFlow);
183
184 m_device->Enqueue(p, MacHeaderType(), ss->GetPrimaryConnection());
185}
186
187void
189{
191
192 // already received DSA-RSP for that particular DSA-REQ
194 {
195 return;
196 }
197
198 Ptr<Packet> dsaAck = CreateDsaAck();
199 m_device->Enqueue(dsaAck, MacHeaderType(), ss->GetPrimaryConnection());
200
201 m_dsaReqRetries = 0;
202 if (m_pendingServiceFlow == nullptr)
203 {
204 // May be the DSA-ACK was not received by the SS
205 return;
206 }
207 ServiceFlow sf = dsaRsp.GetServiceFlow();
208 (*m_pendingServiceFlow) = sf;
211 Ptr<WimaxConnection> transportConnection =
213
214 m_pendingServiceFlow->SetConnection(transportConnection);
215 transportConnection->SetServiceFlow(m_pendingServiceFlow);
216 ss->GetConnectionManager()->AddConnection(transportConnection, Cid::TRANSPORT);
218 m_pendingServiceFlow = nullptr;
219 // check if all service flow have been initiated
221 if (serviceFlow == nullptr)
222 {
223 ss->SetAreServiceFlowsAllocated(true);
224 }
225 else
226 {
227 m_pendingServiceFlow = serviceFlow;
229 }
230}
231
232} // namespace ns3
@ TRANSPORT
Definition cid.h:35
This class implements the DSA-ACK message described by "IEEE Standard forLocal and metropolitan area ...
void SetConfirmationCode(uint16_t confirmationCode)
Set confirmation code field.
void SetTransactionId(uint16_t transactionId)
Set transaction ID field.
This class implements the DSA-REQ message described by "IEEE Standard forLocal and metropolitan area ...
void SetTransactionId(uint16_t transactionId)
set the transaction ID
uint16_t GetTransactionId() const
void SetServiceFlow(ServiceFlow sf)
specify a service flow to be requested by this message
This class implements the DSA-RSP message described by "IEEE Standard forLocal and metropolitan area ...
ServiceFlow GetServiceFlow() const
uint16_t GetTransactionId() const
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.
This class implements service flows as described by the IEEE-802.16 standard.
uint16_t GetCid() const
Get CID.
void SetUnsolicitedGrantInterval(uint16_t unsolicitedGrantInterval)
Set unsolicited grant interval.
void SetUnsolicitedPollingInterval(uint16_t unsolicitedPollingInterval)
Set unsolicited polling interval.
void SetConnection(Ptr< WimaxConnection > connection)
Set connection.
void SetIsEnabled(bool isEnabled)
Set is enabled flag.
The same service flow manager class serves both for BS and SS though some functions are exclusive to ...
ServiceFlow * GetNextServiceFlowToAllocate()
void AddServiceFlow(ServiceFlow *serviceFlow)
Add service flow 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
void ScheduleDsaReq(const ServiceFlow *serviceFlow)
Schedule DSA response.
void ProcessDsaRsp(const DsaRsp &dsaRsp)
Process DSA response.
uint16_t m_currentTransactionId
current transaction ID
EventId GetDsaRspTimeoutEvent() const
Get DSA response timeout event.
uint8_t m_dsaReqRetries
DSA request retries.
EventId m_dsaAckTimeoutEvent
DSA ack timeout event.
ServiceFlow * m_pendingServiceFlow
pending service flow
EventId GetDsaAckTimeoutEvent() const
Get DSA ack timeout event.
void InitiateServiceFlows()
Initiate service flows.
EventId m_dsaRspTimeoutEvent
DSA response timeout event.
DsaReq CreateDsaReq(const ServiceFlow *serviceFlow)
Create DSA request.
void AddServiceFlow(ServiceFlow *serviceFlow)
add a service flow to the list
SsServiceFlowManager(Ptr< SubscriberStationNetDevice > device)
Constructor.
Ptr< SubscriberStationNetDevice > m_device
the device
uint16_t m_transactionIdIndex
transaction ID index
uint8_t m_maxDsaReqRetries
maximum DSA request retries
static TypeId GetTypeId()
Register this type.
void DoDispose() override
Destructor implementation.
void SetMaxDsaReqRetries(uint8_t maxDsaReqRetries)
sets the maximum retries on DSA request message
Ptr< Packet > CreateDsaAck()
Create DSA ack.
SubscriberStationNetDevice subclass of WimaxNetDevice.
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_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
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
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.