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 <map>
35 #include <set>
36 #include <stdint.h>
37 #include <utility>
38 
39 namespace ns3
40 {
41 
51 class SatRandomAccess : public Object
52 {
53  public:
58  typedef Callback<bool> IsDamaAvailableCallback;
59 
64  typedef Callback<bool> AreBuffersEmptyCallback;
65 
71  typedef struct
72  {
75  std::map<uint32_t, std::set<uint32_t>> crdsaTxOpportunities;
78 
83 
87  SatRandomAccess(Ptr<SatRandomAccessConf> randomAccessConf,
88  SatEnums::RandomAccessModel_t randomAccessModel);
89 
93  virtual ~SatRandomAccess();
94 
99  static TypeId GetTypeId(void);
100 
105  void SetRandomAccessModel(SatEnums::RandomAccessModel_t randomAccessModel);
106 
112  void SetCrdsaBackoffTimeInMilliSeconds(uint32_t allocationChannel,
113  uint32_t backoffTimeInMilliSeconds);
114 
120  void SetCrdsaBackoffProbability(uint32_t allocationChannel, uint16_t backoffProbability);
121 
129  void SetCrdsaRandomizationParameters(uint32_t allocationChannel,
130  uint32_t minRandomizationValue,
131  uint32_t maxRandomizationValue,
132  uint32_t numOfInstances);
133 
141  void SetCrdsaMaximumDataRateLimitationParameters(uint32_t allocationChannel,
142  uint32_t maxUniquePayloadPerBlock,
143  uint32_t maxConsecutiveBlocksAccessed,
144  uint32_t minIdleBlocks);
145 
151  void SetFSimBackoffTimeInFrames(uint32_t allocationChannel, uint32_t backoffTimeInFrames);
152 
158  void SetFSimBackoffProbability(uint32_t allocationChannel, uint16_t backoffPersistence);
159 
165  void SetBackoffTime(uint32_t allocationChannel, uint32_t backoffTime);
166 
172  void SetBackoffProbability(uint32_t allocationChannel, uint16_t backoffProbability);
173 
180  uint32_t controlRandomizationIntervalInMilliSeconds);
181 
190  uint32_t allocationChannel,
192 
198 
204 
210 
216 
222  bool CrdsaHasBackoffTimePassed(uint32_t allocationChannel) const;
223 
224  protected:
228  void DoDispose();
229 
230  private:
234  void PrintVariables();
235 
241  uint32_t GetConfigurationIdForAllocationChannel(uint32_t allocationChannelId);
242 
248  SatRandomAccess::RandomAccessTxOpportunities_s DoEssa(uint32_t allocationChannel);
249 
255 
263 
268 
274  SatRandomAccess::RandomAccessTxOpportunities_s DoCrdsa(uint32_t allocationChannel);
275 
281  bool CrdsaDoBackoff(uint32_t allocationChannel);
282 
289  std::pair<std::set<uint32_t>, std::set<uint32_t>> CrdsaRandomizeTxOpportunities(
290  uint32_t allocationChannel,
291  std::pair<std::set<uint32_t>, std::set<uint32_t>> slots);
292 
300  uint32_t allocationChannel);
301 
306  void CrdsaSetBackoffTimer(uint32_t allocationChannel);
307 
313  void CrdsaIncreaseConsecutiveBlocksUsed(uint32_t allocationChannel);
314 
320 
325  void CrdsaReduceIdleBlocks(uint32_t allocationChannel);
326 
331 
337 
342  void CrdsaResetConsecutiveBlocksUsed(uint32_t allocationChannel);
343 
349  bool CrdsaIsAllocationChannelFree(uint32_t allocationChannel);
350 
356  bool IsCrdsaAllocationChannel(uint32_t allocationChannel);
357 
363  bool IsSlottedAlohaAllocationChannel(uint32_t allocationChannel);
364 
370  bool IsEssaAllocationChannel(uint32_t allocationChannel);
371 
375  Ptr<UniformRandomVariable> m_uniformRandomVariable;
376 
381 
385  Ptr<SatRandomAccessConf> m_randomAccessConf;
386 
391 
397 
402 
407 };
408 
409 } // namespace ns3
410 
411 #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