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;
This class implements the bandwidth-request mac Header as described by IEEE Standard for Local and me...
static Cid InitialRanging(void)
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...
uint8_t GetUiuc(void) const
Get UIUC.
void SetStartTime(uint16_t startTime)
Set start time.
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...
bool GetPollForRanging(void) const
Get poll for ranging.
WimaxNetDevice::RangingStatus GetRangingStatus(void) const
Get ranging status.
WimaxPhy::ModulationType GetModulationType(void) const
Get modulation type.
std::vector< ServiceFlow * > GetServiceFlows(enum ServiceFlow::SchedulingType schedulingType) const
Get service flows.
bool GetAreServiceFlowsAllocated(void) const
Check if service flows are allocated.
bool GetIsBroadcastSS(void)
Get is broadcast SS.
Cid GetBasicCid(void) const
Get basic CID.
This class implements service flows as described by the IEEE-802.16 standard.
enum WimaxPhy::ModulationType GetModulation(void) const
Get modulation.
uint32_t GetMinReservedTrafficRate(void) const
Get minimum reserved traffic rate.
uint8_t GetSduSize(void) const
Get SDU size.
enum ServiceFlow::SchedulingType GetSchedulingType(void) const
Get scheduling type.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
ServiceFlowRecord * GetRecord(void) const
Get service flow record.
Ptr< WimaxConnection > GetConnection(void) const
Can return a null connection is this service flow has not been associated yet to a connection.
void SetUnsolicitedGrantInterval(uint16_t unsolicitedGrantInterval)
Set unsolicied grant interval.
bool GetIsMulticast(void) const
Get is multicast.
void SetUnsolicitedPollingInterval(uint16_t unsolicitedPollingInterval)
Set unsolicited polling interval.
uint32_t GetToleratedJitter(void) const
Get tolerated jitter.
uint32_t GetSfid(void) const
Get SFID.
this class implements a structure to manage some parameters and statistics related to a service flow
Time GetGrantTimeStamp(void) const
uint32_t GetRequestedBandwidth(void)
uint32_t GetBwSinceLastExpiry(void)
void SetGrantSize(uint32_t grantSize)
Set the grant size (only for UGS service flows)
void SetBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
set BW since last expiry
void UpdateGrantedBandwidth(uint32_t grantedBandwidth)
update the granted bandwidth
uint32_t GetGrantedBandwidth(void)
void SetGrantTimeStamp(Time grantTimeStamp)
Set the grant time stamp.
void SetGrantedBandwidth(uint32_t grantedBandwidth)
set the granted bandwidth
static Time Now(void)
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 Time GetDcdTimeStamp(void) const
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(void) const
virtual void SetIsInvIrIntrvlAllocated(bool isInvIrIntrvlAllocated)
Set if the Inv IR interval is allocated.
virtual Time GetTimeStampIrInterval(void)
virtual Time GetUcdTimeStamp(void) const
virtual void SetTimeStampIrInterval(Time timeStampIrInterval)
Set timestamp IR interval.
virtual Ptr< BaseStationNetDevice > GetBs(void)
Uplink Scheduler - simplified.
void InitOnce(void)
Init once function.
void AddUplinkAllocation(OfdmUlMapIe &ulMapIe, const uint32_t &allocationSize, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Add uplink allocation.
void AllocateInitialRangingInterval(uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Allocate Initial Ranging Interval function.
void Schedule(void)
Schedule function.
UplinkSchedulerSimple(void)
std::list< OfdmUlMapIe > GetUplinkAllocations(void) const
uint32_t CalculateAllocationStartTime(void)
void ProcessBandwidthRequest(const BandwidthRequestHeader &bwRequestHdr)
Process bandwidth requet function.
std::list< OfdmUlMapIe > m_uplinkAllocations
uplink allocations
void SetupServiceFlow(SSRecord *ssRecord, ServiceFlow *serviceFlow)
Setup service flow function.
static TypeId GetTypeId(void)
Get the type ID.
void OnSetRequestedBandwidth(ServiceFlowRecord *sfr)
Set requested bandwidth function.
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 &updateDcd, bool &updateUcd, bool &sendDcd, bool &sendUcd)
Determines if channel descriptors sent in the current frame are required to be updated.
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.
~UplinkSchedulerSimple(void)
@ 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_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.