satellite-beam-scheduler.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Magister Solutions Ltd
4  * Copyright (c) 2018 CNES
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Sami Rantanen <sami.rantanen@magister.fi>
20  * Author: Mathias Ettinger <mettinger@toulouse.viveris.com>
21  */
22 
23 #ifndef SAT_BEAM_SCHEDULER_H
24 #define SAT_BEAM_SCHEDULER_H
25 
27 #include "satellite-enums.h"
29 
30 #include <ns3/callback.h>
31 #include <ns3/nstime.h>
32 #include <ns3/object.h>
33 #include <ns3/ptr.h>
34 #include <ns3/simple-ref-count.h>
35 #include <ns3/traced-callback.h>
36 
37 #include <list>
38 #include <map>
39 #include <vector>
40 
41 namespace ns3
42 {
43 
44 class Address;
45 class Ipv4Address;
46 class SatControlMessage;
47 class SatCrMessage;
48 class SatTbtpMessage;
49 class SatTimuMessage;
50 class SatSuperframeSeq;
51 class SatSuperframeAllocator;
52 class SatLowerLayerServiceConf;
53 class SatDamaEntry;
54 
73 class SatBeamScheduler : public Object
74 {
75  public:
80  typedef enum
81  {
85 
90  static TypeId GetTypeId(void);
91 
99 
106 
112  typedef Callback<bool, Ptr<SatControlMessage>, const Address&> SendCtrlMsgCallback;
113 
117  typedef Callback<void, Ptr<SatTbtpMessage>> SendTbtpCallback;
118 
123  typedef Callback<void, uint32_t, Ptr<SatTbtpMessage>> TbtpAddCallback;
124 
133  void Initialize(uint32_t beamId,
135  Ptr<SatSuperframeSeq> seq,
136  uint32_t maxFrameSizeInBytes,
137  Address gwAddress);
138 
146  uint32_t AddUt(Address utId, Ptr<SatLowerLayerServiceConf> llsConf);
147 
154  bool HasUt(Address utId);
155 
162  void UpdateUtCno(Address utId, double cno);
163 
170  void UpdateSatelliteCno(Address satelliteMac, double cno);
171 
178  void UtCrReceived(Address utId, Ptr<SatCrMessage> crMsg);
179 
186  bool Send(Ptr<SatControlMessage> message);
187 
195  bool SendTo(Ptr<SatControlMessage> message, Address utId);
196 
204  bool SendToSatellite(Ptr<SatControlMessage> msg, Address satelliteMac);
205 
210 
221  typedef void (*BacklogRequestsTraceCallback)(std::string trace);
222 
228  typedef void (*WaveformTraceCallback)(uint32_t waveformId);
229 
235  typedef void (*UsableCapacityTraceCallback)(uint32_t usableCapacity);
236 
243  typedef void (*UnmetCapacityTraceCallback)(uint32_t unmetCapacity);
244 
251  typedef void (*ExceedingCapacityTraceCallback)(uint32_t exceedingCapacity);
252 
257  Ptr<SatTimuMessage> CreateTimu() const;
258 
264  void TransferUtToBeam(Address utId, Ptr<SatBeamScheduler> destination);
265 
270  void RemoveUt(Address utId);
271 
272  void ReserveLogonChannel(uint32_t logonChannelId);
273 
277  inline Address GetGwAddress(void) const
278  {
279  return m_gwAddress;
280  }
281 
282  private:
288  class SatUtInfo : public SimpleRefCount<SatUtInfo>
289  {
290  public:
300  SatUtInfo(Ptr<SatDamaEntry> damaEntry,
301  Ptr<SatCnoEstimator> cnoEstimator,
302  Time controlSlotOffset,
303  bool controlSlotsEnabled);
304 
310  Ptr<SatDamaEntry> GetDamaEntry();
311 
315  void UpdateDamaEntryFromCrs();
316 
322  void AddCnoSample(double sample);
323 
329  double GetCnoEstimation();
330 
337  void AddCrMsg(Ptr<SatCrMessage> crMsg);
338 
343  void ClearCrMsgs();
344 
350  bool IsControlSlotGenerationTime() const;
351 
357  void SetControlSlotGenerationTime(Time offset);
358 
359  private:
363  typedef std::vector<Ptr<SatCrMessage>> CrMsgContainer_t;
364 
368  Ptr<SatDamaEntry> m_damaEntry;
369 
373  Ptr<SatCnoEstimator> m_cnoEstimator;
374 
379 
384 
389  };
390 
394  typedef std::pair<Address, SatFrameAllocator::SatFrameAllocReq> UtReqInfoItem_t;
395 
399  typedef std::map<Address, Ptr<SatUtInfo>> UtInfoMap_t;
400 
404  typedef std::list<UtReqInfoItem_t> UtReqInfoContainer_t;
405 
410  {
411  public:
417  CnoCompare(const UtInfoMap_t& utInfoMap)
418  : m_utInfoMap(utInfoMap)
419  {
420  }
421 
429  bool operator()(UtReqInfoItem_t utReqInfo1, UtReqInfoItem_t utReqInfo2)
430  {
431  double result = false;
432 
433  double cnoFirst = m_utInfoMap.at(utReqInfo1.first)->GetCnoEstimation();
434  double cnoSecond = m_utInfoMap.at(utReqInfo2.first)->GetCnoEstimation();
435 
436  if (!std::isnan(cnoFirst))
437  {
438  if (std::isnan(cnoSecond))
439  {
440  result = false;
441  }
442  else
443  {
444  result = (cnoFirst < cnoSecond);
445  }
446  }
447 
448  return result;
449  }
450 
451  private:
456  };
457 
461  uint32_t m_beamId;
462 
466  Ptr<SatSuperframeSeq> m_superframeSeq;
467 
472 
477 
482 
487 
492 
496  Ptr<RandomVariableStream> m_raChRandomIndex;
497 
502 
507 
512 
516  Ptr<SatSuperframeAllocator> m_superframeAllocator;
517 
524 
531 
536 
541 
546 
550  TracedCallback<std::string> m_backlogRequestsTrace;
551 
555  TracedCallback<uint32_t> m_waveformTrace;
556 
560  TracedCallback<uint32_t, uint32_t> m_frameUtLoadTrace;
561 
565  TracedCallback<uint32_t, double> m_frameLoadTrace;
566 
570  TracedCallback<uint32_t> m_usableCapacityTrace;
571 
575  TracedCallback<uint32_t> m_unmetCapacityTrace;
576 
580  TracedCallback<uint32_t> m_exceedingCapacityTrace;
581 
585  void DoDispose(void);
586 
590  void Schedule();
591 
595  uint32_t UpdateDamaEntriesWithReqs();
596 
604 
609 
614  void AddRaChannels(std::vector<Ptr<SatTbtpMessage>>& tbtpContainer);
615 
616  void AddUtInfo(Address utId, Ptr<SatUtInfo> utInfo);
617  void RemoveUtInfo(UtInfoMap_t::iterator iterator);
618 
623  Ptr<SatCnoEstimator> CreateCnoEstimator();
624 
628  void SendCnoToSatellite();
629 
630  Address m_gwAddress;
631 
633 
638 
642  Ptr<SatCnoEstimator> m_satelliteCnoEstimator;
643 
647  Address m_satelliteMac;
648 
653 };
654 
655 } // namespace ns3
656 
657 #endif /* SAT_BEAM_SCHEDULER_H */
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.
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.
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.
HandoverInformationForward_t
Strategies to exchange informations between beams.
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.
TracedCallback< uint32_t, uint32_t > m_frameUtLoadTrace
Trace count of UTs scheduled per Frame.
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).
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.
bool HasUt(Address utId)
Check whether an UT is handled by this scheduler.
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.
void Initialize(uint32_t beamId, SatBeamScheduler::SendCtrlMsgCallback cb, Ptr< SatSuperframeSeq > seq, uint32_t maxFrameSizeInBytes, Address gwAddress)
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.
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.
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.
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.
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.
std::map< Address, UtAllocInfoItem_t > UtAllocInfoContainer_t
Map container to store UT allocation information.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.