23 #ifndef SAT_BEAM_SCHEDULER_H
24 #define SAT_BEAM_SCHEDULER_H
33 #include <ns3/callback.h>
34 #include <ns3/nstime.h>
35 #include <ns3/object.h>
37 #include <ns3/simple-ref-count.h>
38 #include <ns3/traced-callback.h>
53 class SatControlMessage;
57 class SatSuperframeSeq;
58 class SatSuperframeAllocator;
59 class SatLowerLayerServiceConf;
146 Ptr<SatNetDevice> gwNetDevice,
147 Ptr<SatOrbiterNetDevice> orbiterNetDevice,
149 Ptr<SatSuperframeSeq> seq,
150 uint32_t maxFrameSizeInBytes,
161 uint32_t
AddUt(Address utId, Ptr<SatLowerLayerServiceConf> llsConf);
169 bool HasUt(Address utId);
200 void UtCrReceived(Address utId, Ptr<SatCrMessage> crMsg);
208 bool Send(Ptr<SatControlMessage> message);
217 bool SendTo(Ptr<SatControlMessage> message, Address utId);
226 bool SendToSatellite(Ptr<SatControlMessage> msg, Address satelliteMac);
365 Ptr<SatCnoEstimator> cnoEstimator,
366 Time controlSlotOffset,
367 bool controlSlotsEnabled);
401 void AddCrMsg(Ptr<SatCrMessage> crMsg);
495 double result =
false;
497 double cnoFirst =
m_utInfoMap.at(utReqInfo1.first)->GetCnoEstimation();
498 double cnoSecond =
m_utInfoMap.at(utReqInfo2.first)->GetCnoEstimation();
500 if (!std::isnan(cnoFirst))
502 if (std::isnan(cnoSecond))
508 result = (cnoFirst < cnoSecond);
693 void AddRaChannels(std::vector<Ptr<SatTbtpMessage>>& tbtpContainer);
695 void AddUtInfo(Address utId, Ptr<SatUtInfo> utInfo);
CnoCompare class to sort UT request according to C/N0 information.
bool operator()(UtReqInfoItem_t utReqInfo1, UtReqInfoItem_t utReqInfo2)
Compare operator to compare request information of the two UTs.
CnoCompare(const UtInfoMap_t &utInfoMap)
Construct CnoCompare object.
const UtInfoMap_t & m_utInfoMap
Reference to map container for the UT information.
UT information helper class for SatBeamScheduler.
void ClearCrMsgs()
Remove all CR messages from UT info to reset capacity requests in case of handover.
void UpdateDamaEntryFromCrs()
Update DamaEntry with information of the received CR messages.
void AddCrMsg(Ptr< SatCrMessage > crMsg)
Add CR message to UT info to be used when capacity request is calculated next time (method UpdateDama...
double GetCnoEstimation()
Get estimated C/N0 value based on added samples.
Ptr< SatDamaEntry > GetDamaEntry()
Get damaEntry of the UT info.
bool IsControlSlotGenerationTime() const
Check if time is expired to send control slot.
Ptr< SatDamaEntry > m_damaEntry
DamaEntry of this UT info.
SatUtInfo(Ptr< SatDamaEntry > damaEntry, Ptr< SatCnoEstimator > cnoEstimator, Time controlSlotOffset, bool controlSlotsEnabled)
Construct SatUtInfo.
Ptr< SatCnoEstimator > m_cnoEstimator
Estimator for the C/N0.
void SetControlSlotGenerationTime(Time offset)
Set time for next time slot generation for this UT.
CrMsgContainer_t m_crContainer
Received CRs since last update round (call of the method UpdateDamaEntryFromCrs).
Time m_controlSlotGenerationTime
Time to send next control time slot.
bool m_controlSlotsEnabled
Flag to indicated if control time slots generation is enabled.
std::vector< Ptr< SatCrMessage > > CrMsgContainer_t
Container to store received CR messages.
void AddCnoSample(double sample)
Add C/N0 sample to UT info's estimator.
class for module Beam Scheduler.
bool SendToSatellite(Ptr< SatControlMessage > msg, Address satelliteMac)
Send control message to the satellite.
void DisconnectGw(Mac48Address address)
Disconnect a new GW address from this scheduler.
HandoverInformationForward_t m_handoverStrategy
void UtCrReceived(Address utId, Ptr< SatCrMessage > crMsg)
Receive capacity requests from UTs.
uint32_t UpdateDamaEntriesWithAllocs(SatFrameAllocator::UtAllocInfoContainer_t &utAllocContainer)
Update dama entries with given allocations at end of the scheduling.
uint32_t m_maxBbFrameSize
Maximum size of the BB frame.
Callback< void, uint32_t, Ptr< SatTbtpMessage > > TbtpAddCallback
Ptr< SatCnoEstimator > m_satelliteCnoEstimator
Estimator for the C/N0 from satellite.
void DisconnectUt(Mac48Address address)
Disconnect a new UT address from this scheduler.
Time m_cnoEstimationWindow
Time window for C/N0 estimation.
bool m_receivedSatelliteCnoSample
Indicates if Cno sample have been received since last C/N0 control message sent.
Callback< bool, Ptr< SatControlMessage >, const Address & > SendCtrlMsgCallback
SatBeamScheduler::SendTbtpCallback m_txTbtpCallback
The TBTP send callback to inform GW Mac.
void AddRaChannels(std::vector< Ptr< SatTbtpMessage >> &tbtpContainer)
Add RA channel information to TBTP(s).
void DoPreResourceAllocation()
Do pre-allocation of the symbols per UT/RC, before time slot generation.
Time m_maxTwoWayPropagationDelay
Maximum two-way propagation delay estimate between GW-SAT-UT-SAT-GW.
void RemoveUtInfo(UtInfoMap_t::iterator iterator)
TracedCallback< uint32_t > m_exceedingCapacityTrace
Trace exceeding capacity.
Callback< void, Ptr< SatTbtpMessage > > SendTbtpCallback
void(* UnmetCapacityTraceCallback)(uint32_t unmetCapacity)
Callback signature for the UnmetCapacityTrace trace source.
void AddUtInfo(Address utId, Ptr< SatUtInfo > utInfo)
TracedCallback< uint32_t > m_usableCapacityTrace
Trace usable capacity.
TracedCallback< uint32_t, double > m_frameLoadTrace
Trace frame load ratio.
void DoDispose(void)
Dispose actions for SatBeamScheduler.
Address GetGwAddress(void) const
Return the address of the gateway responsible of this beam.
SatBeamScheduler::SendCtrlMsgCallback m_txCallback
The control message send callback.
uint32_t m_logonChannelIndex
Logon channel ID to exclude it from the RA channel selection.
SatEnums::SuperframeAllocatorType_t m_superframeAllocatorType
Type of SatSuperframeAllocator class to use.
void ConnectUt(Mac48Address address)
Connect a new UT address to this scheduler.
HandoverInformationForward_t
Strategies to exchange informations between beams.
void ConnectGw(Mac48Address address)
Connect a new GW address to this scheduler.
void SetSendTbtpCallback(SendTbtpCallback cb)
Set the callback to inform NCC a TBTP has been sent.
Time m_controlSlotInterval
Interval to generate control time slots.
bool Send(Ptr< SatControlMessage > message)
Send control messages to the beam.
bool SendTo(Ptr< SatControlMessage > message, Address utId)
Send control message to an UT into the beam.
std::map< Address, Ptr< SatUtInfo > > UtInfoMap_t
Map container to store UT information.
Ptr< SatSuperframeSeq > m_superframeSeq
Pointer to super frame sequence.
Ptr< SatCnoEstimator > CreateCnoEstimator()
Create estimator for the UT according to set attributes.
Ptr< SatSuperframeAllocator > m_superframeAllocator
Superframe allocator to maintain load information of the frames and their configurations.
TracedCallback< std::string > m_backlogRequestsTrace
Trace for backlog requests done to beam scheduler.
void Initialize(uint32_t satId, uint32_t beamId, Ptr< SatNetDevice > gwNetDevice, Ptr< SatOrbiterNetDevice > orbiterNetDevice, SatBeamScheduler::SendCtrlMsgCallback cb, Ptr< SatSuperframeSeq > seq, uint32_t maxFrameSizeInBytes, Address satAddress, Address gwAddress)
TracedCallback< uint32_t, uint32_t > m_frameUtLoadTrace
Trace count of UTs scheduled per Frame.
bool HasUt()
Check whether an UT is handled by this scheduler.
Ptr< SatOrbiterNetDevice > m_orbiterNetDevice
OrbiterNetDevice on satellite linked to this beam.
TracedCallback< uint32_t > m_waveformTrace
Trace first wave form scheduled for the UT.
Ptr< RandomVariableStream > m_raChRandomIndex
Random variable stream to select RA channel for a UT.
void(* ExceedingCapacityTraceCallback)(uint32_t exceedingCapacity)
Callback signature for the ExceedingCapacityTrace trace source.
void(* BacklogRequestsTraceCallback)(std::string trace)
Callback signature for BacklogRequestsTrace trace source.
static TypeId GetTypeId(void)
Get the type ID.
Time m_maxTbtpTxAndProcessingDelay
Maximum TBTP tx and processing delay estimate at the GW (scheduler).
uint32_t m_satId
ID of the satellite using this beam.
void SendCnoToSatellite()
Send an estimation of cno to satellite, if samples have been received.
void TransferUtToBeam(Address utId, Ptr< SatBeamScheduler > destination)
Transfer ownership of a terminal to the given SatBeamScheduler.
void ReserveLogonChannel(uint32_t logonChannelId)
std::list< UtReqInfoItem_t > UtReqInfoContainer_t
Container to store capacity request information for the UTs.
~SatBeamScheduler()
Destroy a SatBeamScheduler.
uint32_t m_superFrameCounter
Counter for super frame sequence.
Ptr< SatTimuMessage > CreateTimu() const
Create a TIM unicast message containing enough data for a terminal to connect to the beam handled by ...
void RemoveUt(Address utId)
Remove a UT from its SatBeamScheduler.
UtReqInfoContainer_t m_utRequestInfos
Container including every UT's allocation requests.
Address m_satelliteMac
MAC address of the satellite (used when regenerative)
SatCnoEstimator::EstimationMode_t m_cnoEstimatorMode
Mode used for C/N0 estimator.
std::pair< Address, SatFrameAllocator::SatFrameAllocReq > UtReqInfoItem_t
Pair to store capacity request information for the UT.
void Schedule()
Schedule UTs added (registered) to scheduler.
void SetUseLora(bool useLora)
Set if SNS-3 is used with Lora standard.
bool m_controlSlotsEnabled
Flag to indicated if control time slots generation is enabled.
void(* UsableCapacityTraceCallback)(uint32_t usableCapacity)
Callback signature for the UsableCapacityTrace trace source.
uint32_t m_beamId
ID of the beam.
Address GetSatAddress(void) const
Return the address of the satellite responsible of this beam.
uint32_t UpdateDamaEntriesWithReqs()
Update dama entries with received requests at beginning of the scheduling.
void UpdateUtCno(Address utId, double cno)
Update UT C/N0 info with the latest value.
void(* WaveformTraceCallback)(uint32_t waveformId)
Callback signature for WaveformTrace trace source.
bool m_useLora
Flag indicating if lora standard is used.
SatBeamScheduler()
Construct a SatBeamScheduler.
uint32_t AddUt(Address utId, Ptr< SatLowerLayerServiceConf > llsConf)
Add UT to scheduler.
UtInfoMap_t m_utInfos
Map to store UT information in beam for updating purposes.
Ptr< SatGwMac > m_gwMac
GW MAC linked to this beam.
void UpdateSatelliteCno(Address satelliteMac, double cno)
Update satellite C/N0 info with the latest value.
TracedCallback< uint32_t > m_unmetCapacityTrace
Trace unmet capacity.
EstimationMode_t
Definition of modes for estimator.
SuperframeAllocatorType_t
std::map< Address, UtAllocInfoItem_t > UtAllocInfoContainer_t
Map container to store UT allocation information.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.