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 ();
228 uint32_t availableSymbolsAux =
GetBs ()->GetNrUlSymbols ();
232 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
233 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
250 allocationSize =
GetBs ()->GetRangReqOppSize ();
253 if (availableSymbols >= allocationSize)
267 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
277 if (!allocationForDsa)
279 allocationSize =
GetBs ()->GetPhy ()->GetNrSymbols (
sizeof(
DsaReq), modulationType);
281 if (availableSymbols >= allocationSize)
284 allocationForDsa =
true;
302 if (availableSymbols)
310 Time frame_duration =
GetBs ()->GetPhy ()->GetFrameDuration ();
360 availableSymbolsAux = availableSymbols;
361 uint32_t symbolsUsed = 0;
364 availableSymbolsAux -= symbolsUsed;
379 SSRecord * ssRecord = job->GetSsRecord ();
386 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
389 ReqType reqType = job->GetType ();
400 else if (reqType ==
DATA)
403 uint32_t allocSizeBytes = job->GetSize ();
422 SSRecord * ssRecord = job->GetSsRecord ();
429 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
432 ReqType reqType = job->GetType ();
445 NS_FATAL_ERROR (
"Intermediate priority queue only should enqueue data packets.");
456 SSRecord * ssRecord = job->GetSsRecord ();
463 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
466 ReqType reqType = job->GetType ();
479 NS_FATAL_ERROR (
"Low priority queue only should enqueue data packets.");
492 GetBs ()->GetBandwidthManager ()->SetSubframeRatio ();
498 uint32_t &symbolsToAllocation, uint32_t &availableSymbols, uint32_t allocationSizeBytes)
500 uint32_t allocSizeBytes = allocationSizeBytes;
501 uint32_t allocSizeSymbols = 0;
507 if (requiredBandwidth > 0)
509 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (allocSizeBytes, modulationType);
511 if (availableSymbols < allocSizeSymbols)
513 allocSizeSymbols = availableSymbols;
516 if (availableSymbols >= allocSizeSymbols)
519 "At " <<
Simulator::Now ().GetSeconds ()<<
" BS uplink scheduler, "
521 <<
" allocation, size: " << allocSizeSymbols <<
" symbols"
524 <<
", SFID: " << serviceFlow->
GetSfid ()
526 <<
", bw granted: " << allocSizeBytes
549 uint32_t symbols = 0;
564 job->SetSsRecord (ssRecord);
565 job->SetSchedulingType (schedType);
566 job->SetServiceFlow (*(ssRecord->
GetServiceFlows (schedType).begin ()));
567 job->SetType (reqType);
574 SSRecord *ssRecord = job->GetSsRecord ();
576 uint32_t allocationSize = 0;
586 allocationSize =
GetBs ()->GetBwReqOppSize ();
592 uint16_t sduSize = serviceFlow->
GetSduSize ();
595 if (requiredBandwidth > 0)
601 allocationSize =
GetBs ()->GetPhy ()->GetNrSymbols (sduSize, modulationType);
605 allocationSize =
GetBs ()->GetPhy ()->GetNrSymbols (requiredBandwidth, modulationType);
609 return allocationSize;
664 Time deadline = job->GetDeadline ();
665 Time frame_duration =
GetBs ()->GetPhy ()->GetFrameDuration ();
670 << job->GetServiceFlow ()->GetMinReservedTrafficRate ()
671 <<
" deadline: "<<job->GetDeadline ().GetSeconds () <<
" frame start: "<<
GetBs ()->m_frameStartTime.GetSeconds ()
672 <<
" frame duration: "<< frame_duration );
678 if (availableSymbols)
680 uint32_t availableBytes =
GetBs ()->GetPhy ()->GetNrBytes (availableSymbols,job->GetSsRecord ()->GetModulationType ());
681 uint32_t allocationSize = job->GetSize ();
682 if (allocationSize > availableBytes)
684 allocationSize = availableBytes;
688 if (allocationSize == 0)
693 uint32_t symbolsToAllocate =
GetBs ()->GetPhy ()->GetNrSymbols (allocationSize, job->GetSsRecord ()->GetModulationType ());
694 if (symbolsToAllocate > availableSymbols)
696 symbolsToAllocate = availableSymbols;
697 allocationSize =
GetBs ()->GetPhy ()->GetNrBytes (symbolsToAllocate,job->GetSsRecord ()->GetModulationType ());
700 job->SetSize (job->GetSize () - allocationSize);
704 newJob->SetSsRecord (job->GetSsRecord ());
705 newJob->SetServiceFlow (job->GetServiceFlow ());
706 newJob->SetSize (allocationSize);
707 newJob->SetDeadline (job->GetDeadline ());
708 newJob->SetReleaseTime (job->GetReleaseTime ());
709 newJob->SetSchedulingType (job->GetSchedulingType ());
710 newJob->SetPeriod (job->GetPeriod ());
711 newJob->SetType (job->GetType ());
717 if ((job->GetSize () - allocationSize) == 0)
740 std::list<Ptr<PriorityUlJob> > priorityUlJobs;
743 std::vector<SSRecord*> *ssRecords =
GetBs ()->GetSSManager ()->GetSSRecords ();
744 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
748 for (std::vector<ServiceFlow*>::iterator iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
773 priorityUlJob->SetUlJob (job);
775 if (minReservedTrafficRate <= grantedBandwidth)
777 priorityUlJob->SetPriority (-10000);
783 uint32_t sduSize = serviceFlow->
GetSduSize ();
785 if (allocationSize > 0)
790 allocationSize = sduSize;
795 priorityUlJob->SetPriority (priority);
802 priorityUlJobs.push_back (priorityUlJob);
811 Ptr<UlJob> job_priority = priorityUlJob->GetUlJob ();
813 if (availableSymbols)
828 uint32_t &symbolsToAllocation,
829 uint32_t &availableSymbols)
831 uint32_t allocationSize = 0;
832 uint8_t uiuc = ulMapIe.
GetUiuc ();
833 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
835 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
843 allocationSize =
GetBs ()->GetBandwidthManager ()->CalculateAllocationSize (ssRecord, serviceFlow);
845 if (availableSymbols < allocationSize)
850 if (allocationSize > 0)
866 NS_LOG_DEBUG (
"BS uplink scheduler, UGS allocation, size: " << allocationSize <<
" symbols");
871 << allocationSize <<
" symbols" <<
", modulation: BPSK 1/2");
887 uint32_t &symbolsToAllocation,
888 uint32_t &availableSymbols)
890 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
892 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
911 uint32_t &symbolsToAllocation,
912 uint32_t &availableSymbols)
914 uint32_t allocSizeBytes = 0;
915 uint32_t allocSizeSymbols = 0;
916 uint16_t sduSize = 0;
922 if (requiredBandwidth > 0)
927 allocSizeBytes = sduSize;
928 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (sduSize, modulationType);
933 allocSizeBytes = requiredBandwidth;
934 allocSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (requiredBandwidth, modulationType);
937 if (availableSymbols >= allocSizeSymbols)
940 << allocSizeSymbols <<
" symbols" <<
", CID: " << serviceFlow->
GetConnection ()->GetCid () <<
", SFID: "
977 if (timeSinceLastIrInterval +
GetBs ()->GetPhy ()->GetFrameDuration () >
GetBs ()->GetInitialRangingInterval ()
978 && availableSymbols >= allocationSize)
982 ulMapIeIr.
SetCid ((
GetBs ()->GetBroadcastConnection ())->GetCid ());
986 NS_LOG_DEBUG (
"BS uplink scheduler, initial ranging allocation, size: " << allocationSize <<
" symbols"
987 <<
", modulation: BPSK 1/2" );
992 GetBs ()->MarkRangingOppStart (ssUlStartTime +
Seconds (symbolsToAllocation
993 *
GetBs ()->GetSymbolDuration ().GetSeconds ()) +
Seconds (i *
GetBs ()->GetRangReqOppSize ()
994 *
GetBs ()->GetSymbolDuration ().GetSeconds ()));
1005 uint8_t delayNrFrames = 1;
1008 uint32_t bytesPerFrame =
1009 (uint32_t ((
double)(bitsPerSecond) *
GetBs ()->GetPhy ()->GetFrameDuration ().GetSeconds ())) / 8;
1010 uint32_t frameDurationMSec =
GetBs ()->GetPhy ()->GetFrameDuration ().GetMilliSeconds ();
1024 uint32_t grantSize =
GetBs ()->GetPhy ()->GetNrSymbols (bytesPerFrame, modulation);
1029 if (toleratedJitter > frameDurationMSec)
1031 delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec);
1034 uint16_t interval = delayNrFrames * frameDurationMSec;
1046 uint16_t interval = 1000;
1063 std::list<Ptr <PriorityUlJob> > priorityUlJobs;
1071 ServiceFlow *serviceFlowJob = job->GetServiceFlow ();
1073 if (serviceFlowJob == serviceFlow)
1075 size += job->GetSize ();
1087 SSRecord *ssRecord =
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ());
1088 ServiceFlow *serviceFlow = connection->GetServiceFlow ();
1090 uint32_t size = bwRequestHdr.
GetBr ();
1093 if (size > pendingSize)
1095 size -= pendingSize;
1110 Time period = deadline;
1116 job->SetSsRecord (ssRecord);
1117 job->SetServiceFlow (serviceFlow);
1118 job->SetSize (size);
1119 job->SetDeadline (deadline);
1120 job->SetReleaseTime (currentTime);
1122 job->SetPeriod (period);
1123 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