satellite-random-access-container-conf.cc
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 
24 
25 #include <ns3/double.h>
26 #include <ns3/log.h>
27 #include <ns3/uinteger.h>
28 
29 #include <limits>
30 #include <map>
31 #include <utility>
32 
33 NS_LOG_COMPONENT_DEFINE("SatRandomAccessConf");
34 
35 namespace ns3
36 {
37 
38 NS_OBJECT_ENSURE_REGISTERED(SatRandomAccessConf);
39 
40 TypeId
42 {
43  static TypeId tid =
44  TypeId("ns3::SatRandomAccessConf")
45  .SetParent<Object>()
46  .AddConstructor<SatRandomAccessConf>()
47  .AddAttribute(
48  "CrdsaSignalingOverheadInBytes",
49  "CRDSA signaling overhead in bytes.",
50  UintegerValue(5),
52  MakeUintegerChecker<uint32_t>())
53  .AddAttribute(
54  "SlottedAlohaSignalingOverheadInBytes",
55  "Slotted ALOHA signaling overhead in bytes.",
56  UintegerValue(3),
58  MakeUintegerChecker<uint32_t>());
59  return tid;
60 }
61 
63  : m_slottedAlohaControlRandomizationIntervalInMilliSeconds(),
64  m_allocationChannelCount(),
65  m_crdsaSignalingOverheadInBytes(),
66  m_slottedAlohaSignalingOverheadInBytes()
67 {
68  NS_LOG_FUNCTION(this);
69  NS_FATAL_ERROR("SatRandomAccessConf::SatRandomAccessConf - Constructor not in use");
70 }
71 
72 SatRandomAccessConf::SatRandomAccessConf(Ptr<SatLowerLayerServiceConf> llsConf,
73  Ptr<SatSuperframeSeq> superframeSeq)
74  : m_configurationIdPerAllocationChannel(),
75  m_slottedAlohaControlRandomizationIntervalInMilliSeconds(),
76  m_allocationChannelCount(llsConf->GetRaServiceCount()),
77  m_crdsaSignalingOverheadInBytes(5),
78  m_slottedAlohaSignalingOverheadInBytes(3)
79 {
80  NS_LOG_FUNCTION(this);
81 
83  {
84  NS_FATAL_ERROR(
85  "SatRandomAccessConf::SatRandomAccessConf - No random access allocation channel");
86  }
87 
89  (llsConf->GetDefaultControlRandomizationInterval()).GetMilliSeconds();
91 
92  for (uint32_t i = 0; i < m_allocationChannelCount; i++)
93  {
94  Ptr<SatRandomAccessAllocationChannel> allocationChannel =
95  CreateObject<SatRandomAccessAllocationChannel>();
96  m_allocationChannelConf.insert(std::make_pair(i, allocationChannel));
97 
98  allocationChannel->SetSlottedAlohaAllowed(llsConf->GetRaIsSlottedAlohaAllowed(i));
99  allocationChannel->SetCrdsaAllowed(llsConf->GetRaIsCrdsaAllowed(i));
100  allocationChannel->SetEssaAllowed(llsConf->GetRaIsEssaAllowed(i));
101  allocationChannel->SetCrdsaMaxUniquePayloadPerBlock(
102  llsConf->GetRaMaximumUniquePayloadPerBlock(i));
103  allocationChannel->SetCrdsaMaxConsecutiveBlocksAccessed(
104  llsConf->GetRaMaximumConsecutiveBlockAccessed(i));
105  allocationChannel->SetCrdsaMinIdleBlocks(llsConf->GetRaMinimumIdleBlock(i));
106  allocationChannel->SetCrdsaNumOfInstances(llsConf->GetRaNumberOfInstances(i));
107  allocationChannel->SetCrdsaBackoffProbability(llsConf->GetRaBackOffProbability(i));
108  allocationChannel->SetCrdsaBackoffTimeInMilliSeconds(
109  llsConf->GetRaBackOffTimeInMilliSeconds(i));
110  allocationChannel->SetFSimBackoffProbability(llsConf->GetRaBackOffProbability(i));
111  allocationChannel->SetFSimBackoffTimeInMilliSeconds(
112  llsConf->GetRaBackOffTimeInMilliSeconds(i));
113  allocationChannel->SetFSimPhysicalLayerFrameInMilliSeconds(
114  (superframeSeq->GetSuperframeConf(0)->GetDuration()).GetMilliSeconds());
115 
117  allocationChannel->SetCrdsaMinRandomizationValue(0);
118  allocationChannel->SetCrdsaMaxRandomizationValue(std::numeric_limits<uint16_t>::max());
119  }
120 
122  Ptr<SatSuperframeConf> superframeConf = superframeSeq->GetSuperframeConf(0);
123  for (uint32_t i = 0; i < superframeConf->GetRaChannelCount(); ++i)
124  {
125  uint8_t allocationChannel = superframeConf->GetRaChannelAllocationChannelId(i);
127  uint16_t raSlotCount = superframeConf->GetRaSlotCount(i) - 1;
128 
129  if (allocationChannel < m_allocationChannelCount)
130  {
131  m_configurationIdPerAllocationChannel.push_back(allocationChannel);
132  auto allocationChannelConf = m_allocationChannelConf[allocationChannel];
133  if (raSlotCount < allocationChannelConf->GetCrdsaMaxRandomizationValue())
134  {
135  allocationChannelConf->SetCrdsaMaxRandomizationValue(raSlotCount);
136  }
137  }
138  else
139  {
140  NS_FATAL_ERROR("Allocation channel for frame " << superframeConf->GetRaChannelFrameId(i)
141  << " is out of range");
142  }
143  }
144 
145  for (auto& allocationChannelConf : m_allocationChannelConf)
146  {
147  if (allocationChannelConf.second->GetCrdsaAllowed())
148  {
149  allocationChannelConf.second->DoCrdsaVariableSanityCheck();
150  }
151  }
152 }
153 
155 {
156  NS_LOG_FUNCTION(this);
157 }
158 
159 Ptr<SatRandomAccessAllocationChannel>
161 {
162  NS_LOG_FUNCTION(this << allocationChannel);
163 
164  std::map<uint32_t, Ptr<SatRandomAccessAllocationChannel>>::iterator iter =
165  m_allocationChannelConf.find(allocationChannel);
166 
167  if (iter == m_allocationChannelConf.end())
168  {
169  NS_FATAL_ERROR(
170  "SatRandomAccessConf::GetAllocationChannelConfiguration - Invalid allocation channel");
171  }
172 
173  return (iter->second);
174 }
175 
176 void
178 {
179  NS_LOG_FUNCTION(this);
180 
182  {
183  NS_FATAL_ERROR("SatRandomAccessConf::DoSlottedAlohaVariableSanityCheck - "
184  "m_slottedAlohaControlRandomizationIntervalInMilliSeconds < 1");
185  }
186 
187  NS_LOG_INFO("Variable sanity check done");
188 }
189 
190 uint32_t
192 {
193  NS_LOG_FUNCTION(this << allocationChannel);
194 
195  if (allocationChannel >= m_configurationIdPerAllocationChannel.size())
196  {
197  NS_FATAL_ERROR(
198  "SatRandomAccessConf::GetAllocationChannelConfigurationId - allocation channel "
199  << allocationChannel << " has no associated configuration.");
200  }
201 
202  return m_configurationIdPerAllocationChannel[allocationChannel];
203 }
204 
205 } // namespace ns3
uint32_t m_allocationChannelCount
Number of available allocation channels.
uint32_t GetAllocationChannelConfigurationId(uint32_t allocationChannel)
Function for retrieving the configuration ID of a given allocation channel.
uint32_t m_slottedAlohaControlRandomizationIntervalInMilliSeconds
Slotted ALOHA control randomization interval in milliseconds.
std::vector< uint32_t > m_configurationIdPerAllocationChannel
Mapping between an allocation channel and its associated configuration index.
void DoSlottedAlohaVariableSanityCheck()
Function for checking the Slotted ALOHA variable sanity.
static TypeId GetTypeId(void)
NS-3 type id function.
Ptr< SatRandomAccessAllocationChannel > GetAllocationChannelConfiguration(uint32_t allocationChannel)
Function for returning the allocation channel specific RA configuration.
uint32_t m_crdsaSignalingOverheadInBytes
Defines the size of the CRDSA signaling overhead in bytes.
uint32_t m_slottedAlohaSignalingOverheadInBytes
Defines the size of the Slotted ALOHA signaling overhead in bytes.
std::map< uint32_t, Ptr< SatRandomAccessAllocationChannel > > m_allocationChannelConf
Map containing the allocation channel configurations.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.