19#include "ns3/simulator.h" 
   20#include "ns3/uinteger.h" 
   34    : m_windowInterval(time)
 
 
   51                            .SetGroupName(
"Wimax")
 
   53                            .AddAttribute(
"WindowInterval",
 
   54                                          "The time to wait to reset window",
 
 
   84    if (randNr % 5 == 0 || 
GetBs()->GetNrDcdSent() == 0)
 
   90    if (randNr % 5 == 0 || 
GetBs()->GetNrUcdSent() == 0)
 
  119    if (timeSinceLastDcd > 
GetBs()->GetDcdInterval())
 
  125    if (timeSinceLastUcd > 
GetBs()->GetUcdInterval())
 
 
  135    return GetBs()->GetNrDlSymbols() * 
GetBs()->GetPhy()->GetPsPerSymbol() + 
GetBs()->GetTtg();
 
 
  147    symbolsToAllocation += allocationSize;
 
  148    availableSymbols -= allocationSize;
 
 
  158    if (!
GetBs()->GetSSManager())
 
  164    std::vector<SSRecord*>* ssRecords = 
GetBs()->GetSSManager()->GetSSRecords();
 
  167    for (
auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter)
 
  170        std::vector<ServiceFlow*> serviceFlows =
 
  174        for (
auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2)
 
 
  215    bool allocationForDsa = 
false;
 
  223    std::vector<SSRecord*>* ssRecords = 
GetBs()->GetSSManager()->GetSSRecords();
 
  224    for (
auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter)
 
  242            allocationSize = 
GetBs()->GetRangReqOppSize();
 
  245            if (availableSymbols >= allocationSize)
 
  259            ulMapIe.
SetUiuc(
GetBs()->GetBurstProfileManager()->GetBurstProfile(
 
  269                if (!allocationForDsa)
 
  272                        GetBs()->GetPhy()->GetNrSymbols(
sizeof(
DsaReq), modulationType);
 
  274                    if (availableSymbols >= allocationSize)
 
  280                        allocationForDsa = 
true;
 
  299                if (availableSymbols)
 
  307                                           << 
" offering be unicast polling");
 
  309                        Time frame_duration = 
GetBs()->GetPhy()->GetFrameDuration();
 
  313                                ->GetLastGrantTime() +
 
  316                                    ->GetUnsolicitedGrantInterval());
 
  318                        int64_t frame = ((timestamp - 
Simulator::Now()) / frame_duration).GetHigh();
 
  338                                           << 
" offering rtps unicast polling");
 
  347                                           << 
" offering nrtps unicast polling");
 
  357                                           << 
" offering be unicast polling");
 
  370    uint32_t availableSymbolsAux = availableSymbols;
 
  374    availableSymbolsAux -= symbolsUsed;
 
  389        SSRecord* ssRecord = job->GetSsRecord();
 
  397            GetBs()->GetBurstProfileManager()->GetBurstProfile(modulationType,
 
  400        ReqType reqType = job->GetType();
 
  411        else if (reqType == 
DATA)
 
  414            uint32_t allocSizeBytes = job->GetSize();
 
  434        SSRecord* ssRecord = job->GetSsRecord();
 
  442            GetBs()->GetBurstProfileManager()->GetBurstProfile(modulationType,
 
  445        ReqType reqType = job->GetType();
 
  458            NS_FATAL_ERROR(
"Intermediate priority queue only should enqueue data packets.");
 
  468        SSRecord* ssRecord = job->GetSsRecord();
 
  476            GetBs()->GetBurstProfileManager()->GetBurstProfile(modulationType,
 
  479        ReqType reqType = job->GetType();
 
  492            NS_FATAL_ERROR(
"Low priority queue only should enqueue data packets.");
 
  505    GetBs()->GetBandwidthManager()->SetSubframeRatio();
 
 
  517    uint32_t allocSizeBytes = allocationSizeBytes;
 
  524    if (requiredBandwidth > 0)
 
  526        allocSizeSymbols = 
GetBs()->GetPhy()->GetNrSymbols(allocSizeBytes, modulationType);
 
  528        if (availableSymbols < allocSizeSymbols)
 
  530            allocSizeSymbols = availableSymbols;
 
  533        if (availableSymbols >= allocSizeSymbols)
 
  537                               << 
" allocation, size: " << allocSizeSymbols << 
" symbols" 
  539                               << 
", SFID: " << serviceFlow->
GetSfid()
 
  541                               << 
", bw granted: " << allocSizeBytes << std::endl);
 
 
  563    for (
auto iter = jobs.begin(); iter != jobs.end(); ++iter)
 
 
  579    job->SetSsRecord(ssRecord);
 
  580    job->SetSchedulingType(schedType);
 
  582    job->SetType(reqType);
 
 
  589    SSRecord* ssRecord = job->GetSsRecord();
 
  601            allocationSize = 
GetBs()->GetBwReqOppSize();
 
  611        if (requiredBandwidth > 0)
 
  617                allocationSize = 
GetBs()->GetPhy()->GetNrSymbols(sduSize, modulationType);
 
  621                allocationSize = 
GetBs()->GetPhy()->GetNrSymbols(requiredBandwidth, modulationType);
 
  625    return allocationSize;
 
 
  680                Time deadline = job->GetDeadline();
 
  681                Time frame_duration = 
GetBs()->GetPhy()->GetFrameDuration();
 
  683                int64_t frame = ((deadline - 
Simulator::Now()) / frame_duration).GetHigh();
 
  686                                   << job->GetServiceFlow()->GetMinReservedTrafficRate()
 
  687                                   << 
" deadline: " << job->GetDeadline().As(
Time::S)
 
  688                                   << 
" frame start: " << 
GetBs()->m_frameStartTime.As(
Time::S)
 
  689                                   << 
" frame duration: " << frame_duration);
 
  694                    if (availableSymbols)
 
  697                            GetBs()->GetPhy()->GetNrBytes(availableSymbols,
 
  698                                                          job->GetSsRecord()->GetModulationType());
 
  699                        uint32_t allocationSize = job->GetSize();
 
  700                        if (allocationSize > availableBytes)
 
  702                            allocationSize = availableBytes;
 
  705                        if (allocationSize == 0)
 
  710                        uint32_t symbolsToAllocate = 
GetBs()->GetPhy()->GetNrSymbols(
 
  712                            job->GetSsRecord()->GetModulationType());
 
  713                        if (symbolsToAllocate > availableSymbols)
 
  715                            symbolsToAllocate = availableSymbols;
 
  716                            allocationSize = 
GetBs()->GetPhy()->GetNrBytes(
 
  718                                job->GetSsRecord()->GetModulationType());
 
  721                        job->SetSize(job->GetSize() - allocationSize);
 
  725                        newJob->SetSsRecord(job->GetSsRecord());
 
  726                        newJob->SetServiceFlow(job->GetServiceFlow());
 
  727                        newJob->SetSize(allocationSize);
 
  728                        newJob->SetDeadline(job->GetDeadline());
 
  729                        newJob->SetReleaseTime(job->GetReleaseTime());
 
  730                        newJob->SetSchedulingType(job->GetSchedulingType());
 
  731                        newJob->SetPeriod(job->GetPeriod());
 
  732                        newJob->SetType(job->GetType());
 
  738                        if ((job->GetSize() - allocationSize) == 0)
 
 
  760    std::list<Ptr<PriorityUlJob>> priorityUlJobs;
 
  763    std::vector<SSRecord*>* ssRecords = 
GetBs()->GetSSManager()->GetSSRecords();
 
  764    for (
auto iter = ssRecords->begin(); iter != ssRecords->end(); ++iter)
 
  767        std::vector<ServiceFlow*> serviceFlows =
 
  769        for (
auto iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2)
 
  797            priorityUlJob->SetUlJob(job);
 
  799            if (minReservedTrafficRate <= grantedBandwidth)
 
  801                priorityUlJob->SetPriority(-10000);
 
  809                if (allocationSize > 0)
 
  814                        allocationSize = sduSize;
 
  820                priorityUlJob->SetPriority(priority);
 
  827            priorityUlJobs.push_back(priorityUlJob);
 
  833    for (
auto iter = priorityUlJobs.begin(); iter != priorityUlJobs.end(); ++iter)
 
  836        Ptr<UlJob> job_priority = priorityUlJob->GetUlJob();
 
  838        if (availableSymbols)
 
 
  857    uint8_t uiuc = ulMapIe.
GetUiuc(); 
 
  858    std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows(schedulingType);
 
  860    for (
auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter)
 
  870            GetBs()->GetBandwidthManager()->CalculateAllocationSize(ssRecord, serviceFlow);
 
  872        if (availableSymbols < allocationSize)
 
  877        if (allocationSize > 0)
 
  894            NS_LOG_DEBUG(
"BS uplink scheduler, UGS allocation, size: " << allocationSize
 
  900                                                 << 
" unicast poll, size: " << allocationSize
 
  901                                                 << 
" symbols, modulation: BPSK 1/2");
 
  905                               << 
", SFID: " << serviceFlow->
GetSfid());
 
 
  921    std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows(schedulingType);
 
  923    for (
auto iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter)
 
 
  947    uint16_t sduSize = 0;
 
  953    if (requiredBandwidth > 0)
 
  958            allocSizeBytes = sduSize;
 
  959            allocSizeSymbols = 
GetBs()->GetPhy()->GetNrSymbols(sduSize, modulationType);
 
  963            allocSizeBytes = requiredBandwidth;
 
  964            allocSizeSymbols = 
GetBs()->GetPhy()->GetNrSymbols(requiredBandwidth, modulationType);
 
  967        if (availableSymbols >= allocSizeSymbols)
 
  971                         << 
" allocation, size: " << allocSizeSymbols << 
" symbols" 
  973                         << 
", SFID: " << serviceFlow->
GetSfid()
 
 
 1005    Time ssUlStartTime =
 
 1013    if (timeSinceLastIrInterval + 
GetBs()->GetPhy()->GetFrameDuration() >
 
 1014            GetBs()->GetInitialRangingInterval() &&
 
 1015        availableSymbols >= allocationSize)
 
 1019        ulMapIeIr.
SetCid((
GetBs()->GetBroadcastConnection())->GetCid());
 
 1023        NS_LOG_DEBUG(
"BS uplink scheduler, initial ranging allocation, size: " 
 1024                     << allocationSize << 
" symbols, modulation: BPSK 1/2");
 
 1029            GetBs()->MarkRangingOppStart(
 
 1031                Seconds(symbolsToAllocation * 
GetBs()->GetSymbolDuration().GetSeconds()) +
 
 1033                        GetBs()->GetSymbolDuration().GetSeconds()));
 
 
 1044    uint8_t delayNrFrames = 1;
 
 1048        (
uint32_t((
double)(bitsPerSecond)*
GetBs()->GetPhy()->GetFrameDuration().GetSeconds())) / 8;
 
 1049    uint32_t frameDurationMSec = 
GetBs()->GetPhy()->GetFrameDuration().GetMilliSeconds();
 
 1062        uint32_t grantSize = 
GetBs()->GetPhy()->GetNrSymbols(bytesPerFrame, modulation);
 
 1067        if (toleratedJitter > frameDurationMSec)
 
 1069            delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec);
 
 1072        uint16_t interval = delayNrFrames * frameDurationMSec;
 
 1082        uint16_t interval = 1000;
 
 
 1099    std::list<Ptr<PriorityUlJob>> priorityUlJobs;
 
 1106        ServiceFlow* serviceFlowJob = job->GetServiceFlow();
 
 1108        if (serviceFlowJob == serviceFlow)
 
 1110            size += job->GetSize();
 
 
 1122        GetBs()->GetConnectionManager()->GetConnection(bwRequestHdr.
GetCid());
 
 1123    SSRecord* ssRecord = 
GetBs()->GetSSManager()->GetSSRecord(connection->GetCid());
 
 1124    ServiceFlow* serviceFlow = connection->GetServiceFlow();
 
 1129    if (size > pendingSize)
 
 1131        size -= pendingSize;
 
 1145    const Time& period = deadline; 
 
 1148                       << 
" at BS uplink scheduler, processing bandwidth request from." 
 1151                       << deadline.
As(
Time::S) << 
" and size " << size << 
" aggreg size " 
 1152                       << bwRequestHdr.
GetBr());
 
 1155    job->SetSsRecord(ssRecord);
 
 1156    job->SetServiceFlow(serviceFlow);
 
 1158    job->SetDeadline(deadline);
 
 1159    job->SetReleaseTime(currentTime);
 
 1161    job->SetPeriod(period);
 
 
This class implements the bandwidth-request mac Header as described by IEEE Standard for Local and me...
uint32_t GetBr() const
Get BR field.
Cid GetCid() const
Get CID field.
This class implements the DSA-REQ message described by "IEEE Standard forLocal and metropolitan area ...
This class implements the UL-MAP_IE message as described by "IEEE Standard forLocal and metropolitan ...
void SetStartTime(uint16_t startTime)
Set start time.
uint8_t GetUiuc() const
Get UIUC.
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 GetHasServiceFlowUgs() const
Check if at least one flow has scheduling type SF_TYPE_UGS.
Cid GetBasicCid() const
Get basic CID.
WimaxNetDevice::RangingStatus GetRangingStatus() const
Get ranging status.
bool GetPollForRanging() const
Get poll for ranging.
bool GetHasServiceFlowRtps() const
Check if at least one flow has scheduling type SF_TYPE_RTPS.
std::vector< ServiceFlow * > GetServiceFlows(ServiceFlow::SchedulingType schedulingType) const
Get service flows.
bool GetAreServiceFlowsAllocated() const
Check if service flows are allocated.
Mac48Address GetMacAddress() const
Get MAC address.
bool GetIsBroadcastSS() const
Get is broadcast SS.
WimaxPhy::ModulationType GetModulationType() const
Get modulation type.
bool GetHasServiceFlowNrtps() const
Check if at least one flow has scheduling type SF_TYPE_NRTPS.
bool GetHasServiceFlowBe() const
Check if at least one flow has scheduling type SF_TYPE_BE.
This class implements service flows as described by the IEEE-802.16 standard.
uint32_t GetSfid() const
Get SFID.
uint32_t GetMaximumLatency() const
Get maximum latency.
ServiceFlow::SchedulingType GetSchedulingType() const
Get scheduling type.
uint16_t GetUnsolicitedPollingInterval() const
Get unsolicited polling interval.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
char * GetSchedulingTypeStr() const
Get scheduling type string.
uint32_t GetMinReservedTrafficRate() const
Get minimum reserved traffic rate.
uint8_t GetSduSize() const
Get SDU size.
WimaxPhy::ModulationType GetModulation() const
Get modulation.
void SetUnsolicitedGrantInterval(uint16_t unsolicitedGrantInterval)
Set unsolicited grant interval.
ServiceFlowRecord * GetRecord() const
Get service flow record.
void SetUnsolicitedPollingInterval(uint16_t unsolicitedPollingInterval)
Set unsolicited polling interval.
bool GetIsMulticast() const
Get is multicast.
uint32_t GetToleratedJitter() const
Get tolerated jitter.
Ptr< WimaxConnection > GetConnection() const
Can return a null connection is this service flow has not been associated yet to a connection.
this class implements a structure to manage some parameters and statistics related to a service flow
Time GetGrantTimeStamp() const
uint32_t GetBacklogged() const
void UpdateRequestedBandwidth(uint32_t requestedBandwidth)
update the requested bandwidth
void UpdateGrantedBandwidthTemp(uint32_t grantedBandwidthTemp)
update the temporary granted bandwidth
uint32_t GetRequestedBandwidth() const
Time GetLastGrantTime() const
void IncreaseBacklogged(uint32_t backlogged)
increase backlogged
uint32_t GetBackloggedTemp() const
void SetBackloggedTemp(uint32_t backloggedTemp)
set temporary back logged
uint32_t GetGrantedBandwidthTemp() const
void SetGrantSize(uint32_t grantSize)
Set the grant size (only for UGS service flows)
uint32_t GetGrantedBandwidth() const
void SetGrantedBandwidthTemp(uint32_t grantedBandwidthTemp)
set the temporary granted bandwidth
void SetBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
set BW since last expiry
void UpdateGrantedBandwidth(uint32_t grantedBandwidth)
update the granted bandwidth
void UpdateBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
update BW since last expiry
void SetBacklogged(uint32_t backlogged)
set backlogged
uint32_t GetBwSinceLastExpiry() const
void SetLastGrantTime(Time grantTime)
set last grant time
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
JobPriority
Job priority enumeration.
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 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() const
virtual void SetIsInvIrIntrvlAllocated(bool isInvIrIntrvlAllocated)
Set if the Inv IR interval is allocated.
virtual Time GetTimeStampIrInterval()
virtual Time GetDcdTimeStamp() const
virtual void SetTimeStampIrInterval(Time timeStampIrInterval)
Set timestamp IR interval.
virtual Ptr< BaseStationNetDevice > GetBs()
virtual Time GetUcdTimeStamp() const
void InitOnce() override
This method is called once to initialize window.
uint32_t CountSymbolsQueue(std::list< Ptr< UlJob > > jobs)
~UplinkSchedulerMBQoS() override
Ptr< UlJob > CreateUlJob(SSRecord *ssRecord, ServiceFlow::SchedulingType schedType, ReqType reqType)
void CheckDeadline(uint32_t &availableSymbols)
Check deadline from jobs. Migrate requests if necessary.
void OnSetRequestedBandwidth(ServiceFlowRecord *sfr) override
Set requested bandwidth.
std::list< Ptr< UlJob > > m_uplinkJobs_inter
uplink jobs intermedite priority
std::list< Ptr< UlJob > > m_uplinkJobs_low
uplink jobs low priority
bool ServiceBandwidthRequestsBytes(ServiceFlow *serviceFlow, ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols, uint32_t allocationSizeBytes)
Service bandwidth requests bytes.
std::list< OfdmUlMapIe > GetUplinkAllocations() const override
Get uplink allocations.
uint32_t CountSymbolsJobs(Ptr< UlJob > job)
void GetChannelDescriptorsToUpdate(bool &updateDcd, bool &updateUcd, bool &sendDcd, bool &sendUcd) override
Determines if channel descriptors sent in the current frame are required to be updated.
void ServiceUnsolicitedGrants(const SSRecord *ssRecord, ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols) override
Service unsolicited grants.
Time m_windowInterval
windows interval
void ProcessBandwidthRequest(const BandwidthRequestHeader &bwRequestHdr) override
Process bandwidth request function.
void AllocateInitialRangingInterval(uint32_t &symbolsToAllocation, uint32_t &availableSymbols) override
Allocate initial ranging interval.
void ServiceBandwidthRequests(const SSRecord *ssRecord, ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols) override
Service bandwidth requests.
Ptr< UlJob > DequeueJob(UlJob::JobPriority priority)
Dequeue a job from a priority queue.
uint32_t CalculateAllocationStartTime() override
Calculate allocation start time.
void Schedule() override
Schedule function.
std::list< Ptr< UlJob > > m_uplinkJobs_high
uplink jobs high priority
uint32_t GetPendingSize(ServiceFlow *serviceFlow)
void EnqueueJob(UlJob::JobPriority priority, Ptr< UlJob > job)
Enqueue a job in a priority queue.
Time DetermineDeadline(ServiceFlow *serviceFlow)
Calculates deadline of a request.
static TypeId GetTypeId()
Get the type ID.
void CheckMinimumBandwidth(uint32_t &availableSymbols)
Check if Minimum bandwidth is guarantee. Migrate requests if necessary.
void UplinkSchedWindowTimer()
Reset the current window.
void SetupServiceFlow(SSRecord *ssRecord, ServiceFlow *serviceFlow) override
Setup service flow.
void AddUplinkAllocation(OfdmUlMapIe &ulMapIe, const uint32_t &allocationSize, uint32_t &symbolsToAllocation, uint32_t &availableSymbols) override
Add uplink allocation.
std::list< OfdmUlMapIe > m_uplinkAllocations
uplink allocations
@ RANGING_STATUS_CONTINUE
ModulationType
ModulationType enumeration.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
#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_LOG(level, msg)
This macro allows you to log an arbitrary message at a specific log level.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ReqType
Request type enumeration.
@ LOG_DEBUG
Full voluminous logging to support debugging.
SortProcessPtr structure.