satellite-lora-conf.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 Magister Solutions Ltd
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Bastien Tauran <bastien.tauran@viveris.fr>
19  */
20 
21 #include "satellite-lora-conf.h"
22 
23 #include "ns3/double.h"
24 #include "ns3/enum.h"
25 #include "ns3/log.h"
26 #include "ns3/satellite-env-variables.h"
27 #include "ns3/satellite-wave-form-conf.h"
28 #include "ns3/simulator.h"
29 #include "ns3/singleton.h"
30 #include "ns3/string.h"
31 
32 #include <stdint.h>
33 #include <vector>
34 
35 NS_LOG_COMPONENT_DEFINE("SatLoraConf");
36 
37 namespace ns3
38 {
39 
40 NS_OBJECT_ENSURE_REGISTERED(SatLoraConf);
41 
42 TypeId
44 {
45  static TypeId tid = TypeId("ns3::SatLoraConf")
46  .SetParent<Object>()
47  .AddConstructor<SatLoraConf>()
48  .AddAttribute("Standard",
49  "Standard used for phy layer configuration",
50  EnumValue(SatLoraConf::SATELLITE),
51  MakeEnumAccessor<SatLoraConf::PhyLayerStandard_t>(
53  MakeEnumChecker(SatLoraConf::SATELLITE,
54  "Satellite",
56  "EU863-870"));
57  return tid;
58 }
59 
60 TypeId
62 {
63  NS_LOG_FUNCTION(this);
64 
65  return GetTypeId();
66 }
67 
69 {
70  NS_LOG_FUNCTION(this);
71 
72  ObjectBase::ConstructSelf(AttributeConstructionList());
73 }
74 
75 void
76 SatLoraConf::SetConf(Ptr<LorawanMacGateway> gatewayMac)
77 {
78  NS_LOG_FUNCTION(this << gatewayMac);
79 
80  switch (m_phyLayerStandard)
81  {
83  SetSatelliteConf(gatewayMac);
84  break;
85  }
87  SetEu863_870Conf(gatewayMac);
88  break;
89  }
90  }
91 }
92 
93 void
94 SatLoraConf::SetConf(Ptr<LorawanMacEndDeviceClassA> endDeviceMac)
95 {
96  NS_LOG_FUNCTION(this << endDeviceMac);
97 
98  switch (m_phyLayerStandard)
99  {
100  case SatLoraConf::SATELLITE: {
101  SetSatelliteConf(endDeviceMac);
102  break;
103  }
104  case SatLoraConf::EU863_870: {
105  SetEu863_870Conf(endDeviceMac);
106  break;
107  }
108  }
109 }
110 
111 void
113 {
114  NS_LOG_FUNCTION(this << satConf);
115 
116  double baseFrequency;
117  double bandwidth;
118  uint32_t channels;
119  double allocatedBandwidth;
120 
121  switch (m_phyLayerStandard)
122  {
123  case SatLoraConf::SATELLITE: {
124  baseFrequency = 1.5e9;
125  bandwidth = 125000;
126  channels = 1;
127  allocatedBandwidth = 125000;
128  break;
129  }
130  case SatLoraConf::EU863_870: {
131  baseFrequency = 0.868e9;
132  bandwidth = 375000;
133  channels = 3;
134  allocatedBandwidth = 125000;
135  break;
136  }
137  default: {
138  NS_FATAL_ERROR("Unknown physical layer standard");
139  }
140  }
141 
142  satConf->SetAttribute("FwdFeederLinkBandwidth", DoubleValue(bandwidth));
143  satConf->SetAttribute("FwdFeederLinkBaseFrequency", DoubleValue(baseFrequency));
144  satConf->SetAttribute("RtnFeederLinkBandwidth", DoubleValue(bandwidth));
145  satConf->SetAttribute("RtnFeederLinkBaseFrequency", DoubleValue(baseFrequency));
146  satConf->SetAttribute("FwdUserLinkBandwidth", DoubleValue(bandwidth));
147  satConf->SetAttribute("FwdUserLinkBaseFrequency", DoubleValue(baseFrequency));
148  satConf->SetAttribute("RtnUserLinkBandwidth", DoubleValue(bandwidth));
149  satConf->SetAttribute("RtnUserLinkBaseFrequency", DoubleValue(baseFrequency));
150  satConf->SetAttribute("FwdUserLinkChannels", UintegerValue(channels));
151  satConf->SetAttribute("RtnUserLinkChannels", UintegerValue(channels));
152  satConf->SetAttribute("FwdFeederLinkChannels", UintegerValue(channels));
153  satConf->SetAttribute("RtnFeederLinkChannels", UintegerValue(channels));
154  satConf->SetAttribute("FwdCarrierAllocatedBandwidth", DoubleValue(allocatedBandwidth));
155 }
156 
157 void
158 SatLoraConf::SetEu863_870Conf(Ptr<LorawanMacGateway> gatewayMac)
159 {
160  NS_LOG_FUNCTION(this << gatewayMac);
161 
162  LoraLogicalChannelHelper channelHelper;
163 
164  channelHelper.AddLoraSubBand(868, 868.6, 0.01, 14);
165  channelHelper.AddLoraSubBand(868.7, 869.2, 0.001, 14);
166  channelHelper.AddLoraSubBand(869.4, 869.65, 0.1, 27);
167 
168  Ptr<LoraLogicalChannel> lc1 = CreateObject<LoraLogicalChannel>(868.1, 0, 5);
169  Ptr<LoraLogicalChannel> lc2 = CreateObject<LoraLogicalChannel>(868.3, 0, 5);
170  Ptr<LoraLogicalChannel> lc3 = CreateObject<LoraLogicalChannel>(868.5, 0, 5);
171  channelHelper.AddChannel(lc1);
172  channelHelper.AddChannel(lc2);
173  channelHelper.AddChannel(lc3);
174 
175  gatewayMac->SetLoraLogicalChannelHelper(channelHelper);
176 
177  gatewayMac->SetSfForDataRate(std::vector<uint8_t>{12, 11, 10, 9, 8, 7, 7});
178  gatewayMac->SetBandwidthForDataRate(
179  std::vector<double>{125000, 125000, 125000, 125000, 125000, 125000, 250000});
180  gatewayMac->SetMaxAppPayloadForDataRate(
181  std::vector<uint32_t>{59, 59, 59, 123, 230, 230, 230, 230});
182 }
183 
184 void
185 SatLoraConf::SetEu863_870Conf(Ptr<LorawanMacEndDeviceClassA> endDeviceMac)
186 {
187  NS_LOG_FUNCTION(this << endDeviceMac);
188 
189  LoraLogicalChannelHelper channelHelper;
190 
191  channelHelper.AddLoraSubBand(868, 868.6, 0.01, 14);
192  channelHelper.AddLoraSubBand(868.7, 869.2, 0.001, 14);
193  channelHelper.AddLoraSubBand(869.4, 869.65, 0.1, 27);
194 
195  Ptr<LoraLogicalChannel> lc1 = CreateObject<LoraLogicalChannel>(868.1, 0, 5);
196  Ptr<LoraLogicalChannel> lc2 = CreateObject<LoraLogicalChannel>(868.3, 0, 5);
197  Ptr<LoraLogicalChannel> lc3 = CreateObject<LoraLogicalChannel>(868.5, 0, 5);
198  channelHelper.AddChannel(lc1);
199  channelHelper.AddChannel(lc2);
200  channelHelper.AddChannel(lc3);
201 
202  endDeviceMac->SetLoraLogicalChannelHelper(channelHelper);
203 
204  endDeviceMac->SetSfForDataRate(std::vector<uint8_t>{12, 11, 10, 9, 8, 7, 7});
205  endDeviceMac->SetBandwidthForDataRate(
206  std::vector<double>{125000, 125000, 125000, 125000, 125000, 125000, 250000});
207  endDeviceMac->SetMaxAppPayloadForDataRate(
208  std::vector<uint32_t>{59, 59, 59, 123, 230, 230, 230, 230});
209 
210  LorawanMac::ReplyDataRateMatrix matrix = {{{{0, 0, 0, 0, 0, 0}},
211  {{1, 0, 0, 0, 0, 0}},
212  {{2, 1, 0, 0, 0, 0}},
213  {{3, 2, 1, 0, 0, 0}},
214  {{4, 3, 2, 1, 0, 0}},
215  {{5, 4, 3, 2, 1, 0}},
216  {{6, 5, 4, 3, 2, 1}},
217  {{7, 6, 5, 4, 3, 2}}}};
218  endDeviceMac->SetReplyDataRateMatrix(matrix);
219 
220  endDeviceMac->SetNPreambleSymbols(8);
221 
222  // TODO should be zero but transmission time is higher than propagation time. This is not
223  // possible right now. Revert to zero when possible.
224  endDeviceMac->SetSecondReceiveWindowDataRate(4);
225  endDeviceMac->SetSecondReceiveWindowFrequency(869.525);
226 }
227 
228 void
229 SatLoraConf::SetSatelliteConf(Ptr<LorawanMacGateway> gatewayMac)
230 {
231  NS_LOG_FUNCTION(this << gatewayMac);
232 
233  LoraLogicalChannelHelper channelHelper;
234 
235  // TODO check values
236 
237  // L -> 1.5GHz
238  // S -> 3GHz
239 
240  // void AddLoraSubBand (double firstFrequency, double lastFrequency, double dutyCycle, double
241  // maxTxPowerDbm) LoraLogicalChannel::LoraLogicalChannel (double frequency, uint8_t minDataRate,
242  // uint8_t maxDataRate)
243 
244  channelHelper.AddLoraSubBand(1500, 1500.25, 0.0, 14);
245 
246  Ptr<LoraLogicalChannel> lc1 = CreateObject<LoraLogicalChannel>(1500.125, 0, 5);
247  channelHelper.AddChannel(lc1);
248 
249  gatewayMac->SetLoraLogicalChannelHelper(channelHelper);
250 
251  gatewayMac->SetSfForDataRate(std::vector<uint8_t>{12, 11, 10, 9, 8, 7, 7});
252  gatewayMac->SetBandwidthForDataRate(
253  std::vector<double>{125000, 125000, 125000, 125000, 125000, 125000, 250000});
254  gatewayMac->SetMaxAppPayloadForDataRate(
255  std::vector<uint32_t>{59, 59, 59, 123, 230, 230, 230, 230});
256 }
257 
258 void
259 SatLoraConf::SetSatelliteConf(Ptr<LorawanMacEndDeviceClassA> endDeviceMac)
260 {
261  NS_LOG_FUNCTION(this << endDeviceMac);
262 
263  LoraLogicalChannelHelper channelHelper;
264 
265  // TODO check values
266 
267  channelHelper.AddLoraSubBand(1500, 1500.25, 0.0, 14);
268 
269  Ptr<LoraLogicalChannel> lc1 = CreateObject<LoraLogicalChannel>(1500.125, 0, 5);
270  channelHelper.AddChannel(lc1);
271 
272  endDeviceMac->SetLoraLogicalChannelHelper(channelHelper);
273 
274  endDeviceMac->SetSfForDataRate(std::vector<uint8_t>{12, 11, 10, 9, 8, 7, 7});
275  endDeviceMac->SetBandwidthForDataRate(
276  std::vector<double>{125000, 125000, 125000, 125000, 125000, 125000, 250000});
277  endDeviceMac->SetMaxAppPayloadForDataRate(
278  std::vector<uint32_t>{59, 59, 59, 123, 230, 230, 230, 230});
279 
280  LorawanMac::ReplyDataRateMatrix matrix = {{{{0, 0, 0, 0, 0, 0}},
281  {{1, 0, 0, 0, 0, 0}},
282  {{2, 1, 0, 0, 0, 0}},
283  {{3, 2, 1, 0, 0, 0}},
284  {{4, 3, 2, 1, 0, 0}},
285  {{5, 4, 3, 2, 1, 0}},
286  {{6, 5, 4, 3, 2, 1}},
287  {{7, 6, 5, 4, 3, 2}}}};
288  endDeviceMac->SetReplyDataRateMatrix(matrix);
289 
290  endDeviceMac->SetNPreambleSymbols(8);
291 
292  // TODO should be zero but transmission time is higher than propagation time. This is not
293  // possible right now. Revert to zero when possible.
294  endDeviceMac->SetSecondReceiveWindowDataRate(4);
295  endDeviceMac->SetSecondReceiveWindowFrequency(869.525);
296 }
297 
298 } // namespace ns3
This class supports LorawanMac instances by managing a list of the logical channels that the device i...
void AddLoraSubBand(double firstFrequency, double lastFrequency, double dutyCycle, double maxTxPowerDbm)
Add a new LoraSubBand to this helper.
void AddChannel(double frequency)
Add a new channel to the list.
std::array< std::array< uint8_t, 6 >, 8 > ReplyDataRateMatrix
Definition: lorawan-mac.h:57
SatLoraConf()
Default constructor.
void SetConf(Ptr< LorawanMacGateway > gatewayMac)
void SetEu863_870Conf(Ptr< LorawanMacGateway > gatewayMac)
static TypeId GetTypeId(void)
Get the type ID.
@ SATELLITE
For Satellite.
PhyLayerStandard_t m_phyLayerStandard
void SetSatelliteConf(Ptr< LorawanMacGateway > gatewayMac)
TypeId GetInstanceTypeId(void) const
void setSatConfAttributes(Ptr< SatConf > satConf)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.