24 #include "ns3/simulator.h" 
   29 #include "ns3/uinteger.h" 
   76     .SetGroupName(
"Wimax")
 
   82 std::list<OfdmUlMapIe>
 
   95   uint32_t randNr = rand ();
 
   96   if (randNr % 5 == 0 || 
GetBs ()->GetNrDcdSent () == 0)
 
  102   if (randNr % 5 == 0 || 
GetBs ()->GetNrUcdSent () == 0)
 
  131   if (timeSinceLastDcd > 
GetBs ()->GetDcdInterval ())
 
  137   if (timeSinceLastUcd > 
GetBs ()->GetUcdInterval ())
 
  147   return GetBs ()->GetNrDlSymbols () * 
GetBs ()->GetPhy ()->GetPsPerSymbol () + 
GetBs ()->GetTtg ();
 
  152                                           const uint32_t &allocationSize,
 
  153                                           uint32_t &symbolsToAllocation,
 
  154                                           uint32_t &availableSymbols)
 
  159   symbolsToAllocation += allocationSize;
 
  160   availableSymbols -= allocationSize;
 
  169   bool allocationForDsa = 
false;
 
  171   uint32_t symbolsToAllocation = 0;
 
  172   uint32_t allocationSize = 0; 
 
  173   uint32_t availableSymbols = 
GetBs ()->GetNrUlSymbols ();
 
  180   std::vector<SSRecord*> *ssRecords = 
GetBs ()->GetSSManager ()->GetSSRecords ();
 
  181   NS_LOG_INFO (
"UL Scheduler start, availableSymbols = " << availableSymbols);
 
  183   for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
 
  199           allocationSize = 
GetBs ()->GetRangReqOppSize ();
 
  202           if (availableSymbols >= allocationSize)
 
  216           ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
 
  225               if (!allocationForDsa)
 
  227                   allocationSize = 
GetBs ()->GetPhy ()->GetNrSymbols (
sizeof(
DsaReq), modulationType);
 
  228                   if (availableSymbols >= allocationSize)
 
  231                       allocationForDsa = 
true;
 
  253               if (availableSymbols)
 
  263               if (availableSymbols)
 
  273               if (availableSymbols)
 
  289   if (availableSymbols)
 
  295   if (availableSymbols)
 
  297       for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
 
  311               ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
 
  315               if (availableSymbols)
 
  325               if (availableSymbols)
 
  346   GetBs ()->GetBandwidthManager ()->SetSubframeRatio ();
 
  354                                                uint32_t &symbolsToAllocation,
 
  355                                                uint32_t &availableSymbols)
 
  357   uint32_t allocationSize = 0; 
 
  358   uint8_t uiuc = ulMapIe.
GetUiuc (); 
 
  359   std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
 
  361   for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
 
  369       allocationSize = 
GetBs ()->GetBandwidthManager ()->CalculateAllocationSize (ssRecord, serviceFlow);
 
  379               if (bps < serviceFlow->GetMinReservedTrafficRate ())
 
  393       if (availableSymbols < allocationSize)
 
  398       if (allocationSize > 0)
 
  414           NS_LOG_DEBUG (
"BS uplink scheduler, UGS allocation, size: " << allocationSize << 
" symbols");
 
  419                                                 << allocationSize << 
" symbols" << 
", modulation: BPSK 1/2");
 
  434                                                uint32_t &symbolsToAllocation,
 
  435                                                uint32_t &availableSymbols)
 
  437   std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
 
  439   for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
 
  458                                                uint32_t &symbolsToAllocation,
 
  459                                                uint32_t &availableSymbols)
 
  461   uint32_t allocSizeBytes = 0;
 
  462   uint32_t allocSizeSymbols = 0;
 
  463   uint16_t sduSize = 0;
 
  469   if (requiredBandwidth > 0)
 
  474           allocSizeBytes = sduSize;
 
  475           allocSizeSymbols = 
GetBs ()->GetPhy ()->GetNrSymbols (sduSize, modulationType);
 
  479           allocSizeBytes = requiredBandwidth;
 
  480           allocSizeSymbols = 
GetBs ()->GetPhy ()->GetNrSymbols (requiredBandwidth, modulationType);
 
  483       if (availableSymbols >= allocSizeSymbols)
 
  487                                                 << allocSizeSymbols << 
" symbols" << 
", CID: " << serviceFlow->
GetConnection ()->GetCid () << 
", SFID: " 
  512   NS_LOG_INFO (
"\t\tavailableSymbols = " << availableSymbols);
 
  514   uint32_t allocSizeSymbols_[100]; 
 
  519   int nbAllocation = 0;
 
  520   uint32_t allocSizeBytes;
 
  521   uint32_t totAllocSizeSymbols = 0;
 
  524   std::vector<SSRecord*> *ssRecords = 
GetBs ()->GetSSManager ()->GetSSRecords ();
 
  526   for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
 
  539           ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
 
  543           for (std::vector<ServiceFlow*>::iterator iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
 
  545               record_[nbAllocation] = (*iter2)->GetRecord ();
 
  549               if (requiredBandwidth > 0)
 
  551                   modulationType_[nbAllocation] = modulationType;
 
  552                   ulMapIe_[nbAllocation] = ulMapIe;
 
  553                   allocSizeBytes = requiredBandwidth;
 
  554                   allocSizeSymbols_[nbAllocation] = 
GetBs ()->GetPhy ()->GetNrSymbols (allocSizeBytes,
 
  555                                                                                        modulationType_[nbAllocation]);
 
  556                   totAllocSizeSymbols += allocSizeSymbols_[nbAllocation];
 
  558                   NS_LOG_INFO (
"\t\tUL Scheduler for CID = " << (*iter2)->GetConnection ()->GetCid ());
 
  559                   NS_LOG_INFO (
"\t\t\trequiredBandwidth = " << record_[nbAllocation]->GetRequestedBandwidth ()
 
  560                                                             << 
", allocSizeSymbols = " << allocSizeSymbols_[nbAllocation] << 
", modulationType = " 
  561                                                             << modulationType_[nbAllocation]);
 
  569   NS_LOG_INFO (
"\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
 
  572   while (totAllocSizeSymbols > availableSymbols)
 
  574       NS_LOG_INFO (
"\tUL Channel Saturation: totAllocSizeSymbols > availableSymbols");
 
  575       double delta = double(availableSymbols) / double(totAllocSizeSymbols);
 
  577       totAllocSizeSymbols = 0;
 
  578       for (
int i = 0; i < nbAllocation; i++)
 
  580           NS_LOG_INFO (
"\t\tprevious allocSizeSymbols_[" << i << 
"] = " << allocSizeSymbols_[i]);
 
  581           allocSizeSymbols_[i] = (uint32_t) std::floor (allocSizeSymbols_[i] * delta);
 
  582           totAllocSizeSymbols += allocSizeSymbols_[i];
 
  583           NS_LOG_INFO (
"\t\tnew allocSizeSymbols_[" << i << 
"] = " << allocSizeSymbols_[i]);
 
  585       NS_LOG_INFO (
"\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
 
  589   for (
int i = 0; i < nbAllocation; i++)
 
  591       AddUplinkAllocation (ulMapIe_[i], allocSizeSymbols_[i], symbolsToAllocation, availableSymbols);
 
  592       allocSizeBytes = 
GetBs ()->GetPhy ()->GetNrBytes (allocSizeSymbols_[i], modulationType_[i]);
 
  593       NS_LOG_INFO (
"\t\tUpdateGrantedBandwidth for " << i << 
" = " << allocSizeBytes);
 
  594       if (record_[i]->GetRequestedBandwidth () < allocSizeBytes)
 
  616   if (timeSinceLastIrInterval + 
GetBs ()->GetPhy ()->GetFrameDuration () > 
GetBs ()->GetInitialRangingInterval ()
 
  617       && availableSymbols >= allocationSize)
 
  621       ulMapIeIr.
SetCid (
GetBs ()->GetBroadcastConnection ()->GetCid ());
 
  625       NS_LOG_DEBUG (
"BS uplink scheduler, initial ranging allocation, size: " << allocationSize << 
" symbols" 
  626                                                                               << 
", modulation: BPSK 1/2");
 
  631           GetBs ()->MarkRangingOppStart (ssUlStartTime + 
Seconds (symbolsToAllocation
 
  632                                                                   * 
GetBs ()->GetSymbolDuration ().GetSeconds ()) + 
Seconds (i * 
GetBs ()->GetRangReqOppSize ()
 
  633                                                                                                                              * 
GetBs ()->GetSymbolDuration ().GetSeconds ()));
 
  644   uint8_t delayNrFrames = 1;
 
  647   uint32_t bytesPerFrame =
 
  648     (uint32_t ((
double)(bitsPerSecond) * 
GetBs ()->GetPhy ()->GetFrameDuration ().GetSeconds ())) / 8;
 
  649   uint32_t frameDurationMSec = 
GetBs ()->GetPhy ()->GetFrameDuration ().GetMilliSeconds ();
 
  663         uint32_t grantSize = 
GetBs ()->GetPhy ()->GetNrSymbols (bytesPerFrame, modulation);
 
  668         if (toleratedJitter > frameDurationMSec)
 
  670             delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec);
 
  673         uint16_t interval = delayNrFrames * frameDurationMSec;
 
  679         if (serviceFlow->
GetSduSize () > bytesPerFrame)
 
  681             delayNrFrames = (uint8_t)(serviceFlow->
GetSduSize () / bytesPerFrame);
 
  684         uint16_t interval = delayNrFrames * frameDurationMSec;
 
  717   uint32_t grantedBandwidth = 0;
 
Simulation virtual time values and global simulation resolution. 
 
enum WimaxPhy::ModulationType GetModulation(void) const 
 
Smart pointer class similar to boost::intrusive_ptr. 
 
enum ServiceFlow::SchedulingType GetSchedulingType(void) const 
 
virtual void SetDcdTimeStamp(Time dcdTimeStamp)
 
static TypeId GetTypeId(void)
 
virtual Time GetUcdTimeStamp(void) const 
 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
 
Cid GetBasicCid(void) const 
 
void ServiceUnsolicitedGrants(const SSRecord *ssRecord, enum ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
 
uint32_t GetRequestedBandwidth(void)
 
void ProcessBandwidthRequest(const BandwidthRequestHeader &bwRequestHdr)
 
this class implements a structure to manage some parameters and statistics related to a service flow ...
 
std::list< OfdmUlMapIe > m_uplinkAllocations
 
void SetRequestedBandwidth(uint32_t requestedBandwidth)
 
void AddUplinkAllocation(OfdmUlMapIe &ulMapIe, const uint32_t &allocationSize, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
 
bool GetAreServiceFlowsAllocated(void) const 
 
virtual void SetIsIrIntrvlAllocated(bool isIrIntrvlAllocated)
 
void SetGrantedBandwidth(uint32_t grantedBandwidth)
 
void SetupServiceFlow(SSRecord *ssRecord, ServiceFlow *serviceFlow)
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
uint32_t GetSfid(void) const 
 
WimaxNetDevice::RangingStatus GetRangingStatus(void) const 
 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO. 
 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate. 
 
std::list< OfdmUlMapIe > GetUplinkAllocations(void) const 
 
This class implements a simple uplink scheduler for rtPS flows. 
 
Ptr< WimaxConnection > GetConnection(void) const 
 
char * GetSchedulingTypeStr(void) const 
 
uint32_t GetMinReservedTrafficRate(void) const 
 
virtual void SetTimeStampIrInterval(Time timeStampIrInterval)
 
virtual Time GetTimeStampIrInterval(void)
 
Time GetGrantTimeStamp(void) const 
 
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
 
Virtual class for uplink scheduler. 
 
uint32_t GetBwSinceLastExpiry(void)
 
static Cid InitialRanging(void)
 
void SetGrantTimeStamp(Time grantTimeStamp)
Set the grant time stamp. 
 
void SetUnsolicitedPollingInterval(uint16_t)
 
virtual void SetNrIrOppsAllocated(uint8_t nrIrOppsAllocated)
 
void SetDuration(uint16_t duration)
 
~UplinkSchedulerRtps(void)
 
void SetGrantSize(uint32_t grantSize)
Set the grant size (only for UGS service flows) 
 
void ULSchedulerRTPSConnection(uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Uplink Scheduler for rtPS connections. 
 
void SetUnsolicitedGrantInterval(uint16_t)
 
std::vector< ServiceFlow * > GetServiceFlows(enum ServiceFlow::SchedulingType schedulingType) const 
 
void ServiceBandwidthRequests(const SSRecord *ssRecord, enum ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
 
virtual void SetIsInvIrIntrvlAllocated(bool isInvIrIntrvlAllocated)
 
uint8_t GetUiuc(void) const 
 
uint32_t CalculateAllocationStartTime(void)
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
this class implements the bandwidth-request mac Header as described by IEEE Standard for Local and me...
 
virtual uint8_t GetNrIrOppsAllocated(void) const 
 
uint8_t GetSduSize(void) const 
 
This class implements service flows as described by the IEEE-802.16 standard. 
 
virtual Ptr< BaseStationNetDevice > GetBs(void)
 
void SetStartTime(uint16_t startTime)
 
static Time Now(void)
Return the current simulation virtual time. 
 
ServiceFlowRecord * GetRecord(void) const 
 
void AllocateInitialRangingInterval(uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
 
bool GetPollForRanging(void) const 
 
bool GetIsBroadcastSS(void)
 
virtual void SetUcdTimeStamp(Time ucdTimeStamp)
 
void Schedule(void)
Schedule function. 
 
uint32_t GetToleratedJitter(void) const 
 
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
 
bool GetIsMulticast(void) const 
 
Time Seconds(double value)
Construct a Time in the indicated unit. 
 
void SetBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
 
This class is used by the base station to store some information related to subscriber station in the...
 
void UpdateGrantedBandwidth(uint32_t grantedBandwidth)
 
uint32_t GetGrantedBandwidth(void)
 
Introspection did not find any typical Config paths. 
 
virtual Time GetDcdTimeStamp(void) const 
 
void OnSetRequestedBandwidth(ServiceFlowRecord *sfr)
 
a unique identifier for an interface. 
 
void SetUiuc(uint8_t uiuc)
 
TypeId SetParent(TypeId tid)
Set the parent TypeId. 
 
void GetChannelDescriptorsToUpdate(bool &, bool &, bool &, bool &)
Determines if channel descriptors sent in the current frame are required to be updated. 
 
WimaxPhy::ModulationType GetModulationType(void) const