A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
ss-scheduler.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007,2008 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
7
*/
8
9
#include "
ss-scheduler.h
"
10
11
#include "
connection-manager.h
"
12
#include "
service-flow-manager.h
"
13
#include "
service-flow-record.h
"
14
#include "
service-flow.h
"
15
#include "
ss-net-device.h
"
16
#include "
wimax-connection.h
"
17
#include "
wimax-mac-queue.h
"
18
#include "
wimax-phy.h
"
19
20
#include "ns3/log.h"
21
#include "ns3/node.h"
22
#include "ns3/simulator.h"
23
24
namespace
ns3
25
{
26
27
NS_LOG_COMPONENT_DEFINE
(
"SSScheduler"
);
28
29
NS_OBJECT_ENSURE_REGISTERED
(
SSScheduler
);
30
31
TypeId
32
SSScheduler::GetTypeId
()
33
{
34
static
TypeId
tid =
TypeId
(
"ns3::SSScheduler"
).
SetParent
<
Object
>().SetGroupName(
"Wimax"
);
35
return
tid;
36
}
37
38
SSScheduler::SSScheduler
(
Ptr<SubscriberStationNetDevice>
ss)
39
:
m_ss
(ss),
40
m_pollMe
(false)
41
{
42
}
43
44
SSScheduler::~SSScheduler
()
45
{
46
}
47
48
void
49
SSScheduler::DoDispose
()
50
{
51
m_ss
=
nullptr
;
52
}
53
54
void
55
SSScheduler::SetPollMe
(
bool
pollMe)
56
{
57
m_pollMe
= pollMe;
58
}
59
60
bool
61
SSScheduler::GetPollMe
()
const
62
{
63
return
m_pollMe
;
64
}
65
66
Ptr<PacketBurst>
67
SSScheduler::Schedule
(uint16_t availableSymbols,
68
WimaxPhy::ModulationType
modulationType,
69
MacHeaderType::HeaderType
packetType,
70
Ptr<WimaxConnection>
& connection)
71
{
72
Time
timeStamp;
73
Ptr<PacketBurst>
burst =
Create<PacketBurst>
();
74
uint16_t nrSymbolsRequired = 0;
75
76
if
(!connection)
77
{
78
connection =
SelectConnection
();
79
}
80
else
81
{
82
NS_ASSERT_MSG
(connection->HasPackets(),
83
"SS: Error while scheduling packets: The selected connection has no packets"
);
84
}
85
86
Ptr<Packet>
packet;
87
88
while
(connection && connection->HasPackets(packetType))
89
{
90
NS_LOG_INFO
(
"FRAG_DEBUG: SS Scheduler"
<< std::endl);
91
92
uint32_t
availableByte =
m_ss
->GetPhy()->GetNrBytes(availableSymbols, modulationType);
93
94
uint32_t
requiredByte = connection->GetQueue()->GetFirstPacketRequiredByte(packetType);
95
96
NS_LOG_INFO
(
"\t availableByte = "
<< availableByte <<
", requiredByte = "
<< requiredByte);
97
98
if
(availableByte >= requiredByte)
99
{
100
// The SS could sent a packet without a other fragmentation
101
NS_LOG_INFO
(
"\t availableByte >= requiredByte"
102
"\n\t Send packet without other fragmentation"
103
<< std::endl);
104
105
packet = connection->Dequeue(packetType);
106
burst->AddPacket(packet);
107
108
nrSymbolsRequired =
m_ss
->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
109
availableSymbols -= nrSymbolsRequired;
110
}
111
else
112
{
113
if
(connection->GetType() ==
Cid::TRANSPORT
)
114
{
115
NS_LOG_INFO
(
"\t availableByte < requiredByte"
116
"\n\t Check if the fragmentation is possible"
);
117
118
uint32_t
headerSize = connection->GetQueue()->GetFirstPacketHdrSize(packetType);
119
if
(!connection->GetQueue()->CheckForFragmentation(packetType))
120
{
121
NS_LOG_INFO
(
"\t Add fragmentSubhdrSize = 2"
);
122
headerSize += 2;
123
}
124
NS_LOG_INFO
(
"\t availableByte = "
<< availableByte
125
<<
" headerSize = "
<< headerSize);
126
127
if
(availableByte > headerSize)
128
{
129
NS_LOG_INFO
(
"\t Fragmentation IS possible"
);
130
packet = connection->Dequeue(packetType, availableByte);
131
burst->AddPacket(packet);
132
133
nrSymbolsRequired =
134
m_ss
->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
135
availableSymbols -= nrSymbolsRequired;
136
}
137
else
138
{
139
NS_LOG_INFO
(
"\t Fragmentation IS NOT possible"
<< std::endl);
140
break
;
141
}
142
}
143
else
144
{
145
NS_LOG_INFO
(
"\t no Transport Connection "
146
"\n\t Fragmentation IS NOT possible, "
147
<< std::endl);
148
break
;
149
}
150
}
151
}
152
return
burst;
153
}
154
155
Ptr<WimaxConnection>
156
SSScheduler::SelectConnection
()
157
{
158
Time
currentTime =
Simulator::Now
();
159
160
NS_LOG_INFO
(
"SS Scheduler: Selecting connection..."
);
161
if
(
m_ss
->GetInitialRangingConnection()->HasPackets())
162
{
163
NS_LOG_INFO
(
"Return GetInitialRangingConnection"
);
164
return
m_ss
->GetInitialRangingConnection();
165
}
166
if
(
m_ss
->GetBasicConnection()->HasPackets())
167
{
168
NS_LOG_INFO
(
"Return GetBasicConnection"
);
169
return
m_ss
->GetBasicConnection();
170
}
171
if
(
m_ss
->GetPrimaryConnection()->HasPackets())
172
{
173
NS_LOG_INFO
(
"Return GetPrimaryConnection"
);
174
return
m_ss
->GetPrimaryConnection();
175
}
176
177
auto
serviceFlows =
m_ss
->GetServiceFlowManager()->GetServiceFlows(
ServiceFlow::SF_TYPE_UGS
);
178
for
(
auto
iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter)
179
{
180
// making sure that this grant was actually intended for this UGS
181
182
if
((*iter)->HasPackets() && (currentTime +
m_ss
->GetPhy()->GetFrameDuration() >
183
MilliSeconds
((*iter)->GetUnsolicitedGrantInterval())))
184
{
185
NS_LOG_INFO
(
"Return UGS SF: CID = "
<< (*iter)->GetCid()
186
<<
"SFID = "
<< (*iter)->GetSfid());
187
return
(*iter)->GetConnection();
188
}
189
}
190
191
/* In the following cases (rtPS, nrtPS and BE flows) connection is seletected only for data
192
packets, for bandwidth request packets connection will itself be passed to Schedule () and
193
hence this function will never be called. */
194
195
serviceFlows =
m_ss
->GetServiceFlowManager()->GetServiceFlows(
ServiceFlow::SF_TYPE_RTPS
);
196
for
(
auto
iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter)
197
{
198
if
((*iter)->HasPackets(
MacHeaderType::HEADER_TYPE_GENERIC
) &&
199
(currentTime +
m_ss
->GetPhy()->GetFrameDuration() >
200
MilliSeconds
((*iter)->GetUnsolicitedPollingInterval())))
201
{
202
NS_LOG_INFO
(
"Return RTPS SF: CID = "
<< (*iter)->GetCid()
203
<<
"SFID = "
<< (*iter)->GetSfid());
204
return
(*iter)->GetConnection();
205
}
206
}
207
208
serviceFlows =
m_ss
->GetServiceFlowManager()->GetServiceFlows(
ServiceFlow::SF_TYPE_NRTPS
);
209
for
(
auto
iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter)
210
{
211
if
((*iter)->HasPackets(
MacHeaderType::HEADER_TYPE_GENERIC
))
212
{
213
NS_LOG_INFO
(
"Return NRTPS SF: CID = "
<< (*iter)->GetCid()
214
<<
"SFID = "
<< (*iter)->GetSfid());
215
return
(*iter)->GetConnection();
216
}
217
}
218
219
serviceFlows =
m_ss
->GetServiceFlowManager()->GetServiceFlows(
ServiceFlow::SF_TYPE_BE
);
220
for
(
auto
iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter)
221
{
222
if
((*iter)->HasPackets(
MacHeaderType::HEADER_TYPE_GENERIC
))
223
{
224
NS_LOG_INFO
(
"Return BE SF: CID = "
<< (*iter)->GetCid()
225
<<
"SFID = "
<< (*iter)->GetSfid());
226
return
(*iter)->GetConnection();
227
}
228
}
229
230
if
(
m_ss
->GetBroadcastConnection()->HasPackets())
231
{
232
return
m_ss
->GetBroadcastConnection();
233
}
234
NS_LOG_INFO
(
"NO connection is selected!"
);
235
return
nullptr
;
236
}
237
238
}
// namespace ns3
ns3::Cid::TRANSPORT
@ TRANSPORT
Definition
cid.h:35
ns3::MacHeaderType::HeaderType
HeaderType
Header type enumeration.
Definition
wimax-mac-header.h:31
ns3::MacHeaderType::HEADER_TYPE_GENERIC
@ HEADER_TYPE_GENERIC
Definition
wimax-mac-header.h:32
ns3::Object::Object
Object()
Constructor.
Definition
object.cc:96
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:66
ns3::SSScheduler
Definition
ss-scheduler.h:33
ns3::SSScheduler::SSScheduler
SSScheduler(Ptr< SubscriberStationNetDevice > ss)
Constructor.
Definition
ss-scheduler.cc:38
ns3::SSScheduler::m_pollMe
bool m_pollMe
poll me flag
Definition
ss-scheduler.h:83
ns3::SSScheduler::DoDispose
void DoDispose() override
Destructor implementation.
Definition
ss-scheduler.cc:49
ns3::SSScheduler::Schedule
Ptr< PacketBurst > Schedule(uint16_t availableSymbols, WimaxPhy::ModulationType modulationType, MacHeaderType::HeaderType packetType, Ptr< WimaxConnection > &connection)
Definition
ss-scheduler.cc:67
ns3::SSScheduler::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
ss-scheduler.cc:32
ns3::SSScheduler::m_ss
Ptr< SubscriberStationNetDevice > m_ss
the subscriber station
Definition
ss-scheduler.h:82
ns3::SSScheduler::SetPollMe
void SetPollMe(bool pollMe)
Set poll me value.
Definition
ss-scheduler.cc:55
ns3::SSScheduler::SelectConnection
Ptr< WimaxConnection > SelectConnection()
Select connection.
Definition
ss-scheduler.cc:156
ns3::SSScheduler::GetPollMe
bool GetPollMe() const
Get the poll me value.
Definition
ss-scheduler.cc:61
ns3::SSScheduler::~SSScheduler
~SSScheduler() override
Definition
ss-scheduler.cc:44
ns3::ServiceFlow::SF_TYPE_RTPS
@ SF_TYPE_RTPS
Definition
service-flow.h:56
ns3::ServiceFlow::SF_TYPE_NRTPS
@ SF_TYPE_NRTPS
Definition
service-flow.h:55
ns3::ServiceFlow::SF_TYPE_UGS
@ SF_TYPE_UGS
Definition
service-flow.h:57
ns3::ServiceFlow::SF_TYPE_BE
@ SF_TYPE_BE
Definition
service-flow.h:54
ns3::Simulator::Now
static Time Now()
Return the current simulation virtual time.
Definition
simulator.cc:197
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::WimaxPhy::ModulationType
ModulationType
ModulationType enumeration.
Definition
wimax-phy.h:43
uint32_t
connection-manager.h
NS_ASSERT_MSG
#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
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition
log.h:264
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
ns3::MilliSeconds
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition
nstime.h:1357
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
service-flow-manager.h
service-flow-record.h
service-flow.h
ss-net-device.h
ss-scheduler.h
wimax-connection.h
wimax-mac-queue.h
wimax-phy.h
src
wimax
model
ss-scheduler.cc
Generated on Wed Jun 11 2025 13:15:43 for ns-3 by
1.13.2