27 #include <ns3/boolean.h>
28 #include <ns3/double.h>
31 #include <ns3/mac48-address.h>
32 #include <ns3/nstime.h>
33 #include <ns3/pointer.h>
34 #include <ns3/simulator.h>
35 #include <ns3/trace-source-accessor.h>
36 #include <ns3/uinteger.h>
45 NS_LOG_COMPONENT_DEFINE(
"SatFwdLinkScheduler");
50 NS_OBJECT_ENSURE_REGISTERED(SatFwdLinkScheduler);
54 #ifdef SAT_FWD_LINK_SCHEDULER_PRINT_SORT_RESULT
56 PrintSoContent(std::string context, std::vector<Ptr<SatSchedulingObject>>& so)
58 std::cout << context << std::endl;
60 for (std::vector<Ptr<SatSchedulingObject>>::const_iterator it = so.begin(); it != so.end();
63 std::cout <<
"So-Content (ptr, priority, load, hol): " << (*it) <<
", "
64 << (*it)->GetPriority() <<
", " << (*it)->GetBufferedBytes() <<
", "
65 << (*it)->GetHolDelay() << std::endl;
68 std::cout << std::endl;
75 return (
bool)(obj1->GetFlowId() < obj2->GetFlowId());
80 Ptr<SatSchedulingObject> obj2)
84 if (obj1->GetFlowId() == obj2->GetFlowId())
86 result = (bool)(obj1->GetBufferedBytes() > obj2->GetBufferedBytes());
94 Ptr<SatSchedulingObject> obj2)
98 if (obj1->GetFlowId() == obj2->GetFlowId())
100 result = (bool)(obj1->GetHolDelay() > obj2->GetHolDelay());
110 TypeId(
"ns3::SatFwdLinkScheduler")
112 .AddConstructor<SatFwdLinkScheduler>()
113 .AddAttribute(
"Interval",
114 "The time for periodic scheduling",
115 TimeValue(MilliSeconds(20)),
118 .AddAttribute(
"BBFrameConf",
119 "BB Frame configuration for this scheduler.",
122 MakePointerChecker<SatBbFrameConf>())
123 .AddAttribute(
"DummyFrameSendingEnabled",
124 "Flag to tell, if dummy frames are sent or not.",
127 MakeBooleanChecker())
128 .AddAttribute(
"AdditionalSortCriteria",
129 "Sorting criteria after priority for scheduling objects from LLC.",
131 MakeEnumAccessor<SatFwdLinkScheduler::ScheduleSortingCriteria_t>(
139 .AddAttribute(
"CnoEstimationMode",
140 "Mode of the C/N0 estimator",
142 MakeEnumAccessor<SatCnoEstimator::EstimationMode_t>(
149 "AverageValueInWindow"))
150 .AddAttribute(
"CnoEstimationWindow",
151 "Time window for C/N0 estimation.",
152 TimeValue(Seconds(5000)),
157 "Scheduler symbol rate for a given packet",
159 "ns3::SatTypedefs::FwdLinkSchedulerSymbolRateCallback")
168 NS_LOG_FUNCTION(
this);
176 m_carrierBandwidthInHz(0.0)
178 NS_LOG_FUNCTION(
this);
179 NS_FATAL_ERROR(
"Default constructor for SatFwdLinkScheduler not supported");
183 Mac48Address address,
184 double carrierBandwidthInHz)
185 : m_macAddress(address),
189 m_carrierBandwidthInHz(carrierBandwidthInHz)
191 NS_LOG_FUNCTION(
this);
193 ObjectBase::ConstructSelf(AttributeConstructionList());
196 m_random = CreateObject<UniformRandomVariable>();
201 NS_LOG_FUNCTION(
this);
207 NS_LOG_FUNCTION(
this);
217 NS_LOG_FUNCTION(
this << &cb);
224 NS_LOG_FUNCTION(
this << &cb);
231 NS_LOG_FUNCTION(
this << &cb);
238 NS_LOG_FUNCTION(
this << message << dest);
242 std::pair<Ptr<SatBbFrame>,
const Time>
245 NS_FATAL_ERROR(
"SatFwdLinkScheduler::GetNextFrame: should not be here");
247 Ptr<SatBbFrame> f =
nullptr;
249 return std::make_pair(f,
m_bbFrameConf->GetDummyBbFrameDuration());
255 NS_LOG_FUNCTION(
this << utAddress << cnoEstimate);
263 std::pair<CnoEstimatorMap_t::const_iterator, bool> result =
267 if (result.second ==
false)
269 NS_FATAL_ERROR(
"Estimator cannot be added to container!!!");
273 it->second->AddSample(cnoEstimate);
279 NS_LOG_FUNCTION(
this);
294 NS_LOG_FUNCTION(
this);
296 NS_FATAL_ERROR(
"Must use subclasses");
302 NS_FATAL_ERROR(
"SatFwdLinkScheduler::ScheduleBbFrames: should not be here");
308 NS_FATAL_ERROR(
"SatFwdLinkScheduler::SendAndClearSymbolsSentStat: should not be here");
314 NS_FATAL_ERROR(
"SatFwdLinkScheduler::ScheduleBbFrames: should not be here");
320 NS_FATAL_ERROR(
"SatFwdLinkScheduler::GetSchedulingObjects: should not be here");
326 NS_LOG_FUNCTION(
this);
329 if ((so.empty() ==
false) && (so.size() > 1))
331 #ifdef SAT_FWD_LINK_SCHEDULER_PRINT_SORT_RESULT
332 PrintSoContent(
"Before sort", so);
350 NS_FATAL_ERROR(
"Not supported sorting criteria!!!");
354 #ifdef SAT_FWD_LINK_SCHEDULER_PRINT_SORT_RESULT
355 PrintSoContent(
"After sort", so);
363 NS_LOG_FUNCTION(
this << cno << frame);
369 if (modCod >= frame->GetModcod())
380 NS_LOG_FUNCTION(
this << ob);
388 cno = it->second->GetCnoEstimation();
397 NS_LOG_FUNCTION(
this);
399 Ptr<SatCnoEstimator> estimator =
nullptr;
410 NS_FATAL_ERROR(
"Not supported C/N0 estimation mode!!!");
SatCnoEstimator class defines interface for C/N0 estimators.
@ MINIMUM
Minimum value in the given window returned.
@ LAST
Last value in the given window returned.
@ AVERAGE
Average value in the given window returned.
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.
static bool CompareSoPriorityLoad(Ptr< SatSchedulingObject > obj1, Ptr< SatSchedulingObject > obj2)
Compares to scheduling objects priorities and load.
SatCnoEstimator::EstimationMode_t m_cnoEstimatorMode
Mode used for C/N0 estimator.
SatFwdLinkScheduler::TxOpportunityCallback m_txOpportunityCallback
Callback to notify the txOpportunity to upper layer Returns a packet Attributes: payload in bytes.
Time m_cnoEstimationWindow
Time window for C/N0 estimation.
void SetDummyFrameSendingEnabled(bool dummyFrameSendingEnabled)
Set the value of m_dummyFrameSendingEnabled.
CnoEstimatorMap_t m_cnoEstimatorContainer
C/N0 estimator per UT.
ScheduleSortingCriteria_t m_additionalSortCriteria
Additional sorting criteria for scheduling objects received from LLC.
void DoDispose(void)
Do dispose actions.
virtual void ClearAllPackets()
Remove all packets being treated.
static TypeId GetTypeId(void)
Get the type ID.
void PeriodicTimerExpired()
Handles periodic timer timeouts.
Ptr< SatBbFrameConf > m_bbFrameConf
Configured BB Frame conf.
virtual void SendAndClearSymbolsSentStat()
Send stats and reset all the symbols sent count for each slice to zero.
void SetSchedContextCallback(SatFwdLinkScheduler::SchedContextCallback cb)
Method to set Tx opportunity callback.
void CnoInfoUpdated(Mac48Address utAddress, double cnoEstimate)
Called when UT's C/N0 estimation is updated.
Callback< void, std::vector< Ptr< SatSchedulingObject > > & > SchedContextCallback
Callback to get scheduling contexts from upper layer.
bool m_dummyFrameSendingEnabled
Flag indicating if Dummy Frames are sent or not.
Callback< Ptr< Packet >, uint32_t, Mac48Address, uint8_t, uint32_t &, uint32_t & > TxOpportunityCallback
Callback to notify upper layer about Tx opportunity.
SatFwdLinkScheduler()
Construct a SatFwdLinkScheduler.
SatFwdLinkScheduler::SendControlMsgCallback m_sendControlMsgCallback
The control message sender callback.
Time GetDefaultFrameDuration() const
Return the BB frame duration of the default frame format, i.e.
Ptr< SatCnoEstimator > CreateCnoEstimator()
Create estimator for the UT according to set attributes.
void ScheduleBbFrames()
Schedule BB Frames.
Ptr< UniformRandomVariable > m_random
Random variable used in FWD link scheduling.
Time m_periodicInterval
The interval for periodic scheduling timer.
void SetSendControlMsgCallback(SatFwdLinkScheduler::SendControlMsgCallback cb)
Method to set the control message sender callback.
double GetSchedulingObjectCno(Ptr< SatSchedulingObject > ob)
virtual std::pair< Ptr< SatBbFrame >, const Time > GetNextFrame()
Get next frame to be transmitted.
void SortSchedulingObjects(std::vector< Ptr< SatSchedulingObject >> &so)
Sorts given scheduling objects according to configured sorting criteria.
bool CnoMatchWithFrame(double cno, Ptr< SatBbFrame > frame) const
Check if given estimated C/N0 match with given frame.
SatFwdLinkScheduler::SchedContextCallback m_schedContextCallback
The scheduling context getter callback.
static bool CompareSoPriorityHol(Ptr< SatSchedulingObject > obj1, Ptr< SatSchedulingObject > obj2)
Compares to scheduling objects priorities and HOL.
@ BUFFERING_DELAY_SORT
BUFFERING_DELAY_SORT.
@ BUFFERING_LOAD_SORT
BUFFERING_LOAD_SORT.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
bool SendControlMsg(Ptr< SatControlMessage > message, const Address &dest) const
Method te send a control message to a destination.
void GetSchedulingObjects(std::vector< Ptr< SatSchedulingObject >> &output)
Gets scheduling object in sorted order according to configured sorting criteria.
~SatFwdLinkScheduler()
Destroy a SatFwdLinkScheduler.
static bool CompareSoFlowId(Ptr< SatSchedulingObject > obj1, Ptr< SatSchedulingObject > obj2)
Compares to scheduling objects priorities.
void SetTxOpportunityCallback(SatFwdLinkScheduler::TxOpportunityCallback cb)
Method to set Tx opportunity callback.
Callback< bool, Ptr< SatControlMessage >, const Address & > SendControlMsgCallback
Callback to notify upper layer about Tx opportunity.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.