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 NS_LOG_COMPONENT_DEFINE("SatLoraConf");
33 
34 namespace ns3
35 {
36 
37 NS_OBJECT_ENSURE_REGISTERED(SatLoraConf);
38 
39 TypeId
41 {
42  static TypeId tid = TypeId("ns3::SatLoraConf")
43  .SetParent<Object>()
44  .AddConstructor<SatLoraConf>()
45  .AddAttribute("Standard",
46  "Standard used for phy layer configuration",
47  EnumValue(SatLoraConf::SATELLITE),
48  MakeEnumAccessor(&SatLoraConf::m_phyLayerStandard),
49  MakeEnumChecker(SatLoraConf::SATELLITE,
50  "Satellite",
52  "EU863-870"));
53  return tid;
54 }
55 
56 TypeId
58 {
59  NS_LOG_FUNCTION(this);
60 
61  return GetTypeId();
62 }
63 
65 {
66  NS_LOG_FUNCTION(this);
67 
68  ObjectBase::ConstructSelf(AttributeConstructionList());
69 }
70 
71 void
72 SatLoraConf::SetConf(Ptr<LorawanMacGateway> gatewayMac)
73 {
74  NS_LOG_FUNCTION(this << gatewayMac);
75 
76  switch (m_phyLayerStandard)
77  {
79  SetSatelliteConf(gatewayMac);
80  break;
81  }
83  SetEu863_870Conf(gatewayMac);
84  break;
85  }
86  }
87 }
88 
89 void
90 SatLoraConf::SetConf(Ptr<LorawanMacEndDeviceClassA> endDeviceMac)
91 {
92  NS_LOG_FUNCTION(this << endDeviceMac);
93 
94  switch (m_phyLayerStandard)
95  {
97  SetSatelliteConf(endDeviceMac);
98  break;
99  }
100  case SatLoraConf::EU863_870: {
101  SetEu863_870Conf(endDeviceMac);
102  break;
103  }
104  }
105 }
106 
107 void
109 {
110  NS_LOG_FUNCTION(this << satConf);
111 
112  double baseFrequency;
113  double bandwidth;
114  uint32_t channels;
115  double allocatedBandwidth;
116 
117  switch (m_phyLayerStandard)
118  {
119  case SatLoraConf::SATELLITE: {
120  baseFrequency = 1.5e9;
121  bandwidth = 125000;
122  channels = 1;
123  allocatedBandwidth = 125000;
124  break;
125  }
126  case SatLoraConf::EU863_870: {
127  baseFrequency = 0.868e9;
128  bandwidth = 375000;
129  channels = 3;
130  allocatedBandwidth = 125000;
131  break;
132  }
133  default: {
134  NS_FATAL_ERROR("Unknown physical layer standard");
135  }
136  }
137 
138  satConf->SetAttribute("FwdFeederLinkBandwidth", DoubleValue(bandwidth));
139  satConf->SetAttribute("FwdFeederLinkBaseFrequency", DoubleValue(baseFrequency));
140  satConf->SetAttribute("RtnFeederLinkBandwidth", DoubleValue(bandwidth));
141  satConf->SetAttribute("RtnFeederLinkBaseFrequency", DoubleValue(baseFrequency));
142  satConf->SetAttribute("FwdUserLinkBandwidth", DoubleValue(bandwidth));
143  satConf->SetAttribute("FwdUserLinkBaseFrequency", DoubleValue(baseFrequency));
144  satConf->SetAttribute("RtnUserLinkBandwidth", DoubleValue(bandwidth));
145  satConf->SetAttribute("RtnUserLinkBaseFrequency", DoubleValue(baseFrequency));
146  satConf->SetAttribute("FwdUserLinkChannels", UintegerValue(channels));
147  satConf->SetAttribute("RtnUserLinkChannels", UintegerValue(channels));
148  satConf->SetAttribute("FwdFeederLinkChannels", UintegerValue(channels));
149  satConf->SetAttribute("RtnFeederLinkChannels", UintegerValue(channels));
150  satConf->SetAttribute("FwdCarrierAllocatedBandwidth", DoubleValue(allocatedBandwidth));
151 }
152 
153 void
154 SatLoraConf::SetEu863_870Conf(Ptr<LorawanMacGateway> gatewayMac)
155 {
156  NS_LOG_FUNCTION(this << gatewayMac);
157 
158  LoraLogicalChannelHelper channelHelper;
159 
160  channelHelper.AddLoraSubBand(868, 868.6, 0.01, 14);
161  channelHelper.AddLoraSubBand(868.7, 869.2, 0.001, 14);
162  channelHelper.AddLoraSubBand(869.4, 869.65, 0.1, 27);
163 
164  Ptr<LoraLogicalChannel> lc1 = CreateObject<LoraLogicalChannel>(868.1, 0, 5);
165  Ptr<LoraLogicalChannel> lc2 = CreateObject<LoraLogicalChannel>(868.3, 0, 5);
166  Ptr<LoraLogicalChannel> lc3 = CreateObject<LoraLogicalChannel>(868.5, 0, 5);
167  channelHelper.AddChannel(lc1);
168  channelHelper.AddChannel(lc2);
169  channelHelper.AddChannel(lc3);
170 
171  gatewayMac->SetLoraLogicalChannelHelper(channelHelper);
172 
173  gatewayMac->SetSfForDataRate(std::vector<uint8_t>{12, 11, 10, 9, 8, 7, 7});
174  gatewayMac->SetBandwidthForDataRate(
175  std::vector<double>{125000, 125000, 125000, 125000, 125000, 125000, 250000});
176  gatewayMac->SetMaxAppPayloadForDataRate(
177  std::vector<uint32_t>{59, 59, 59, 123, 230, 230, 230, 230});
178 }
179 
180 void
181 SatLoraConf::SetEu863_870Conf(Ptr<LorawanMacEndDeviceClassA> endDeviceMac)
182 {
183  NS_LOG_FUNCTION(this << endDeviceMac);
184 
185  LoraLogicalChannelHelper channelHelper;
186 
187  channelHelper.AddLoraSubBand(868, 868.6, 0.01, 14);
188  channelHelper.AddLoraSubBand(868.7, 869.2, 0.001, 14);
189  channelHelper.AddLoraSubBand(869.4, 869.65, 0.1, 27);
190 
191  Ptr<LoraLogicalChannel> lc1 = CreateObject<LoraLogicalChannel>(868.1, 0, 5);
192  Ptr<LoraLogicalChannel> lc2 = CreateObject<LoraLogicalChannel>(868.3, 0, 5);
193  Ptr<LoraLogicalChannel> lc3 = CreateObject<LoraLogicalChannel>(868.5, 0, 5);
194  channelHelper.AddChannel(lc1);
195  channelHelper.AddChannel(lc2);
196  channelHelper.AddChannel(lc3);
197 
198  endDeviceMac->SetLoraLogicalChannelHelper(channelHelper);
199 
200  endDeviceMac->SetSfForDataRate(std::vector<uint8_t>{12, 11, 10, 9, 8, 7, 7});
201  endDeviceMac->SetBandwidthForDataRate(
202  std::vector<double>{125000, 125000, 125000, 125000, 125000, 125000, 250000});
203  endDeviceMac->SetMaxAppPayloadForDataRate(
204  std::vector<uint32_t>{59, 59, 59, 123, 230, 230, 230, 230});
205 
206  LorawanMac::ReplyDataRateMatrix matrix = {{{{0, 0, 0, 0, 0, 0}},
207  {{1, 0, 0, 0, 0, 0}},
208  {{2, 1, 0, 0, 0, 0}},
209  {{3, 2, 1, 0, 0, 0}},
210  {{4, 3, 2, 1, 0, 0}},
211  {{5, 4, 3, 2, 1, 0}},
212  {{6, 5, 4, 3, 2, 1}},
213  {{7, 6, 5, 4, 3, 2}}}};
214  endDeviceMac->SetReplyDataRateMatrix(matrix);
215 
216  endDeviceMac->SetNPreambleSymbols(8);
217 
218  // TODO should be zero but transmission time is higher than propagation time. This is not
219  // possible right now. Revert to zero when possible.
220  endDeviceMac->SetSecondReceiveWindowDataRate(4);
221  endDeviceMac->SetSecondReceiveWindowFrequency(869.525);
222 }
223 
224 void
225 SatLoraConf::SetSatelliteConf(Ptr<LorawanMacGateway> gatewayMac)
226 {
227  NS_LOG_FUNCTION(this << gatewayMac);
228 
229  LoraLogicalChannelHelper channelHelper;
230 
231  // TODO check values
232 
233  // L -> 1.5GHz
234  // S -> 3GHz
235 
236  // void AddLoraSubBand (double firstFrequency, double lastFrequency, double dutyCycle, double
237  // maxTxPowerDbm) LoraLogicalChannel::LoraLogicalChannel (double frequency, uint8_t minDataRate,
238  // uint8_t maxDataRate)
239 
240  channelHelper.AddLoraSubBand(1500, 1500.25, 0.0, 14);
241 
242  Ptr<LoraLogicalChannel> lc1 = CreateObject<LoraLogicalChannel>(1500.125, 0, 5);
243  channelHelper.AddChannel(lc1);
244 
245  gatewayMac->SetLoraLogicalChannelHelper(channelHelper);
246 
247  gatewayMac->SetSfForDataRate(std::vector<uint8_t>{12, 11, 10, 9, 8, 7, 7});
248  gatewayMac->SetBandwidthForDataRate(
249  std::vector<double>{125000, 125000, 125000, 125000, 125000, 125000, 250000});
250  gatewayMac->SetMaxAppPayloadForDataRate(
251  std::vector<uint32_t>{59, 59, 59, 123, 230, 230, 230, 230});
252 }
253 
254 void
255 SatLoraConf::SetSatelliteConf(Ptr<LorawanMacEndDeviceClassA> endDeviceMac)
256 {
257  NS_LOG_FUNCTION(this << endDeviceMac);
258 
259  LoraLogicalChannelHelper channelHelper;
260 
261  // TODO check values
262 
263  channelHelper.AddLoraSubBand(1500, 1500.25, 0.0, 14);
264 
265  Ptr<LoraLogicalChannel> lc1 = CreateObject<LoraLogicalChannel>(1500.125, 0, 5);
266  channelHelper.AddChannel(lc1);
267 
268  endDeviceMac->SetLoraLogicalChannelHelper(channelHelper);
269 
270  endDeviceMac->SetSfForDataRate(std::vector<uint8_t>{12, 11, 10, 9, 8, 7, 7});
271  endDeviceMac->SetBandwidthForDataRate(
272  std::vector<double>{125000, 125000, 125000, 125000, 125000, 125000, 250000});
273  endDeviceMac->SetMaxAppPayloadForDataRate(
274  std::vector<uint32_t>{59, 59, 59, 123, 230, 230, 230, 230});
275 
276  LorawanMac::ReplyDataRateMatrix matrix = {{{{0, 0, 0, 0, 0, 0}},
277  {{1, 0, 0, 0, 0, 0}},
278  {{2, 1, 0, 0, 0, 0}},
279  {{3, 2, 1, 0, 0, 0}},
280  {{4, 3, 2, 1, 0, 0}},
281  {{5, 4, 3, 2, 1, 0}},
282  {{6, 5, 4, 3, 2, 1}},
283  {{7, 6, 5, 4, 3, 2}}}};
284  endDeviceMac->SetReplyDataRateMatrix(matrix);
285 
286  endDeviceMac->SetNPreambleSymbols(8);
287 
288  // TODO should be zero but transmission time is higher than propagation time. This is not
289  // possible right now. Revert to zero when possible.
290  endDeviceMac->SetSecondReceiveWindowDataRate(4);
291  endDeviceMac->SetSecondReceiveWindowFrequency(869.525);
292 }
293 
294 } // 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:55
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.