20 #include "ns3/simulator.h"
25 #include "ns3/uinteger.h"
43 : m_windowInterval (time)
61 .AddAttribute (
"WindowInterval",
62 "The time to wait to reset window",
75 std::list<OfdmUlMapIe>
91 uint32_t randNr = rand ();
92 if (randNr % 5 == 0 ||
GetBs ()->GetNrDcdSent () == 0)
98 if (randNr % 5 == 0 ||
GetBs ()->GetNrUcdSent () == 0)
127 if (timeSinceLastDcd >
GetBs ()->GetDcdInterval ())
133 if (timeSinceLastUcd >
GetBs ()->GetUcdInterval ())
143 return GetBs ()->GetNrDlSymbols () *
GetBs ()->GetPhy ()->GetPsPerSymbol () +
GetBs ()->GetTtg ();
148 const uint32_t &allocationSize,
149 uint32_t &symbolsToAllocation,
150 uint32_t &availableSymbols)
155 symbolsToAllocation += allocationSize;
156 availableSymbols -= allocationSize;
167 if (!
GetBs ()->GetSSManager ())
173 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
176 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
182 for (std::vector<ServiceFlow*>::iterator iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
221 bool allocationForDsa =
false;
223 uint32_t symbolsToAllocation = 0;
224 uint32_t allocationSize = 0;
225 uint32_t availableSymbols =
GetBs ()->GetNrUlSymbols ();
226 uint32_t availableSymbolsAux =
GetBs ()->GetNrUlSymbols ();
230 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
231 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
248 allocationSize =
GetBs ()->GetRangReqOppSize ();
251 if (availableSymbols >= allocationSize)
265 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
275 if (!allocationForDsa)
277 allocationSize =
GetBs ()->GetPhy ()->GetNrSymbols (
sizeof(
DsaReq), modulationType);
279 if (availableSymbols >= allocationSize)
282 allocationForDsa =
true;
300 if (availableSymbols)
308 Time frame_duration =
GetBs ()->GetPhy ()->GetFrameDuration ();
358 availableSymbolsAux = availableSymbols;
359 uint32_t symbolsUsed = 0;
362 availableSymbolsAux -= symbolsUsed;
377 SSRecord * ssRecord = job->GetSsRecord ();
384 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
387 ReqType reqType = job->GetType ();
398 else if (reqType ==
DATA)
401 uint32_t allocSizeBytes = job->GetSize ();
420 SSRecord * ssRecord = job->GetSsRecord ();
427 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
430 ReqType reqType = job->GetType ();
443 NS_FATAL_ERROR (
"Intermediate priority queue only should enqueue data packets.");
454 SSRecord * ssRecord = job->GetSsRecord ();
461 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
464 ReqType reqType = job->GetType ();
477 NS_FATAL_ERROR (
"Low priority queue only should enqueue data packets.");
490 GetBs ()->GetBandwidthManager ()->SetSubframeRatio ();
496 uint32_t &symbolsToAllocation, uint32_t &availableSymbols, uint32_t allocationSizeBytes)
498 uint32_t allocSizeBytes = allocationSizeBytes;
499 uint32_t allocSizeSymbols = 0;
505 if (requiredBandwidth > 0)
507 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (allocSizeBytes, modulationType);
509 if (availableSymbols < allocSizeSymbols)
511 allocSizeSymbols = availableSymbols;
514 if (availableSymbols >= allocSizeSymbols)
517 "At " <<
Simulator::Now ().GetSeconds ()<<
" BS uplink scheduler, "
519 <<
" allocation, size: " << allocSizeSymbols <<
" symbols"
522 <<
", SFID: " << serviceFlow->
GetSfid ()
524 <<
", bw granted: " << allocSizeBytes
547 uint32_t symbols = 0;
562 job->SetSsRecord (ssRecord);
563 job->SetSchedulingType (schedType);
564 job->SetServiceFlow (*(ssRecord->
GetServiceFlows (schedType).begin ()));
565 job->SetType (reqType);
572 SSRecord *ssRecord = job->GetSsRecord ();
574 uint32_t allocationSize = 0;
584 allocationSize =
GetBs ()->GetBwReqOppSize ();
590 uint16_t sduSize = serviceFlow->
GetSduSize ();
593 if (requiredBandwidth > 0)
599 allocationSize =
GetBs ()->GetPhy ()->GetNrSymbols (sduSize, modulationType);
603 allocationSize =
GetBs ()->GetPhy ()->GetNrSymbols (requiredBandwidth, modulationType);
607 return allocationSize;
662 Time deadline = job->GetDeadline ();
663 Time frame_duration =
GetBs ()->GetPhy ()->GetFrameDuration ();
668 << job->GetServiceFlow ()->GetMinReservedTrafficRate ()
669 <<
" deadline: "<<job->GetDeadline ().GetSeconds () <<
" frame start: "<<
GetBs ()->m_frameStartTime.GetSeconds ()
670 <<
" frame duration: "<< frame_duration );
676 if (availableSymbols)
678 uint32_t availableBytes =
GetBs ()->GetPhy ()->GetNrBytes (availableSymbols,job->GetSsRecord ()->GetModulationType ());
679 uint32_t allocationSize = job->GetSize ();
680 if (allocationSize > availableBytes)
682 allocationSize = availableBytes;
686 if (allocationSize == 0)
691 uint32_t symbolsToAllocate =
GetBs ()->GetPhy ()->GetNrSymbols (allocationSize, job->GetSsRecord ()->GetModulationType ());
692 if (symbolsToAllocate > availableSymbols)
694 symbolsToAllocate = availableSymbols;
695 allocationSize =
GetBs ()->GetPhy ()->GetNrBytes (symbolsToAllocate,job->GetSsRecord ()->GetModulationType ());
698 job->SetSize (job->GetSize () - allocationSize);
702 newJob->SetSsRecord (job->GetSsRecord ());
703 newJob->SetServiceFlow (job->GetServiceFlow ());
704 newJob->SetSize (allocationSize);
705 newJob->SetDeadline (job->GetDeadline ());
706 newJob->SetReleaseTime (job->GetReleaseTime ());
707 newJob->SetSchedulingType (job->GetSchedulingType ());
708 newJob->SetPeriod (job->GetPeriod ());
709 newJob->SetType (job->GetType ());
715 if ((job->GetSize () - allocationSize) == 0)
738 std::list<Ptr<PriorityUlJob> > priorityUlJobs;
741 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
742 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
746 for (std::vector<ServiceFlow*>::iterator iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
771 priorityUlJob->SetUlJob (job);
773 if (minReservedTrafficRate <= grantedBandwidth)
775 priorityUlJob->SetPriority (-10000);
781 uint32_t sduSize = serviceFlow->
GetSduSize ();
783 if (allocationSize > 0)
788 allocationSize = sduSize;
793 priorityUlJob->SetPriority (priority);
800 priorityUlJobs.push_back (priorityUlJob);
809 Ptr<UlJob> job_priority = priorityUlJob->GetUlJob ();
811 if (availableSymbols)
826 uint32_t &symbolsToAllocation,
827 uint32_t &availableSymbols)
829 uint32_t allocationSize = 0;
830 uint8_t uiuc = ulMapIe.
GetUiuc ();
831 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
833 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
841 allocationSize =
GetBs ()->GetBandwidthManager ()->CalculateAllocationSize (ssRecord, serviceFlow);
843 if (availableSymbols < allocationSize)
848 if (allocationSize > 0)
864 NS_LOG_DEBUG (
"BS uplink scheduler, UGS allocation, size: " << allocationSize <<
" symbols");
869 << allocationSize <<
" symbols" <<
", modulation: BPSK 1/2");
885 uint32_t &symbolsToAllocation,
886 uint32_t &availableSymbols)
888 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
890 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
909 uint32_t &symbolsToAllocation,
910 uint32_t &availableSymbols)
912 uint32_t allocSizeBytes = 0;
913 uint32_t allocSizeSymbols = 0;
914 uint16_t sduSize = 0;
920 if (requiredBandwidth > 0)
925 allocSizeBytes = sduSize;
926 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (sduSize, modulationType);
931 allocSizeBytes = requiredBandwidth;
932 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (requiredBandwidth, modulationType);
935 if (availableSymbols >= allocSizeSymbols)
938 << allocSizeSymbols <<
" symbols" <<
", CID: " << serviceFlow->
GetConnection ()->GetCid () <<
", SFID: "
975 if (timeSinceLastIrInterval +
GetBs ()->GetPhy ()->GetFrameDuration () >
GetBs ()->GetInitialRangingInterval ()
976 && availableSymbols >= allocationSize)
980 ulMapIeIr.
SetCid ((
GetBs ()->GetBroadcastConnection ())->GetCid ());
984 NS_LOG_DEBUG (
"BS uplink scheduler, initial ranging allocation, size: " << allocationSize <<
" symbols"
985 <<
", modulation: BPSK 1/2" );
990 GetBs ()->MarkRangingOppStart (ssUlStartTime +
Seconds (symbolsToAllocation
991 *
GetBs ()->GetSymbolDuration ().GetSeconds ()) +
Seconds (i *
GetBs ()->GetRangReqOppSize ()
992 *
GetBs ()->GetSymbolDuration ().GetSeconds ()));
1003 uint8_t delayNrFrames = 1;
1006 uint32_t bytesPerFrame =
1007 (uint32_t ((
double)(bitsPerSecond) *
GetBs ()->GetPhy ()->GetFrameDuration ().GetSeconds ())) / 8;
1008 uint32_t frameDurationMSec =
GetBs ()->GetPhy ()->GetFrameDuration ().GetMilliSeconds ();
1022 uint32_t grantSize =
GetBs ()->GetPhy ()->GetNrSymbols (bytesPerFrame, modulation);
1027 if (toleratedJitter > frameDurationMSec)
1029 delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec);
1032 uint16_t interval = delayNrFrames * frameDurationMSec;
1044 uint16_t interval = 1000;
1061 std::list<Ptr <PriorityUlJob> > priorityUlJobs;
1069 ServiceFlow *serviceFlowJob = job->GetServiceFlow ();
1071 if (serviceFlowJob == serviceFlow)
1073 size += job->GetSize ();
1085 SSRecord *ssRecord =
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ());
1086 ServiceFlow *serviceFlow = connection->GetServiceFlow ();
1088 uint32_t size = bwRequestHdr.
GetBr ();
1091 if (size > pendingSize)
1093 size -= pendingSize;
1108 Time period = deadline;
1114 job->SetSsRecord (ssRecord);
1115 job->SetServiceFlow (serviceFlow);
1116 job->SetSize (size);
1117 job->SetDeadline (deadline);
1118 job->SetReleaseTime (currentTime);
1120 job->SetPeriod (period);
1121 job->SetType (
DATA);
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
Simulation virtual time values and 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)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
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)
void AddUplinkAllocation(OfdmUlMapIe &ulMapIe, const uint32_t &allocationSize, uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
#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 GetSfid(void) const
WimaxNetDevice::RangingStatus GetRangingStatus(void) const
#define NS_FATAL_ERROR(msg)
Fatal error handling.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Rare ad-hoc debug messages.
Ptr< WimaxConnection > GetConnection(void) const
char * GetSchedulingTypeStr(void) const
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
uint32_t GetMinReservedTrafficRate(void) const
void UpdateGrantedBandwidthTemp(uint32_t grantedBandwidthTemp)
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
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)
AttributeValue implementation for 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)
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)
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
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...
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)
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
bool GetHasServiceFlowNrtps(void) const
static Time Now(void)
Return the current simulation virtual 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)
Use NS_LOG to output a message of level LOG_DEBUG.
bool GetIsMulticast(void) const
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)
void SetBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
void SetLastGrantTime(Time grantTime)
void SetupServiceFlow(SSRecord *ssRecord, ServiceFlow *serviceFlow)
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
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