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>
40 NS_LOG_COMPONENT_DEFINE(
"SatFwdLinkScheduler");
45 NS_OBJECT_ENSURE_REGISTERED(SatFwdLinkScheduler);
49 #ifdef SAT_FWD_LINK_SCHEDULER_PRINT_SORT_RESULT
51 PrintSoContent(std::string context, std::vector<Ptr<SatSchedulingObject>>& so)
53 std::cout << context << std::endl;
55 for (std::vector<Ptr<SatSchedulingObject>>::const_iterator it = so.begin(); it != so.end();
58 std::cout <<
"So-Content (ptr, priority, load, hol): " << (*it) <<
", "
59 << (*it)->GetPriority() <<
", " << (*it)->GetBufferedBytes() <<
", "
60 << (*it)->GetHolDelay() << std::endl;
63 std::cout << std::endl;
70 return (
bool)(obj1->GetFlowId() < obj2->GetFlowId());
75 Ptr<SatSchedulingObject> obj2)
79 if (obj1->GetFlowId() == obj2->GetFlowId())
81 result = (bool)(obj1->GetBufferedBytes() > obj2->GetBufferedBytes());
89 Ptr<SatSchedulingObject> obj2)
93 if (obj1->GetFlowId() == obj2->GetFlowId())
95 result = (bool)(obj1->GetHolDelay() > obj2->GetHolDelay());
105 TypeId(
"ns3::SatFwdLinkScheduler")
107 .AddConstructor<SatFwdLinkScheduler>()
108 .AddAttribute(
"Interval",
109 "The time for periodic scheduling",
110 TimeValue(MilliSeconds(20)),
113 .AddAttribute(
"BBFrameConf",
114 "BB Frame configuration for this scheduler.",
117 MakePointerChecker<SatBbFrameConf>())
118 .AddAttribute(
"DummyFrameSendingEnabled",
119 "Flag to tell, if dummy frames are sent or not.",
122 MakeBooleanChecker())
123 .AddAttribute(
"AdditionalSortCriteria",
124 "Sorting criteria after priority for scheduling objects from LLC.",
133 .AddAttribute(
"CnoEstimationMode",
134 "Mode of the C/N0 estimator",
142 "AverageValueInWindow"))
143 .AddAttribute(
"CnoEstimationWindow",
144 "Time window for C/N0 estimation.",
145 TimeValue(Seconds(5000)),
150 "Scheduler symbol rate for a given packet",
152 "ns3::SatTypedefs::FwdLinkSchedulerSymbolRateCallback")
161 NS_LOG_FUNCTION(
this);
169 m_carrierBandwidthInHz(0.0)
171 NS_LOG_FUNCTION(
this);
172 NS_FATAL_ERROR(
"Default constructor for SatFwdLinkScheduler not supported");
176 Mac48Address address,
177 double carrierBandwidthInHz)
178 : m_macAddress(address),
182 m_carrierBandwidthInHz(carrierBandwidthInHz)
184 NS_LOG_FUNCTION(
this);
186 ObjectBase::ConstructSelf(AttributeConstructionList());
189 m_random = CreateObject<UniformRandomVariable>();
194 NS_LOG_FUNCTION(
this);
200 NS_LOG_FUNCTION(
this);
210 NS_LOG_FUNCTION(
this << &cb);
217 NS_LOG_FUNCTION(
this << &cb);
224 NS_LOG_FUNCTION(
this << &cb);
231 NS_LOG_FUNCTION(
this << message << dest);
235 std::pair<Ptr<SatBbFrame>,
const Time>
238 NS_FATAL_ERROR(
"SatFwdLinkScheduler::GetNextFrame: should not be here");
240 Ptr<SatBbFrame> f = NULL;
242 return std::make_pair(f,
m_bbFrameConf->GetDummyBbFrameDuration());
248 NS_LOG_FUNCTION(
this << utAddress << cnoEstimate);
256 std::pair<CnoEstimatorMap_t::const_iterator, bool> result =
260 if (result.second ==
false)
262 NS_FATAL_ERROR(
"Estimator cannot be added to container!!!");
266 it->second->AddSample(cnoEstimate);
272 NS_LOG_FUNCTION(
this);
287 NS_FATAL_ERROR(
"SatFwdLinkScheduler::ScheduleBbFrames: should not be here");
293 NS_FATAL_ERROR(
"SatFwdLinkScheduler::SendAndClearSymbolsSentStat: should not be here");
299 NS_FATAL_ERROR(
"SatFwdLinkScheduler::ScheduleBbFrames: should not be here");
305 NS_FATAL_ERROR(
"SatFwdLinkScheduler::GetSchedulingObjects: should not be here");
311 NS_LOG_FUNCTION(
this);
314 if ((so.empty() ==
false) && (so.size() > 1))
316 #ifdef SAT_FWD_LINK_SCHEDULER_PRINT_SORT_RESULT
317 PrintSoContent(
"Before sort", so);
335 NS_FATAL_ERROR(
"Not supported sorting criteria!!!");
339 #ifdef SAT_FWD_LINK_SCHEDULER_PRINT_SORT_RESULT
340 PrintSoContent(
"After sort", so);
348 NS_LOG_FUNCTION(
this << cno << frame);
354 if (modCod >= frame->GetModcod())
365 NS_LOG_FUNCTION(
this << ob);
373 cno = it->second->GetCnoEstimation();
382 NS_LOG_FUNCTION(
this);
384 Ptr<SatCnoEstimator> estimator = NULL;
395 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.
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.