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;
std::list< OfdmUlMapIe > GetUplinkAllocations(void) const
Get uplink allocations.
void SetCid(const Cid &cid)
Set CID.
bool GetIsMulticast(void) const
Get is multicast.
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
virtual void SetDcdTimeStamp(Time dcdTimeStamp)
Set DCD timestamp.
static TypeId GetTypeId(void)
Get the type ID.
void InitOnce(void)
Init once function.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
void ServiceUnsolicitedGrants(const SSRecord *ssRecord, enum ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Service Unsolicited Grants function.
Time GetGrantTimeStamp(void) const
uint32_t GetRequestedBandwidth(void)
WimaxPhy::ModulationType GetModulationType(void) const
Get modulation type.
void ProcessBandwidthRequest(const BandwidthRequestHeader &bwRequestHdr)
Process bandwidth requet function.
this class implements a structure to manage some parameters and statistics related to a service flow ...
std::list< OfdmUlMapIe > m_uplinkAllocations
uplink allocations
void SetRequestedBandwidth(uint32_t requestedBandwidth)
set the requested bandwidth
std::vector< ServiceFlow * > GetServiceFlows(enum ServiceFlow::SchedulingType schedulingType) const
Get service flows.
void AddUplinkAllocation(OfdmUlMapIe &ulMapIe, const uint32_t &allocationSize, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Add Uplink Allocation function.
uint8_t GetSduSize(void) const
Get SDU size.
virtual uint8_t GetNrIrOppsAllocated(void) const
virtual void SetIsIrIntrvlAllocated(bool isIrIntrvlAllocated)
Set if the IR interval is allocated.
void SetGrantedBandwidth(uint32_t grantedBandwidth)
set the granted bandwidth
void SetupServiceFlow(SSRecord *ssRecord, ServiceFlow *serviceFlow)
Setup service flow function.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#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.
enum WimaxPhy::ModulationType GetModulation(void) const
Get modulation.
bool GetPollForRanging(void) const
Get poll for ranging.
uint32_t GetSfid(void) const
Get SFID.
This class implements a simple uplink scheduler for rtPS flows.
uint8_t GetUiuc(void) const
Get UIUC.
void GetChannelDescriptorsToUpdate(bool &updateDcd, bool &updateUcd, bool &sendDcd, bool &sendUcd)
Determines if channel descriptors sent in the current frame are required to be updated.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
Ptr< WimaxConnection > GetConnection(void) const
Can return a null connection is this service flow has not been associated yet to a connection...
char * GetSchedulingTypeStr(void) const
Get scheduling type string.
virtual void SetTimeStampIrInterval(Time timeStampIrInterval)
Set timestamp IR interval.
virtual Time GetTimeStampIrInterval(void)
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
Set base station device.
bool GetAreServiceFlowsAllocated(void) const
Check if service flows are allocated.
virtual Time GetDcdTimeStamp(void) const
Virtual class for uplink scheduler.
uint32_t GetToleratedJitter(void) const
Get tolerated jitter.
uint32_t GetBwSinceLastExpiry(void)
static Cid InitialRanging(void)
void SetGrantTimeStamp(Time grantTimeStamp)
Set the grant time stamp.
virtual void SetNrIrOppsAllocated(uint8_t nrIrOppsAllocated)
Set the number of IR opps allocated.
void SetDuration(uint16_t duration)
Set duration.
~UplinkSchedulerRtps(void)
void SetUnsolicitedGrantInterval(uint16_t unsolicitedGrantInterval)
Set unsolicied grant interval.
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.
ServiceFlowRecord * GetRecord(void) const
Get service flow record.
void ServiceBandwidthRequests(const SSRecord *ssRecord, enum ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Service Bandwidth Requests function.
virtual void SetIsInvIrIntrvlAllocated(bool isInvIrIntrvlAllocated)
Set if the Inv IR interval is allocated.
uint32_t CalculateAllocationStartTime(void)
Calculate allocation start time function.
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...
This class implements service flows as described by the IEEE-802.16 standard.
uint32_t GetMinReservedTrafficRate(void) const
Get minimum reserved traffic rate.
virtual Ptr< BaseStationNetDevice > GetBs(void)
void SetStartTime(uint16_t startTime)
Set start time.
static Time Now(void)
Return the current simulation virtual time.
WimaxNetDevice::RangingStatus GetRangingStatus(void) const
Get ranging status.
void AllocateInitialRangingInterval(uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Allocate Initial Ranging Interval function.
bool GetIsBroadcastSS(void)
Get is broadcast SS.
virtual void SetUcdTimeStamp(Time ucdTimeStamp)
Set UCD timestamp.
void Schedule(void)
Schedule function.
ModulationType
ModulationType enumeration.
enum ServiceFlow::SchedulingType GetSchedulingType(void) const
Get scheduling type.
void SetUnsolicitedPollingInterval(uint16_t unsolicitedPollingInterval)
Set unsolicited polling interval.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
virtual Time GetUcdTimeStamp(void) const
void SetBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
set BW since last expiry
This class is used by the base station to store some information related to subscriber station in the...
Cid GetBasicCid(void) const
Get basic CID.
void UpdateGrantedBandwidth(uint32_t grantedBandwidth)
update the granted bandwidth
uint32_t GetGrantedBandwidth(void)
This class implements the DSA-REQ message described by "IEEE Standard for Local and metropolitan area...
void OnSetRequestedBandwidth(ServiceFlowRecord *sfr)
Set requested bandwidth function.
This class implements the UL-MAP_IE message as described by "IEEE Standard for Local and metropolitan...
a unique identifier for an interface.
void SetUiuc(uint8_t uiuc)
Set UIUC.
TypeId SetParent(TypeId tid)
Set the parent TypeId.