24 #include "ns3/simulator.h"
29 #include "ns3/uinteger.h"
77 std::list<OfdmUlMapIe>
90 uint32_t randNr = rand ();
91 if (randNr % 5 == 0 ||
GetBs ()->GetNrDcdSent () == 0)
97 if (randNr % 5 == 0 ||
GetBs ()->GetNrUcdSent () == 0)
126 if (timeSinceLastDcd >
GetBs ()->GetDcdInterval ())
132 if (timeSinceLastUcd >
GetBs ()->GetUcdInterval ())
142 return GetBs ()->GetNrDlSymbols () *
GetBs ()->GetPhy ()->GetPsPerSymbol () +
GetBs ()->GetTtg ();
147 const uint32_t &allocationSize,
148 uint32_t &symbolsToAllocation,
149 uint32_t &availableSymbols)
154 symbolsToAllocation += allocationSize;
155 availableSymbols -= allocationSize;
164 bool allocationForDsa =
false;
166 uint32_t symbolsToAllocation = 0;
167 uint32_t allocationSize = 0;
168 uint32_t availableSymbols =
GetBs ()->GetNrUlSymbols ();
175 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
176 NS_LOG_INFO (
"UL Scheduler start, availableSymbols = " << availableSymbols);
178 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
194 allocationSize =
GetBs ()->GetRangReqOppSize ();
197 if (availableSymbols >= allocationSize)
211 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
220 if (!allocationForDsa)
222 allocationSize =
GetBs ()->GetPhy ()->GetNrSymbols (
sizeof(
DsaReq), modulationType);
223 if (availableSymbols >= allocationSize)
226 allocationForDsa =
true;
248 if (availableSymbols)
258 if (availableSymbols)
268 if (availableSymbols)
284 if (availableSymbols)
290 if (availableSymbols)
292 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
306 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
310 if (availableSymbols)
320 if (availableSymbols)
341 GetBs ()->GetBandwidthManager ()->SetSubframeRatio ();
349 uint32_t &symbolsToAllocation,
350 uint32_t &availableSymbols)
352 uint32_t allocationSize = 0;
353 uint8_t uiuc = ulMapIe.
GetUiuc ();
354 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
356 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
364 allocationSize =
GetBs ()->GetBandwidthManager ()->CalculateAllocationSize (ssRecord, serviceFlow);
374 if (bps < serviceFlow->GetMinReservedTrafficRate ())
388 if (availableSymbols < allocationSize)
393 if (allocationSize > 0)
409 NS_LOG_DEBUG (
"BS uplink scheduler, UGS allocation, size: " << allocationSize <<
" symbols");
414 << allocationSize <<
" symbols" <<
", modulation: BPSK 1/2");
429 uint32_t &symbolsToAllocation,
430 uint32_t &availableSymbols)
432 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
434 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
453 uint32_t &symbolsToAllocation,
454 uint32_t &availableSymbols)
456 uint32_t allocSizeBytes = 0;
457 uint32_t allocSizeSymbols = 0;
458 uint16_t sduSize = 0;
464 if (requiredBandwidth > 0)
469 allocSizeBytes = sduSize;
470 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (sduSize, modulationType);
474 allocSizeBytes = requiredBandwidth;
475 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (requiredBandwidth, modulationType);
478 if (availableSymbols >= allocSizeSymbols)
482 << allocSizeSymbols <<
" symbols" <<
", CID: " << serviceFlow->
GetConnection ()->GetCid () <<
", SFID: "
507 NS_LOG_INFO (
"\t\tavailableSymbols = " << availableSymbols);
509 uint32_t allocSizeSymbols_[100];
514 int nbAllocation = 0;
515 uint32_t allocSizeBytes;
516 uint32_t totAllocSizeSymbols = 0;
519 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
521 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
534 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
538 for (std::vector<ServiceFlow*>::iterator iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
540 record_[nbAllocation] = (*iter2)->GetRecord ();
544 if (requiredBandwidth > 0)
546 modulationType_[nbAllocation] = modulationType;
547 ulMapIe_[nbAllocation] = ulMapIe;
548 allocSizeBytes = requiredBandwidth;
549 allocSizeSymbols_[nbAllocation] =
GetBs ()->GetPhy ()->GetNrSymbols (allocSizeBytes,
550 modulationType_[nbAllocation]);
551 totAllocSizeSymbols += allocSizeSymbols_[nbAllocation];
553 NS_LOG_INFO (
"\t\tUL Scheduler for CID = " << (*iter2)->GetConnection ()->GetCid ());
554 NS_LOG_INFO (
"\t\t\trequiredBandwidth = " << record_[nbAllocation]->GetRequestedBandwidth ()
555 <<
", allocSizeSymbols = " << allocSizeSymbols_[nbAllocation] <<
", modulationType = "
556 << modulationType_[nbAllocation]);
564 NS_LOG_INFO (
"\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
567 while (totAllocSizeSymbols > availableSymbols)
569 NS_LOG_INFO (
"\tUL Channel Saturation: totAllocSizeSymbols > availableSymbols");
570 double delta = double(availableSymbols) / double(totAllocSizeSymbols);
572 totAllocSizeSymbols = 0;
573 for (
int i = 0; i < nbAllocation; i++)
575 NS_LOG_INFO (
"\t\tprevious allocSizeSymbols_[" << i <<
"] = " << allocSizeSymbols_[i]);
576 allocSizeSymbols_[i] = (uint32_t) std::floor (allocSizeSymbols_[i] * delta);
577 totAllocSizeSymbols += allocSizeSymbols_[i];
578 NS_LOG_INFO (
"\t\tnew allocSizeSymbols_[" << i <<
"] = " << allocSizeSymbols_[i]);
580 NS_LOG_INFO (
"\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
584 for (
int i = 0; i < nbAllocation; i++)
586 AddUplinkAllocation (ulMapIe_[i], allocSizeSymbols_[i], symbolsToAllocation, availableSymbols);
587 allocSizeBytes =
GetBs ()->GetPhy ()->GetNrBytes (allocSizeSymbols_[i], modulationType_[i]);
588 NS_LOG_INFO (
"\t\tUpdateGrantedBandwidth for " << i <<
" = " << allocSizeBytes);
589 if (record_[i]->GetRequestedBandwidth () < allocSizeBytes)
611 if (timeSinceLastIrInterval +
GetBs ()->GetPhy ()->GetFrameDuration () >
GetBs ()->GetInitialRangingInterval ()
612 && availableSymbols >= allocationSize)
616 ulMapIeIr.
SetCid (
GetBs ()->GetBroadcastConnection ()->GetCid ());
620 NS_LOG_DEBUG (
"BS uplink scheduler, initial ranging allocation, size: " << allocationSize <<
" symbols"
621 <<
", modulation: BPSK 1/2");
626 GetBs ()->MarkRangingOppStart (ssUlStartTime + Seconds (symbolsToAllocation
627 *
GetBs ()->GetSymbolDuration ().GetSeconds ()) + Seconds (i *
GetBs ()->GetRangReqOppSize ()
628 *
GetBs ()->GetSymbolDuration ().GetSeconds ()));
639 uint8_t delayNrFrames = 1;
642 uint32_t bytesPerFrame =
643 (uint32_t ((
double)(bitsPerSecond) *
GetBs ()->GetPhy ()->GetFrameDuration ().GetSeconds ())) / 8;
644 uint32_t frameDurationMSec =
GetBs ()->GetPhy ()->GetFrameDuration ().GetMilliSeconds ();
658 uint32_t grantSize =
GetBs ()->GetPhy ()->GetNrSymbols (bytesPerFrame, modulation);
663 if (toleratedJitter > frameDurationMSec)
665 delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec);
668 uint16_t interval = delayNrFrames * frameDurationMSec;
674 if (serviceFlow->
GetSduSize () > bytesPerFrame)
676 delayNrFrames = (uint8_t)(serviceFlow->
GetSduSize () / bytesPerFrame);
679 uint16_t interval = delayNrFrames * frameDurationMSec;
712 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 the class in the ns-3 factory.
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)
fatal error handling
std::list< OfdmUlMapIe > GetUplinkAllocations(void) const
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)
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 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
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)
Doxygen 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)
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