36#include "ns3/packet-burst.h"
37#include "ns3/simulator.h"
51 .SetGroupName(
"Wimax")
72 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>* downlinkBursts =
m_downlinkBursts;
73 std::pair<OfdmDlMapIe*, Ptr<PacketBurst>> pair;
74 while (!downlinkBursts->empty())
76 pair = downlinkBursts->front();
77 pair.second =
nullptr;
85std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>*
98 dlMapIe->
SetCid(connection->GetCid());
101 NS_LOG_INFO(
"BS scheduler, burst size: " << burst->GetSize() <<
" bytes"
102 <<
", pkts: " << burst->GetNPackets()
103 <<
", connection: " << connection->GetTypeStr()
104 <<
", CID: " << connection->GetCid());
107 NS_LOG_INFO(
", SFID: " << connection->GetServiceFlow()->GetSfid() <<
", service: "
108 << connection->GetServiceFlow()->GetSchedulingTypeStr());
130 if (connection !=
GetBs()->GetInitialRangingConnection() &&
131 connection !=
GetBs()->GetBroadcastConnection())
137 modulationType = connection->GetServiceFlow()->GetModulation();
142 GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType();
144 diuc =
GetBs()->GetBurstProfileManager()->GetBurstProfile(
148 else if (connection ==
GetBs()->GetInitialRangingConnection() ||
149 connection ==
GetBs()->GetBroadcastConnection())
162 nrSymbolsRequired = connection->GetServiceFlow()->GetRecord()->GetGrantSize();
163 if (nrSymbolsRequired < availableSymbols)
166 CreateUgsBurst(connection->GetServiceFlow(), modulationType, nrSymbolsRequired);
171 CreateUgsBurst(connection->GetServiceFlow(), modulationType, availableSymbols);
173 if (burst->GetNPackets() != 0)
176 GetBs()->GetPhy()->GetNrSymbols(burst->GetSize(), modulationType);
179 if (availableSymbols <= BurstSizeSymbols)
189 burst = Create<PacketBurst>();
190 while (connection->HasPackets())
192 uint32_t FirstPacketSize = connection->GetQueue()->GetFirstPacketRequiredByte(
195 GetBs()->GetPhy()->GetNrSymbols(FirstPacketSize, modulationType);
196 if (availableSymbols < nrSymbolsRequired &&
200 GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
202 availableSymbols = 0;
204 else if (availableSymbols >= nrSymbolsRequired)
206 packet = connection->Dequeue();
207 availableSymbols -= nrSymbolsRequired;
213 burst->AddPacket(packet);
217 if (availableSymbols == 0)
226 "BS scheduler, number of bursts: "
227 <<
m_downlinkBursts->size() <<
", symbols left: " << availableSymbols << std::endl
228 <<
"BS scheduler, queues:"
229 <<
" IR " <<
GetBs()->GetInitialRangingConnection()->GetQueue()->
GetSize()
230 <<
" broadcast " <<
GetBs()->GetBroadcastConnection()->GetQueue()->
GetSize()
244 connection =
nullptr;
246 std::vector<Ptr<WimaxConnection>>::const_iterator iter1;
247 std::vector<ServiceFlow*>::iterator iter2;
249 NS_LOG_INFO(
"BS Scheduler: Selecting connection...");
250 if (
GetBs()->GetBroadcastConnection()->HasPackets())
253 connection =
GetBs()->GetBroadcastConnection();
256 else if (
GetBs()->GetInitialRangingConnection()->HasPackets())
259 connection =
GetBs()->GetInitialRangingConnection();
264 std::vector<Ptr<WimaxConnection>> connections;
265 std::vector<ServiceFlow*> serviceFlows;
267 connections =
GetBs()->GetConnectionManager()->GetConnections(
Cid::BASIC);
268 for (iter1 = connections.begin(); iter1 != connections.end(); ++iter1)
270 if ((*iter1)->HasPackets())
279 for (iter1 = connections.begin(); iter1 != connections.end(); ++iter1)
281 if ((*iter1)->HasPackets())
290 for (iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2)
292 serviceFlowRecord = (*iter2)->GetRecord();
294 << (*iter2)->HasPackets() <<
"max Latency = "
295 <<
MilliSeconds((*iter2)->GetMaximumLatency()) <<
"Delay = "
297 GetBs()->GetPhy()->GetFrameDuration()));
300 if ((*iter2)->HasPackets() && ((currentTime - serviceFlowRecord->
GetDlTimeStamp()) +
301 GetBs()->GetPhy()->GetFrameDuration()) >
305 connection = (*iter2)->GetConnection();
306 NS_LOG_INFO(
"Return UGS SF: CID = " << (*iter2)->GetCid()
307 <<
"SFID = " << (*iter2)->GetSfid());
313 for (iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2)
315 serviceFlowRecord = (*iter2)->GetRecord();
318 if ((*iter2)->HasPackets() && ((currentTime - serviceFlowRecord->
GetDlTimeStamp()) +
319 GetBs()->GetPhy()->GetFrameDuration()) >
323 connection = (*iter2)->GetConnection();
324 NS_LOG_INFO(
"Return RTPS SF: CID = " << (*iter2)->GetCid()
325 <<
"SFID = " << (*iter2)->GetSfid());
332 for (iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2)
335 if ((*iter2)->HasPackets())
337 NS_LOG_INFO(
"Return NRTPS SF: CID = " << (*iter2)->GetCid()
338 <<
"SFID = " << (*iter2)->GetSfid());
339 connection = (*iter2)->GetConnection();
345 for (iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2)
348 if ((*iter2)->HasPackets())
350 NS_LOG_INFO(
"Return BE SF: CID = " << (*iter2)->GetCid()
351 <<
"SFID = " << (*iter2)->GetSfid());
352 connection = (*iter2)->GetConnection();
378 nrSymbolsRequired =
GetBs()->GetPhy()->GetNrSymbols(FirstPacketSize, modulationType);
379 if (availableSymbols < nrSymbolsRequired &&
383 GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
385 availableSymbols = 0;
389 packet = connection->Dequeue();
390 availableSymbols -= nrSymbolsRequired;
392 burst->AddPacket(packet);
393 if (availableSymbols <= 0)
virtual Ptr< BaseStationNetDevice > GetBs()
Get the base station.
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
Set the base station.
bool CheckForFragmentation(Ptr< WimaxConnection > connection, int availableSymbols, WimaxPhy::ModulationType modulationType)
Check if the packet fragmentation is possible for transport connection.
BaseStation Scheduler - simplified.
~BSSchedulerSimple() override
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * GetDownlinkBursts() const override
This function returns all the downlink bursts scheduled for the next downlink sub-frame.
void AddDownlinkBurst(Ptr< const WimaxConnection > connection, uint8_t diuc, WimaxPhy::ModulationType modulationType, Ptr< PacketBurst > burst) override
This function adds a downlink burst to the list of downlink bursts scheduled for the next downlink su...
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * m_downlinkBursts
down link bursts
static TypeId GetTypeId()
Get the type ID.
void Schedule() override
the scheduling function for the downlink subframe.
Ptr< PacketBurst > CreateUgsBurst(ServiceFlow *serviceFlow, WimaxPhy::ModulationType modulationType, uint32_t availableSymbols) override
Creates a downlink UGS burst.
bool SelectConnection(Ptr< WimaxConnection > &connection) override
Selects a connection from the list of connections having packets to be sent .
This class implements the OFDM DL-MAP information element as described by "IEEE Standard for Local an...
void SetCid(Cid cid)
Set CID function.
void SetDiuc(uint8_t diuc)
Set DIUC field.
this class implement a burst as a list of packets
Smart pointer class similar to boost::intrusive_ptr.
This class implements service flows as described by the IEEE-802.16 standard.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
bool HasPackets() const
Check if packets are present.
Ptr< WimaxConnection > GetConnection() const
Can return a null connection is this service flow has not been associated yet to a connection.
this class implements a structure to manage some parameters and statistics related to a service flow
void SetDlTimeStamp(Time dlTimeStamp)
Set the DlTimeStamp.
Time GetDlTimeStamp() const
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
ModulationType
ModulationType enumeration.
@ MODULATION_TYPE_BPSK_12
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr, bool isAmpdu)
Return the total size of the packet after WifiMacHeader and FCS trailer have been added.