25 NS_LOG_COMPONENT_DEFINE(
"SatFwdLinkSchedulerTimeSlicing");
30 NS_OBJECT_ENSURE_REGISTERED(SatFwdLinkSchedulerTimeSlicing);
36 TypeId(
"ns3::SatFwdLinkSchedulerTimeSlicing")
38 .AddConstructor<SatFwdLinkSchedulerTimeSlicing>()
39 .AddAttribute(
"NumberOfSlices",
40 "Number of slices used.",
43 MakeUintegerChecker<uint8_t>(1, 255));
56 NS_LOG_FUNCTION(
this);
57 NS_FATAL_ERROR(
"Default constructor for SatFwdLinkSchedulerTimeSlicing not supported");
62 double carrierBandwidthInHz)
64 m_lastSliceAssigned(1),
65 m_lastSliceDequeued(1)
67 NS_LOG_FUNCTION(
this);
69 ObjectBase::ConstructSelf(AttributeConstructionList());
71 std::vector<SatEnums::SatModcod_t> modCods = conf->GetModCodsUsed();
82 Ptr<SatBbFrameContainer> container =
95 for (std::map<uint8_t, Ptr<SatBbFrameContainer>>::iterator it =
m_bbFrameContainers.begin();
99 uint32_t maxSymbolPerCycle =
101 uint32_t symbolsMostRobustModcod;
105 symbolsMostRobustModcod = it->second->GetFrameSymbols(
111 symbolsMostRobustModcod = it->second->GetFrameSymbols(
114 if (symbolsMostRobustModcod > maxSymbolPerCycle)
116 NS_FATAL_ERROR(
"Symbol rate of slice " + std::to_string(it->first) +
" (" +
117 std::to_string(it->second->GetMaxSymbolRate()) +
118 " Baud) is too low to allow at least one BBFrame of the most robust "
119 "ModCod. Must be at least " +
120 std::to_string((uint32_t)(symbolsMostRobustModcod /
133 NS_LOG_FUNCTION(
this);
139 NS_LOG_FUNCTION(
this);
144 std::pair<Ptr<SatBbFrame>,
const Time>
147 NS_LOG_FUNCTION(
this);
149 Ptr<SatBbFrame> frame;
158 frame->SetSliceId(0);
159 frameDuration = frame->GetDuration();
182 frameDuration = frame->GetDuration();
186 NS_LOG_WARN(
"Symbol rate not respected for slice " +
189 " while max is " + std::to_string(maxSymbolRate) +
" Baud");
203 frame = Create<SatBbFrame>(
m_bbFrameConf->GetDefaultModCod(),
208 Ptr<Packet> dummyPacket = Create<Packet>(1);
214 dummyPacket->AddPacketTag(mTag);
220 dummyPacket->AddPacketTag(addressE2ETag);
223 frame->AddPayload(dummyPacket);
224 frame->SetSliceId(0);
225 frameDuration = frame->GetDuration();
228 else if (frame == NULL)
233 return std::make_pair(frame, frameDuration);
239 NS_LOG_FUNCTION(
this);
252 NS_LOG_FUNCTION(
this);
254 for (std::map<uint8_t, uint32_t>::iterator it =
m_symbolsSent.begin();
272 NS_LOG_FUNCTION(
this);
275 std::vector<Ptr<SatSchedulingObject>> so;
278 for (std::vector<Ptr<SatSchedulingObject>>::const_iterator it = so.begin();
282 uint32_t currentObBytes = (*it)->GetBufferedBytes();
283 uint32_t currentObMinReqBytes = (*it)->GetMinTxOpportunityInBytes();
284 uint8_t flowId = (*it)->GetFlowId();
285 Mac48Address address = (*it)->GetMacAddress();
288 (address != Mac48Address::GetBroadcast()))
300 Simulator::Schedule(Seconds(0),
305 uint8_t slice = (address == Mac48Address::GetBroadcast()) ? 0 :
m_slicesMapping.at(address);
309 uint32_t frameBytes =
320 if (frameBytes < currentObMinReqBytes)
333 if (frameBytes < currentObMinReqBytes)
335 NS_FATAL_ERROR(
"Control package probably too long!!!");
343 currentObMinReqBytes);
347 if ((flowId == 0) || (address == Mac48Address::GetBroadcast()))
371 NS_FATAL_ERROR(
"Packet does not fit in empty BB Frame. Control package too long or "
372 "fragmentation problem in user package!!!");
383 NS_LOG_FUNCTION(
this);
397 NS_LOG_FUNCTION(
this);
399 Time duration = Time(0);
400 for (std::map<uint8_t, Ptr<SatBbFrameContainer>>::iterator it =
m_bbFrameContainers.begin();
404 duration += it->second->GetTotalDuration();
412 std::vector<uint8_t> slices)
414 NS_LOG_FUNCTION(
this);
416 for (std::vector<uint8_t>::iterator it = slices.begin(); it != slices.end(); ++it)
418 Ptr<SatSliceSubscriptionMessage> sliceSubscription =
419 CreateObject<SatSliceSubscriptionMessage>();
420 sliceSubscription->SetSliceId(*it);
421 sliceSubscription->SetAddress(address);
429 uint32_t priorityClass,
432 NS_LOG_FUNCTION(
this);
434 if (priorityClass == 0)
441 uint8_t sliceId = (address == Mac48Address::GetBroadcast()) ? 0 :
m_slicesMapping.at(address);
448 for (std::map<uint8_t, Ptr<SatBbFrameContainer>>::iterator it =
m_bbFrameContainers.begin();
458 if (symbolRate > maxSymbolRate)
472 return symbolRate < maxSymbolRate;
479 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.
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.