24 #include "ns3/simulator.h"
29 #include "ns3/uinteger.h"
78 std::list<OfdmUlMapIe>
91 uint32_t randNr = rand ();
92 if (randNr % 5 == 0 ||
GetBs ()->GetNrDcdSent () == 0)
98 if (randNr % 5 == 0 ||
GetBs ()->GetNrUcdSent () == 0)
127 if (timeSinceLastDcd >
GetBs ()->GetDcdInterval ())
133 if (timeSinceLastUcd >
GetBs ()->GetUcdInterval ())
143 return GetBs ()->GetNrDlSymbols () *
GetBs ()->GetPhy ()->GetPsPerSymbol () +
GetBs ()->GetTtg ();
148 const uint32_t &allocationSize,
149 uint32_t &symbolsToAllocation,
150 uint32_t &availableSymbols)
155 symbolsToAllocation += allocationSize;
156 availableSymbols -= allocationSize;
165 bool allocationForDsa =
false;
167 uint32_t symbolsToAllocation = 0;
168 uint32_t allocationSize = 0;
169 uint32_t availableSymbols =
GetBs ()->GetNrUlSymbols ();
176 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
177 NS_LOG_INFO (
"UL Scheduler start, availableSymbols = " << availableSymbols);
179 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
195 allocationSize =
GetBs ()->GetRangReqOppSize ();
198 if (availableSymbols >= allocationSize)
212 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
221 if (!allocationForDsa)
223 allocationSize =
GetBs ()->GetPhy ()->GetNrSymbols (
sizeof(
DsaReq), modulationType);
224 if (availableSymbols >= allocationSize)
227 allocationForDsa =
true;
249 if (availableSymbols)
259 if (availableSymbols)
269 if (availableSymbols)
285 if (availableSymbols)
291 if (availableSymbols)
293 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
307 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
311 if (availableSymbols)
321 if (availableSymbols)
342 GetBs ()->GetBandwidthManager ()->SetSubframeRatio ();
350 uint32_t &symbolsToAllocation,
351 uint32_t &availableSymbols)
353 uint32_t allocationSize = 0;
354 uint8_t uiuc = ulMapIe.
GetUiuc ();
355 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
357 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
365 allocationSize =
GetBs ()->GetBandwidthManager ()->CalculateAllocationSize (ssRecord, serviceFlow);
375 if (bps < serviceFlow->GetMinReservedTrafficRate ())
389 if (availableSymbols < allocationSize)
394 if (allocationSize > 0)
410 NS_LOG_DEBUG (
"BS uplink scheduler, UGS allocation, size: " << allocationSize <<
" symbols");
415 << allocationSize <<
" symbols" <<
", modulation: BPSK 1/2");
430 uint32_t &symbolsToAllocation,
431 uint32_t &availableSymbols)
433 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
435 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
454 uint32_t &symbolsToAllocation,
455 uint32_t &availableSymbols)
457 uint32_t allocSizeBytes = 0;
458 uint32_t allocSizeSymbols = 0;
459 uint16_t sduSize = 0;
465 if (requiredBandwidth > 0)
470 allocSizeBytes = sduSize;
471 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (sduSize, modulationType);
475 allocSizeBytes = requiredBandwidth;
476 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (requiredBandwidth, modulationType);
479 if (availableSymbols >= allocSizeSymbols)
483 << allocSizeSymbols <<
" symbols" <<
", CID: " << serviceFlow->
GetConnection ()->GetCid () <<
", SFID: "
508 NS_LOG_INFO (
"\t\tavailableSymbols = " << availableSymbols);
510 uint32_t allocSizeSymbols_[100];
515 int nbAllocation = 0;
516 uint32_t allocSizeBytes;
517 uint32_t totAllocSizeSymbols = 0;
520 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
522 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
535 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
539 for (std::vector<ServiceFlow*>::iterator iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
541 record_[nbAllocation] = (*iter2)->GetRecord ();
545 if (requiredBandwidth > 0)
547 modulationType_[nbAllocation] = modulationType;
548 ulMapIe_[nbAllocation] = ulMapIe;
549 allocSizeBytes = requiredBandwidth;
550 allocSizeSymbols_[nbAllocation] =
GetBs ()->GetPhy ()->GetNrSymbols (allocSizeBytes,
551 modulationType_[nbAllocation]);
552 totAllocSizeSymbols += allocSizeSymbols_[nbAllocation];
554 NS_LOG_INFO (
"\t\tUL Scheduler for CID = " << (*iter2)->GetConnection ()->GetCid ());
555 NS_LOG_INFO (
"\t\t\trequiredBandwidth = " << record_[nbAllocation]->GetRequestedBandwidth ()
556 <<
", allocSizeSymbols = " << allocSizeSymbols_[nbAllocation] <<
", modulationType = "
557 << modulationType_[nbAllocation]);
565 NS_LOG_INFO (
"\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
568 while (totAllocSizeSymbols > availableSymbols)
570 NS_LOG_INFO (
"\tUL Channel Saturation: totAllocSizeSymbols > availableSymbols");
571 double delta = double(availableSymbols) / double(totAllocSizeSymbols);
573 totAllocSizeSymbols = 0;
574 for (
int i = 0; i < nbAllocation; i++)
576 NS_LOG_INFO (
"\t\tprevious allocSizeSymbols_[" << i <<
"] = " << allocSizeSymbols_[i]);
577 allocSizeSymbols_[i] = (uint32_t) std::floor (allocSizeSymbols_[i] * delta);
578 totAllocSizeSymbols += allocSizeSymbols_[i];
579 NS_LOG_INFO (
"\t\tnew allocSizeSymbols_[" << i <<
"] = " << allocSizeSymbols_[i]);
581 NS_LOG_INFO (
"\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
585 for (
int i = 0; i < nbAllocation; i++)
587 AddUplinkAllocation (ulMapIe_[i], allocSizeSymbols_[i], symbolsToAllocation, availableSymbols);
588 allocSizeBytes =
GetBs ()->GetPhy ()->GetNrBytes (allocSizeSymbols_[i], modulationType_[i]);
589 NS_LOG_INFO (
"\t\tUpdateGrantedBandwidth for " << i <<
" = " << allocSizeBytes);
590 if (record_[i]->GetRequestedBandwidth () < allocSizeBytes)
612 if (timeSinceLastIrInterval +
GetBs ()->GetPhy ()->GetFrameDuration () >
GetBs ()->GetInitialRangingInterval ()
613 && availableSymbols >= allocationSize)
617 ulMapIeIr.
SetCid (
GetBs ()->GetBroadcastConnection ()->GetCid ());
621 NS_LOG_DEBUG (
"BS uplink scheduler, initial ranging allocation, size: " << allocationSize <<
" symbols"
622 <<
", modulation: BPSK 1/2");
627 GetBs ()->MarkRangingOppStart (ssUlStartTime + Seconds (symbolsToAllocation
628 *
GetBs ()->GetSymbolDuration ().GetSeconds ()) + Seconds (i *
GetBs ()->GetRangReqOppSize ()
629 *
GetBs ()->GetSymbolDuration ().GetSeconds ()));
640 uint8_t delayNrFrames = 1;
643 uint32_t bytesPerFrame =
644 (uint32_t ((
double)(bitsPerSecond) *
GetBs ()->GetPhy ()->GetFrameDuration ().GetSeconds ())) / 8;
645 uint32_t frameDurationMSec =
GetBs ()->GetPhy ()->GetFrameDuration ().GetMilliSeconds ();
659 uint32_t grantSize =
GetBs ()->GetPhy ()->GetNrSymbols (bytesPerFrame, modulation);
664 if (toleratedJitter > frameDurationMSec)
666 delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec);
669 uint16_t interval = delayNrFrames * frameDurationMSec;
675 if (serviceFlow->
GetSduSize () > bytesPerFrame)
677 delayNrFrames = (uint8_t)(serviceFlow->
GetSduSize () / bytesPerFrame);
680 uint16_t interval = delayNrFrames * frameDurationMSec;
713 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)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
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.
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)
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)
NS_LOG_COMPONENT_DEFINE("UplinkSchedulerRtps")
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