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