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 * 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 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
18 */
19
20#include "bs-net-device.h"
21#include "bs-uplink-scheduler.h"
22#include "connection-manager.h"
24#include "service-flow-record.h"
25#include "service-flow.h"
26#include "ss-manager.h"
27#include "ss-net-device.h"
28#include "ss-record.h"
29#include "ss-scheduler.h"
30#include "wimax-connection.h"
31#include "wimax-net-device.h"
32
33#include "ns3/buffer.h"
34#include "ns3/enum.h"
35#include "ns3/log.h"
36#include "ns3/node.h"
37#include "ns3/packet.h"
38#include "ns3/pointer.h"
39#include "ns3/simulator.h"
40
41#include <stdint.h>
42
43namespace ns3
44{
45
46NS_LOG_COMPONENT_DEFINE("SsServiceFlowManager");
47
49 : m_device(device),
50 m_maxDsaReqRetries(100),
51 m_dsaReq(DsaReq()),
52 m_dsaAck(DsaAck()),
53 m_currentTransactionId(0),
54 m_transactionIdIndex(1),
55 m_dsaReqRetries(0),
56 m_pendingServiceFlow(nullptr)
57{
58}
59
61{
62}
63
64/* static */
67{
68 static TypeId tid =
69 TypeId("ns3::SsServiceFlowManager").SetParent<ServiceFlowManager>().SetGroupName("Wimax")
70 // No AddConstructor because this is an abstract class.
71 ;
72 return tid;
73}
74
75void
77{
79}
80
81void
83{
84 m_maxDsaReqRetries = maxDsaReqRetries;
85}
86
87uint8_t
89{
90 return m_maxDsaReqRetries;
91}
92
95{
97}
98
101{
103}
104
105void
107{
108 auto sf = new ServiceFlow();
109 sf->CopyParametersFrom(serviceFlow);
111}
112
113void
115{
117}
118
119void
121{
124 serviceFlow != nullptr,
125 "Error while initiating a new service flow: All service flows have been initiated");
126 m_pendingServiceFlow = serviceFlow;
128}
129
130DsaReq
132{
133 DsaReq dsaReq;
136
137 /*as it is SS-initiated DSA therefore SFID and CID will
138 not be included, see 6.3.2.3.10.1 and 6.3.2.3.11.1*/
139 dsaReq.SetServiceFlow(*serviceFlow);
140 // dsaReq.SetParameterSet (*serviceFlow->GetParameterSet ());
141 return dsaReq;
142}
143
146{
147 DsaAck dsaAck;
150 m_dsaAck = dsaAck;
151 Ptr<Packet> p = Create<Packet>();
152 p->AddHeader(dsaAck);
154 return p;
155}
156
157void
159{
160 Ptr<Packet> p = Create<Packet>();
161 DsaReq dsaReq;
163
164 if (m_dsaReqRetries == 0)
165 {
166 dsaReq = CreateDsaReq(serviceFlow);
167 p->AddHeader(dsaReq);
168 m_dsaReq = dsaReq;
169 }
170 else
171 {
173 {
174 p->AddHeader(m_dsaReq);
175 }
176 else
177 {
178 NS_LOG_DEBUG("Service flows could not be initialized!");
179 }
180 }
181
184
186 {
188 }
189
190 m_dsaRspTimeoutEvent = Simulator::Schedule(ss->GetIntervalT7(),
192 this,
193 serviceFlow);
194
195 m_device->Enqueue(p, MacHeaderType(), ss->GetPrimaryConnection());
196}
197
198void
200{
202
203 // already received DSA-RSP for that particular DSA-REQ
205 {
206 return;
207 }
208
209 Ptr<Packet> dsaAck = CreateDsaAck();
210 m_device->Enqueue(dsaAck, MacHeaderType(), ss->GetPrimaryConnection());
211
212 m_dsaReqRetries = 0;
213 if (m_pendingServiceFlow == nullptr)
214 {
215 // May be the DSA-ACK was not received by the SS
216 return;
217 }
218 ServiceFlow sf = dsaRsp.GetServiceFlow();
219 (*m_pendingServiceFlow) = sf;
222 Ptr<WimaxConnection> transportConnection =
223 CreateObject<WimaxConnection>(sf.GetCid(), Cid::TRANSPORT);
224
225 m_pendingServiceFlow->SetConnection(transportConnection);
226 transportConnection->SetServiceFlow(m_pendingServiceFlow);
227 ss->GetConnectionManager()->AddConnection(transportConnection, Cid::TRANSPORT);
229 m_pendingServiceFlow = nullptr;
230 // check if all service flow have been initiated
232 if (serviceFlow == nullptr)
233 {
234 ss->SetAreServiceFlowsAllocated(true);
235 }
236 else
237 {
238 m_pendingServiceFlow = serviceFlow;
240 }
241}
242
243} // namespace ns3
@ TRANSPORT
Definition: cid.h:46
This class implements the DSA-ACK message described by "IEEE Standard for Local and metropolitan area...
Definition: mac-messages.h:590
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 for Local and metropolitan area...
Definition: mac-messages.h:386
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 for Local and metropolitan ar...
Definition: mac-messages.h:490
ServiceFlow GetServiceFlow() const
uint16_t GetTransactionId() const
An identifier for simulation events.
Definition: event-id.h:55
bool IsRunning() const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:76
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.
Definition: mac-messages.h:44
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:43
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:571
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:285
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.
Definition: ss-net-device.h:50
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_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:86
#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
Every class exported by the ns3 library is enclosed in the ns3 namespace.