30 NS_LOG_COMPONENT_DEFINE(
"SatFwdLinkSchedulerTimeSlicing");
35 NS_OBJECT_ENSURE_REGISTERED(SatFwdLinkSchedulerTimeSlicing);
41 TypeId(
"ns3::SatFwdLinkSchedulerTimeSlicing")
43 .AddConstructor<SatFwdLinkSchedulerTimeSlicing>()
44 .AddAttribute(
"NumberOfSlices",
45 "Number of slices used.",
48 MakeUintegerChecker<uint8_t>(1, 255));
61 NS_LOG_FUNCTION(
this);
62 NS_FATAL_ERROR(
"Default constructor for SatFwdLinkSchedulerTimeSlicing not supported");
67 double carrierBandwidthInHz)
69 m_lastSliceAssigned(1),
70 m_lastSliceDequeued(1)
72 NS_LOG_FUNCTION(
this);
74 ObjectBase::ConstructSelf(AttributeConstructionList());
76 std::vector<SatEnums::SatModcod_t> modCods = conf->GetModCodsUsed();
87 Ptr<SatBbFrameContainer> container =
100 for (std::map<uint8_t, Ptr<SatBbFrameContainer>>::iterator it =
m_bbFrameContainers.begin();
104 uint32_t maxSymbolPerCycle =
106 uint32_t symbolsMostRobustModcod;
110 symbolsMostRobustModcod = it->second->GetFrameSymbols(
116 symbolsMostRobustModcod = it->second->GetFrameSymbols(
119 if (symbolsMostRobustModcod > maxSymbolPerCycle)
121 NS_FATAL_ERROR(
"Symbol rate of slice " + std::to_string(it->first) +
" (" +
122 std::to_string(it->second->GetMaxSymbolRate()) +
123 " Baud) is too low to allow at least one BBFrame of the most robust "
124 "ModCod. Must be at least " +
125 std::to_string((uint32_t)(symbolsMostRobustModcod /
138 NS_LOG_FUNCTION(
this);
144 NS_LOG_FUNCTION(
this);
149 std::pair<Ptr<SatBbFrame>,
const Time>
152 NS_LOG_FUNCTION(
this);
154 Ptr<SatBbFrame> frame;
161 if (frame !=
nullptr)
163 frame->SetSliceId(0);
164 frameDuration = frame->GetDuration();
181 if (frame !=
nullptr)
187 frameDuration = frame->GetDuration();
191 NS_LOG_WARN(
"Symbol rate not respected for slice " +
194 " while max is " + std::to_string(maxSymbolRate) +
" Baud");
208 frame = Create<SatBbFrame>(
m_bbFrameConf->GetDefaultModCod(),
213 Ptr<Packet> dummyPacket = Create<Packet>(1);
219 dummyPacket->AddPacketTag(mTag);
225 dummyPacket->AddPacketTag(addressE2ETag);
228 frame->AddPayload(dummyPacket);
229 frame->SetSliceId(0);
230 frameDuration = frame->GetDuration();
233 else if (frame ==
nullptr)
238 return std::make_pair(frame, frameDuration);
244 NS_LOG_FUNCTION(
this);
246 std::map<uint8_t, Ptr<SatBbFrameContainer>>::iterator it;
249 it->second->ClearAllFrames();
256 NS_LOG_FUNCTION(
this);
269 NS_LOG_FUNCTION(
this);
271 for (std::map<uint8_t, uint32_t>::iterator it =
m_symbolsSent.begin();
289 NS_LOG_FUNCTION(
this);
292 std::vector<Ptr<SatSchedulingObject>> so;
295 for (std::vector<Ptr<SatSchedulingObject>>::const_iterator it = so.begin();
299 uint32_t currentObBytes = (*it)->GetBufferedBytes();
300 uint32_t currentObMinReqBytes = (*it)->GetMinTxOpportunityInBytes();
301 uint8_t flowId = (*it)->GetFlowId();
302 Mac48Address address = (*it)->GetMacAddress();
305 (address != Mac48Address::GetBroadcast()))
317 Simulator::Schedule(Seconds(0),
322 uint8_t slice = (address == Mac48Address::GetBroadcast()) ? 0 :
m_slicesMapping.at(address);
326 uint32_t frameBytes =
337 if (frameBytes < currentObMinReqBytes)
350 if (frameBytes < currentObMinReqBytes)
352 NS_FATAL_ERROR(
"Control package probably too long!!!");
360 currentObMinReqBytes);
364 if ((flowId == 0) || (address == Mac48Address::GetBroadcast()))
388 NS_FATAL_ERROR(
"Packet does not fit in empty BB Frame. Control package too long or "
389 "fragmentation problem in user package!!!");
400 NS_LOG_FUNCTION(
this);
414 NS_LOG_FUNCTION(
this);
416 Time duration = Time(0);
417 for (std::map<uint8_t, Ptr<SatBbFrameContainer>>::iterator it =
m_bbFrameContainers.begin();
421 duration += it->second->GetTotalDuration();
429 std::vector<uint8_t> slices)
431 NS_LOG_FUNCTION(
this);
433 for (std::vector<uint8_t>::iterator it = slices.begin(); it != slices.end(); ++it)
435 Ptr<SatSliceSubscriptionMessage> sliceSubscription =
436 CreateObject<SatSliceSubscriptionMessage>();
437 sliceSubscription->SetSliceId(*it);
438 sliceSubscription->SetAddress(address);
446 uint32_t priorityClass,
449 NS_LOG_FUNCTION(
this);
451 if (priorityClass == 0)
458 uint8_t sliceId = (address == Mac48Address::GetBroadcast()) ? 0 :
m_slicesMapping.at(address);
465 for (std::map<uint8_t, Ptr<SatBbFrameContainer>>::iterator it =
m_bbFrameContainers.begin();
475 if (symbolRate > maxSymbolRate)
489 return symbolRate < maxSymbolRate;
496 NS_LOG_FUNCTION(
this);
This class implements a tag that carries the satellite MAC of GW and UT.
void SetE2ESourceAddress(Mac48Address e2eSourceAddress)
Set E2E source MAC address.
void SetE2EDestAddress(Mac48Address e2eDestAddress)
Set E2E destination MAC address.
SatModcod_t
Modulation scheme and coding rate for DVB-S2.
SatFwdLinkScheduler schedules BB frames for forward link.
TracedCallback< uint8_t, double > m_schedulingSymbolRateTrace
Traced callback for symbol rate, with flowId, requested Modcod info.
SatFwdLinkScheduler::TxOpportunityCallback m_txOpportunityCallback
Callback to notify the txOpportunity to upper layer Returns a packet Attributes: payload in bytes.
double m_carrierBandwidthInHz
Carrier bandwidth in hertz where scheduler is associated to.
void DoDispose(void)
Do dispose actions.
Ptr< SatBbFrameConf > m_bbFrameConf
Configured BB Frame conf.
bool m_dummyFrameSendingEnabled
Flag indicating if Dummy Frames are sent or not.
Mac48Address m_macAddress
MAC address of the this instance (node)
SatFwdLinkScheduler::SendControlMsgCallback m_sendControlMsgCallback
The control message sender callback.
Time m_periodicInterval
The interval for periodic scheduling timer.
double GetSchedulingObjectCno(Ptr< SatSchedulingObject > ob)
void SortSchedulingObjects(std::vector< Ptr< SatSchedulingObject >> &so)
Sorts given scheduling objects according to configured sorting criteria.
SatFwdLinkScheduler::SchedContextCallback m_schedContextCallback
The scheduling context getter callback.
std::map< uint8_t, Ptr< SatBbFrameContainer > > m_bbFrameContainers
The containers for BBFrames.
uint8_t m_numberOfSlices
The number of slices.
void GetSchedulingObjects(std::vector< Ptr< SatSchedulingObject >> &output)
Gets scheduling object in sorted order according to configured sorting criteria.
static TypeId GetTypeId(void)
Get the type ID.
SatFwdLinkSchedulerTimeSlicing()
Construct a SatFwdLinkScheduler.
virtual std::pair< Ptr< SatBbFrame >, const Time > GetNextFrame()
Get next frame to be transmitted.
virtual void ClearAllPackets()
Remove all packets being treated.
std::map< uint8_t, uint32_t > m_symbolsSent
The number of symbols sent for each slice during an allocation cycle.
uint8_t m_lastSliceDequeued
The last slice from which a BBFrame has been sent.
void SendAndClearSymbolsSentStat()
Send stats and reset all the symbols sent count for each slice to zero.
void SendTimeSliceSubscription(Mac48Address address, std::vector< uint8_t > slices)
uint8_t m_lastSliceAssigned
The slice of the last MAC address discovered.
void DoDispose(void)
Do dispose actions.
uint32_t GetSymbols(uint8_t sliceId, SatEnums::SatModcod_t modcod)
void ScheduleBbFrames()
Schedule BB Frames.
~SatFwdLinkSchedulerTimeSlicing()
Destroy a SatFwdLinkScheduler.
bool CanOpenBbFrame(Mac48Address address, uint32_t priorityClass, SatEnums::SatModcod_t modcod)
TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
void PeriodicTimerExpired()
Handles periodic timer timeouts.
std::map< Mac48Address, uint8_t > m_slicesMapping
The association between a destination MAC address and its slice.
This class implements a tag that carries the satellite MAC specific information, such as source and d...
void SetDestAddress(Mac48Address dest)
Set destination MAC address.
void SetSourceAddress(Mac48Address source)
Set source MAC address.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.