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 ())
148 const uint32_t &allocationSize,
149 uint32_t &symbolsToAllocation,
150 uint32_t &availableSymbols)
155 symbolsToAllocation += allocationSize;
156 availableSymbols -= allocationSize;
167 if (!
GetBs ()->GetSSManager ())
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;
231 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
251 if (availableSymbols >= allocationSize)
265 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
275 if (!allocationForDsa)
279 if (availableSymbols >= allocationSize)
282 allocationForDsa =
true;
300 if (availableSymbols)
358 availableSymbolsAux = availableSymbols;
359 uint32_t symbolsUsed = 0;
362 availableSymbolsAux -= symbolsUsed;
384 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
398 else if (reqType ==
DATA)
401 uint32_t allocSizeBytes = job->
GetSize ();
427 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
443 NS_FATAL_ERROR (
"Intermediate priority queue only should enqueue data packets.");
461 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
477 NS_FATAL_ERROR (
"Low priority queue only should enqueue data packets.");
496 uint32_t &symbolsToAllocation, uint32_t &availableSymbols, uint32_t allocationSizeBytes)
498 uint32_t allocSizeBytes = allocationSizeBytes;
499 uint32_t allocSizeSymbols = 0;
505 if (requiredBandwidth > 0)
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;
574 uint32_t allocationSize = 0;
590 uint16_t sduSize = serviceFlow->
GetSduSize ();
593 if (requiredBandwidth > 0)
607 return allocationSize;
670 <<
" frame duration: "<< frame_duration );
676 if (availableSymbols)
679 uint32_t allocationSize = job->
GetSize ();
680 if (allocationSize > availableBytes)
682 allocationSize = availableBytes;
686 if (allocationSize == 0)
692 if (symbolsToAllocate > availableSymbols)
694 symbolsToAllocate = availableSymbols;
704 newJob->
SetSize (allocationSize);
715 if ((job->
GetSize () - allocationSize) == 0)
738 std::list<Ptr<PriorityUlJob> > priorityUlJobs;
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)
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;
931 allocSizeBytes = requiredBandwidth;
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" );
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;
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;
1071 if (serviceFlowJob == serviceFlow)
1086 ServiceFlow *serviceFlow = connection->GetServiceFlow ();
1088 uint32_t size = bwRequestHdr.
GetBr ();
1091 if (size > pendingSize)
1093 size -= pendingSize;
1108 Time period = deadline;
1149 Time deadline = MilliSeconds (latency) + lastGrantTime;