A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lorawan-mac-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 University of Padova
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Davide Magrin <magrinda@dei.unipd.it>
18 */
19
20#include "lorawan-mac-helper.h"
21
22#include "ns3/end-device-lora-phy.h"
23#include "ns3/gateway-lora-phy.h"
24#include "ns3/log.h"
25#include "ns3/lora-net-device.h"
26#include "ns3/random-variable-stream.h"
27
28namespace ns3
29{
30namespace lorawan
31{
32
33NS_LOG_COMPONENT_DEFINE("LorawanMacHelper");
34
36 : m_region(LorawanMacHelper::EU)
37{
38}
39
40void
41LorawanMacHelper::Set(std::string name, const AttributeValue& v)
42{
43 m_mac.Set(name, v);
44}
45
46void
48{
49 NS_LOG_FUNCTION(this << dt);
50 switch (dt)
51 {
52 case GW:
53 m_mac.SetTypeId("ns3::GatewayLorawanMac");
54 break;
55 case ED_A:
56 m_mac.SetTypeId("ns3::ClassAEndDeviceLorawanMac");
57 break;
58 }
59 m_deviceType = dt;
60}
61
62void
64{
65 NS_LOG_FUNCTION(this);
66
67 m_addrGen = addrGen;
68}
69
70void
72{
73 m_region = region;
74}
75
78{
80 mac->SetDevice(device);
81
82 // If we are operating on an end device, add an address to it
83 if (m_deviceType == ED_A && m_addrGen)
84 {
85 mac->GetObject<ClassAEndDeviceLorawanMac>()->SetDeviceAddress(m_addrGen->NextAddress());
86 }
87
88 // Add a basic list of channels based on the region where the device is
89 // operating
90 if (m_deviceType == ED_A)
91 {
93 switch (m_region)
94 {
97 break;
98 }
101 break;
102 }
105 break;
106 }
107 default: {
108 NS_LOG_ERROR("This region isn't supported yet!");
109 break;
110 }
111 }
112 }
113 else
114 {
115 Ptr<GatewayLorawanMac> gwMac = mac->GetObject<GatewayLorawanMac>();
116 switch (m_region)
117 {
120 break;
121 }
124 break;
125 }
128 break;
129 }
130 default: {
131 NS_LOG_ERROR("This region isn't supported yet!");
132 break;
133 }
134 }
135 }
136 return mac;
137}
138
139void
141{
143
145
146 /////////////////////////////////////////////////////
147 // TxPower -> Transmission power in dBm conversion //
148 /////////////////////////////////////////////////////
149 edMac->SetTxDbmForTxPower(std::vector<double>{16, 14, 12, 10, 8, 6, 4, 2});
150
151 ////////////////////////////////////////////////////////////
152 // Matrix to know which data rate the gateway will respond with //
153 ////////////////////////////////////////////////////////////
154 LorawanMac::ReplyDataRateMatrix matrix = {{{{0, 0, 0, 0, 0, 0}},
155 {{1, 0, 0, 0, 0, 0}},
156 {{2, 1, 0, 0, 0, 0}},
157 {{3, 2, 1, 0, 0, 0}},
158 {{4, 3, 2, 1, 0, 0}},
159 {{5, 4, 3, 2, 1, 0}},
160 {{6, 5, 4, 3, 2, 1}},
161 {{7, 6, 5, 4, 3, 2}}}};
162 edMac->SetReplyDataRateMatrix(matrix);
163
164 /////////////////////
165 // Preamble length //
166 /////////////////////
167 edMac->SetNPreambleSymbols(8);
168
169 //////////////////////////////////////
170 // Second receive window parameters //
171 //////////////////////////////////////
172 edMac->SetSecondReceiveWindowDataRate(0);
173 edMac->SetSecondReceiveWindowFrequency(869.525);
174}
175
176void
178{
180
181 ///////////////////////////////
182 // ReceivePath configuration //
183 ///////////////////////////////
184 Ptr<GatewayLoraPhy> gwPhy =
185 gwMac->GetDevice()->GetObject<LoraNetDevice>()->GetPhy()->GetObject<GatewayLoraPhy>();
186
188
189 if (gwPhy) // If cast is successful, there's a GatewayLoraPhy
190 {
191 NS_LOG_DEBUG("Resetting reception paths");
192 gwPhy->ResetReceptionPaths();
193
194 int receptionPaths = 0;
195 int maxReceptionPaths = 1;
196 while (receptionPaths < maxReceptionPaths)
197 {
198 gwPhy->GetObject<GatewayLoraPhy>()->AddReceptionPath();
199 receptionPaths++;
200 }
201 gwPhy->AddFrequency(868.1);
202 }
203}
204
205void
207{
209
210 //////////////
211 // SubBands //
212 //////////////
213
214 LogicalLoraChannelHelper channelHelper;
215 channelHelper.AddSubBand(868, 868.6, 1, 14);
216
217 //////////////////////
218 // Default channels //
219 //////////////////////
220 Ptr<LogicalLoraChannel> lc1 = CreateObject<LogicalLoraChannel>(868.1, 0, 5);
221 channelHelper.AddChannel(lc1);
222
223 lorawanMac->SetLogicalLoraChannelHelper(channelHelper);
224
225 ///////////////////////////////////////////////////////////
226 // Data rate -> Spreading factor, Data rate -> Bandwidth //
227 // and Data rate -> MaxAppPayload conversions //
228 ///////////////////////////////////////////////////////////
229 lorawanMac->SetSfForDataRate(std::vector<uint8_t>{12, 11, 10, 9, 8, 7, 7});
230 lorawanMac->SetBandwidthForDataRate(
231 std::vector<double>{125000, 125000, 125000, 125000, 125000, 125000, 250000});
232 lorawanMac->SetMaxAppPayloadForDataRate(
233 std::vector<uint32_t>{59, 59, 59, 123, 230, 230, 230, 230});
234}
235
236void
238{
240
242
243 /////////////////////////////////////////////////////
244 // TxPower -> Transmission power in dBm conversion //
245 /////////////////////////////////////////////////////
246 edMac->SetTxDbmForTxPower(std::vector<double>{16, 14, 12, 10, 8, 6, 4, 2});
247
248 ////////////////////////////////////////////////////////////
249 // Matrix to know which data rate the gateway will respond with //
250 ////////////////////////////////////////////////////////////
251 LorawanMac::ReplyDataRateMatrix matrix = {{{{0, 0, 0, 0, 0, 0}},
252 {{1, 0, 0, 0, 0, 0}},
253 {{2, 1, 0, 0, 0, 0}},
254 {{3, 2, 1, 0, 0, 0}},
255 {{4, 3, 2, 1, 0, 0}},
256 {{5, 4, 3, 2, 1, 0}},
257 {{6, 5, 4, 3, 2, 1}},
258 {{7, 6, 5, 4, 3, 2}}}};
259 edMac->SetReplyDataRateMatrix(matrix);
260
261 /////////////////////
262 // Preamble length //
263 /////////////////////
264 edMac->SetNPreambleSymbols(8);
265
266 //////////////////////////////////////
267 // Second receive window parameters //
268 //////////////////////////////////////
269 edMac->SetSecondReceiveWindowDataRate(0);
270 edMac->SetSecondReceiveWindowFrequency(869.525);
271}
272
273void
275{
277
278 ///////////////////////////////
279 // ReceivePath configuration //
280 ///////////////////////////////
281 Ptr<GatewayLoraPhy> gwPhy =
282 gwMac->GetDevice()->GetObject<LoraNetDevice>()->GetPhy()->GetObject<GatewayLoraPhy>();
283
285
286 if (gwPhy) // If cast is successful, there's a GatewayLoraPhy
287 {
288 NS_LOG_DEBUG("Resetting reception paths");
289 gwPhy->ResetReceptionPaths();
290
291 std::vector<double> frequencies;
292 frequencies.push_back(868.1);
293 frequencies.push_back(868.3);
294 frequencies.push_back(868.5);
295
296 for (auto& f : frequencies)
297 {
298 gwPhy->AddFrequency(f);
299 }
300
301 int receptionPaths = 0;
302 int maxReceptionPaths = 8;
303 while (receptionPaths < maxReceptionPaths)
304 {
305 gwPhy->GetObject<GatewayLoraPhy>()->AddReceptionPath();
306 receptionPaths++;
307 }
308 }
309}
310
311void
313{
315
316 //////////////
317 // SubBands //
318 //////////////
319
320 LogicalLoraChannelHelper channelHelper;
321 channelHelper.AddSubBand(868, 868.6, 0.01, 14);
322 channelHelper.AddSubBand(868.7, 869.2, 0.001, 14);
323 channelHelper.AddSubBand(869.4, 869.65, 0.1, 27);
324
325 //////////////////////
326 // Default channels //
327 //////////////////////
328 Ptr<LogicalLoraChannel> lc1 = CreateObject<LogicalLoraChannel>(868.1, 0, 5);
329 Ptr<LogicalLoraChannel> lc2 = CreateObject<LogicalLoraChannel>(868.3, 0, 5);
330 Ptr<LogicalLoraChannel> lc3 = CreateObject<LogicalLoraChannel>(868.5, 0, 5);
331 channelHelper.AddChannel(lc1);
332 channelHelper.AddChannel(lc2);
333 channelHelper.AddChannel(lc3);
334
335 lorawanMac->SetLogicalLoraChannelHelper(channelHelper);
336
337 ///////////////////////////////////////////////////////////
338 // Data rate -> Spreading factor, Data rate -> Bandwidth //
339 // and Data rate -> MaxAppPayload conversions //
340 ///////////////////////////////////////////////////////////
341 lorawanMac->SetSfForDataRate(std::vector<uint8_t>{12, 11, 10, 9, 8, 7, 7});
342 lorawanMac->SetBandwidthForDataRate(
343 std::vector<double>{125000, 125000, 125000, 125000, 125000, 125000, 250000});
344 lorawanMac->SetMaxAppPayloadForDataRate(
345 std::vector<uint32_t>{59, 59, 59, 123, 230, 230, 230, 230});
346}
347
348///////////////////////////////
349
350void
352{
354
356
357 /////////////////////////////////////////////////////
358 // TxPower -> Transmission power in dBm conversion //
359 /////////////////////////////////////////////////////
360 edMac->SetTxDbmForTxPower(std::vector<double>{16, 14, 12, 10, 8, 6, 4, 2});
361
362 ////////////////////////////////////////////////////////////
363 // Matrix to know which DataRate the gateway will respond with //
364 ////////////////////////////////////////////////////////////
365 LorawanMac::ReplyDataRateMatrix matrix = {{{{0, 0, 0, 0, 0, 0}},
366 {{1, 0, 0, 0, 0, 0}},
367 {{2, 1, 0, 0, 0, 0}},
368 {{3, 2, 1, 0, 0, 0}},
369 {{4, 3, 2, 1, 0, 0}},
370 {{5, 4, 3, 2, 1, 0}},
371 {{6, 5, 4, 3, 2, 1}},
372 {{7, 6, 5, 4, 3, 2}}}};
373 edMac->SetReplyDataRateMatrix(matrix);
374
375 /////////////////////
376 // Preamble length //
377 /////////////////////
378 edMac->SetNPreambleSymbols(8);
379
380 //////////////////////////////////////
381 // Second receive window parameters //
382 //////////////////////////////////////
383 edMac->SetSecondReceiveWindowDataRate(0);
384 edMac->SetSecondReceiveWindowFrequency(869.525);
385}
386
387void
389{
391
392 ///////////////////////////////
393 // ReceivePath configuration //
394 ///////////////////////////////
395 Ptr<GatewayLoraPhy> gwPhy =
396 gwMac->GetDevice()->GetObject<LoraNetDevice>()->GetPhy()->GetObject<GatewayLoraPhy>();
397
399
400 if (gwPhy) // If cast is successful, there's a GatewayLoraPhy
401 {
402 NS_LOG_DEBUG("Resetting reception paths");
403 gwPhy->ResetReceptionPaths();
404
405 std::vector<double> frequencies;
406 frequencies.push_back(868.1);
407
408 for (auto& f : frequencies)
409 {
410 gwPhy->AddFrequency(f);
411 }
412
413 int receptionPaths = 0;
414 int maxReceptionPaths = 8;
415 while (receptionPaths < maxReceptionPaths)
416 {
417 gwPhy->GetObject<GatewayLoraPhy>()->AddReceptionPath();
418 receptionPaths++;
419 }
420 }
421}
422
423void
425{
427
428 //////////////
429 // SubBands //
430 //////////////
431
432 LogicalLoraChannelHelper channelHelper;
433 channelHelper.AddSubBand(868, 868.6, 0.01, 14);
434 channelHelper.AddSubBand(868.7, 869.2, 0.001, 14);
435 channelHelper.AddSubBand(869.4, 869.65, 0.1, 27);
436
437 //////////////////////
438 // Default channels //
439 //////////////////////
440 Ptr<LogicalLoraChannel> lc1 = CreateObject<LogicalLoraChannel>(868.1, 0, 5);
441 channelHelper.AddChannel(lc1);
442
443 lorawanMac->SetLogicalLoraChannelHelper(channelHelper);
444
445 ///////////////////////////////////////////////////////////
446 // Data rate -> Spreading factor, Data rate -> Bandwidth //
447 // and Data rate -> MaxAppPayload conversions //
448 ///////////////////////////////////////////////////////////
449 lorawanMac->SetSfForDataRate(std::vector<uint8_t>{12, 11, 10, 9, 8, 7, 7});
450 lorawanMac->SetBandwidthForDataRate(
451 std::vector<double>{125000, 125000, 125000, 125000, 125000, 125000, 250000});
452 lorawanMac->SetMaxAppPayloadForDataRate(
453 std::vector<uint32_t>{59, 59, 59, 123, 230, 230, 230, 230});
454}
455
456std::vector<int>
458 NodeContainer gateways,
459 Ptr<LoraChannel> channel)
460{
462
463 std::vector<int> sfQuantity(7, 0);
464 for (auto j = endDevices.Begin(); j != endDevices.End(); ++j)
465 {
466 Ptr<Node> object = *j;
467 Ptr<MobilityModel> position = object->GetObject<MobilityModel>();
468 NS_ASSERT(position);
469 Ptr<NetDevice> netDevice = object->GetDevice(0);
470 Ptr<LoraNetDevice> loraNetDevice = netDevice->GetObject<LoraNetDevice>();
471 NS_ASSERT(loraNetDevice);
473 loraNetDevice->GetMac()->GetObject<ClassAEndDeviceLorawanMac>();
474 NS_ASSERT(mac);
475
476 // Try computing the distance from each gateway and find the best one
477 Ptr<Node> bestGateway = gateways.Get(0);
478 Ptr<MobilityModel> bestGatewayPosition = bestGateway->GetObject<MobilityModel>();
479
480 // Assume devices transmit at 14 dBm
481 double highestRxPower = channel->GetRxPower(14, position, bestGatewayPosition);
482
483 for (auto currentGw = gateways.Begin() + 1; currentGw != gateways.End(); ++currentGw)
484 {
485 // Compute the power received from the current gateway
486 Ptr<Node> curr = *currentGw;
487 Ptr<MobilityModel> currPosition = curr->GetObject<MobilityModel>();
488 double currentRxPower = channel->GetRxPower(14, position, currPosition); // dBm
489
490 if (currentRxPower > highestRxPower)
491 {
492 bestGateway = curr;
493 bestGatewayPosition = curr->GetObject<MobilityModel>();
494 highestRxPower = currentRxPower;
495 }
496 }
497
498 // NS_LOG_DEBUG ("Rx Power: " << highestRxPower);
499 double rxPower = highestRxPower;
500
501 // Get the end device sensitivity
502 Ptr<EndDeviceLoraPhy> edPhy = loraNetDevice->GetPhy()->GetObject<EndDeviceLoraPhy>();
503 const double* edSensitivity = edPhy->sensitivity;
504
505 if (rxPower > *edSensitivity)
506 {
507 mac->SetDataRate(5);
508 sfQuantity[0] = sfQuantity[0] + 1;
509 }
510 else if (rxPower > *(edSensitivity + 1))
511 {
512 mac->SetDataRate(4);
513 sfQuantity[1] = sfQuantity[1] + 1;
514 }
515 else if (rxPower > *(edSensitivity + 2))
516 {
517 mac->SetDataRate(3);
518 sfQuantity[2] = sfQuantity[2] + 1;
519 }
520 else if (rxPower > *(edSensitivity + 3))
521 {
522 mac->SetDataRate(2);
523 sfQuantity[3] = sfQuantity[3] + 1;
524 }
525 else if (rxPower > *(edSensitivity + 4))
526 {
527 mac->SetDataRate(1);
528 sfQuantity[4] = sfQuantity[4] + 1;
529 }
530 else if (rxPower > *(edSensitivity + 5))
531 {
532 mac->SetDataRate(0);
533 sfQuantity[5] = sfQuantity[5] + 1;
534 }
535 else // Device is out of range. Assign SF12.
536 {
537 // NS_LOG_DEBUG ("Device out of range");
538 mac->SetDataRate(0);
539 sfQuantity[6] = sfQuantity[6] + 1;
540 // NS_LOG_DEBUG ("sfQuantity[6] = " << sfQuantity[6]);
541 }
542
543 /*
544
545 // Get the Gw sensitivity
546 Ptr<NetDevice> gatewayNetDevice = bestGateway->GetDevice (0);
547 Ptr<LoraNetDevice> gatewayLoraNetDevice = gatewayNetDevice->GetObject<LoraNetDevice> ();
548 Ptr<GatewayLoraPhy> gatewayPhy = gatewayLoraNetDevice->GetPhy ()->GetObject<GatewayLoraPhy>
549 (); const double *gwSensitivity = gatewayPhy->sensitivity;
550
551 if(rxPower > *gwSensitivity)
552 {
553 mac->SetDataRate (5);
554 sfQuantity[0] = sfQuantity[0] + 1;
555
556 }
557 else if (rxPower > *(gwSensitivity+1))
558 {
559 mac->SetDataRate (4);
560 sfQuantity[1] = sfQuantity[1] + 1;
561
562 }
563 else if (rxPower > *(gwSensitivity+2))
564 {
565 mac->SetDataRate (3);
566 sfQuantity[2] = sfQuantity[2] + 1;
567
568 }
569 else if (rxPower > *(gwSensitivity+3))
570 {
571 mac->SetDataRate (2);
572 sfQuantity[3] = sfQuantity[3] + 1;
573 }
574 else if (rxPower > *(gwSensitivity+4))
575 {
576 mac->SetDataRate (1);
577 sfQuantity[4] = sfQuantity[4] + 1;
578 }
579 else if (rxPower > *(gwSensitivity+5))
580 {
581 mac->SetDataRate (0);
582 sfQuantity[5] = sfQuantity[5] + 1;
583
584 }
585 else // Device is out of range. Assign SF12.
586 {
587 mac->SetDataRate (0);
588 sfQuantity[6] = sfQuantity[6] + 1;
589
590 }
591 */
592
593 } // end loop on nodes
594
595 return sfQuantity;
596
597} // end function
598
599std::vector<int>
601 NodeContainer gateways,
602 std::vector<double> distribution)
603{
605 NS_ASSERT(distribution.size() == 6);
606
607 std::vector<int> sfQuantity(7, 0);
608 Ptr<UniformRandomVariable> uniformRV = CreateObject<UniformRandomVariable>();
609 std::vector<double> cumdistr(6);
610 cumdistr[0] = distribution[0];
611 for (int i = 1; i < 6; ++i)
612 {
613 cumdistr[i] = distribution[i] + cumdistr[i - 1];
614 }
615
616 NS_LOG_DEBUG("Distribution: " << distribution[0] << " " << distribution[1] << " "
617 << distribution[2] << " " << distribution[3] << " "
618 << distribution[4] << " " << distribution[5]);
619 NS_LOG_DEBUG("Cumulative distribution: " << cumdistr[0] << " " << cumdistr[1] << " "
620 << cumdistr[2] << " " << cumdistr[3] << " "
621 << cumdistr[4] << " " << cumdistr[5]);
622
623 for (auto j = endDevices.Begin(); j != endDevices.End(); ++j)
624 {
625 Ptr<Node> object = *j;
626 Ptr<MobilityModel> position = object->GetObject<MobilityModel>();
627 NS_ASSERT(position);
628 Ptr<NetDevice> netDevice = object->GetDevice(0);
629 Ptr<LoraNetDevice> loraNetDevice = netDevice->GetObject<LoraNetDevice>();
630 NS_ASSERT(loraNetDevice);
632 loraNetDevice->GetMac()->GetObject<ClassAEndDeviceLorawanMac>();
633 NS_ASSERT(mac);
634
635 double prob = uniformRV->GetValue(0, 1);
636
637 // NS_LOG_DEBUG ("Probability: " << prob);
638 if (prob < cumdistr[0])
639 {
640 mac->SetDataRate(5);
641 sfQuantity[0] = sfQuantity[0] + 1;
642 }
643 else if (prob > cumdistr[0] && prob < cumdistr[1])
644 {
645 mac->SetDataRate(4);
646 sfQuantity[1] = sfQuantity[1] + 1;
647 }
648 else if (prob > cumdistr[1] && prob < cumdistr[2])
649 {
650 mac->SetDataRate(3);
651 sfQuantity[2] = sfQuantity[2] + 1;
652 }
653 else if (prob > cumdistr[2] && prob < cumdistr[3])
654 {
655 mac->SetDataRate(2);
656 sfQuantity[3] = sfQuantity[3] + 1;
657 }
658 else if (prob > cumdistr[3] && prob < cumdistr[4])
659 {
660 mac->SetDataRate(1);
661 sfQuantity[4] = sfQuantity[4] + 1;
662 }
663 else
664 {
665 mac->SetDataRate(0);
666 sfQuantity[5] = sfQuantity[5] + 1;
667 }
668
669 } // end loop on nodes
670
671 return sfQuantity;
672
673} // end function
674
675} // namespace lorawan
676} // namespace ns3
Hold a value for an Attribute.
Definition: attribute.h:70
Keep track of the current position and velocity of an object.
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:522
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Class representing the MAC layer of a Class A LoRaWAN device.
Class representing a LoRa transceiver.
Class modeling a Lora SX1301 chip.
Class representing the MAC layer of a LoRaWAN gateway.
This class supports LorawanMac instances by managing a list of the logical channels that the device i...
void AddSubBand(double firstFrequency, double lastFrequency, double dutyCycle, double maxTxPowerDbm)
Add a new SubBand to this helper.
void AddChannel(double frequency)
Add a new channel to the list.
Hold together all LoRa related objects.
Helper class for configuring and installing the LorawanMac class on devices and gateways.
void ConfigureForAlohaRegion(Ptr< ClassAEndDeviceLorawanMac > edMac) const
Perform region-specific configurations for the ALOHA band.
LorawanMacHelper()
Default constructor.
void SetDeviceType(enum DeviceType dt)
Set the kind of MAC this helper will create.
void SetAddressGenerator(Ptr< LoraDeviceAddressGenerator > addrGen)
Set the address generator to use for creation of these nodes.
static std::vector< int > SetSpreadingFactorsUp(NodeContainer endDevices, NodeContainer gateways, Ptr< LoraChannel > channel)
Initialize the end devices' data rate parameter.
void ApplyCommonEuConfigurations(Ptr< LorawanMac > lorawanMac) const
Apply configurations that are common both for the GatewayLorawanMac and the ClassAEndDeviceLorawanMac...
enum Regions m_region
The region in which the device will operate.
Regions
Define the operational region.
void SetRegion(enum Regions region)
Set the region in which the device is to operate.
void Set(std::string name, const AttributeValue &v)
Set an attribute of the underlying MAC object.
ObjectFactory m_mac
MAC-layer object factory.
Ptr< LorawanMac > Create(Ptr< Node > node, Ptr< NetDevice > device) const
Create the LorawanMac instance and connect it to a device.
static std::vector< int > SetSpreadingFactorsGivenDistribution(NodeContainer endDevices, NodeContainer gateways, std::vector< double > distribution)
Randomly initialize the end devices' data rate parameter according to the given distribution.
Ptr< LoraDeviceAddressGenerator > m_addrGen
Pointer to the address generator to use.
void ConfigureForSingleChannelRegion(Ptr< ClassAEndDeviceLorawanMac > edMac) const
Perform region-specific configurations for the SINGLECHANNEL band.
void ApplyCommonSingleChannelConfigurations(Ptr< LorawanMac > lorawanMac) const
Apply configurations that are common both for the GatewayLorawanMac and the ClassAEndDeviceLorawanMac...
DeviceType
Define the kind of device.
void ApplyCommonAlohaConfigurations(Ptr< LorawanMac > lorawanMac) const
Apply configurations that are common both for the GatewayLorawanMac and the ClassAEndDeviceLorawanMac...
enum DeviceType m_deviceType
The kind of device to install.
void ConfigureForEuRegion(Ptr< ClassAEndDeviceLorawanMac > edMac) const
Perform region-specific configurations for the 868 MHz EU band.
Class representing the LoRaWAN MAC layer.
Definition: lorawan-mac.h:48
std::array< std::array< uint8_t, 6 >, 8 > ReplyDataRateMatrix
Matrix structure to store possible data rate value to be used by a LoRaWAN end device for listening d...
Definition: lorawan-mac.h:64
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:254
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.