20 #include "ns3/simulator.h" 25 #include "ns3/uinteger.h" 43 : m_windowInterval (time)
61 .SetGroupName(
"Wimax")
63 .AddAttribute (
"WindowInterval",
64 "The time to wait to reset window",
77 std::list<OfdmUlMapIe>
93 uint32_t randNr = rand ();
94 if (randNr % 5 == 0 ||
GetBs ()->GetNrDcdSent () == 0)
100 if (randNr % 5 == 0 ||
GetBs ()->GetNrUcdSent () == 0)
129 if (timeSinceLastDcd >
GetBs ()->GetDcdInterval ())
135 if (timeSinceLastUcd >
GetBs ()->GetUcdInterval ())
145 return GetBs ()->GetNrDlSymbols () *
GetBs ()->GetPhy ()->GetPsPerSymbol () +
GetBs ()->GetTtg ();
150 const uint32_t &allocationSize,
151 uint32_t &symbolsToAllocation,
152 uint32_t &availableSymbols)
157 symbolsToAllocation += allocationSize;
158 availableSymbols -= allocationSize;
169 if (!
GetBs ()->GetSSManager ())
175 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
178 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
184 for (std::vector<ServiceFlow*>::iterator iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
223 bool allocationForDsa =
false;
225 uint32_t symbolsToAllocation = 0;
226 uint32_t allocationSize = 0;
227 uint32_t availableSymbols =
GetBs ()->GetNrUlSymbols ();
231 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
232 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
249 allocationSize =
GetBs ()->GetRangReqOppSize ();
252 if (availableSymbols >= allocationSize)
266 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
276 if (!allocationForDsa)
278 allocationSize =
GetBs ()->GetPhy ()->GetNrSymbols (
sizeof(
DsaReq), modulationType);
280 if (availableSymbols >= allocationSize)
283 allocationForDsa =
true;
301 if (availableSymbols)
309 Time frame_duration =
GetBs ()->GetPhy ()->GetFrameDuration ();
359 uint32_t availableSymbolsAux = availableSymbols;
360 uint32_t symbolsUsed = 0;
363 availableSymbolsAux -= symbolsUsed;
378 SSRecord * ssRecord = job->GetSsRecord ();
385 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
388 ReqType reqType = job->GetType ();
399 else if (reqType ==
DATA)
402 uint32_t allocSizeBytes = job->GetSize ();
421 SSRecord * ssRecord = job->GetSsRecord ();
428 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
431 ReqType reqType = job->GetType ();
444 NS_FATAL_ERROR (
"Intermediate priority queue only should enqueue data packets.");
455 SSRecord * ssRecord = job->GetSsRecord ();
462 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
465 ReqType reqType = job->GetType ();
478 NS_FATAL_ERROR (
"Low priority queue only should enqueue data packets.");
491 GetBs ()->GetBandwidthManager ()->SetSubframeRatio ();
497 uint32_t &symbolsToAllocation, uint32_t &availableSymbols, uint32_t allocationSizeBytes)
499 uint32_t allocSizeBytes = allocationSizeBytes;
500 uint32_t allocSizeSymbols = 0;
506 if (requiredBandwidth > 0)
508 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (allocSizeBytes, modulationType);
510 if (availableSymbols < allocSizeSymbols)
512 allocSizeSymbols = availableSymbols;
515 if (availableSymbols >= allocSizeSymbols)
518 "At " <<
Simulator::Now ().GetSeconds ()<<
" BS uplink scheduler, " 520 <<
" allocation, size: " << allocSizeSymbols <<
" symbols" 523 <<
", SFID: " << serviceFlow->
GetSfid ()
525 <<
", bw granted: " << allocSizeBytes
548 uint32_t symbols = 0;
563 job->SetSsRecord (ssRecord);
564 job->SetSchedulingType (schedType);
565 job->SetServiceFlow (*(ssRecord->
GetServiceFlows (schedType).begin ()));
566 job->SetType (reqType);
573 SSRecord *ssRecord = job->GetSsRecord ();
575 uint32_t allocationSize = 0;
585 allocationSize =
GetBs ()->GetBwReqOppSize ();
591 uint16_t sduSize = serviceFlow->
GetSduSize ();
594 if (requiredBandwidth > 0)
600 allocationSize =
GetBs ()->GetPhy ()->GetNrSymbols (sduSize, modulationType);
604 allocationSize =
GetBs ()->GetPhy ()->GetNrSymbols (requiredBandwidth, modulationType);
608 return allocationSize;
663 Time deadline = job->GetDeadline ();
664 Time frame_duration =
GetBs ()->GetPhy ()->GetFrameDuration ();
669 << job->GetServiceFlow ()->GetMinReservedTrafficRate ()
670 <<
" deadline: "<<job->GetDeadline ().GetSeconds () <<
" frame start: "<<
GetBs ()->m_frameStartTime.GetSeconds ()
671 <<
" frame duration: "<< frame_duration );
677 if (availableSymbols)
679 uint32_t availableBytes =
GetBs ()->GetPhy ()->GetNrBytes (availableSymbols,job->GetSsRecord ()->GetModulationType ());
680 uint32_t allocationSize = job->GetSize ();
681 if (allocationSize > availableBytes)
683 allocationSize = availableBytes;
687 if (allocationSize == 0)
692 uint32_t symbolsToAllocate =
GetBs ()->GetPhy ()->GetNrSymbols (allocationSize, job->GetSsRecord ()->GetModulationType ());
693 if (symbolsToAllocate > availableSymbols)
695 symbolsToAllocate = availableSymbols;
696 allocationSize =
GetBs ()->GetPhy ()->GetNrBytes (symbolsToAllocate,job->GetSsRecord ()->GetModulationType ());
699 job->SetSize (job->GetSize () - allocationSize);
703 newJob->SetSsRecord (job->GetSsRecord ());
704 newJob->SetServiceFlow (job->GetServiceFlow ());
705 newJob->SetSize (allocationSize);
706 newJob->SetDeadline (job->GetDeadline ());
707 newJob->SetReleaseTime (job->GetReleaseTime ());
708 newJob->SetSchedulingType (job->GetSchedulingType ());
709 newJob->SetPeriod (job->GetPeriod ());
710 newJob->SetType (job->GetType ());
716 if ((job->GetSize () - allocationSize) == 0)
739 std::list<Ptr<PriorityUlJob> > priorityUlJobs;
742 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
743 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
747 for (std::vector<ServiceFlow*>::iterator iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
772 priorityUlJob->SetUlJob (job);
774 if (minReservedTrafficRate <= grantedBandwidth)
776 priorityUlJob->SetPriority (-10000);
782 uint32_t sduSize = serviceFlow->
GetSduSize ();
784 if (allocationSize > 0)
789 allocationSize = sduSize;
794 priorityUlJob->SetPriority (priority);
801 priorityUlJobs.push_back (priorityUlJob);
810 Ptr<UlJob> job_priority = priorityUlJob->GetUlJob ();
812 if (availableSymbols)
827 uint32_t &symbolsToAllocation,
828 uint32_t &availableSymbols)
830 uint32_t allocationSize = 0;
831 uint8_t uiuc = ulMapIe.
GetUiuc ();
832 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
834 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
842 allocationSize =
GetBs ()->GetBandwidthManager ()->CalculateAllocationSize (ssRecord, serviceFlow);
844 if (availableSymbols < allocationSize)
849 if (allocationSize > 0)
865 NS_LOG_DEBUG (
"BS uplink scheduler, UGS allocation, size: " << allocationSize <<
" symbols");
870 << allocationSize <<
" symbols" <<
", modulation: BPSK 1/2");
886 uint32_t &symbolsToAllocation,
887 uint32_t &availableSymbols)
889 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
891 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
910 uint32_t &symbolsToAllocation,
911 uint32_t &availableSymbols)
913 uint32_t allocSizeBytes = 0;
914 uint32_t allocSizeSymbols = 0;
915 uint16_t sduSize = 0;
921 if (requiredBandwidth > 0)
926 allocSizeBytes = sduSize;
927 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (sduSize, modulationType);
932 allocSizeBytes = requiredBandwidth;
933 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (requiredBandwidth, modulationType);
936 if (availableSymbols >= allocSizeSymbols)
939 << allocSizeSymbols <<
" symbols" <<
", CID: " << serviceFlow->
GetConnection ()->GetCid () <<
", SFID: " 976 if (timeSinceLastIrInterval +
GetBs ()->GetPhy ()->GetFrameDuration () >
GetBs ()->GetInitialRangingInterval ()
977 && availableSymbols >= allocationSize)
981 ulMapIeIr.
SetCid ((
GetBs ()->GetBroadcastConnection ())->GetCid ());
985 NS_LOG_DEBUG (
"BS uplink scheduler, initial ranging allocation, size: " << allocationSize <<
" symbols" 986 <<
", modulation: BPSK 1/2" );
991 GetBs ()->MarkRangingOppStart (ssUlStartTime +
Seconds (symbolsToAllocation
992 *
GetBs ()->GetSymbolDuration ().GetSeconds ()) +
Seconds (i *
GetBs ()->GetRangReqOppSize ()
993 *
GetBs ()->GetSymbolDuration ().GetSeconds ()));
1004 uint8_t delayNrFrames = 1;
1007 uint32_t bytesPerFrame =
1008 (uint32_t ((
double)(bitsPerSecond) *
GetBs ()->GetPhy ()->GetFrameDuration ().GetSeconds ())) / 8;
1009 uint32_t frameDurationMSec =
GetBs ()->GetPhy ()->GetFrameDuration ().GetMilliSeconds ();
1023 uint32_t grantSize =
GetBs ()->GetPhy ()->GetNrSymbols (bytesPerFrame, modulation);
1028 if (toleratedJitter > frameDurationMSec)
1030 delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec);
1033 uint16_t interval = delayNrFrames * frameDurationMSec;
1045 uint16_t interval = 1000;
1062 std::list<Ptr <PriorityUlJob> > priorityUlJobs;
1070 ServiceFlow *serviceFlowJob = job->GetServiceFlow ();
1072 if (serviceFlowJob == serviceFlow)
1074 size += job->GetSize ();
1086 SSRecord *ssRecord =
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ());
1087 ServiceFlow *serviceFlow = connection->GetServiceFlow ();
1089 uint32_t size = bwRequestHdr.
GetBr ();
1092 if (size > pendingSize)
1094 size -= pendingSize;
1109 Time period = deadline;
1115 job->SetSsRecord (ssRecord);
1116 job->SetServiceFlow (serviceFlow);
1117 job->SetSize (size);
1118 job->SetDeadline (deadline);
1119 job->SetReleaseTime (currentTime);
1121 job->SetPeriod (period);
1122 job->SetType (
DATA);
Ptr< UlJob > DequeueJob(UlJob::JobPriority priority)
Dequeue a job from a priority queue.
void SetBackloggedTemp(uint32_t backloggedTemp)
set temporary back logged
void SetCid(const Cid &cid)
Set CID.
void AllocateInitialRangingInterval(uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Allocate initial ranging interval.
uint32_t CalculateAllocationStartTime(void)
Calculate allocation start time.
bool GetIsMulticast(void) const
Get is multicast.
bool GetHasServiceFlowNrtps(void) const
Check if at least one flow has scheduling type SF_TYPE_NRTPS.
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
virtual void SetDcdTimeStamp(Time dcdTimeStamp)
Set DCD timestamp.
uint32_t CountSymbolsJobs(Ptr< UlJob > job)
ReqType
Request type enumeration.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
void UpdateBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
update BW since last expiry
Time GetGrantTimeStamp(void) const
uint32_t GetRequestedBandwidth(void)
WimaxPhy::ModulationType GetModulationType(void) const
Get modulation type.
this class implements a structure to manage some parameters and statistics related to a service flow ...
std::vector< ServiceFlow * > GetServiceFlows(enum ServiceFlow::SchedulingType schedulingType) const
Get service flows.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
uint32_t GetPendingSize(ServiceFlow *serviceFlow)
void InitOnce(void)
This method is called once to initialize window.
uint8_t GetSduSize(void) const
Get SDU size.
virtual uint8_t GetNrIrOppsAllocated(void) const
virtual void SetIsIrIntrvlAllocated(bool isIrIntrvlAllocated)
Set if the IR interval is allocated.
void UpdateRequestedBandwidth(uint32_t requestedBandwidth)
update the requested bandwidth
static TypeId GetTypeId(void)
Get the type ID.
void AddUplinkAllocation(OfdmUlMapIe &ulMapIe, const uint32_t &allocationSize, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Add uplink allocation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
uint32_t GetMaximumLatency(void) const
Get maximum latency.
Time m_windowInterval
windows interval
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
std::list< OfdmUlMapIe > GetUplinkAllocations(void) const
Get uplink allocations.
enum WimaxPhy::ModulationType GetModulation(void) const
Get modulation.
bool GetPollForRanging(void) const
Get poll for ranging.
void GetChannelDescriptorsToUpdate(bool &updateDcd, bool &updateUcd, bool &sendDcd, bool &sendUcd)
Determines if channel descriptors sent in the current frame are required to be updated.
bool GetHasServiceFlowUgs(void) const
Check if at least one flow has scheduling type SF_TYPE_UGS.
uint32_t GetSfid(void) const
Get SFID.
uint8_t GetUiuc(void) const
Get UIUC.
SortProcessPtr structure.
uint32_t GetBacklogged(void) const
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
void UpdateGrantedBandwidthTemp(uint32_t grantedBandwidthTemp)
update the temporary granted bandwidth
Cid GetCid(void) const
Get CID field.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
bool ServiceBandwidthRequestsBytes(ServiceFlow *serviceFlow, enum ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols, uint32_t allocationSizeBytes)
Service bandwidth requests bytes.
Ptr< WimaxConnection > GetConnection(void) const
Can return a null connection is this service flow has not been associated yet to a connection...
std::list< Ptr< UlJob > > m_uplinkJobs_low
uplink jobs low priority
char * GetSchedulingTypeStr(void) const
Get scheduling type string.
virtual void SetTimeStampIrInterval(Time timeStampIrInterval)
Set timestamp IR interval.
virtual Time GetTimeStampIrInterval(void)
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
Set base station device.
AttributeValue implementation for Time.
bool GetAreServiceFlowsAllocated(void) const
Check if service flows are allocated.
virtual Time GetDcdTimeStamp(void) const
Virtual class for uplink scheduler.
uint32_t CountSymbolsQueue(std::list< Ptr< UlJob > > jobs)
uint32_t GetToleratedJitter(void) const
Get tolerated jitter.
void OnSetRequestedBandwidth(ServiceFlowRecord *sfr)
Set requested bandwidth.
uint32_t GetBwSinceLastExpiry(void)
void UplinkSchedWindowTimer(void)
Reset the current window.
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.
std::list< Ptr< UlJob > > m_uplinkJobs_high
uplink jobs high priority
#define NS_LOG(level, msg)
This macro allows you to log an arbitrary message at a specific log level.
void SetGrantSize(uint32_t grantSize)
Set the grant size (only for UGS service flows)
void ProcessBandwidthRequest(const BandwidthRequestHeader &bwRequestHdr)
Process bandwidth request function.
ServiceFlowRecord * GetRecord(void) const
Get service flow record.
uint32_t GetBr(void) const
Get BR field.
virtual void SetIsInvIrIntrvlAllocated(bool isInvIrIntrvlAllocated)
Set if the Inv IR interval is allocated.
Mac48Address GetMacAddress(void) const
Get MAC address.
Time GetLastGrantTime(void) const
bool GetHasServiceFlowBe(void) const
Check if at least one flow has scheduling type SF_TYPE_BE.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
This class implements the bandwidth-request mac Header as described by IEEE Standard for Local and me...
void CheckMinimumBandwidth(uint32_t &availableSymbols)
Check if Minimum bandwidth is guarantee. Migrate requests if necessary.
uint32_t GetGrantedBandwidthTemp(void)
bool GetHasServiceFlowRtps(void) const
Check if at least one flow has scheduling type SF_TYPE_RTPS.
This class implements service flows as described by the IEEE-802.16 standard.
uint32_t GetMinReservedTrafficRate(void) const
Get minimum reserved traffic rate.
void SetGrantedBandwidthTemp(uint32_t grantedBandwidthTemp)
set the temporary granted bandwidth
virtual Ptr< BaseStationNetDevice > GetBs(void)
void SetStartTime(uint16_t startTime)
Set start time.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static Time Now(void)
Return the current simulation virtual time.
WimaxNetDevice::RangingStatus GetRangingStatus(void) const
Get ranging status.
~UplinkSchedulerMBQoS(void)
bool GetIsBroadcastSS(void)
Get is broadcast SS.
virtual void SetUcdTimeStamp(Time ucdTimeStamp)
Set UCD timestamp.
void EnqueueJob(UlJob::JobPriority priority, Ptr< UlJob > job)
Enqueue a job in a priority queue.
ModulationType
ModulationType enumeration.
enum ServiceFlow::SchedulingType GetSchedulingType(void) const
Get scheduling type.
Ptr< UlJob > CreateUlJob(SSRecord *ssRecord, enum ServiceFlow::SchedulingType schedType, ReqType reqType)
void SetUnsolicitedPollingInterval(uint16_t unsolicitedPollingInterval)
Set unsolicited polling interval.
void ServiceBandwidthRequests(const SSRecord *ssRecord, enum ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Service bandwidth requests.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
void ServiceUnsolicitedGrants(const SSRecord *ssRecord, enum ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
Service unsolicited grants.
JobPriority
Job priority enumeration.
virtual Time GetUcdTimeStamp(void) const
void SetBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
set BW since last expiry
void SetLastGrantTime(Time grantTime)
set last grant time
void SetupServiceFlow(SSRecord *ssRecord, ServiceFlow *serviceFlow)
Setup service flow.
Rare ad-hoc debug messages.
This class is used by the base station to store some information related to subscriber station in the...
Cid GetBasicCid(void) const
Get basic CID.
void UpdateGrantedBandwidth(uint32_t grantedBandwidth)
update the granted bandwidth
void SetBacklogged(uint32_t backlogged)
set backlogged
uint32_t GetGrantedBandwidth(void)
std::list< Ptr< UlJob > > m_uplinkJobs_inter
uplink jobs intermedite priority
uint16_t GetUnsolicitedPollingInterval(void) const
Get unsolicited polling interval.
void Schedule(void)
Schedule function.
uint32_t GetBackloggedTemp(void) const
This class implements the DSA-REQ message described by "IEEE Standard for Local and metropolitan area...
std::list< OfdmUlMapIe > m_uplinkAllocations
uplink allocations
Time DetermineDeadline(ServiceFlow *serviceFlow)
Calculates deadline of a request.
void IncreaseBacklogged(uint32_t backlogged)
increase backlogged
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.
void CheckDeadline(uint32_t &availableSymbols)
Check deadline from jobs. Migrate requests if necessary.