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