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;
85 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>*
98 dlMapIe->SetCid(connection->GetCid());
99 dlMapIe->SetDiuc(diuc);
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());
110 NS_LOG_INFO(
", modulation: " << modulationType <<
", DIUC: " << (uint32_t)diuc);
121 uint32_t nrSymbolsRequired = 0;
126 uint32_t availableSymbols =
GetBs()->GetNrDlSymbols();
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)
175 uint32_t BurstSizeSymbols =
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 &&
199 uint32_t availableByte =
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;
247 NS_LOG_INFO(
"BS Scheduler: Selecting connection...");
248 if (
GetBs()->GetBroadcastConnection()->HasPackets())
251 connection =
GetBs()->GetBroadcastConnection();
254 else if (
GetBs()->GetInitialRangingConnection()->HasPackets())
257 connection =
GetBs()->GetInitialRangingConnection();
262 std::vector<Ptr<WimaxConnection>> connections;
263 std::vector<ServiceFlow*> serviceFlows;
265 connections =
GetBs()->GetConnectionManager()->GetConnections(
Cid::BASIC);
266 for (
auto iter1 = connections.begin(); iter1 != connections.end(); ++iter1)
268 if ((*iter1)->HasPackets())
277 for (
auto iter1 = connections.begin(); iter1 != connections.end(); ++iter1)
279 if ((*iter1)->HasPackets())
288 for (
auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2)
290 serviceFlowRecord = (*iter2)->GetRecord();
292 << (*iter2)->HasPackets() <<
"max Latency = "
293 <<
MilliSeconds((*iter2)->GetMaximumLatency()) <<
"Delay = "
295 GetBs()->GetPhy()->GetFrameDuration()));
298 if ((*iter2)->HasPackets() && ((currentTime - serviceFlowRecord->
GetDlTimeStamp()) +
299 GetBs()->GetPhy()->GetFrameDuration()) >
303 connection = (*iter2)->GetConnection();
304 NS_LOG_INFO(
"Return UGS SF: CID = " << (*iter2)->GetCid()
305 <<
"SFID = " << (*iter2)->GetSfid());
311 for (
auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2)
313 serviceFlowRecord = (*iter2)->GetRecord();
316 if ((*iter2)->HasPackets() && ((currentTime - serviceFlowRecord->
GetDlTimeStamp()) +
317 GetBs()->GetPhy()->GetFrameDuration()) >
321 connection = (*iter2)->GetConnection();
322 NS_LOG_INFO(
"Return RTPS SF: CID = " << (*iter2)->GetCid()
323 <<
"SFID = " << (*iter2)->GetSfid());
330 for (
auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2)
333 if ((*iter2)->HasPackets())
335 NS_LOG_INFO(
"Return NRTPS SF: CID = " << (*iter2)->GetCid()
336 <<
"SFID = " << (*iter2)->GetSfid());
337 connection = (*iter2)->GetConnection();
343 for (
auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2)
346 if ((*iter2)->HasPackets())
348 NS_LOG_INFO(
"Return BE SF: CID = " << (*iter2)->GetCid()
349 <<
"SFID = " << (*iter2)->GetSfid());
350 connection = (*iter2)->GetConnection();
362 uint32_t availableSymbols)
368 uint32_t nrSymbolsRequired = 0;
374 uint32_t FirstPacketSize =
376 nrSymbolsRequired =
GetBs()->GetPhy()->GetNrSymbols(FirstPacketSize, modulationType);
377 if (availableSymbols < nrSymbolsRequired &&
380 uint32_t availableByte =
381 GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
383 availableSymbols = 0;
387 packet = connection->Dequeue();
388 availableSymbols -= nrSymbolsRequired;
390 burst->AddPacket(packet);
391 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...
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.