24 #include "ns3/simulator.h"
29 #include "ns3/uinteger.h"
76 std::list<OfdmUlMapIe>
89 uint32_t randNr = rand ();
90 if (randNr % 5 == 0 ||
GetBs ()->GetNrDcdSent () == 0)
96 if (randNr % 5 == 0 ||
GetBs ()->GetNrUcdSent () == 0)
125 if (timeSinceLastDcd >
GetBs ()->GetDcdInterval ())
131 if (timeSinceLastUcd >
GetBs ()->GetUcdInterval ())
141 return GetBs ()->GetNrDlSymbols () *
GetBs ()->GetPhy ()->GetPsPerSymbol () +
GetBs ()->GetTtg ();
146 const uint32_t &allocationSize,
147 uint32_t &symbolsToAllocation,
148 uint32_t &availableSymbols)
153 symbolsToAllocation += allocationSize;
154 availableSymbols -= allocationSize;
163 bool allocationForDsa =
false;
165 uint32_t symbolsToAllocation = 0;
166 uint32_t allocationSize = 0;
167 uint32_t availableSymbols =
GetBs ()->GetNrUlSymbols ();
174 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
175 NS_LOG_INFO (
"UL Scheduler start, availableSymbols = " << availableSymbols);
177 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
193 allocationSize =
GetBs ()->GetRangReqOppSize ();
196 if (availableSymbols >= allocationSize)
210 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
219 if (!allocationForDsa)
221 allocationSize =
GetBs ()->GetPhy ()->GetNrSymbols (
sizeof(
DsaReq), modulationType);
222 if (availableSymbols >= allocationSize)
225 allocationForDsa =
true;
247 if (availableSymbols)
257 if (availableSymbols)
267 if (availableSymbols)
283 if (availableSymbols)
289 if (availableSymbols)
291 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
305 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
309 if (availableSymbols)
319 if (availableSymbols)
340 GetBs ()->GetBandwidthManager ()->SetSubframeRatio ();
348 uint32_t &symbolsToAllocation,
349 uint32_t &availableSymbols)
351 uint32_t allocationSize = 0;
352 uint8_t uiuc = ulMapIe.
GetUiuc ();
353 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
355 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
363 allocationSize =
GetBs ()->GetBandwidthManager ()->CalculateAllocationSize (ssRecord, serviceFlow);
373 if (bps < serviceFlow->GetMinReservedTrafficRate ())
387 if (availableSymbols < allocationSize)
392 if (allocationSize > 0)
408 NS_LOG_DEBUG (
"BS uplink scheduler, UGS allocation, size: " << allocationSize <<
" symbols");
413 << allocationSize <<
" symbols" <<
", modulation: BPSK 1/2");
428 uint32_t &symbolsToAllocation,
429 uint32_t &availableSymbols)
431 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
433 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
452 uint32_t &symbolsToAllocation,
453 uint32_t &availableSymbols)
455 uint32_t allocSizeBytes = 0;
456 uint32_t allocSizeSymbols = 0;
457 uint16_t sduSize = 0;
463 if (requiredBandwidth > 0)
468 allocSizeBytes = sduSize;
469 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (sduSize, modulationType);
473 allocSizeBytes = requiredBandwidth;
474 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (requiredBandwidth, modulationType);
477 if (availableSymbols >= allocSizeSymbols)
481 << allocSizeSymbols <<
" symbols" <<
", CID: " << serviceFlow->
GetConnection ()->GetCid () <<
", SFID: "
506 NS_LOG_INFO (
"\t\tavailableSymbols = " << availableSymbols);
508 uint32_t allocSizeSymbols_[100];
513 int nbAllocation = 0;
514 uint32_t allocSizeBytes;
515 uint32_t totAllocSizeSymbols = 0;
518 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
520 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
533 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
537 for (std::vector<ServiceFlow*>::iterator iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
539 record_[nbAllocation] = (*iter2)->GetRecord ();
543 if (requiredBandwidth > 0)
545 modulationType_[nbAllocation] = modulationType;
546 ulMapIe_[nbAllocation] = ulMapIe;
547 allocSizeBytes = requiredBandwidth;
548 allocSizeSymbols_[nbAllocation] =
GetBs ()->GetPhy ()->GetNrSymbols (allocSizeBytes,
549 modulationType_[nbAllocation]);
550 totAllocSizeSymbols += allocSizeSymbols_[nbAllocation];
552 NS_LOG_INFO (
"\t\tUL Scheduler for CID = " << (*iter2)->GetConnection ()->GetCid ());
553 NS_LOG_INFO (
"\t\t\trequiredBandwidth = " << record_[nbAllocation]->GetRequestedBandwidth ()
554 <<
", allocSizeSymbols = " << allocSizeSymbols_[nbAllocation] <<
", modulationType = "
555 << modulationType_[nbAllocation]);
563 NS_LOG_INFO (
"\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
566 while (totAllocSizeSymbols > availableSymbols)
568 NS_LOG_INFO (
"\tUL Channel Saturation: totAllocSizeSymbols > availableSymbols");
569 double delta = double(availableSymbols) / double(totAllocSizeSymbols);
571 totAllocSizeSymbols = 0;
572 for (
int i = 0; i < nbAllocation; i++)
574 NS_LOG_INFO (
"\t\tprevious allocSizeSymbols_[" << i <<
"] = " << allocSizeSymbols_[i]);
575 allocSizeSymbols_[i] = (uint32_t) std::floor (allocSizeSymbols_[i] * delta);
576 totAllocSizeSymbols += allocSizeSymbols_[i];
577 NS_LOG_INFO (
"\t\tnew allocSizeSymbols_[" << i <<
"] = " << allocSizeSymbols_[i]);
579 NS_LOG_INFO (
"\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
583 for (
int i = 0; i < nbAllocation; i++)
585 AddUplinkAllocation (ulMapIe_[i], allocSizeSymbols_[i], symbolsToAllocation, availableSymbols);
586 allocSizeBytes =
GetBs ()->GetPhy ()->GetNrBytes (allocSizeSymbols_[i], modulationType_[i]);
587 NS_LOG_INFO (
"\t\tUpdateGrantedBandwidth for " << i <<
" = " << allocSizeBytes);
588 if (record_[i]->GetRequestedBandwidth () < allocSizeBytes)
610 if (timeSinceLastIrInterval +
GetBs ()->GetPhy ()->GetFrameDuration () >
GetBs ()->GetInitialRangingInterval ()
611 && availableSymbols >= allocationSize)
615 ulMapIeIr.
SetCid (
GetBs ()->GetBroadcastConnection ()->GetCid ());
619 NS_LOG_DEBUG (
"BS uplink scheduler, initial ranging allocation, size: " << allocationSize <<
" symbols"
620 <<
", modulation: BPSK 1/2");
625 GetBs ()->MarkRangingOppStart (ssUlStartTime + Seconds (symbolsToAllocation
626 *
GetBs ()->GetSymbolDuration ().GetSeconds ()) + Seconds (i *
GetBs ()->GetRangReqOppSize ()
627 *
GetBs ()->GetSymbolDuration ().GetSeconds ()));
638 uint8_t delayNrFrames = 1;
641 uint32_t bytesPerFrame =
642 (uint32_t ((
double)(bitsPerSecond) *
GetBs ()->GetPhy ()->GetFrameDuration ().GetSeconds ())) / 8;
643 uint32_t frameDurationMSec =
GetBs ()->GetPhy ()->GetFrameDuration ().GetMilliSeconds ();
657 uint32_t grantSize =
GetBs ()->GetPhy ()->GetNrSymbols (bytesPerFrame, modulation);
662 if (toleratedJitter > frameDurationMSec)
664 delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec);
667 uint16_t interval = delayNrFrames * frameDurationMSec;
673 if (serviceFlow->
GetSduSize () > bytesPerFrame)
675 delayNrFrames = (uint8_t)(serviceFlow->
GetSduSize () / bytesPerFrame);
678 uint16_t interval = delayNrFrames * frameDurationMSec;
711 uint32_t grantedBandwidth = 0;
keep track of time values and allow control of 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
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)
uint32_t GetSfid(void) const
WimaxNetDevice::RangingStatus GetRangingStatus(void) const
std::list< OfdmUlMapIe > GetUplinkAllocations(void) const
Ptr< WimaxConnection > GetConnection(void) const
char * GetSchedulingTypeStr(void) const
#define NS_FATAL_ERROR(msg)
fatal error handling
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. Used for data alocation for ugs flows, and unicast poll (bw request) for no...
void SetUnsolicitedPollingInterval(uint16_t)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
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)
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
virtual Ptr< BaseStationNetDevice > GetBs(void)
void SetStartTime(uint16_t startTime)
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)
bool GetIsMulticast(void) const
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)
virtual Time GetDcdTimeStamp(void) const
void OnSetRequestedBandwidth(ServiceFlowRecord *sfr)
a unique identifier for an interface.
void SetUiuc(uint8_t uiuc)
TypeId SetParent(TypeId tid)
void GetChannelDescriptorsToUpdate(bool &, bool &, bool &, bool &)
WimaxPhy::ModulationType GetModulationType(void) const