A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mac-command.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 University of Padova
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Davide Magrin <magrinda@dei.unipd.it>
7 */
8
9#ifndef MAC_COMMAND_H
10#define MAC_COMMAND_H
11
12#include "ns3/buffer.h"
13#include "ns3/nstime.h"
14#include "ns3/object.h"
15
16namespace ns3
17{
18namespace lorawan
19{
20
21/**
22 * Enum for every possible command type
23 */
46
47/**
48 * @ingroup lorawan
49 *
50 * This base class is used to represent a general MAC command.
51 *
52 * Pure virtual methods that handle serialization, deserialization and other
53 * common features are supposed to be defined in detail by child classes, based
54 * on that MAC command's attributes and structure.
55 */
56class MacCommand : public Object
57{
58 public:
59 /**
60 * Register this type.
61 * @return The object TypeId.
62 */
63 static TypeId GetTypeId();
64
65 MacCommand(); //!< Default constructor
66 ~MacCommand() override; //!< Destructor
67
68 /**
69 * Serialize the contents of this MAC command into a buffer, according to the
70 * LoRaWAN standard.
71 *
72 * @param start A pointer to the buffer into which to serialize the command.
73 */
74 virtual void Serialize(Buffer::Iterator& start) const = 0;
75
76 /**
77 * Deserialize the buffer into a MAC command.
78 *
79 * @param start A pointer to the buffer that contains the serialized command.
80 * @return The number of bytes that were consumed.
81 */
82 virtual uint8_t Deserialize(Buffer::Iterator& start) = 0;
83
84 /**
85 * Print the contents of this MAC command in human-readable format.
86 *
87 * @param os The std::ostream instance on which to print the MAC command.
88 */
89 virtual void Print(std::ostream& os) const = 0;
90
91 /**
92 * Get serialized length of this MAC command.
93 *
94 * @return The number of bytes the MAC command takes up.
95 */
96 virtual uint8_t GetSerializedSize() const;
97
98 /**
99 * Get the commandType of this MAC command.
100 *
101 * @return The type of MAC command this object represents.
102 */
103 virtual enum MacCommandType GetCommandType() const;
104
105 /**
106 * Get the CID that corresponds to a type of MAC command.
107 *
108 * @param commandType The type of MAC command.
109 * @return The CID as a uint8_t type.
110 */
111 static uint8_t GetCIDFromMacCommand(enum MacCommandType commandType);
112
113 protected:
114 enum MacCommandType m_commandType; //!< The type of this command.
115 uint8_t m_serializedSize; //!< This MAC command's serialized size.
116};
117
118/**
119 * @ingroup lorawan
120 *
121 * Implementation of the LinkCheckReq LoRaWAN MAC command.
122 *
123 * This command holds no variables, and just consists in the CID.
124 */
126{
127 public:
128 LinkCheckReq(); //!< Default constructor
129
130 void Serialize(Buffer::Iterator& start) const override;
131 uint8_t Deserialize(Buffer::Iterator& start) override;
132 void Print(std::ostream& os) const override;
133};
134
135/**
136 * @ingroup lorawan
137 *
138 * Implementation of the LinkCheckAns LoRaWAN MAC command.
139 *
140 * This command contains the demodulation margin and the number of receiving
141 * gateways of the packet containing the LinkCheckReq command.
142 */
144{
145 public:
146 LinkCheckAns(); //!< Default constructor
147
148 /**
149 * Constructor with given fields.
150 *
151 * @param margin The demodulation margin to set.
152 * @param gwCnt The gateway count to set.
153 */
154 LinkCheckAns(uint8_t margin, uint8_t gwCnt);
155
156 void Serialize(Buffer::Iterator& start) const override;
157 uint8_t Deserialize(Buffer::Iterator& start) override;
158 void Print(std::ostream& os) const override;
159
160 /**
161 * Get the demodulation margin value.
162 *
163 * @return The demodulation margin value.
164 */
165 uint8_t GetMargin() const;
166
167 /**
168 * Get the gateway count value.
169 *
170 * @return The gateway count value.
171 */
172 uint8_t GetGwCnt() const;
173
174 private:
175 uint8_t m_margin; //!< This MAC command's demodulation margin value.
176 uint8_t m_gwCnt; //!< This MAC command's gateway count value.
177};
178
179/**
180 * @ingroup lorawan
181 *
182 * Implementation of the LinkAdrReq LoRaWAN MAC command.
183 *
184 * With this command, the network server can request a device to change its
185 * data rate, transmission power and the channel it uses for uplink
186 * transmissions.
187 */
188class LinkAdrReq : public MacCommand
189{
190 public:
191 LinkAdrReq(); //!< Default constructor
192
193 /**
194 * Constructor with given fields.
195 *
196 * The parameters of this constructor are serializable fields of the MAC command specified by
197 * the LoRaWAN protocol. They represent MAC and PHY layer configurations to be applied by the
198 * receiving end device. See, [LoRaWAN® L2 1.0.4 Specification (TS001-1.0.4)] and [LoRaWAN®
199 * Regional Parameters RP002-1.0.4] for more details on how the fields are used and which
200 * physical values they stand for.
201 *
202 * @param dataRate The DataRate field to set.
203 * @param txPower The TXPower field to set.
204 * @param chMask The ChMask field to set.
205 * @param chMaskCntl The ChMaskCntl field to set.
206 * @param nbTrans The NbTrans field to set.
207 */
208 LinkAdrReq(uint8_t dataRate,
209 uint8_t txPower,
210 uint16_t chMask,
211 uint8_t chMaskCntl,
212 uint8_t nbTrans);
213
214 void Serialize(Buffer::Iterator& start) const override;
215 uint8_t Deserialize(Buffer::Iterator& start) override;
216 void Print(std::ostream& os) const override;
217
218 /**
219 * Return the data rate prescribed by this MAC command.
220 *
221 * @return An unsigned 8-bit integer containing the data rate.
222 */
223 uint8_t GetDataRate() const;
224
225 /**
226 * Get the transmission power prescribed by this MAC command.
227 *
228 * The MAC layer is expected to translate this value to a certain power in
229 * dBm when communicating it to the PHY, and the translation will vary based
230 * on the region of the device.
231 *
232 * @return The TX power, encoded as an unsigned 8-bit integer.
233 */
234 uint8_t GetTxPower() const;
235
236 /**
237 * Get the 16 bit mask of enabled channels.
238 *
239 * @return The 16 bit channel mask.
240 */
241 uint16_t GetChMask() const;
242
243 /**
244 * Get the ChMaskCntl field, used as an indicator of the 16-channel bank to apply the ChMask to.
245 *
246 * The interpretation of this field is region-dependent.
247 *
248 * @return The ChMaskCntl field.
249 */
250 uint8_t GetChMaskCntl() const;
251
252 /**
253 * Get the number of repeated transmissions prescribed by this MAC command.
254 *
255 * @return The number of repeated transmissions.
256 */
257 uint8_t GetNbTrans() const;
258
259 private:
260 uint8_t m_dataRate; //!< The DataRate field, a serializable parameter for setting the
261 //!< spreading factor and bandwidth of end devices
262 uint8_t m_txPower; //!< The TXPower field, a serializable parameter for setting the
263 //!< transmission power of end devices
264 uint16_t m_chMask; //!< The ChMask field
265 uint8_t m_chMaskCntl; //!< The ChMaskCntl field
266 uint8_t m_nbTrans; //!< The NbTrans field
267};
268
269/**
270 * @ingroup lorawan
271 *
272 * Implementation of the LinkAdrAns LoRaWAN MAC command.
273 *
274 * With this command, the end device acknowledges a LinkAdrReq.
275 */
276class LinkAdrAns : public MacCommand
277{
278 public:
279 LinkAdrAns(); //!< Default constructor
280
281 /**
282 * Constructor with given fields.
283 *
284 * @param powerAck The PowerACK field to set.
285 * @param dataRateAck The DataRateACK field to set.
286 * @param channelMaskAck The ChannelMaskACK field to set.
287 */
288 LinkAdrAns(bool powerAck, bool dataRateAck, bool channelMaskAck);
289
290 void Serialize(Buffer::Iterator& start) const override;
291 uint8_t Deserialize(Buffer::Iterator& start) override;
292 void Print(std::ostream& os) const override;
293
294 /**
295 * Get the PowerAck field value of the LinkAdrAns command.
296 *
297 * @return true The power level was successfully set.
298 * @return false The end-device is unable to operate at or below the requested power level. The
299 * command was discarded and the end-device state was not changed.
300 */
301 bool GetPowerAck() const;
302
303 /**
304 * Get the DataRateAck field value of the LinkAdrAns command.
305 *
306 * @return true The data rate was successfully set.
307 * @return false The data rate requested is unknown to the end-device or is not possible, given
308 * the channel mask provided (not supported by any of the enabled channels). The command was
309 * discarded, and the end-device state was not changed.
310 */
311 bool GetDataRateAck() const;
312
313 /**
314 * Get the ChannelMaskAck field value of the LinkAdrAns command.
315 *
316 * @return true The channel mask sent was successfully interpreted. All currently defined
317 * channel states were set according to the mask.
318 * @return false The channel mask enables a yet undefined channel or the channel mask required
319 * all channels to be disabled or the channel mask is incompatible with the resulting data rate
320 * or TX power. The command was discarded, and the end-device state was not changed.
321 */
322 bool GetChannelMaskAck() const;
323
324 private:
325 bool m_powerAck; //!< The PowerACK field
326 bool m_dataRateAck; //!< The DataRateACK field
327 bool m_channelMaskAck; //!< The ChannelMaskACK field
328};
329
330/**
331 * @ingroup lorawan
332 *
333 * Implementation of the DutyCycleReq LoRaWAN MAC command.
334 *
335 * With this command, the network server can limit the maximum aggregated
336 * transmit duty cycle of an end device. The aggregate duty cycle is computed
337 * as the duty cycle among all sub bands.
338 */
340{
341 public:
342 DutyCycleReq(); //!< Default constructor
343
344 /**
345 * Constructor providing initialization of all parameters.
346 *
347 * @param maxDutyCycle The MaxDutyCycle field as a 8-bit unsigned integer.
348 */
349 DutyCycleReq(uint8_t maxDutyCycle);
350
351 void Serialize(Buffer::Iterator& start) const override;
352 uint8_t Deserialize(Buffer::Iterator& start) override;
353 void Print(std::ostream& os) const override;
354
355 /**
356 * Get the maximum duty cycle prescribed by this Mac command, encoded in 4 bits.
357 *
358 * @return The MaxDutyCycle field value.
359 */
360 uint8_t GetMaxDutyCycle() const;
361
362 private:
363 uint8_t m_maxDutyCycle; //!< The MaxDutyCycle field
364};
365
366/**
367 * @ingroup lorawan
368 *
369 * Implementation of the DutyCycleAns LoRaWAN MAC command.
370 *
371 * This command holds no variables, and just consists in the CID.
372 */
374{
375 public:
376 DutyCycleAns(); //!< Default constructor
377
378 void Serialize(Buffer::Iterator& start) const override;
379 uint8_t Deserialize(Buffer::Iterator& start) override;
380 void Print(std::ostream& os) const override;
381};
382
383/**
384 * @ingroup lorawan
385 *
386 * Implementation of the RxParamSetupReq LoRaWAN MAC command.
387 */
389{
390 public:
391 RxParamSetupReq(); //!< Default constructor
392
393 /**
394 * Constructor providing initialization of all fields.
395 *
396 * @param rx1DrOffset The data rate offset to use for the first receive window.
397 * @param rx2DataRate The data rate to use for the second receive window.
398 * @param frequencyHz The frequency in Hz to use for the second receive window.
399 */
400 RxParamSetupReq(uint8_t rx1DrOffset, uint8_t rx2DataRate, uint32_t frequencyHz);
401
402 void Serialize(Buffer::Iterator& start) const override;
403 uint8_t Deserialize(Buffer::Iterator& start) override;
404 void Print(std::ostream& os) const override;
405
406 /**
407 * Get this command's Rx1DrOffset parameter.
408 *
409 * @return The Rx1DrOffset parameter.
410 */
411 uint8_t GetRx1DrOffset();
412
413 /**
414 * Get this command's Rx2DataRate parameter.
415 *
416 * @return The Rx2DataRate parameter.
417 */
418 uint8_t GetRx2DataRate();
419
420 /**
421 * Get this command's frequency.
422 *
423 * @return The frequency parameter, in Hz.
424 */
426
427 private:
428 uint8_t m_rx1DrOffset; //!< The RX1DROffset field
429 uint8_t m_rx2DataRate; //!< The RX2DataRate field
430 uint32_t m_frequencyHz; //!< The Frequency field, _in Hz_
431};
432
433/**
434 * @ingroup lorawan
435 *
436 * Implementation of the RxParamSetupAns LoRaWAN MAC command.
437 */
439{
440 public:
441 RxParamSetupAns(); //!< Default constructor
442
443 /**
444 * Constructor with initialization of all parameters.
445 *
446 * @param rx1DrOffsetAck Whether or not the offset was correctly set.
447 * @param rx2DataRateAck Whether or not the second slot data rate was correctly set.
448 * @param channelAck Whether or not the second slot frequency was correctly set.
449 */
450 RxParamSetupAns(bool rx1DrOffsetAck, bool rx2DataRateAck, bool channelAck);
451
452 void Serialize(Buffer::Iterator& start) const override;
453 uint8_t Deserialize(Buffer::Iterator& start) override;
454 void Print(std::ostream& os) const override;
455
456 /**
457 * Get the Rx1DrOffsetAck field value of the RxParamSetupAns command.
458 *
459 * @return true RX1 data-rate offset was successfully set.
460 * @return false The uplink/downlink data rate offset for RX1 slot is not within the allowed
461 * range.
462 */
463 bool GetRx1DrOffsetAck() const;
464
465 /**
466 * Get the Rx2DataRateAck field value of the RxParamSetupAns command.
467 *
468 * @return true RX2 slot data rate was successfully set.
469 * @return false The data rate requested is unknown to the end-device.
470 */
471 bool GetRx2DataRateAck() const;
472
473 /**
474 * Get the ChannelAck field value of the RxParamSetupAns command.
475 *
476 * @return true RX2 slot channel was successfully set.
477 * @return false The frequency requested is not usable by the end-device.
478 */
479 bool GetChannelAck() const;
480
481 private:
482 bool m_rx1DrOffsetAck; //!< The RX1DROffsetACK field
483 bool m_rx2DataRateAck; //!< The RX2DataRateACK field
484 bool m_channelAck; //!< The ChannelACK field
485};
486
487/**
488 * @ingroup lorawan
489 *
490 * Implementation of the DevStatusReq LoRaWAN MAC command.
491 *
492 * This command holds no variables, and just consists in the CID.
493 */
495{
496 public:
497 DevStatusReq(); //!< Default constructor
498
499 void Serialize(Buffer::Iterator& start) const override;
500 uint8_t Deserialize(Buffer::Iterator& start) override;
501 void Print(std::ostream& os) const override;
502};
503
504/**
505 * @ingroup lorawan
506 *
507 * Implementation of the DevStatusAns LoRaWAN MAC command.
508 */
510{
511 public:
512 DevStatusAns(); //!< Default constructor
513
514 /**
515 * Constructor with initialization of all parameters.
516 *
517 * @param battery The battery level in [0, 255].
518 * @param margin The demodulation margin of the last received DevStatusReq packet.
519 */
520 DevStatusAns(uint8_t battery, uint8_t margin);
521
522 void Serialize(Buffer::Iterator& start) const override;
523 uint8_t Deserialize(Buffer::Iterator& start) override;
524 void Print(std::ostream& os) const override;
525
526 /**
527 * Get the battery information contained in this MAC command.
528 *
529 * @return The battery level.
530 */
531 uint8_t GetBattery() const;
532
533 /**
534 * Get the demodulation margin contained in this MAC command.
535 *
536 * @return The margin.
537 */
538 uint8_t GetMargin() const;
539
540 private:
541 uint8_t m_battery; //!< The Battery field
542 uint8_t m_margin; //!< The RadioStatus field
543};
544
545/**
546 * @ingroup lorawan
547 *
548 * Implementation of the NewChannelReq LoRaWAN MAC command.
549 */
551{
552 public:
553 NewChannelReq(); //!< Default constructor
554
555 /**
556 * Constructor providing initialization of all parameters.
557 *
558 * @param chIndex The index of the channel this command wants to operate on.
559 * @param frequencyHz The new frequency for this channel in Hz.
560 * @param minDataRate The minimum data rate allowed on this channel.
561 * @param maxDataRate The maximum data rate allowed on this channel.
562 */
563 NewChannelReq(uint8_t chIndex, uint32_t frequencyHz, uint8_t minDataRate, uint8_t maxDataRate);
564
565 void Serialize(Buffer::Iterator& start) const override;
566 uint8_t Deserialize(Buffer::Iterator& start) override;
567 void Print(std::ostream& os) const override;
568
569 /**
570 * Get the the ChIndex field contained in this MAC command.
571 *
572 * @return The ChIndex field.
573 */
574 uint8_t GetChannelIndex() const;
575 /**
576 * Get the the Frequency field contained in this MAC command.
577 *
578 * @return The Frequency field in Hz.
579 */
580 uint32_t GetFrequency() const;
581 /**
582 * Get the the MinDR field contained in this MAC command.
583 *
584 * @return The MinDR field.
585 */
586 uint8_t GetMinDataRate() const;
587 /**
588 * Get the the MaxDR field contained in this MAC command.
589 *
590 * @return The MaxDR field.
591 */
592 uint8_t GetMaxDataRate() const;
593
594 private:
595 uint8_t m_chIndex; //!< The ChIndex field
596 uint32_t m_frequencyHz; //!< The Frequency field, in Hz
597 uint8_t m_minDataRate; //!< The MinDR field
598 uint8_t m_maxDataRate; //!< The MaxDR field
599};
600
601/**
602 * @ingroup lorawan
603 *
604 * Implementation of the NewChannelAns LoRaWAN MAC command.
605 */
607{
608 public:
609 NewChannelAns(); //!< Default constructor
610
611 /**
612 * Constructor providing initialization of all parameters.
613 *
614 * @param dataRateRangeOk Whether or not the requested data rate range was set
615 * correctly.
616 * @param channelFrequencyOk Whether or not the requested channel frequency
617 * was set correctly.
618 */
619 NewChannelAns(bool dataRateRangeOk, bool channelFrequencyOk);
620
621 void Serialize(Buffer::Iterator& start) const override;
622 uint8_t Deserialize(Buffer::Iterator& start) override;
623 void Print(std::ostream& os) const override;
624
625 /**
626 * Get the DataRateRangOk field of the NewChannelAns command.
627 *
628 * @return true The data-rate range is compatible with the capabilities of the end-device.
629 * @return false The designated data-rate range exceeds the ones currently defined for this
630 * end-device.
631 */
632 bool GetDataRateRangeOk() const;
633
634 /**
635 * Get the ChannelFrequencyOk field of the NewChannelAns command.
636 *
637 * @return true The end-device is able to use this frequency.
638 * @return false The end-device cannot use this frequency.
639 */
640 bool GetChannelFrequencyOk() const;
641
642 private:
643 bool m_dataRateRangeOk; //!< The Data-rate range ok field
644 bool m_channelFrequencyOk; //!< The Channel frequency ok field
645};
646
647/**
648 * @ingroup lorawan
649 *
650 * Implementation of the RxTimingSetupReq LoRaWAN MAC command.
651 */
653{
654 public:
655 RxTimingSetupReq(); //!< Default constructor
656
657 /**
658 * Constructor providing initialization of all parameters.
659 *
660 * @param delay The delay encoded in this MAC command.
661 */
662 RxTimingSetupReq(uint8_t delay);
663
664 void Serialize(Buffer::Iterator& start) const override;
665 uint8_t Deserialize(Buffer::Iterator& start) override;
666 void Print(std::ostream& os) const override;
667
668 /**
669 * Get the first window delay as a Time instance.
670 *
671 * @return The delay.
672 */
673 Time GetDelay();
674
675 private:
676 uint8_t m_delay; //!< The Del field
677};
678
679/**
680 * @ingroup lorawan
681 *
682 * Implementation of the RxTimingSetupAns LoRaWAN MAC command.
683 *
684 * This command holds no variables, and just consists in the CID.
685 */
687{
688 public:
689 RxTimingSetupAns(); //!< Default constructor
690
691 void Serialize(Buffer::Iterator& start) const override;
692 uint8_t Deserialize(Buffer::Iterator& start) override;
693 void Print(std::ostream& os) const override;
694
695 private:
696};
697
698/**
699 * @ingroup lorawan
700 *
701 * Implementation of the TxParamSetupReq LoRaWAN MAC command.
702 *
703 * @todo implementation
704 */
706{
707 public:
708 TxParamSetupReq(); //!< Default constructor
709
710 void Serialize(Buffer::Iterator& start) const override;
711 uint8_t Deserialize(Buffer::Iterator& start) override;
712 void Print(std::ostream& os) const override;
713
714 private:
715};
716
717/**
718 * @ingroup lorawan
719 *
720 * Implementation of the TxParamSetupAns LoRaWAN MAC command.
721 *
722 * This command holds no variables, and just consists in the CID.
723 */
725{
726 public:
727 TxParamSetupAns(); //!< Default constructor
728
729 void Serialize(Buffer::Iterator& start) const override;
730 uint8_t Deserialize(Buffer::Iterator& start) override;
731 void Print(std::ostream& os) const override;
732
733 private:
734};
735
736/**
737 * @ingroup lorawan
738 *
739 * Implementation of the DlChannelAns LoRaWAN MAC command.
740 *
741 * @todo implementation
742 */
744{
745 public:
746 DlChannelAns(); //!< Default constructor
747
748 void Serialize(Buffer::Iterator& start) const override;
749 uint8_t Deserialize(Buffer::Iterator& start) override;
750 void Print(std::ostream& os) const override;
751
752 private:
753};
754} // namespace lorawan
755
756} // namespace ns3
757#endif /* DEVICE_STATUS_H */
iterator in a Buffer instance
Definition buffer.h:89
A base class which provides memory management and object aggregation.
Definition object.h:78
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:49
Implementation of the DevStatusAns LoRaWAN MAC command.
uint8_t GetMargin() const
Get the demodulation margin contained in this MAC command.
DevStatusAns()
Default constructor.
uint8_t m_battery
The Battery field.
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
uint8_t GetBattery() const
Get the battery information contained in this MAC command.
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
uint8_t m_margin
The RadioStatus field.
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
Implementation of the DevStatusReq LoRaWAN MAC command.
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
DevStatusReq()
Default constructor.
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
Implementation of the DlChannelAns LoRaWAN MAC command.
DlChannelAns()
Default constructor.
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
Implementation of the DutyCycleAns LoRaWAN MAC command.
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
DutyCycleAns()
Default constructor.
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
Implementation of the DutyCycleReq LoRaWAN MAC command.
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
DutyCycleReq()
Default constructor.
uint8_t GetMaxDutyCycle() const
Get the maximum duty cycle prescribed by this Mac command, encoded in 4 bits.
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
uint8_t m_maxDutyCycle
The MaxDutyCycle field.
This base class is used to represent a general MAC command.
Definition mac-command.h:57
virtual enum MacCommandType GetCommandType() const
Get the commandType of this MAC command.
virtual void Serialize(Buffer::Iterator &start) const =0
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual uint8_t GetSerializedSize() const
Get serialized length of this MAC command.
virtual void Print(std::ostream &os) const =0
Print the contents of this MAC command in human-readable format.
uint8_t m_serializedSize
This MAC command's serialized size.
enum MacCommandType m_commandType
The type of this command.
static uint8_t GetCIDFromMacCommand(enum MacCommandType commandType)
Get the CID that corresponds to a type of MAC command.
static TypeId GetTypeId()
Register this type.
~MacCommand() override
Destructor.
MacCommand()
Default constructor.
virtual uint8_t Deserialize(Buffer::Iterator &start)=0
Deserialize the buffer into a MAC command.
Implementation of the NewChannelAns LoRaWAN MAC command.
bool GetDataRateRangeOk() const
Get the DataRateRangOk field of the NewChannelAns command.
bool m_channelFrequencyOk
The Channel frequency ok field.
NewChannelAns()
Default constructor.
bool m_dataRateRangeOk
The Data-rate range ok field.
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
bool GetChannelFrequencyOk() const
Get the ChannelFrequencyOk field of the NewChannelAns command.
Implementation of the NewChannelReq LoRaWAN MAC command.
uint8_t GetMinDataRate() const
Get the the MinDR field contained in this MAC command.
NewChannelReq()
Default constructor.
uint8_t GetMaxDataRate() const
Get the the MaxDR field contained in this MAC command.
uint8_t m_maxDataRate
The MaxDR field.
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
uint8_t m_minDataRate
The MinDR field.
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
uint32_t GetFrequency() const
Get the the Frequency field contained in this MAC command.
uint8_t GetChannelIndex() const
Get the the ChIndex field contained in this MAC command.
uint8_t m_chIndex
The ChIndex field.
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
uint32_t m_frequencyHz
The Frequency field, in Hz.
Implementation of the RxParamSetupAns LoRaWAN MAC command.
RxParamSetupAns()
Default constructor.
bool m_rx2DataRateAck
The RX2DataRateACK field.
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
bool GetRx1DrOffsetAck() const
Get the Rx1DrOffsetAck field value of the RxParamSetupAns command.
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
bool m_channelAck
The ChannelACK field.
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
bool GetRx2DataRateAck() const
Get the Rx2DataRateAck field value of the RxParamSetupAns command.
bool m_rx1DrOffsetAck
The RX1DROffsetACK field.
bool GetChannelAck() const
Get the ChannelAck field value of the RxParamSetupAns command.
Implementation of the RxParamSetupReq LoRaWAN MAC command.
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
uint8_t GetRx1DrOffset()
Get this command's Rx1DrOffset parameter.
uint8_t m_rx2DataRate
The RX2DataRate field.
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
uint8_t GetRx2DataRate()
Get this command's Rx2DataRate parameter.
uint32_t m_frequencyHz
The Frequency field, in Hz
uint8_t m_rx1DrOffset
The RX1DROffset field.
uint32_t GetFrequency()
Get this command's frequency.
RxParamSetupReq()
Default constructor.
Implementation of the RxTimingSetupAns LoRaWAN MAC command.
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
RxTimingSetupAns()
Default constructor.
Implementation of the RxTimingSetupReq LoRaWAN MAC command.
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
uint8_t m_delay
The Del field.
Time GetDelay()
Get the first window delay as a Time instance.
RxTimingSetupReq()
Default constructor.
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
Implementation of the TxParamSetupAns LoRaWAN MAC command.
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
TxParamSetupAns()
Default constructor.
Implementation of the TxParamSetupReq LoRaWAN MAC command.
TxParamSetupReq()
Default constructor.
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
MacCommandType
Enum for every possible command type.
Definition mac-command.h:25
Every class exported by the ns3 library is enclosed in the ns3 namespace.