23 #include "ns3/simulator.h"
28 #include "ns3/uinteger.h"
78 static TypeId tid =
TypeId (
"ns3::UplinkSchedulerSimple")
80 .SetGroupName(
"Wimax")
86 std::list<OfdmUlMapIe>
102 uint32_t randNr = rand ();
103 if (randNr % 5 == 0 ||
GetBs ()->GetNrDcdSent () == 0)
109 if (randNr % 5 == 0 ||
GetBs ()->GetNrUcdSent () == 0)
138 if (timeSinceLastDcd >
GetBs ()->GetDcdInterval ())
144 if (timeSinceLastUcd >
GetBs ()->GetUcdInterval ())
154 return GetBs ()->GetNrDlSymbols () *
GetBs ()->GetPhy ()->GetPsPerSymbol () +
GetBs ()->GetTtg ();
159 const uint32_t &allocationSize,
160 uint32_t &symbolsToAllocation,
161 uint32_t &availableSymbols)
166 symbolsToAllocation += allocationSize;
167 availableSymbols -= allocationSize;
176 bool allocationForDsa =
false;
178 uint32_t symbolsToAllocation = 0;
179 uint32_t allocationSize = 0;
180 uint32_t availableSymbols =
GetBs ()->GetNrUlSymbols ();
184 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
185 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
203 allocationSize =
GetBs ()->GetRangReqOppSize ();
206 if (availableSymbols >= allocationSize)
221 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
231 if (!allocationForDsa)
233 allocationSize =
GetBs ()->GetPhy ()->GetNrSymbols (
sizeof(
DsaReq), modulationType);
235 if (availableSymbols >= allocationSize)
238 allocationForDsa =
true;
260 if (availableSymbols)
270 if (availableSymbols)
280 if (availableSymbols)
292 if (availableSymbols)
302 if (availableSymbols)
312 if (availableSymbols)
333 GetBs ()->GetBandwidthManager ()->SetSubframeRatio ();
341 uint32_t &symbolsToAllocation,
342 uint32_t &availableSymbols)
344 uint32_t allocationSize = 0;
345 uint8_t uiuc = ulMapIe.
GetUiuc ();
346 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
348 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
356 allocationSize =
GetBs ()->GetBandwidthManager ()->CalculateAllocationSize (ssRecord, serviceFlow);
365 if (bps < serviceFlow->GetMinReservedTrafficRate ())
379 if (availableSymbols < allocationSize)
384 if (allocationSize > 0)
410 uint32_t &symbolsToAllocation,
411 uint32_t &availableSymbols)
413 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
415 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
434 uint32_t &symbolsToAllocation,
435 uint32_t &availableSymbols)
437 uint32_t allocSizeBytes = 0;
438 uint32_t allocSizeSymbols = 0;
439 uint16_t sduSize = 0;
445 if (requiredBandwidth > 0)
450 allocSizeBytes = sduSize;
451 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (sduSize, modulationType);
455 allocSizeBytes = requiredBandwidth;
456 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (requiredBandwidth, modulationType);
459 if (availableSymbols >= allocSizeSymbols)
487 if (timeSinceLastIrInterval +
GetBs ()->GetPhy ()->GetFrameDuration () >
GetBs ()->GetInitialRangingInterval ()
488 && availableSymbols >= allocationSize)
492 ulMapIeIr.
SetCid ((
GetBs ()->GetBroadcastConnection ())->GetCid ());
496 NS_LOG_DEBUG (
"BS uplink scheduler, initial ranging allocation, size: " << allocationSize <<
" symbols"
497 <<
", modulation: BPSK 1/2");
502 GetBs ()->MarkRangingOppStart (ssUlStartTime +
Seconds (symbolsToAllocation
503 *
GetBs ()->GetSymbolDuration ().GetSeconds ()) +
Seconds (i *
GetBs ()->GetRangReqOppSize ()
504 *
GetBs ()->GetSymbolDuration ().GetSeconds ()));
515 uint8_t delayNrFrames = 1;
518 uint32_t bytesPerFrame =
519 (uint32_t ((
double)(bitsPerSecond) *
GetBs ()->GetPhy ()->GetFrameDuration ().GetSeconds ())) / 8;
520 uint32_t frameDurationMSec =
GetBs ()->GetPhy ()->GetFrameDuration ().GetMilliSeconds ();
534 uint32_t grantSize =
GetBs ()->GetPhy ()->GetNrSymbols (bytesPerFrame, modulation);
539 if (toleratedJitter > frameDurationMSec)
541 delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec);
544 uint16_t interval = delayNrFrames * frameDurationMSec;
550 if (serviceFlow->
GetSduSize () > bytesPerFrame)
552 delayNrFrames = (uint8_t)(serviceFlow->
GetSduSize () / bytesPerFrame);
555 uint16_t interval = delayNrFrames * frameDurationMSec;
585 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.
void SetupServiceFlow(SSRecord *ssRecord, ServiceFlow *serviceFlow)
enum ServiceFlow::SchedulingType GetSchedulingType(void) const
virtual void SetDcdTimeStamp(Time dcdTimeStamp)
virtual Time GetUcdTimeStamp(void) const
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
void AddUplinkAllocation(OfdmUlMapIe &ulMapIe, const uint32_t &allocationSize, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Cid GetBasicCid(void) const
void AllocateInitialRangingInterval(uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
uint32_t GetRequestedBandwidth(void)
this class implements a structure to manage some parameters and statistics related to a service flow ...
void ServiceBandwidthRequests(const SSRecord *ssRecord, enum ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
bool GetAreServiceFlowsAllocated(void) const
virtual void SetIsIrIntrvlAllocated(bool isIrIntrvlAllocated)
void SetGrantedBandwidth(uint32_t grantedBandwidth)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void ServiceUnsolicitedGrants(const SSRecord *ssRecord, enum ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
void GetChannelDescriptorsToUpdate(bool &, bool &, bool &, bool &)
Determines if channel descriptors sent in the current frame are required to be updated.
uint32_t GetSfid(void) const
WimaxNetDevice::RangingStatus GetRangingStatus(void) const
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
static TypeId GetTypeId(void)
Ptr< WimaxConnection > GetConnection(void) const
uint32_t GetMinReservedTrafficRate(void) const
std::list< OfdmUlMapIe > m_uplinkAllocations
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)
void SetGrantSize(uint32_t grantSize)
Set the grant size (only for UGS service flows)
void SetUnsolicitedGrantInterval(uint16_t)
std::vector< ServiceFlow * > GetServiceFlows(enum ServiceFlow::SchedulingType schedulingType) const
virtual void SetIsInvIrIntrvlAllocated(bool isInvIrIntrvlAllocated)
uint8_t GetUiuc(void) const
UplinkSchedulerSimple(void)
std::list< OfdmUlMapIe > GetUplinkAllocations(void) const
void ProcessBandwidthRequest(const BandwidthRequestHeader &bwRequestHdr)
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 virtual time.
ServiceFlowRecord * GetRecord(void) const
bool GetPollForRanging(void) const
bool GetIsBroadcastSS(void)
virtual void SetUcdTimeStamp(Time ucdTimeStamp)
uint32_t GetToleratedJitter(void) const
~UplinkSchedulerSimple(void)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
bool GetIsMulticast(void) const
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
void OnSetRequestedBandwidth(ServiceFlowRecord *sfr)
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)
Introspection did not find any typical Config paths.
uint32_t CalculateAllocationStartTime(void)
virtual Time GetDcdTimeStamp(void) const
a unique identifier for an interface.
void SetUiuc(uint8_t uiuc)
TypeId SetParent(TypeId tid)
Set the parent TypeId.
WimaxPhy::ModulationType GetModulationType(void) const