satellite-random-access-container.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: Frans Laakso <frans.laakso@magister.fi>
20  * Author: Mathias Ettinger <mettinger@toulouse.viveris.fr>
21  */
22 
23 #ifndef SATELLITE_RANDOM_ACCESS_H
24 #define SATELLITE_RANDOM_ACCESS_H
25 
26 #include "satellite-enums.h"
28 
29 #include <ns3/object.h>
30 #include <ns3/random-variable-stream.h>
31 #include <ns3/simulator.h>
32 #include <ns3/uinteger.h>
33 
34 #include <set>
35 
36 namespace ns3
37 {
38 
48 class SatRandomAccess : public Object
49 {
50  public:
55  typedef Callback<bool> IsDamaAvailableCallback;
56 
61  typedef Callback<bool> AreBuffersEmptyCallback;
62 
68  typedef struct
69  {
72  std::map<uint32_t, std::set<uint32_t>> crdsaTxOpportunities;
75 
80 
84  SatRandomAccess(Ptr<SatRandomAccessConf> randomAccessConf,
85  SatEnums::RandomAccessModel_t randomAccessModel);
86 
90  virtual ~SatRandomAccess();
91 
96  static TypeId GetTypeId(void);
97 
102  void SetRandomAccessModel(SatEnums::RandomAccessModel_t randomAccessModel);
103 
109  void SetCrdsaBackoffTimeInMilliSeconds(uint32_t allocationChannel,
110  uint32_t backoffTimeInMilliSeconds);
111 
117  void SetCrdsaBackoffProbability(uint32_t allocationChannel, uint16_t backoffProbability);
118 
126  void SetCrdsaRandomizationParameters(uint32_t allocationChannel,
127  uint32_t minRandomizationValue,
128  uint32_t maxRandomizationValue,
129  uint32_t numOfInstances);
130 
138  void SetCrdsaMaximumDataRateLimitationParameters(uint32_t allocationChannel,
139  uint32_t maxUniquePayloadPerBlock,
140  uint32_t maxConsecutiveBlocksAccessed,
141  uint32_t minIdleBlocks);
142 
148  void SetFSimBackoffTimeInFrames(uint32_t allocationChannel, uint32_t backoffTimeInFrames);
149 
155  void SetFSimBackoffProbability(uint32_t allocationChannel, uint16_t backoffPersistence);
156 
162  void SetBackoffTime(uint32_t allocationChannel, uint32_t backoffTime);
163 
169  void SetBackoffProbability(uint32_t allocationChannel, uint16_t backoffProbability);
170 
177  uint32_t controlRandomizationIntervalInMilliSeconds);
178 
187  uint32_t allocationChannel,
189 
195 
201 
207 
213 
219  bool CrdsaHasBackoffTimePassed(uint32_t allocationChannel) const;
220 
221  protected:
225  void DoDispose();
226 
227  private:
231  void PrintVariables();
232 
238  uint32_t GetConfigurationIdForAllocationChannel(uint32_t allocationChannelId);
239 
245  SatRandomAccess::RandomAccessTxOpportunities_s DoEssa(uint32_t allocationChannel);
246 
252 
260 
265 
271  SatRandomAccess::RandomAccessTxOpportunities_s DoCrdsa(uint32_t allocationChannel);
272 
278  bool CrdsaDoBackoff(uint32_t allocationChannel);
279 
286  std::pair<std::set<uint32_t>, std::set<uint32_t>> CrdsaRandomizeTxOpportunities(
287  uint32_t allocationChannel,
288  std::pair<std::set<uint32_t>, std::set<uint32_t>> slots);
289 
297  uint32_t allocationChannel);
298 
303  void CrdsaSetBackoffTimer(uint32_t allocationChannel);
304 
310  void CrdsaIncreaseConsecutiveBlocksUsed(uint32_t allocationChannel);
311 
317 
322  void CrdsaReduceIdleBlocks(uint32_t allocationChannel);
323 
328 
334 
339  void CrdsaResetConsecutiveBlocksUsed(uint32_t allocationChannel);
340 
346  bool CrdsaIsAllocationChannelFree(uint32_t allocationChannel);
347 
353  bool IsCrdsaAllocationChannel(uint32_t allocationChannel);
354 
360  bool IsSlottedAlohaAllocationChannel(uint32_t allocationChannel);
361 
367  bool IsEssaAllocationChannel(uint32_t allocationChannel);
368 
372  Ptr<UniformRandomVariable> m_uniformRandomVariable;
373 
378 
382  Ptr<SatRandomAccessConf> m_randomAccessConf;
383 
388 
394 
399 
404 };
405 
406 } // namespace ns3
407 
408 #endif /* SATELLITE_RANDOM_ACCESS_H */
RandomAccessTxOpportunityType_t
Random access Tx opportunity types.
RandomAccessModel_t
The defined random access models.
RandomAccessTriggerType_t
The defined random access trigger types.
Class for random access algorithms.
SatEnums::RandomAccessModel_t m_randomAccessModel
The used random access model.
void CrdsaResetConsecutiveBlocksUsedForAllAllocationChannels()
Function for resetting the number of consecutive blocks to zero for all allocation channels.
bool IsEssaAllocationChannel(uint32_t allocationChannel)
Function for checking if the allocation channel is ESSA allocation channel.
void PrintVariables()
Function for printing out various module variables to console.
void SetCrdsaMaximumDataRateLimitationParameters(uint32_t allocationChannel, uint32_t maxUniquePayloadPerBlock, uint32_t maxConsecutiveBlocksAccessed, uint32_t minIdleBlocks)
Function for setting the maximum rate limitation parameters.
SatRandomAccess::RandomAccessTxOpportunities_s DoEssa(uint32_t allocationChannel)
Main function for ESSA.
void SetCrdsaBackoffTimeInMilliSeconds(uint32_t allocationChannel, uint32_t backoffTimeInMilliSeconds)
Function for setting the backoff time in milliseconds.
IsDamaAvailableCallback m_isDamaAvailableCb
Callback for known DAMA status.
std::pair< std::set< uint32_t >, std::set< uint32_t > > CrdsaRandomizeTxOpportunities(uint32_t allocationChannel, std::pair< std::set< uint32_t >, std::set< uint32_t >> slots)
Function for randomizing the CRDSA Tx opportunities (slots) for each unique packet.
bool IsSlottedAlohaAllocationChannel(uint32_t allocationChannel)
Function for checking if the allocation channel is Slotted ALOHA allocation channel.
SatRandomAccess::RandomAccessTxOpportunities_s DoRandomAccess(uint32_t allocationChannel, SatEnums::RandomAccessTriggerType_t triggerType)
Main function of this module.
uint32_t m_numOfAllocationChannels
Number of allocation channels available.
void SlottedAlohaDoVariableSanityCheck()
Function for checking the sanity of Slotted ALOHA related variables.
void CrdsaIncreaseConsecutiveBlocksUsed(uint32_t allocationChannel)
Function for increasing the allocation channel specific count of consecutive used blocks.
uint32_t GetConfigurationIdForAllocationChannel(uint32_t allocationChannelId)
Function to convert a carrier allocation channel ID into its allocation channel configuration ID.
void CrdsaResetConsecutiveBlocksUsed(uint32_t allocationChannel)
Function for resetting the number of consecutive blocks to zero for a specific allocation channel.
SatRandomAccess::RandomAccessTxOpportunities_s CrdsaPrepareToTransmit(uint32_t allocationChannel)
Function for evaluating backoff for each unique CRDSA packet and calling the randomization of Tx oppo...
bool CrdsaIsAllocationChannelFree(uint32_t allocationChannel)
Function for checking if the allocation channel is free.
void CrdsaIncreaseConsecutiveBlocksUsedForAllAllocationChannels()
Function for increasing the count of consecutive used blocks for all allocation channels.
void SetSlottedAlohaControlRandomizationIntervalInMilliSeconds(uint32_t controlRandomizationIntervalInMilliSeconds)
Function for setting the Slotted ALOHA control randomization interval.
AreBuffersEmptyCallback m_areBuffersEmptyCb
Callback for buffer status.
static TypeId GetTypeId(void)
NS-3 type id function.
Callback< bool > AreBuffersEmptyCallback
Typedef of callback for buffer status.
void CrdsaSetBackoffTimer(uint32_t allocationChannel)
Function for setting the allocation channel specific backoff timer.
void SetFSimBackoffTimeInFrames(uint32_t allocationChannel, uint32_t backoffTimeInFrames)
Function for setting the backoff time in frames.
SatRandomAccess::RandomAccessTxOpportunities_s DoCrdsa(uint32_t allocationChannel)
Main function for CRDSA algorithm.
void SetFSimBackoffProbability(uint32_t allocationChannel, uint16_t backoffPersistence)
Function for setting the backoff probability.
void SetCrdsaRandomizationParameters(uint32_t allocationChannel, uint32_t minRandomizationValue, uint32_t maxRandomizationValue, uint32_t numOfInstances)
Function for setting the parameters related to CRDSA randomization.
Ptr< SatRandomAccessConf > m_randomAccessConf
A pointer to random access configuration.
bool CrdsaHasBackoffTimePassed(uint32_t allocationChannel) const
Function for checking whether the backoff time has passed for this allocation channel.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Uniform random variable object.
void SetAreBuffersEmptyCallback(SatRandomAccess::AreBuffersEmptyCallback callback)
Function for setting the AreBuffersEmpty callback.
void SetRandomAccessModel(SatEnums::RandomAccessModel_t randomAccessModel)
Function for setting the used random access model.
void SetIsDamaAvailableCallback(SatRandomAccess::IsDamaAvailableCallback callback)
Function for setting the IsDamaAvailable callback.
uint32_t GetSlottedAlohaSignalingOverheadInBytes()
Function for getting the Slotted ALOHA signaling overhead in bytes.
bool CrdsaDoBackoff(uint32_t allocationChannel)
Function for evaluating the backoff for this allocation channel.
SatRandomAccess::RandomAccessTxOpportunities_s DoSlottedAloha()
Main function for Slotted ALOHA.
uint32_t SlottedAlohaRandomizeReleaseTime()
Function for performing the Slotted ALOHA release time randomization, i.e., the time after which the ...
void CrdsaReduceIdleBlocksForAllAllocationChannels()
Function for reducing the idle blocks in effect for all allocation channels.
void SetBackoffTime(uint32_t allocationChannel, uint32_t backoffTime)
Function for setting the backoff time.
uint32_t GetCrdsaSignalingOverheadInBytes()
Function for getting the CRDSA signaling overhead in bytes.
bool m_crdsaNewData
A flag defining whether the buffers were emptied the last time RA was evaluated, i....
bool IsCrdsaAllocationChannel(uint32_t allocationChannel)
Function for checking if the allocation channel is CRDSA allocation channel.
void SetCrdsaBackoffProbability(uint32_t allocationChannel, uint16_t backoffProbability)
Function for setting the backoff probability.
void DoDispose()
Function for disposing the module and its variables.
void SetBackoffProbability(uint32_t allocationChannel, uint16_t backoffProbability)
Function for setting the backoff probability.
void CrdsaReduceIdleBlocks(uint32_t allocationChannel)
Function for reducing the allocation channel specific number of idle blocks in effect.
Callback< bool > IsDamaAvailableCallback
Typedef of callback for known DAMA status.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
std::map< uint32_t, std::set< uint32_t > > crdsaTxOpportunities