23 #include "ns3/simulator.h" 
   25 #include "ns3/packet-burst.h" 
   51     .SetGroupName(
"Wimax")
 
   74   std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > *downlinkBursts = 
m_downlinkBursts;
 
   75   std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > pair;
 
   76   while (downlinkBursts->size ())
 
   78       pair = downlinkBursts->front ();
 
   88 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > >*
 
  101   dlMapIe->
SetCid (connection->GetCid ());
 
  104   NS_LOG_INFO (
"BS scheduler, burst size: " << burst->GetSize () << 
" bytes" << 
", pkts: " << burst->GetNPackets ()
 
  105                                             << 
", connection: " << connection->GetTypeStr () << 
", CID: " 
  106                                             << connection->GetCid ());
 
  109       NS_LOG_INFO (
", SFID: " << connection->GetServiceFlow ()->GetSfid () << 
", service: " 
  110                               << connection->GetServiceFlow ()->GetSchedulingTypeStr ());
 
  112   NS_LOG_INFO (
", modulation: " << modulationType << 
", DIUC: " << (uint32_t) diuc);
 
  135   uint32_t availableSymbols = 
GetBs ()->GetNrDlSymbols ();
 
  156                                                        << availableSymbols << std::endl << 
"BS scheduler, queues:" << 
" IR " 
  157                                                        << 
GetBs ()->GetInitialRangingConnection ()->GetQueue ()->GetSize ()
 
  159                                                        << 
GetBs ()->GetBroadcastConnection ()->GetQueue ()->GetSize ()
 
  172                                                   uint32_t availableSymbols)
 
  178   uint32_t nrSymbolsRequired = 0;
 
  185       nrSymbolsRequired = 
GetBs ()->GetPhy ()->GetNrSymbols (FirstPacketSize,modulationType);
 
  190           uint32_t availableByte = 
GetBs ()->GetPhy ()->GetNrBytes (availableSymbols, modulationType);
 
  192           availableSymbols = 0;
 
  196           packet = connection->Dequeue ();
 
  197           availableSymbols -= nrSymbolsRequired;
 
  199       burst->AddPacket (packet);
 
  200       if (availableSymbols <= 0)
 
  221   uint32_t nrSymbolsRequired = 0;
 
  226   while (
GetBs ()->GetBroadcastConnection ()->HasPackets () && availableSymbols > 0)
 
  228       connection = 
GetBs ()->GetBroadcastConnection ();
 
  230       packet = connection->GetQueue ()->Peek (hdr);
 
  231       nrSymbolsRequired = 
GetBs ()->GetPhy ()->GetNrSymbols (packet->
GetSize (), modulationType);
 
  233       if (availableSymbols < nrSymbolsRequired
 
  238       else if (availableSymbols < nrSymbolsRequired
 
  241           uint32_t availableByte = 
GetBs ()->GetPhy ()->
 
  242             GetNrBytes (availableSymbols, modulationType);
 
  248           packet = connection->Dequeue ();
 
  252                      "Base station: Error while scheduling broadcast connection: header CID != connection CID");
 
  253       burst->AddPacket (packet);
 
  254       availableSymbols -= nrSymbolsRequired;
 
  256   if (burst->GetNPackets () != 0)
 
  268   uint32_t nrSymbolsRequired = 0;
 
  273   while (
GetBs ()->GetInitialRangingConnection ()->HasPackets () && availableSymbols > 0)
 
  275       connection = 
GetBs ()->GetInitialRangingConnection ();
 
  277       packet = connection->GetQueue ()->Peek (hdr);
 
  278       nrSymbolsRequired = 
GetBs ()->GetPhy ()->GetNrSymbols (packet->
GetSize (), modulationType);
 
  281       if (availableSymbols < nrSymbolsRequired
 
  286       else if (availableSymbols < nrSymbolsRequired
 
  289           uint32_t availableByte = 
GetBs ()->GetPhy ()->
 
  290             GetNrBytes (availableSymbols, modulationType);
 
  296           packet = connection->Dequeue ();
 
  300                      "Base station: Error while scheduling initial ranging connection: header CID != connection CID");
 
  301       burst->AddPacket (packet);
 
  302       availableSymbols -= nrSymbolsRequired;
 
  304   if (burst->GetNPackets ())
 
  316   uint32_t nrSymbolsRequired = 0;
 
  321   std::vector<Ptr<WimaxConnection> >::const_iterator iter;
 
  322   std::vector<Ptr<WimaxConnection> > connections;
 
  324   connections = 
GetBs ()->GetConnectionManager ()->GetConnections (
Cid::BASIC);
 
  325   for (iter = connections.begin (); iter != connections.end (); ++iter)
 
  327       while ((*iter)->HasPackets () && availableSymbols > 0)
 
  331           modulationType = 
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
 
  332           diuc = 
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
 
  335           packet = connection->GetQueue ()->Peek (hdr);
 
  336           nrSymbolsRequired = 
GetBs ()->GetPhy ()->GetNrSymbols (packet->
GetSize (), modulationType);
 
  339           if (availableSymbols < nrSymbolsRequired
 
  344           else if (availableSymbols < nrSymbolsRequired
 
  347               uint32_t availableByte = 
GetBs ()->GetPhy ()->
 
  348                 GetNrBytes (availableSymbols, modulationType);
 
  353               packet = connection->Dequeue ();
 
  357                          "Base station: Error while scheduling basic connection: header CID != connection CID");
 
  358           burst->AddPacket (packet);
 
  359           availableSymbols -= nrSymbolsRequired;
 
  361       if (burst->GetNPackets () != 0)
 
  364           burst = Create<PacketBurst> ();
 
  375   uint32_t nrSymbolsRequired = 0;
 
  380   std::vector<Ptr<WimaxConnection> >::const_iterator iter;
 
  381   std::vector<Ptr<WimaxConnection> > connections;
 
  384   for (iter = connections.begin (); iter != connections.end (); ++iter)
 
  386       while ((*iter)->HasPackets () && availableSymbols > 0)
 
  390           modulationType = 
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
 
  391           diuc = 
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
 
  394           packet = connection->GetQueue ()->Peek (hdr);
 
  395           nrSymbolsRequired = 
GetBs ()->GetPhy ()->GetNrSymbols (packet->
GetSize (), modulationType);
 
  398           if (availableSymbols < nrSymbolsRequired
 
  403           else if (availableSymbols < nrSymbolsRequired
 
  406               uint32_t availableByte = 
GetBs ()->GetPhy ()->
 
  407                 GetNrBytes (availableSymbols, modulationType);
 
  412               packet = connection->Dequeue ();
 
  416                          "Base station: Error while scheduling primary connection: header CID != connection CID");
 
  417           burst->AddPacket (packet);
 
  418           availableSymbols -= nrSymbolsRequired;
 
  420       if (burst->GetNPackets () != 0)
 
  433   uint32_t nrSymbolsRequired = 0;
 
  440   std::vector<ServiceFlow*>::iterator iter;
 
  442   std::vector<ServiceFlow*> serviceFlows;
 
  445   for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
 
  447       serviceFlowRecord = (*iter)->GetRecord ();
 
  449       if ((*iter)->HasPackets () && ((currentTime - serviceFlowRecord->
GetDlTimeStamp ())
 
  450                                      + 
GetBs ()->GetPhy ()->GetFrameDuration ()) > 
MilliSeconds ((*iter)->GetMaximumLatency ()))
 
  452           connection = (*iter)->GetConnection ();
 
  455               modulationType = connection->GetServiceFlow ()->GetModulation ();
 
  459               modulationType = 
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
 
  461           diuc = 
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
 
  464           nrSymbolsRequired = connection->GetServiceFlow ()->GetRecord ()->GetGrantSize ();
 
  467           if (availableSymbols > nrSymbolsRequired)
 
  469               availableSymbols -= nrSymbolsRequired;
 
  470               burst = 
CreateUgsBurst (connection->GetServiceFlow (), modulationType, nrSymbolsRequired);
 
  471               if (burst->GetNPackets () != 0)
 
  476                   burst = Create<PacketBurst> ();
 
  495   std::vector<Ptr<WimaxConnection> >::const_iterator iter;
 
  496   std::vector<Ptr<WimaxConnection> > connections;
 
  497   std::vector<ServiceFlow*>::iterator iter2;
 
  499   std::vector<ServiceFlow*> serviceFlows;
 
  501   uint32_t symbolsRequired[100];
 
  506   uint32_t totSymbolsRequired = 0;
 
  507   int nbConnection = 0;
 
  509   NS_LOG_INFO (
"\tDL Scheduler for rtPS flows \n" << 
"\t\tavailableSymbols = " << availableSymbols);
 
  513   for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
 
  516       serviceFlowRecord = (*iter2)->GetRecord ();
 
  518       if ((*iter2)->HasPackets ())
 
  522           rtPSConnection[nbConnection] = (*iter2)->GetConnection ();
 
  525               modulationType_[nbConnection] = rtPSConnection[nbConnection]->GetServiceFlow ()->GetModulation ();
 
  529               modulationType_[nbConnection]
 
  530                 = 
GetBs ()->GetSSManager ()->GetSSRecord (rtPSConnection[nbConnection]->GetCid ())->GetModulationType ();
 
  533             = 
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType_[nbConnection],
 
  536           dataToSend = rtPSConnection[nbConnection]->GetQueue ()->GetQueueLengthWithMACOverhead ();
 
  537           NS_LOG_INFO (
"\t\tRTPS DL Scheduler for CID = " << rtPSConnection[nbConnection]->GetCid ()
 
  538                                                           << 
"\n\t\t\t dataToSend = " << dataToSend);
 
  540           symbolsRequired[nbConnection] = 
GetBs ()->GetPhy ()->GetNrSymbols (dataToSend,
 
  541                                                                              modulationType_[nbConnection]);
 
  543           totSymbolsRequired += symbolsRequired[nbConnection];
 
  548   NS_LOG_INFO (
"\t\ttotSymbolsRequired = " << totSymbolsRequired);
 
  551   while (totSymbolsRequired > availableSymbols)
 
  553       NS_LOG_INFO (
"\tDL Channel Saturation: totSymbolsRequired > availableSymbols_rtPS");
 
  554       double delta = double(availableSymbols) / double(totSymbolsRequired);
 
  556       totSymbolsRequired = 0;
 
  557       for (
int i = 0; i < nbConnection; i++)
 
  559           NS_LOG_INFO (
"\t\tprevious symbolsRequired[" << i << 
"] = " << symbolsRequired[i]);
 
  560           symbolsRequired[i] = (uint32_t) std::floor (symbolsRequired[i] * delta);
 
  561           totSymbolsRequired += symbolsRequired[i];
 
  562           NS_LOG_INFO (
"\t\tnew symbolsRequired[" << i << 
"] = " << symbolsRequired[i]);
 
  564       NS_LOG_INFO (
"\t\ttotSymbolsRequired = " << totSymbolsRequired);
 
  568   for (
int i = 0; i < nbConnection; i++)
 
  571       packet = rtPSConnection[i]->GetQueue ()->Peek (hdr);
 
  572       uint32_t symbolsForPacketTransmission = 0;
 
  573       burst = Create<PacketBurst> ();
 
  574       NS_LOG_INFO (
"\t\tCID = " << rtPSConnection[i]->GetCid () << 
" assignedSymbols = " << symbolsRequired[i]);
 
  576       while (symbolsRequired[i] > 0)
 
  578           symbolsForPacketTransmission = 
GetBs ()->GetPhy ()
 
  579             ->GetNrSymbols (rtPSConnection[i]->GetQueue ()
 
  584           if (symbolsForPacketTransmission > symbolsRequired[i]
 
  591           else if (symbolsForPacketTransmission > symbolsRequired[i]
 
  596               uint32_t availableByte = 
GetBs ()->GetPhy ()->
 
  597                 GetNrBytes (symbolsRequired[i], modulationType_[i]);
 
  599               symbolsRequired[i] = 0;
 
  603               packet = rtPSConnection[i]->Dequeue ();
 
  604               symbolsRequired[i] -= symbolsForPacketTransmission;
 
  608                          "Base station: Error while scheduling RTPs connection: header CID != connection CID");
 
  609           burst->AddPacket (packet);
 
  612       if (burst->GetNPackets () != 0)
 
  618   availableSymbols -= totSymbolsRequired;
 
  627   uint32_t nrSymbolsRequired = 0;
 
  632   std::vector<ServiceFlow*>::iterator iter;
 
  633   std::vector<ServiceFlow*> serviceFlows;
 
  636   for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
 
  638       connection = (*iter)->GetConnection ();
 
  640       while ((*iter)->HasPackets () && availableSymbols > 0)
 
  644               modulationType = connection->GetServiceFlow ()->GetModulation ();
 
  648               modulationType = 
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
 
  651           diuc = 
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
 
  654           packet = connection->GetQueue ()->Peek (hdr);
 
  655           nrSymbolsRequired = 
GetBs ()->GetPhy ()->GetNrSymbols (packet->
GetSize (), modulationType);
 
  657           if (availableSymbols < nrSymbolsRequired)
 
  662           packet = connection->Dequeue ();
 
  664                          "Base station: Error while scheduling NRTPs connection: header CID != connection CID");
 
  665           burst->AddPacket (packet);
 
  666           availableSymbols -= nrSymbolsRequired;
 
  668       if (burst->GetNPackets () != 0)
 
  671           burst = Create<PacketBurst> ();
 
  682   uint32_t nrSymbolsRequired = 0;
 
  687   std::vector<ServiceFlow*>::iterator iter;
 
  688   std::vector<ServiceFlow*> serviceFlows;
 
  691   for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
 
  693       connection = (*iter)->GetConnection ();
 
  695       while ((*iter)->HasPackets () && availableSymbols > 0)
 
  699               modulationType = connection->GetServiceFlow ()->GetModulation ();
 
  703               modulationType = 
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
 
  705           diuc = 
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
 
  708           packet = connection->GetQueue ()->Peek (hdr);
 
  709           nrSymbolsRequired = 
GetBs ()->GetPhy ()->GetNrSymbols (packet->
GetSize (), modulationType);
 
  711           if (availableSymbols < nrSymbolsRequired)
 
  716           packet = connection->Dequeue ();
 
  718                          "Base station: Error while scheduling BE connection: header CID != connection CID");
 
  719           burst->AddPacket (packet);
 
  720           availableSymbols -= nrSymbolsRequired;
 
  722       if (burst->GetNPackets () != 0)
 
  725           burst = Create<PacketBurst> ();
 
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * GetDownlinkBursts(void) const 
 
Simulation virtual time values and global simulation resolution. 
 
Smart pointer class similar to boost::intrusive_ptr. 
 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
 
this class implements a structure to manage some parameters and statistics related to a service flow ...
 
void BSSchedulerInitialRangingConnection(uint32_t &availableSymbols)
 
void BSSchedulerUGSConnection(uint32_t &availableSymbols)
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit. 
 
uint32_t GetSize(void) const 
Returns the the size in bytes of the packet (including the zero-filled initial payload). 
 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO. 
 
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)
 
This class implements a simple downlink scheduler for rtPS flows. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
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 virtual 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)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
 
void BSSchedulerPrimaryConnection(uint32_t &availableSymbols)
 
void Schedule(void)
Schedule function. 
 
void SetDlTimeStamp(Time dlTimeStamp)
Set the DlTimeStamp. 
 
this class implement a burst as a list of packets 
 
Time GetDlTimeStamp(void) const 
 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
 
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * m_downlinkBursts
 
uint16_t GetIdentifier(void) const 
 
void BSSchedulerNRTPSConnection(uint32_t &availableSymbols)
 
a unique identifier for an interface. 
 
TypeId SetParent(TypeId tid)
Set the parent TypeId. 
 
void BSSchedulerBEConnection(uint32_t &availableSymbols)
 
bool HasPackets(void) const