20 #include "ns3/simulator.h"
25 #include "ns3/uinteger.h"
44 : m_windowInterval (time)
62 .AddAttribute (
"WindowInterval",
63 "The time to wait to reset window",
76 std::list<OfdmUlMapIe>
92 uint32_t randNr = rand ();
93 if (randNr % 5 == 0 ||
GetBs ()->GetNrDcdSent () == 0)
99 if (randNr % 5 == 0 ||
GetBs ()->GetNrUcdSent () == 0)
128 if (timeSinceLastDcd >
GetBs ()->GetDcdInterval ())
134 if (timeSinceLastUcd >
GetBs ()->GetUcdInterval ())
144 return GetBs ()->GetNrDlSymbols () *
GetBs ()->GetPhy ()->GetPsPerSymbol () +
GetBs ()->GetTtg ();
149 const uint32_t &allocationSize,
150 uint32_t &symbolsToAllocation,
151 uint32_t &availableSymbols)
156 symbolsToAllocation += allocationSize;
157 availableSymbols -= allocationSize;
168 if (!
GetBs ()->GetSSManager ())
174 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
177 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
183 for (std::vector<ServiceFlow*>::iterator iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
222 bool allocationForDsa =
false;
224 uint32_t symbolsToAllocation = 0;
225 uint32_t allocationSize = 0;
226 uint32_t availableSymbols =
GetBs ()->GetNrUlSymbols ();
227 uint32_t availableSymbolsAux =
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 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);
1150 Time deadline = MilliSeconds (latency) + lastGrantTime;
Ptr< UlJob > DequeueJob(UlJob::JobPriority priority)
Dequeue a job from a priority queue.
void SetBackloggedTemp(uint32_t backloggedTemp)
void AllocateInitialRangingInterval(uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
uint32_t CalculateAllocationStartTime(void)
Mac48Address GetMacAddress(void) const
keep track of time values and allow control of global simulation resolution
enum WimaxPhy::ModulationType GetModulation(void) const
smart pointer class similar to boost::intrusive_ptr
enum ServiceFlow::SchedulingType GetSchedulingType(void) const
virtual void SetDcdTimeStamp(Time dcdTimeStamp)
void GetChannelDescriptorsToUpdate(bool &, bool &, bool &, bool &)
Determines if channel descriptors sent in the current frame are required to be updated.
virtual Time GetUcdTimeStamp(void) const
bool GetHasServiceFlowBe(void) const
uint32_t CountSymbolsJobs(Ptr< UlJob > job)
Cid GetBasicCid(void) const
void UpdateBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
uint32_t GetRequestedBandwidth(void)
this class implements a structure to manage some parameters and statistics related to a service flow ...
uint32_t GetPendingSize(ServiceFlow *serviceFlow)
void InitOnce(void)
This method is called once to initialize window.
bool GetAreServiceFlowsAllocated(void) const
virtual void SetIsIrIntrvlAllocated(bool isIrIntrvlAllocated)
void UpdateRequestedBandwidth(uint32_t requestedBandwidth)
static TypeId GetTypeId(void)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
void AddUplinkAllocation(OfdmUlMapIe &ulMapIe, const uint32_t &allocationSize, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
#define NS_LOG_COMPONENT_DEFINE(name)
uint32_t GetSfid(void) const
WimaxNetDevice::RangingStatus GetRangingStatus(void) const
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Ptr< WimaxConnection > GetConnection(void) const
char * GetSchedulingTypeStr(void) const
#define NS_FATAL_ERROR(msg)
fatal error handling
uint32_t GetMinReservedTrafficRate(void) const
void UpdateGrantedBandwidthTemp(uint32_t grantedBandwidthTemp)
double GetSeconds(void) const
bool ServiceBandwidthRequestsBytes(ServiceFlow *serviceFlow, enum ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols, uint32_t allocationSizeBytes)
std::list< Ptr< UlJob > > m_uplinkJobs_low
virtual void SetTimeStampIrInterval(Time timeStampIrInterval)
virtual Time GetTimeStampIrInterval(void)
Time GetGrantTimeStamp(void) const
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
hold objects of type ns3::Time
Virtual class for uplink scheduler.
uint32_t CountSymbolsQueue(std::list< Ptr< UlJob > > jobs)
void OnSetRequestedBandwidth(ServiceFlowRecord *sfr)
uint32_t GetBwSinceLastExpiry(void)
void UplinkSchedWindowTimer(void)
Reset the current window.
void SetUnsolicitedPollingInterval(uint16_t)
virtual void SetNrIrOppsAllocated(uint8_t nrIrOppsAllocated)
void SetDuration(uint16_t duration)
bool GetHasServiceFlowRtps(void) const
std::list< Ptr< UlJob > > m_uplinkJobs_high
#define NS_LOG(level, msg)
void SetGrantSize(uint32_t grantSize)
Set the grant size (only for UGS service flows)
void ProcessBandwidthRequest(const BandwidthRequestHeader &bwRequestHdr)
void SetUnsolicitedGrantInterval(uint16_t)
std::vector< ServiceFlow * > GetServiceFlows(enum ServiceFlow::SchedulingType schedulingType) const
uint32_t GetMaximumLatency(void) const
virtual void SetIsInvIrIntrvlAllocated(bool isInvIrIntrvlAllocated)
uint8_t GetUiuc(void) const
uint32_t GetBackloggedTemp(void) const
bool GetHasServiceFlowUgs(void) const
this class implements the bandwidth-request mac Header as described by IEEE Standard for Local and me...
virtual uint8_t GetNrIrOppsAllocated(void) const
uint32_t GetBacklogged(void) const
uint8_t GetSduSize(void) const
void CheckMinimumBandwidth(uint32_t &availableSymbols)
Check if Minimum bandwidth is guarantee. Migrate requests if necessary.
uint32_t GetGrantedBandwidthTemp(void)
This class implements service flows as described by the IEEE-802.16 standard.
void SetGrantedBandwidthTemp(uint32_t grantedBandwidthTemp)
virtual Ptr< BaseStationNetDevice > GetBs(void)
void SetStartTime(uint16_t startTime)
bool GetHasServiceFlowNrtps(void) const
static Time Now(void)
Return the "current simulation time".
ServiceFlowRecord * GetRecord(void) const
Time GetLastGrantTime(void) const
~UplinkSchedulerMBQoS(void)
bool GetPollForRanging(void) const
bool GetIsBroadcastSS(void)
virtual void SetUcdTimeStamp(Time ucdTimeStamp)
void EnqueueJob(UlJob::JobPriority priority, Ptr< UlJob > job)
Enqueue a job in a priority queue.
uint32_t GetToleratedJitter(void) const
uint32_t GetBr(void) const
Ptr< UlJob > CreateUlJob(SSRecord *ssRecord, enum ServiceFlow::SchedulingType schedType, ReqType reqType)
void ServiceBandwidthRequests(const SSRecord *ssRecord, enum ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
#define NS_LOG_DEBUG(msg)
bool GetIsMulticast(void) const
void ServiceUnsolicitedGrants(const SSRecord *ssRecord, enum ServiceFlow::SchedulingType schedulingType, OfdmUlMapIe &ulMapIe, const WimaxPhy::ModulationType modulationType, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
void SetBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
void SetLastGrantTime(Time grantTime)
void SetupServiceFlow(SSRecord *ssRecord, ServiceFlow *serviceFlow)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
This class is used by the base station to store some information related to subscriber station in the...
void UpdateGrantedBandwidth(uint32_t grantedBandwidth)
void SetBacklogged(uint32_t backlogged)
uint32_t GetGrantedBandwidth(void)
std::list< Ptr< UlJob > > m_uplinkJobs_inter
Doxygen introspection did not find any typical Config paths.
virtual Time GetDcdTimeStamp(void) const
std::list< OfdmUlMapIe > m_uplinkAllocations
std::list< OfdmUlMapIe > GetUplinkAllocations(void) const
Time DetermineDeadline(ServiceFlow *serviceFlow)
Calculates deadline of a request.
void IncreaseBacklogged(uint32_t backlogged)
a unique identifier for an interface.
void SetUiuc(uint8_t uiuc)
TypeId SetParent(TypeId tid)
void CheckDeadline(uint32_t &availableSymbols)
Check deadline from jobs. Migrate requests if necessary.
WimaxPhy::ModulationType GetModulationType(void) const
uint16_t GetUnsolicitedPollingInterval(void) const