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