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