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 NS_LOG_COMPONENT_DEFINE("SatRandomAccessConf");
30 
31 namespace ns3
32 {
33 
34 NS_OBJECT_ENSURE_REGISTERED(SatRandomAccessConf);
35 
36 TypeId
38 {
39  static TypeId tid =
40  TypeId("ns3::SatRandomAccessConf")
41  .SetParent<Object>()
42  .AddConstructor<SatRandomAccessConf>()
43  .AddAttribute(
44  "CrdsaSignalingOverheadInBytes",
45  "CRDSA signaling overhead in bytes.",
46  UintegerValue(5),
48  MakeUintegerChecker<uint32_t>())
49  .AddAttribute(
50  "SlottedAlohaSignalingOverheadInBytes",
51  "Slotted ALOHA signaling overhead in bytes.",
52  UintegerValue(3),
54  MakeUintegerChecker<uint32_t>());
55  return tid;
56 }
57 
59  : m_slottedAlohaControlRandomizationIntervalInMilliSeconds(),
60  m_allocationChannelCount(),
61  m_crdsaSignalingOverheadInBytes(),
62  m_slottedAlohaSignalingOverheadInBytes()
63 {
64  NS_LOG_FUNCTION(this);
65  NS_FATAL_ERROR("SatRandomAccessConf::SatRandomAccessConf - Constructor not in use");
66 }
67 
68 SatRandomAccessConf::SatRandomAccessConf(Ptr<SatLowerLayerServiceConf> llsConf,
69  Ptr<SatSuperframeSeq> superframeSeq)
70  : m_configurationIdPerAllocationChannel(),
71  m_slottedAlohaControlRandomizationIntervalInMilliSeconds(),
72  m_allocationChannelCount(llsConf->GetRaServiceCount()),
73  m_crdsaSignalingOverheadInBytes(5),
74  m_slottedAlohaSignalingOverheadInBytes(3)
75 {
76  NS_LOG_FUNCTION(this);
77 
79  {
80  NS_FATAL_ERROR(
81  "SatRandomAccessConf::SatRandomAccessConf - No random access allocation channel");
82  }
83 
85  (llsConf->GetDefaultControlRandomizationInterval()).GetMilliSeconds();
87 
88  for (uint32_t i = 0; i < m_allocationChannelCount; i++)
89  {
90  Ptr<SatRandomAccessAllocationChannel> allocationChannel =
91  CreateObject<SatRandomAccessAllocationChannel>();
92  m_allocationChannelConf.insert(std::make_pair(i, allocationChannel));
93 
94  allocationChannel->SetSlottedAlohaAllowed(llsConf->GetRaIsSlottedAlohaAllowed(i));
95  allocationChannel->SetCrdsaAllowed(llsConf->GetRaIsCrdsaAllowed(i));
96  allocationChannel->SetEssaAllowed(llsConf->GetRaIsEssaAllowed(i));
97  allocationChannel->SetCrdsaMaxUniquePayloadPerBlock(
98  llsConf->GetRaMaximumUniquePayloadPerBlock(i));
99  allocationChannel->SetCrdsaMaxConsecutiveBlocksAccessed(
100  llsConf->GetRaMaximumConsecutiveBlockAccessed(i));
101  allocationChannel->SetCrdsaMinIdleBlocks(llsConf->GetRaMinimumIdleBlock(i));
102  allocationChannel->SetCrdsaNumOfInstances(llsConf->GetRaNumberOfInstances(i));
103  allocationChannel->SetCrdsaBackoffProbability(llsConf->GetRaBackOffProbability(i));
104  allocationChannel->SetCrdsaBackoffTimeInMilliSeconds(
105  llsConf->GetRaBackOffTimeInMilliSeconds(i));
106  allocationChannel->SetFSimBackoffProbability(llsConf->GetRaBackOffProbability(i));
107  allocationChannel->SetFSimBackoffTimeInMilliSeconds(
108  llsConf->GetRaBackOffTimeInMilliSeconds(i));
109  allocationChannel->SetFSimPhysicalLayerFrameInMilliSeconds(
110  (superframeSeq->GetSuperframeConf(0)->GetDuration()).GetMilliSeconds());
111 
113  allocationChannel->SetCrdsaMinRandomizationValue(0);
114  allocationChannel->SetCrdsaMaxRandomizationValue(std::numeric_limits<uint16_t>::max());
115  }
116 
118  Ptr<SatSuperframeConf> superframeConf = superframeSeq->GetSuperframeConf(0);
119  for (uint32_t i = 0; i < superframeConf->GetRaChannelCount(); ++i)
120  {
121  uint8_t allocationChannel = superframeConf->GetRaChannelAllocationChannelId(i);
123  uint16_t raSlotCount = superframeConf->GetRaSlotCount(i) - 1;
124 
125  if (allocationChannel < m_allocationChannelCount)
126  {
127  m_configurationIdPerAllocationChannel.push_back(allocationChannel);
128  auto allocationChannelConf = m_allocationChannelConf[allocationChannel];
129  if (raSlotCount < allocationChannelConf->GetCrdsaMaxRandomizationValue())
130  {
131  allocationChannelConf->SetCrdsaMaxRandomizationValue(raSlotCount);
132  }
133  }
134  else
135  {
136  NS_FATAL_ERROR("Allocation channel for frame " << superframeConf->GetRaChannelFrameId(i)
137  << " is out of range");
138  }
139  }
140 
141  for (auto& allocationChannelConf : m_allocationChannelConf)
142  {
143  if (allocationChannelConf.second->GetCrdsaAllowed())
144  {
145  allocationChannelConf.second->DoCrdsaVariableSanityCheck();
146  }
147  }
148 }
149 
151 {
152  NS_LOG_FUNCTION(this);
153 }
154 
155 Ptr<SatRandomAccessAllocationChannel>
157 {
158  NS_LOG_FUNCTION(this << allocationChannel);
159 
160  std::map<uint32_t, Ptr<SatRandomAccessAllocationChannel>>::iterator iter =
161  m_allocationChannelConf.find(allocationChannel);
162 
163  if (iter == m_allocationChannelConf.end())
164  {
165  NS_FATAL_ERROR(
166  "SatRandomAccessConf::GetAllocationChannelConfiguration - Invalid allocation channel");
167  }
168 
169  return (iter->second);
170 }
171 
172 void
174 {
175  NS_LOG_FUNCTION(this);
176 
178  {
179  NS_FATAL_ERROR("SatRandomAccessConf::DoSlottedAlohaVariableSanityCheck - "
180  "m_slottedAlohaControlRandomizationIntervalInMilliSeconds < 1");
181  }
182 
183  NS_LOG_INFO("Variable sanity check done");
184 }
185 
186 uint32_t
188 {
189  NS_LOG_FUNCTION(this << allocationChannel);
190 
191  if (allocationChannel >= m_configurationIdPerAllocationChannel.size())
192  {
193  NS_FATAL_ERROR(
194  "SatRandomAccessConf::GetAllocationChannelConfigurationId - allocation channel "
195  << allocationChannel << " has no associated configuration.");
196  }
197 
198  return m_configurationIdPerAllocationChannel[allocationChannel];
199 }
200 
201 } // 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.