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;
void SetCid(const Cid &cid)
Set CID.
Simulation virtual time values and global simulation resolution.
enum WimaxPhy::ModulationType GetModulation(void) const
Get modulation.
Smart pointer class similar to boost::intrusive_ptr.
void SetupServiceFlow(SSRecord *ssRecord, ServiceFlow *serviceFlow)
Setup service flow function.
enum ServiceFlow::SchedulingType GetSchedulingType(void) const
Get scheduling type.
virtual void SetDcdTimeStamp(Time dcdTimeStamp)
Set DCD timestamp.
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)
Add uplink allocation.
Cid GetBasicCid(void) const
Get basic CID.
void AllocateInitialRangingInterval(uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Allocate Initial Ranging Interval function.
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)
Service Bandwidth Requests function.
bool GetAreServiceFlowsAllocated(void) const
Check if service flows are allocated.
virtual void SetIsIrIntrvlAllocated(bool isIrIntrvlAllocated)
Set if the IR interval is allocated.
void SetGrantedBandwidth(uint32_t grantedBandwidth)
set the granted bandwidth
#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)
Service Unsolicited Grants function.
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
Get SFID.
WimaxNetDevice::RangingStatus GetRangingStatus(void) const
Get ranging status.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< WimaxConnection > GetConnection(void) const
Can return a null connection is this service flow has not been associated yet to a connection...
void InitOnce(void)
Init once function.
uint32_t GetMinReservedTrafficRate(void) const
Get minimum reserved traffic rate.
std::list< OfdmUlMapIe > m_uplinkAllocations
uplink allocations
virtual void SetTimeStampIrInterval(Time timeStampIrInterval)
Set timestamp IR interval.
virtual Time GetTimeStampIrInterval(void)
Time GetGrantTimeStamp(void) const
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
Set base station device.
Virtual class for uplink scheduler.
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.
void SetUnsolicitedGrantInterval(uint16_t unsolicitedGrantInterval)
Set unsolicied grant interval.
void SetGrantSize(uint32_t grantSize)
Set the grant size (only for UGS service flows)
std::vector< ServiceFlow * > GetServiceFlows(enum ServiceFlow::SchedulingType schedulingType) const
Get service flows.
ModulationType
ModulationType enumeration.
virtual void SetIsInvIrIntrvlAllocated(bool isInvIrIntrvlAllocated)
Set if the Inv IR interval is allocated.
uint8_t GetUiuc(void) const
Get UIUC.
UplinkSchedulerSimple(void)
std::list< OfdmUlMapIe > GetUplinkAllocations(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void ProcessBandwidthRequest(const BandwidthRequestHeader &bwRequestHdr)
Process bandwidth requet function.
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
Get SDU size.
This class implements service flows as described by the IEEE-802.16 standard.
virtual Ptr< BaseStationNetDevice > GetBs(void)
void Schedule(void)
Schedule function.
void SetStartTime(uint16_t startTime)
Set start time.
static Time Now(void)
Return the current simulation virtual time.
ServiceFlowRecord * GetRecord(void) const
Get service flow record.
bool GetPollForRanging(void) const
Get poll for ranging.
bool GetIsBroadcastSS(void)
Get is broadcast SS.
virtual void SetUcdTimeStamp(Time ucdTimeStamp)
Set UCD timestamp.
uint32_t GetToleratedJitter(void) const
Get tolerated jitter.
~UplinkSchedulerSimple(void)
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.
bool GetIsMulticast(void) const
Get is multicast.
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
set BW since last expiry
void OnSetRequestedBandwidth(ServiceFlowRecord *sfr)
Set requested bandwidth function.
This class is used by the base station to store some information related to subscriber station in the...
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...
uint32_t CalculateAllocationStartTime(void)
virtual Time GetDcdTimeStamp(void) const
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.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
WimaxPhy::ModulationType GetModulationType(void) const
Get modulation type.