34#include "ns3/simulator.h"
35#include "ns3/uinteger.h"
77 .SetGroupName(
"Wimax")
99 if (randNr % 5 == 0 ||
GetBs()->GetNrDcdSent() == 0)
105 if (randNr % 5 == 0 ||
GetBs()->GetNrUcdSent() == 0)
134 if (timeSinceLastDcd >
GetBs()->GetDcdInterval())
140 if (timeSinceLastUcd >
GetBs()->GetUcdInterval())
150 return GetBs()->GetNrDlSymbols() *
GetBs()->GetPhy()->GetPsPerSymbol() +
GetBs()->GetTtg();
162 symbolsToAllocation += allocationSize;
163 availableSymbols -= allocationSize;
172 bool allocationForDsa =
false;
183 std::vector<SSRecord*>* ssRecords =
GetBs()->GetSSManager()->GetSSRecords();
184 NS_LOG_INFO(
"UL Scheduler start, availableSymbols = " << availableSymbols);
186 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin(); iter != ssRecords->end();
204 allocationSize =
GetBs()->GetRangReqOppSize();
207 if (availableSymbols >= allocationSize)
221 ulMapIe.
SetUiuc(
GetBs()->GetBurstProfileManager()->GetBurstProfile(
231 if (!allocationForDsa)
234 GetBs()->GetPhy()->GetNrSymbols(
sizeof(
DsaReq), modulationType);
235 if (availableSymbols >= allocationSize)
241 allocationForDsa =
true;
264 if (availableSymbols)
274 if (availableSymbols)
284 if (availableSymbols)
300 if (availableSymbols)
306 if (availableSymbols)
308 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin(); iter != ssRecords->end();
324 ulMapIe.
SetUiuc(
GetBs()->GetBurstProfileManager()->GetBurstProfile(
338 if (availableSymbols)
359 GetBs()->GetBandwidthManager()->SetSubframeRatio();
371 uint8_t uiuc = ulMapIe.
GetUiuc();
372 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows(schedulingType);
374 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin();
375 iter != serviceFlows.end();
386 GetBs()->GetBandwidthManager()->CalculateAllocationSize(ssRecord, serviceFlow);
396 if (bps < serviceFlow->GetMinReservedTrafficRate())
410 if (availableSymbols < allocationSize)
415 if (allocationSize > 0)
432 NS_LOG_DEBUG(
"BS uplink scheduler, UGS allocation, size: " << allocationSize
438 <<
" unicast poll, size: " << allocationSize
440 <<
", modulation: BPSK 1/2");
444 <<
", SFID: " << serviceFlow->
GetSfid());
459 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows(schedulingType);
461 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin();
462 iter != serviceFlows.end();
487 uint16_t sduSize = 0;
493 if (requiredBandwidth > 0)
498 allocSizeBytes = sduSize;
499 allocSizeSymbols =
GetBs()->GetPhy()->GetNrSymbols(sduSize, modulationType);
503 allocSizeBytes = requiredBandwidth;
504 allocSizeSymbols =
GetBs()->GetPhy()->GetNrSymbols(requiredBandwidth, modulationType);
507 if (availableSymbols >= allocSizeSymbols)
511 <<
" allocation, size: " << allocSizeSymbols <<
" symbols"
513 <<
", SFID: " << serviceFlow->
GetSfid()
539 NS_LOG_INFO(
"\t\tavailableSymbols = " << availableSymbols);
546 int nbAllocation = 0;
551 std::vector<SSRecord*>* ssRecords =
GetBs()->GetSSManager()->GetSSRecords();
553 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin(); iter != ssRecords->end();
568 ulMapIe.
SetUiuc(
GetBs()->GetBurstProfileManager()->GetBurstProfile(
572 std::vector<ServiceFlow*> serviceFlows =
574 for (std::vector<ServiceFlow*>::iterator iter2 = serviceFlows.begin();
575 iter2 != serviceFlows.end();
578 record_[nbAllocation] = (*iter2)->GetRecord();
582 if (requiredBandwidth > 0)
584 modulationType_[nbAllocation] = modulationType;
585 ulMapIe_[nbAllocation] = ulMapIe;
586 allocSizeBytes = requiredBandwidth;
587 allocSizeSymbols_[nbAllocation] =
588 GetBs()->GetPhy()->GetNrSymbols(allocSizeBytes,
589 modulationType_[nbAllocation]);
590 totAllocSizeSymbols += allocSizeSymbols_[nbAllocation];
593 "\t\tUL Scheduler for CID = " << (*iter2)->GetConnection()->GetCid());
595 << record_[nbAllocation]->GetRequestedBandwidth()
596 <<
", allocSizeSymbols = " << allocSizeSymbols_[nbAllocation]
597 <<
", modulationType = " << modulationType_[nbAllocation]);
605 NS_LOG_INFO(
"\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
608 while (totAllocSizeSymbols > availableSymbols)
610 NS_LOG_INFO(
"\tUL Channel Saturation: totAllocSizeSymbols > availableSymbols");
611 double delta =
double(availableSymbols) /
double(totAllocSizeSymbols);
613 totAllocSizeSymbols = 0;
614 for (
int i = 0; i < nbAllocation; i++)
616 NS_LOG_INFO(
"\t\tprevious allocSizeSymbols_[" << i <<
"] = " << allocSizeSymbols_[i]);
617 allocSizeSymbols_[i] = (
uint32_t)std::floor(allocSizeSymbols_[i] * delta);
618 totAllocSizeSymbols += allocSizeSymbols_[i];
619 NS_LOG_INFO(
"\t\tnew allocSizeSymbols_[" << i <<
"] = " << allocSizeSymbols_[i]);
621 NS_LOG_INFO(
"\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
625 for (
int i = 0; i < nbAllocation; i++)
628 allocSizeSymbols_[i],
631 allocSizeBytes =
GetBs()->GetPhy()->GetNrBytes(allocSizeSymbols_[i], modulationType_[i]);
632 NS_LOG_INFO(
"\t\tUpdateGrantedBandwidth for " << i <<
" = " << allocSizeBytes);
633 if (record_[i]->GetRequestedBandwidth() < allocSizeBytes)
658 if (timeSinceLastIrInterval +
GetBs()->GetPhy()->GetFrameDuration() >
659 GetBs()->GetInitialRangingInterval() &&
660 availableSymbols >= allocationSize)
664 ulMapIeIr.
SetCid(
GetBs()->GetBroadcastConnection()->GetCid());
668 NS_LOG_DEBUG(
"BS uplink scheduler, initial ranging allocation, size: "
669 << allocationSize <<
" symbols"
670 <<
", modulation: BPSK 1/2");
675 GetBs()->MarkRangingOppStart(
677 Seconds(symbolsToAllocation *
GetBs()->GetSymbolDuration().GetSeconds()) +
679 GetBs()->GetSymbolDuration().GetSeconds()));
690 uint8_t delayNrFrames = 1;
694 (
uint32_t((
double)(bitsPerSecond)*
GetBs()->GetPhy()->GetFrameDuration().GetSeconds())) / 8;
695 uint32_t frameDurationMSec =
GetBs()->GetPhy()->GetFrameDuration().GetMilliSeconds();
708 uint32_t grantSize =
GetBs()->GetPhy()->GetNrSymbols(bytesPerFrame, modulation);
713 if (toleratedJitter > frameDurationMSec)
715 delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec);
718 uint16_t interval = delayNrFrames * frameDurationMSec;
723 if (serviceFlow->
GetSduSize() > bytesPerFrame)
725 delayNrFrames = (uint8_t)(serviceFlow->
GetSduSize() / bytesPerFrame);
728 uint16_t interval = delayNrFrames * frameDurationMSec;
This class implements the bandwidth-request mac Header as described by IEEE Standard for Local and me...
static Cid InitialRanging()
This class implements the DSA-REQ message described by "IEEE Standard for Local and metropolitan area...
This class implements the UL-MAP_IE message as described by "IEEE Standard for Local and metropolitan...
void SetStartTime(uint16_t startTime)
Set start time.
uint8_t GetUiuc() const
Get UIUC.
void SetDuration(uint16_t duration)
Set duration.
void SetCid(const Cid &cid)
Set CID.
void SetUiuc(uint8_t uiuc)
Set UIUC.
Smart pointer class similar to boost::intrusive_ptr.
This class is used by the base station to store some information related to subscriber station in the...
Cid GetBasicCid() const
Get basic CID.
WimaxNetDevice::RangingStatus GetRangingStatus() const
Get ranging status.
bool GetPollForRanging() const
Get poll for ranging.
std::vector< ServiceFlow * > GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const
Get service flows.
bool GetAreServiceFlowsAllocated() const
Check if service flows are allocated.
bool GetIsBroadcastSS() const
Get is broadcast SS.
WimaxPhy::ModulationType GetModulationType() const
Get modulation type.
This class implements service flows as described by the IEEE-802.16 standard.
uint32_t GetSfid() const
Get SFID.
ServiceFlow::SchedulingType GetSchedulingType() const
Get scheduling type.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
char * GetSchedulingTypeStr() const
Get scheduling type string.
uint32_t GetMinReservedTrafficRate() const
Get minimum reserved traffic rate.
uint8_t GetSduSize() const
Get SDU size.
WimaxPhy::ModulationType GetModulation() const
Get modulation.
void SetUnsolicitedGrantInterval(uint16_t unsolicitedGrantInterval)
Set unsolicited grant interval.
ServiceFlowRecord * GetRecord() const
Get service flow record.
void SetUnsolicitedPollingInterval(uint16_t unsolicitedPollingInterval)
Set unsolicited polling interval.
bool GetIsMulticast() const
Get is multicast.
uint32_t GetToleratedJitter() const
Get tolerated jitter.
Ptr< WimaxConnection > GetConnection() const
Can return a null connection is this service flow has not been associated yet to a connection.
this class implements a structure to manage some parameters and statistics related to a service flow
Time GetGrantTimeStamp() const
uint32_t GetRequestedBandwidth() const
void SetRequestedBandwidth(uint32_t requestedBandwidth)
set the requested bandwidth
void SetGrantSize(uint32_t grantSize)
Set the grant size (only for UGS service flows)
uint32_t GetGrantedBandwidth() const
void SetBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
set BW since last expiry
void UpdateGrantedBandwidth(uint32_t grantedBandwidth)
update the granted bandwidth
uint32_t GetBwSinceLastExpiry() const
void SetGrantTimeStamp(Time grantTimeStamp)
Set the grant time stamp.
void SetGrantedBandwidth(uint32_t grantedBandwidth)
set the granted bandwidth
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Virtual class for uplink scheduler.
virtual void SetUcdTimeStamp(Time ucdTimeStamp)
Set UCD timestamp.
virtual void SetDcdTimeStamp(Time dcdTimeStamp)
Set DCD timestamp.
virtual void SetNrIrOppsAllocated(uint8_t nrIrOppsAllocated)
Set the number of IR opps allocated.
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
Set base station device.
virtual void SetIsIrIntrvlAllocated(bool isIrIntrvlAllocated)
Set if the IR interval is allocated.
virtual uint8_t GetNrIrOppsAllocated() const
virtual void SetIsInvIrIntrvlAllocated(bool isInvIrIntrvlAllocated)
Set if the Inv IR interval is allocated.
virtual Time GetTimeStampIrInterval()
virtual Time GetDcdTimeStamp() const
virtual void SetTimeStampIrInterval(Time timeStampIrInterval)
Set timestamp IR interval.
virtual Ptr< BaseStationNetDevice > GetBs()
virtual Time GetUcdTimeStamp() const
This class implements a simple uplink scheduler for rtPS flows.
void AddUplinkAllocation(OfdmUlMapIe &ulMapIe, const uint32_t &allocationSize, uint32_t &symbolsToAllocation, uint32_t &availableSymbols) override
Add Uplink Allocation function.
void ProcessBandwidthRequest(const BandwidthRequestHeader &bwRequestHdr) override
Process bandwidth request function.
std::list< OfdmUlMapIe > m_uplinkAllocations
uplink allocations
void GetChannelDescriptorsToUpdate(bool &updateDcd, bool &updateUcd, bool &sendDcd, bool &sendUcd) override
Determines if channel descriptors sent in the current frame are required to be updated.
void AllocateInitialRangingInterval(uint32_t &symbolsToAllocation, uint32_t &availableSymbols) override
Allocate Initial Ranging Interval function.
~UplinkSchedulerRtps() override
std::list< OfdmUlMapIe > GetUplinkAllocations() const override
Get uplink allocations.
static TypeId GetTypeId()
Get the type ID.
void ServiceUnsolicitedGrants(const SSRecord *ssRecord, ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols) override
Service Unsolicited Grants function.
uint32_t CalculateAllocationStartTime() override
Calculate allocation start time function.
void InitOnce() override
Init once function.
void SetupServiceFlow(SSRecord *ssRecord, ServiceFlow *serviceFlow) override
Setup service flow function.
void OnSetRequestedBandwidth(ServiceFlowRecord *sfr) override
Set requested bandwidth function.
void ULSchedulerRTPSConnection(uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Uplink Scheduler for rtPS connections.
void Schedule() override
Schedule function.
void ServiceBandwidthRequests(const SSRecord *ssRecord, ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols) override
Service Bandwidth Requests function.
@ RANGING_STATUS_CONTINUE
ModulationType
ModulationType enumeration.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.