24 #include "ns3/simulator.h"
29 #include "ns3/uinteger.h"
76 std::list<OfdmUlMapIe>
89 uint32_t randNr = rand ();
90 if (randNr % 5 == 0 ||
GetBs ()->GetNrDcdSent () == 0)
96 if (randNr % 5 == 0 ||
GetBs ()->GetNrUcdSent () == 0)
125 if (timeSinceLastDcd >
GetBs ()->GetDcdInterval ())
131 if (timeSinceLastUcd >
GetBs ()->GetUcdInterval ())
146 const uint32_t &allocationSize,
147 uint32_t &symbolsToAllocation,
148 uint32_t &availableSymbols)
153 symbolsToAllocation += allocationSize;
154 availableSymbols -= allocationSize;
163 bool allocationForDsa =
false;
165 uint32_t symbolsToAllocation = 0;
166 uint32_t allocationSize = 0;
175 NS_LOG_INFO (
"UL Scheduler start, availableSymbols = " << availableSymbols);
177 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
196 if (availableSymbols >= allocationSize)
210 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
219 if (!allocationForDsa)
222 if (availableSymbols >= allocationSize)
225 allocationForDsa =
true;
247 if (availableSymbols)
257 if (availableSymbols)
267 if (availableSymbols)
283 if (availableSymbols)
289 if (availableSymbols)
291 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
305 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
309 if (availableSymbols)
319 if (availableSymbols)
348 uint32_t &symbolsToAllocation,
349 uint32_t &availableSymbols)
351 uint32_t allocationSize = 0;
352 uint8_t uiuc = ulMapIe.
GetUiuc ();
353 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
355 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
373 if (bps < serviceFlow->GetMinReservedTrafficRate ())
387 if (availableSymbols < allocationSize)
392 if (allocationSize > 0)
408 NS_LOG_DEBUG (
"BS uplink scheduler, UGS allocation, size: " << allocationSize <<
" symbols");
413 << allocationSize <<
" symbols" <<
", modulation: BPSK 1/2");
428 uint32_t &symbolsToAllocation,
429 uint32_t &availableSymbols)
431 std::vector<ServiceFlow*> serviceFlows = ssRecord->
GetServiceFlows (schedulingType);
433 for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
452 uint32_t &symbolsToAllocation,
453 uint32_t &availableSymbols)
455 uint32_t allocSizeBytes = 0;
456 uint32_t allocSizeSymbols = 0;
457 uint16_t sduSize = 0;
463 if (requiredBandwidth > 0)
468 allocSizeBytes = sduSize;
473 allocSizeBytes = requiredBandwidth;
477 if (availableSymbols >= allocSizeSymbols)
481 << allocSizeSymbols <<
" symbols" <<
", CID: " << serviceFlow->
GetConnection ()->
GetCid () <<
", SFID: "
506 NS_LOG_INFO (
"\t\tavailableSymbols = " << availableSymbols);
508 uint32_t allocSizeSymbols_[100];
513 int nbAllocation = 0;
514 uint32_t allocSizeBytes;
515 uint32_t totAllocSizeSymbols = 0;
520 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
533 ulMapIe.
SetUiuc (
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
537 for (std::vector<ServiceFlow*>::iterator iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
539 record_[nbAllocation] = (*iter2)->GetRecord ();
543 if (requiredBandwidth > 0)
545 modulationType_[nbAllocation] = modulationType;
546 ulMapIe_[nbAllocation] = ulMapIe;
547 allocSizeBytes = requiredBandwidth;
549 modulationType_[nbAllocation]);
550 totAllocSizeSymbols += allocSizeSymbols_[nbAllocation];
552 NS_LOG_INFO (
"\t\tUL Scheduler for CID = " << (*iter2)->GetConnection ()->GetCid ());
553 NS_LOG_INFO (
"\t\t\trequiredBandwidth = " << record_[nbAllocation]->GetRequestedBandwidth ()
554 <<
", allocSizeSymbols = " << allocSizeSymbols_[nbAllocation] <<
", modulationType = "
555 << modulationType_[nbAllocation]);
563 NS_LOG_INFO (
"\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
566 while (totAllocSizeSymbols > availableSymbols)
568 NS_LOG_INFO (
"\tUL Channel Saturation: totAllocSizeSymbols > availableSymbols");
569 double delta = double(availableSymbols) / double(totAllocSizeSymbols);
571 totAllocSizeSymbols = 0;
572 for (
int i = 0; i < nbAllocation; i++)
574 NS_LOG_INFO (
"\t\tprevious allocSizeSymbols_[" << i <<
"] = " << allocSizeSymbols_[i]);
575 allocSizeSymbols_[i] = (uint32_t) floor (allocSizeSymbols_[i] * delta);
576 totAllocSizeSymbols += allocSizeSymbols_[i];
577 NS_LOG_INFO (
"\t\tnew allocSizeSymbols_[" << i <<
"] = " << allocSizeSymbols_[i]);
579 NS_LOG_INFO (
"\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
583 for (
int i = 0; i < nbAllocation; i++)
585 AddUplinkAllocation (ulMapIe_[i], allocSizeSymbols_[i], symbolsToAllocation, availableSymbols);
587 NS_LOG_INFO (
"\t\tUpdateGrantedBandwidth for " << i <<
" = " << allocSizeBytes);
588 if (record_[i]->GetRequestedBandwidth () < allocSizeBytes)
610 if (timeSinceLastIrInterval +
GetBs ()->GetPhy ()->GetFrameDuration () >
GetBs ()->GetInitialRangingInterval ()
611 && availableSymbols >= allocationSize)
615 ulMapIeIr.
SetCid (
GetBs ()->GetBroadcastConnection ()->GetCid ());
619 NS_LOG_DEBUG (
"BS uplink scheduler, initial ranging allocation, size: " << allocationSize <<
" symbols"
620 <<
", modulation: BPSK 1/2");
626 *
GetBs ()->GetSymbolDuration ().GetSeconds ()) +
Seconds (i *
GetBs ()->GetRangReqOppSize ()
627 *
GetBs ()->GetSymbolDuration ().GetSeconds ()));
638 uint8_t delayNrFrames = 1;
641 uint32_t bytesPerFrame =
642 (uint32_t ((
double)(bitsPerSecond) *
GetBs ()->GetPhy ()->GetFrameDuration ().GetSeconds ())) / 8;
662 if (toleratedJitter > frameDurationMSec)
664 delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec);
667 uint16_t interval = delayNrFrames * frameDurationMSec;
673 if (serviceFlow->
GetSduSize () > bytesPerFrame)
675 delayNrFrames = (uint8_t)(serviceFlow->
GetSduSize () / bytesPerFrame);
678 uint16_t interval = delayNrFrames * frameDurationMSec;
711 uint32_t grantedBandwidth = 0;