23 #include "ns3/simulator.h"
25 #include "ns3/packet-burst.h"
71 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > *downlinkBursts =
m_downlinkBursts;
72 std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > pair;
73 while (downlinkBursts->size ())
75 pair = downlinkBursts->front ();
85 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > >*
98 dlMapIe->
SetCid (connection->GetCid ());
101 NS_LOG_INFO (
"BS scheduler, burst size: " << burst->GetSize () <<
" bytes" <<
", pkts: " << burst->GetNPackets ()
102 <<
", connection: " << connection->GetTypeStr () <<
", CID: "
103 << connection->GetCid ());
106 NS_LOG_INFO (
", SFID: " << connection->GetServiceFlow ()->GetSfid () <<
", service: "
107 << connection->GetServiceFlow ()->GetSchedulingTypeStr ());
109 NS_LOG_INFO (
", modulation: " << modulationType <<
", DIUC: " << (uint32_t) diuc);
132 uint32_t availableSymbols =
GetBs ()->GetNrDlSymbols ();
153 << availableSymbols << std::endl <<
"BS scheduler, queues:" <<
" IR "
154 <<
GetBs ()->GetInitialRangingConnection ()->GetQueue ()->GetSize ()
156 <<
GetBs ()->GetBroadcastConnection ()->GetQueue ()->GetSize ()
169 uint32_t availableSymbols)
175 uint32_t nrSymbolsRequired = 0;
182 nrSymbolsRequired =
GetBs ()->GetPhy ()->GetNrSymbols (FirstPacketSize,modulationType);
187 uint32_t availableByte =
GetBs ()->GetPhy ()->GetNrBytes (availableSymbols, modulationType);
189 availableSymbols = 0;
193 packet = connection->Dequeue ();
194 availableSymbols -= nrSymbolsRequired;
196 burst->AddPacket (packet);
197 if (availableSymbols <= 0)
218 uint32_t nrSymbolsRequired = 0;
223 while (
GetBs ()->GetBroadcastConnection ()->HasPackets () && availableSymbols > 0)
225 connection =
GetBs ()->GetBroadcastConnection ();
227 packet = connection->GetQueue ()->Peek (hdr);
228 nrSymbolsRequired =
GetBs ()->GetPhy ()->GetNrSymbols (packet->
GetSize (), modulationType);
230 if (availableSymbols < nrSymbolsRequired
235 else if (availableSymbols < nrSymbolsRequired
238 uint32_t availableByte =
GetBs ()->GetPhy ()->
239 GetNrBytes (availableSymbols, modulationType);
245 packet = connection->Dequeue ();
249 "Base station: Error while scheduling broadcast connection: header CID != connection CID");
250 burst->AddPacket (packet);
251 availableSymbols -= nrSymbolsRequired;
253 if (burst->GetNPackets () != 0)
265 uint32_t nrSymbolsRequired = 0;
270 while (
GetBs ()->GetInitialRangingConnection ()->HasPackets () && availableSymbols > 0)
272 connection =
GetBs ()->GetInitialRangingConnection ();
274 packet = connection->GetQueue ()->Peek (hdr);
275 nrSymbolsRequired =
GetBs ()->GetPhy ()->GetNrSymbols (packet->
GetSize (), modulationType);
278 if (availableSymbols < nrSymbolsRequired
283 else if (availableSymbols < nrSymbolsRequired
286 uint32_t availableByte =
GetBs ()->GetPhy ()->
287 GetNrBytes (availableSymbols, modulationType);
293 packet = connection->Dequeue ();
297 "Base station: Error while scheduling initial ranging connection: header CID != connection CID");
298 burst->AddPacket (packet);
299 availableSymbols -= nrSymbolsRequired;
301 if (burst->GetNPackets ())
313 uint32_t nrSymbolsRequired = 0;
318 std::vector<Ptr<WimaxConnection> >::const_iterator iter;
319 std::vector<Ptr<WimaxConnection> > connections;
321 connections =
GetBs ()->GetConnectionManager ()->GetConnections (
Cid::BASIC);
322 for (iter = connections.begin (); iter != connections.end (); ++iter)
324 while ((*iter)->HasPackets () && availableSymbols > 0)
328 modulationType =
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
329 diuc =
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
332 packet = connection->GetQueue ()->Peek (hdr);
333 nrSymbolsRequired =
GetBs ()->GetPhy ()->GetNrSymbols (packet->
GetSize (), modulationType);
336 if (availableSymbols < nrSymbolsRequired
341 else if (availableSymbols < nrSymbolsRequired
344 uint32_t availableByte =
GetBs ()->GetPhy ()->
345 GetNrBytes (availableSymbols, modulationType);
350 packet = connection->Dequeue ();
354 "Base station: Error while scheduling basic connection: header CID != connection CID");
355 burst->AddPacket (packet);
356 availableSymbols -= nrSymbolsRequired;
358 if (burst->GetNPackets () != 0)
361 burst = Create<PacketBurst> ();
372 uint32_t nrSymbolsRequired = 0;
377 std::vector<Ptr<WimaxConnection> >::const_iterator iter;
378 std::vector<Ptr<WimaxConnection> > connections;
381 for (iter = connections.begin (); iter != connections.end (); ++iter)
383 while ((*iter)->HasPackets () && availableSymbols > 0)
387 modulationType =
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
388 diuc =
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
391 packet = connection->GetQueue ()->Peek (hdr);
392 nrSymbolsRequired =
GetBs ()->GetPhy ()->GetNrSymbols (packet->
GetSize (), modulationType);
395 if (availableSymbols < nrSymbolsRequired
400 else if (availableSymbols < nrSymbolsRequired
403 uint32_t availableByte =
GetBs ()->GetPhy ()->
404 GetNrBytes (availableSymbols, modulationType);
409 packet = connection->Dequeue ();
413 "Base station: Error while scheduling primary connection: header CID != connection CID");
414 burst->AddPacket (packet);
415 availableSymbols -= nrSymbolsRequired;
417 if (burst->GetNPackets () != 0)
430 uint32_t nrSymbolsRequired = 0;
437 std::vector<ServiceFlow*>::iterator iter;
439 std::vector<ServiceFlow*> serviceFlows;
442 for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
444 serviceFlowRecord = (*iter)->GetRecord ();
446 if ((*iter)->HasPackets () && ((currentTime - serviceFlowRecord->
GetDlTimeStamp ())
447 +
GetBs ()->GetPhy ()->GetFrameDuration ()) > MilliSeconds ((*iter)->GetMaximumLatency ()))
449 connection = (*iter)->GetConnection ();
452 modulationType = connection->GetServiceFlow ()->GetModulation ();
456 modulationType =
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
458 diuc =
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
461 nrSymbolsRequired = connection->GetServiceFlow ()->GetRecord ()->GetGrantSize ();
464 if (availableSymbols > nrSymbolsRequired)
466 availableSymbols -= nrSymbolsRequired;
467 burst =
CreateUgsBurst (connection->GetServiceFlow (), modulationType, nrSymbolsRequired);
468 if (burst->GetNPackets () != 0)
473 burst = Create<PacketBurst> ();
492 std::vector<Ptr<WimaxConnection> >::const_iterator iter;
493 std::vector<Ptr<WimaxConnection> > connections;
494 std::vector<ServiceFlow*>::iterator iter2;
496 std::vector<ServiceFlow*> serviceFlows;
498 uint32_t symbolsRequired[100];
503 uint32_t totSymbolsRequired = 0;
504 int nbConnection = 0;
506 NS_LOG_INFO (
"\tDL Scheduler for rtPS flows \n" <<
"\t\tavailableSymbols = " << availableSymbols);
510 for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
513 serviceFlowRecord = (*iter2)->GetRecord ();
515 if ((*iter2)->HasPackets ())
519 rtPSConnection[nbConnection] = (*iter2)->GetConnection ();
522 modulationType_[nbConnection] = rtPSConnection[nbConnection]->GetServiceFlow ()->GetModulation ();
526 modulationType_[nbConnection]
527 =
GetBs ()->GetSSManager ()->GetSSRecord (rtPSConnection[nbConnection]->GetCid ())->GetModulationType ();
530 =
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType_[nbConnection],
533 dataToSend = rtPSConnection[nbConnection]->GetQueue ()->GetQueueLengthWithMACOverhead ();
534 NS_LOG_INFO (
"\t\tRTPS DL Scheduler for CID = " << rtPSConnection[nbConnection]->GetCid ()
535 <<
"\n\t\t\t dataToSend = " << dataToSend);
537 symbolsRequired[nbConnection] =
GetBs ()->GetPhy ()->GetNrSymbols (dataToSend,
538 modulationType_[nbConnection]);
540 totSymbolsRequired += symbolsRequired[nbConnection];
545 NS_LOG_INFO (
"\t\ttotSymbolsRequired = " << totSymbolsRequired);
548 while (totSymbolsRequired > availableSymbols)
550 NS_LOG_INFO (
"\tDL Channel Saturation: totSymbolsRequired > availableSymbols_rtPS");
551 double delta = double(availableSymbols) / double(totSymbolsRequired);
553 totSymbolsRequired = 0;
554 for (
int i = 0; i < nbConnection; i++)
556 NS_LOG_INFO (
"\t\tprevious symbolsRequired[" << i <<
"] = " << symbolsRequired[i]);
557 symbolsRequired[i] = (uint32_t) std::floor (symbolsRequired[i] * delta);
558 totSymbolsRequired += symbolsRequired[i];
559 NS_LOG_INFO (
"\t\tnew symbolsRequired[" << i <<
"] = " << symbolsRequired[i]);
561 NS_LOG_INFO (
"\t\ttotSymbolsRequired = " << totSymbolsRequired);
565 for (
int i = 0; i < nbConnection; i++)
568 packet = rtPSConnection[i]->GetQueue ()->Peek (hdr);
569 uint32_t symbolsForPacketTransmission = 0;
570 burst = Create<PacketBurst> ();
571 NS_LOG_INFO (
"\t\tCID = " << rtPSConnection[i]->GetCid () <<
" assignedSymbols = " << symbolsRequired[i]);
573 while (symbolsRequired[i] > 0)
575 symbolsForPacketTransmission =
GetBs ()->GetPhy ()
576 ->GetNrSymbols (rtPSConnection[i]->GetQueue ()
581 if (symbolsForPacketTransmission > symbolsRequired[i]
588 else if (symbolsForPacketTransmission > symbolsRequired[i]
593 uint32_t availableByte =
GetBs ()->GetPhy ()->
594 GetNrBytes (symbolsRequired[i], modulationType_[i]);
596 symbolsRequired[i] = 0;
600 packet = rtPSConnection[i]->Dequeue ();
601 symbolsRequired[i] -= symbolsForPacketTransmission;
605 "Base station: Error while scheduling RTPs connection: header CID != connection CID");
606 burst->AddPacket (packet);
609 if (burst->GetNPackets () != 0)
615 availableSymbols -= totSymbolsRequired;
624 uint32_t nrSymbolsRequired = 0;
629 std::vector<ServiceFlow*>::iterator iter;
630 std::vector<ServiceFlow*> serviceFlows;
633 for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
635 connection = (*iter)->GetConnection ();
637 while ((*iter)->HasPackets () && availableSymbols > 0)
641 modulationType = connection->GetServiceFlow ()->GetModulation ();
645 modulationType =
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
648 diuc =
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
651 packet = connection->GetQueue ()->Peek (hdr);
652 nrSymbolsRequired =
GetBs ()->GetPhy ()->GetNrSymbols (packet->
GetSize (), modulationType);
654 if (availableSymbols < nrSymbolsRequired)
659 packet = connection->Dequeue ();
661 "Base station: Error while scheduling NRTPs connection: header CID != connection CID");
662 burst->AddPacket (packet);
663 availableSymbols -= nrSymbolsRequired;
665 if (burst->GetNPackets () != 0)
668 burst = Create<PacketBurst> ();
679 uint32_t nrSymbolsRequired = 0;
684 std::vector<ServiceFlow*>::iterator iter;
685 std::vector<ServiceFlow*> serviceFlows;
688 for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
690 connection = (*iter)->GetConnection ();
692 while ((*iter)->HasPackets () && availableSymbols > 0)
696 modulationType = connection->GetServiceFlow ()->GetModulation ();
700 modulationType =
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
702 diuc =
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
705 packet = connection->GetQueue ()->Peek (hdr);
706 nrSymbolsRequired =
GetBs ()->GetPhy ()->GetNrSymbols (packet->
GetSize (), modulationType);
708 if (availableSymbols < nrSymbolsRequired)
713 packet = connection->Dequeue ();
715 "Base station: Error while scheduling BE connection: header CID != connection CID");
716 burst->AddPacket (packet);
717 availableSymbols -= nrSymbolsRequired;
719 if (burst->GetNPackets () != 0)
722 burst = Create<PacketBurst> ();
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * GetDownlinkBursts(void) const
keep track of time values and allow control of global simulation resolution
smart pointer class similar to boost::intrusive_ptr
this class implements a structure to manage some parameters and statistics related to a service flow ...
void BSSchedulerInitialRangingConnection(uint32_t &availableSymbols)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
void BSSchedulerUGSConnection(uint32_t &availableSymbols)
uint32_t GetSize(void) const
void BSSchedulerBroadcastConnection(uint32_t &availableSymbols)
Ptr< WimaxConnection > GetConnection(void) const
bool CheckForFragmentation(Ptr< WimaxConnection > connection, int availableSymbols, WimaxPhy::ModulationType modulationType)
void SetDiuc(uint8_t diuc)
static TypeId GetTypeId(void)
void BSSchedulerRTPSConnection(uint32_t &availableSymbols)
Downlink Scheduler for rtPS connections.
Ptr< PacketBurst > CreateUgsBurst(ServiceFlow *serviceFlow, WimaxPhy::ModulationType modulationType, uint32_t availableSymbols)
NS_LOG_COMPONENT_DEFINE("BSSchedulerRtps")
void BSSchedulerBasicConnection(uint32_t &availableSymbols)
This class implements service flows as described by the IEEE-802.16 standard.
virtual Ptr< BaseStationNetDevice > GetBs(void)
static Time Now(void)
Return the "current simulation time".
bool SelectConnection(Ptr< WimaxConnection > &connection)
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
void AddDownlinkBurst(Ptr< const WimaxConnection > connection, uint8_t diuc, WimaxPhy::ModulationType modulationType, Ptr< PacketBurst > burst)
#define NS_ASSERT_MSG(condition, message)
void BSSchedulerPrimaryConnection(uint32_t &availableSymbols)
void Schedule(void)
Schedule function.
void SetDlTimeStamp(Time dlTimeStamp)
Set the DlTimeStamp.
Doxygen introspection did not find any typical Config paths.
Time GetDlTimeStamp(void) const
#define NS_LOG_DEBUG(msg)
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * m_downlinkBursts
uint16_t GetIdentifier(void) const
a base class which provides memory management and object aggregation
void BSSchedulerNRTPSConnection(uint32_t &availableSymbols)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void BSSchedulerBEConnection(uint32_t &availableSymbols)
bool HasPackets(void) const