A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
mac-command.cc
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#include "mac-command.h"
10
11#include <bitset>
12
13namespace ns3
14{
15namespace lorawan
16{
17
18NS_LOG_COMPONENT_DEFINE("MacCommand");
19
24
28
31{
32 NS_LOG_FUNCTION(this);
33 return m_commandType;
34}
35
36uint8_t
42
43uint8_t
45{
47 switch (commandType)
48 {
49 case (INVALID): {
50 return 0x0;
51 }
52 case (LINK_CHECK_REQ):
53 case (LINK_CHECK_ANS): {
54 return 0x02;
55 }
56 case (LINK_ADR_REQ):
57 case (LINK_ADR_ANS): {
58 return 0x03;
59 }
60 case (DUTY_CYCLE_REQ):
61 case (DUTY_CYCLE_ANS): {
62 return 0x04;
63 }
64 case (RX_PARAM_SETUP_REQ):
65 case (RX_PARAM_SETUP_ANS): {
66 return 0x05;
67 }
68 case (DEV_STATUS_REQ):
69 case (DEV_STATUS_ANS): {
70 return 0x06;
71 }
72 case (NEW_CHANNEL_REQ):
73 case (NEW_CHANNEL_ANS): {
74 return 0x07;
75 }
77 case (RX_TIMING_SETUP_ANS): {
78 return 0x08;
79 }
80 case (TX_PARAM_SETUP_REQ):
81 case (TX_PARAM_SETUP_ANS): {
82 return 0x09;
83 }
84 case (DL_CHANNEL_REQ):
85 case (DL_CHANNEL_ANS): {
86 return 0x0A;
87 }
88 }
89 return 0;
90}
91
92//////////////////
93// LinkCheckReq //
94//////////////////
95
102
103void
105{
106 NS_LOG_FUNCTION(this);
107 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
108}
109
110uint8_t
112{
113 NS_LOG_FUNCTION(this);
114 start.ReadU8(); // Consume the CID
115 return m_serializedSize;
116}
117
118void
119LinkCheckReq::Print(std::ostream& os) const
120{
121 NS_LOG_FUNCTION(this);
122 os << "LinkCheckReq()";
123}
124
125//////////////////
126// LinkCheckAns //
127//////////////////
128
135
136LinkCheckAns::LinkCheckAns(uint8_t margin, uint8_t gwCnt)
137 : m_margin(margin),
138 m_gwCnt(gwCnt)
139{
140 NS_LOG_FUNCTION(this << unsigned(margin) << unsigned(gwCnt));
143}
144
145void
147{
148 NS_LOG_FUNCTION(this);
149 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
150 start.WriteU8(m_margin); // Write the margin
151 start.WriteU8(m_gwCnt); // Write the gwCnt
152}
153
154uint8_t
156{
157 NS_LOG_FUNCTION(this);
158 start.ReadU8(); // Consume the CID
159 m_margin = start.ReadU8();
160 m_gwCnt = start.ReadU8();
161 return m_serializedSize;
162}
163
164void
165LinkCheckAns::Print(std::ostream& os) const
166{
167 NS_LOG_FUNCTION(this);
168 os << "LinkCheckAns(";
169 os << "Margin=" << unsigned(m_margin);
170 os << ", GwCnt=" << unsigned(m_gwCnt);
171 os << ")";
172}
173
174uint8_t
176{
177 NS_LOG_FUNCTION(this);
178 return m_margin;
179}
180
181uint8_t
183{
184 NS_LOG_FUNCTION(this);
185
186 return m_gwCnt;
187}
188
189////////////////
190// LinkAdrReq //
191////////////////
192
199
200LinkAdrReq::LinkAdrReq(uint8_t dataRate,
201 uint8_t txPower,
202 uint16_t chMask,
203 uint8_t chMaskCntl,
204 uint8_t nbTrans)
205 : m_dataRate(dataRate),
206 m_txPower(txPower),
207 m_chMask(chMask),
208 m_chMaskCntl(chMaskCntl),
209 m_nbTrans(nbTrans)
210{
211 NS_LOG_FUNCTION(this);
212 NS_ASSERT_MSG(!(dataRate & 0xF0), "dataRate field > 4 bits");
213 NS_ASSERT_MSG(!(txPower & 0xF0), "txPower field > 4 bits");
214 NS_ASSERT_MSG(!(chMaskCntl & 0xF8), "chMaskCntl field > 3 bits");
215 NS_ASSERT_MSG(!(nbTrans & 0xF0), "nbTrans field > 4 bits");
218}
219
220void
222{
223 NS_LOG_FUNCTION(this);
224 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
225 start.WriteU8(m_dataRate << 4 | (m_txPower & 0b1111));
226 start.WriteU16(m_chMask);
227 start.WriteU8(m_chMaskCntl << 4 | (m_nbTrans & 0b1111));
228}
229
230uint8_t
232{
233 NS_LOG_FUNCTION(this);
234 start.ReadU8(); // Consume the CID
235 uint8_t firstByte = start.ReadU8();
236 m_dataRate = firstByte >> 4;
237 m_txPower = firstByte & 0b1111;
238 m_chMask = start.ReadU16();
239 uint8_t fourthByte = start.ReadU8();
240 m_chMaskCntl = fourthByte >> 4;
241 m_nbTrans = fourthByte & 0b1111;
242 return m_serializedSize;
243}
244
245void
246LinkAdrReq::Print(std::ostream& os) const
247{
248 NS_LOG_FUNCTION(this);
249 os << "LinkAdrReq(";
250 os << "DataRate=" << unsigned(m_dataRate);
251 os << ", TXPower=" << unsigned(m_txPower);
252 os << ", ChMask=" << std::bitset<16>(m_chMask);
253 os << ", ChMaskCntl=" << unsigned(m_chMaskCntl);
254 os << ", NbTrans=" << unsigned(m_nbTrans);
255 os << ")";
256}
257
258uint8_t
260{
261 NS_LOG_FUNCTION(this);
262 return m_dataRate;
263}
264
265uint8_t
267{
268 NS_LOG_FUNCTION(this);
269 return m_txPower;
270}
271
272uint16_t
274{
275 NS_LOG_FUNCTION(this);
276 return m_chMask;
277}
278
279uint8_t
281{
282 NS_LOG_FUNCTION(this);
283 return m_chMaskCntl;
284}
285
286uint8_t
288{
289 NS_LOG_FUNCTION(this);
290 return m_nbTrans;
291}
292
293////////////////
294// LinkAdrAns //
295////////////////
296
303
304LinkAdrAns::LinkAdrAns(bool powerAck, bool dataRateAck, bool channelMaskAck)
305 : m_powerAck(powerAck),
306 m_dataRateAck(dataRateAck),
307 m_channelMaskAck(channelMaskAck)
308{
309 NS_LOG_FUNCTION(this);
312}
313
314void
316{
317 NS_LOG_FUNCTION(this);
318 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
319 start.WriteU8((uint8_t(m_powerAck) << 2) | (uint8_t(m_dataRateAck) << 1) |
320 uint8_t(m_channelMaskAck));
321}
322
323uint8_t
325{
326 NS_LOG_FUNCTION(this);
327 start.ReadU8(); // Consume the CID
328 uint8_t byte = start.ReadU8();
329 m_powerAck = byte & 0b100;
330 m_dataRateAck = byte & 0b10;
331 m_channelMaskAck = byte & 0b1;
332 return m_serializedSize;
333}
334
335void
336LinkAdrAns::Print(std::ostream& os) const
337{
338 NS_LOG_FUNCTION(this);
339 os << "LinkAdrAns(";
340 os << "PowerACK=" << m_powerAck;
341 os << ", DataRateACK=" << m_dataRateAck;
342 os << ", ChannelMaskACK=" << m_channelMaskAck;
343 os << ")";
344}
345
346bool
348{
349 NS_LOG_FUNCTION(this);
350 return m_powerAck;
351}
352
353bool
355{
356 NS_LOG_FUNCTION(this);
357 return m_dataRateAck;
358}
359
360bool
362{
363 NS_LOG_FUNCTION(this);
364 return m_channelMaskAck;
365}
366
367//////////////////
368// DutyCycleReq //
369//////////////////
370
377
378DutyCycleReq::DutyCycleReq(uint8_t maxDutyCycle)
379{
380 NS_LOG_FUNCTION(this << unsigned(maxDutyCycle));
381 NS_ASSERT_MSG(!(maxDutyCycle & 0xF0), "maxDutyCycle > 4 bits");
382 m_maxDutyCycle = maxDutyCycle;
385}
386
387void
389{
390 NS_LOG_FUNCTION(this);
391 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
392 start.WriteU8(m_maxDutyCycle);
393}
394
395uint8_t
397{
398 NS_LOG_FUNCTION(this);
399 start.ReadU8(); // Consume the CID
400 m_maxDutyCycle = start.ReadU8();
401 return m_serializedSize;
402}
403
404void
405DutyCycleReq::Print(std::ostream& os) const
406{
407 NS_LOG_FUNCTION(this);
408 os << "DutyCycleReq(";
409 os << "MaxDutyCycle=" << unsigned(m_maxDutyCycle);
410 os << ")";
411}
412
413uint8_t
415{
416 NS_LOG_FUNCTION(this);
417 return m_maxDutyCycle;
418}
419
420//////////////////
421// DutyCycleAns //
422//////////////////
423
430
431void
433{
434 NS_LOG_FUNCTION(this);
435 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
436}
437
438uint8_t
440{
441 NS_LOG_FUNCTION(this);
442 start.ReadU8(); // Consume the CID
443 return m_serializedSize;
444}
445
446void
447DutyCycleAns::Print(std::ostream& os) const
448{
449 NS_LOG_FUNCTION(this);
450 os << "DutyCycleAns()";
451}
452
453/////////////////////
454// RxParamSetupReq //
455/////////////////////
456
463
464RxParamSetupReq::RxParamSetupReq(uint8_t rx1DrOffset, uint8_t rx2DataRate, uint32_t frequencyHz)
465 : m_rx1DrOffset(rx1DrOffset),
466 m_rx2DataRate(rx2DataRate),
467 m_frequencyHz(frequencyHz)
468{
469 NS_LOG_FUNCTION(this << unsigned(rx1DrOffset) << unsigned(rx2DataRate) << frequencyHz);
470 NS_ASSERT_MSG(!(rx1DrOffset & 0xF8), "rx1DrOffset > 3 bits");
471 NS_ASSERT_MSG(!(rx2DataRate & 0xF0), "rx2DataRate > 4 bits");
474}
475
476void
478{
479 NS_LOG_FUNCTION(this);
480 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
481 start.WriteU8((m_rx1DrOffset & 0b111) << 4 | (m_rx2DataRate & 0b1111));
482 uint32_t encodedFrequency = m_frequencyHz / 100;
483 // Frequency is in little endian (lsb -> msb)
484 start.WriteU8(encodedFrequency); // Least significant byte
485 start.WriteU8(encodedFrequency >> 8); // Middle byte
486 start.WriteU8(encodedFrequency >> 16); // Most significant byte
487}
488
489uint8_t
491{
492 NS_LOG_FUNCTION(this);
493 start.ReadU8(); // Consume the CID
494 uint8_t firstByte = start.ReadU8();
495 m_rx1DrOffset = (firstByte & 0b1110000) >> 4;
496 m_rx2DataRate = firstByte & 0b1111;
497 uint32_t encodedFrequency = 0;
498 // Frequency is in little endian (lsb -> msb)
499 encodedFrequency += start.ReadU8(); // Least significant byte
500 encodedFrequency += start.ReadU8() << 8; // Middle byte
501 encodedFrequency += start.ReadU8() << 16; // Most significant byte
502 m_frequencyHz = encodedFrequency * 100;
503 return m_serializedSize;
504}
505
506void
507RxParamSetupReq::Print(std::ostream& os) const
508{
509 NS_LOG_FUNCTION(this);
510 os << "RxParamSetupReq(";
511 os << "RX1DROffset=" << unsigned(m_rx1DrOffset);
512 os << ", RX2DataRate=" << unsigned(m_rx2DataRate);
513 os << ", Frequency=" << m_frequencyHz;
514 os << ")";
515}
516
517uint8_t
523
524uint8_t
530
537
538/////////////////////
539// RxParamSetupAns //
540/////////////////////
541
548
549RxParamSetupAns::RxParamSetupAns(bool rx1DrOffsetAck, bool rx2DataRateAck, bool channelAck)
550 : m_rx1DrOffsetAck(rx1DrOffsetAck),
551 m_rx2DataRateAck(rx2DataRateAck),
552 m_channelAck(channelAck)
553{
554 NS_LOG_FUNCTION(this << rx1DrOffsetAck << rx2DataRateAck << channelAck);
557}
558
559void
561{
562 NS_LOG_FUNCTION(this);
563 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
564 start.WriteU8(uint8_t(m_rx1DrOffsetAck) << 2 | uint8_t(m_rx2DataRateAck) << 1 |
565 uint8_t(m_channelAck));
566}
567
568uint8_t
570{
571 NS_LOG_FUNCTION(this);
572 start.ReadU8(); // Consume the CID
573 uint8_t byte = start.ReadU8();
574 m_rx1DrOffsetAck = (byte & 0b100) >> 2;
575 m_rx2DataRateAck = (byte & 0b10) >> 1;
576 m_channelAck = byte & 0b1;
577 return m_serializedSize;
578}
579
580void
581RxParamSetupAns::Print(std::ostream& os) const
582{
583 NS_LOG_FUNCTION(this);
584 os << "RxParamSetupAns(";
585 os << "RX1DROffsetACK=" << m_rx1DrOffsetAck;
586 os << ", RX2DataRateACK=" << m_rx2DataRateAck;
587 os << ", ChannelACK=" << m_channelAck;
588 os << ")";
589}
590
591bool
597
598bool
604
605bool
607{
608 NS_LOG_FUNCTION(this);
609 return m_channelAck;
610}
611
612//////////////////
613// DevStatusReq //
614//////////////////
615
622
623void
625{
626 NS_LOG_FUNCTION(this);
627 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
628}
629
630uint8_t
632{
633 NS_LOG_FUNCTION(this);
634 start.ReadU8(); // Consume the CID
635 return m_serializedSize;
636}
637
638void
639DevStatusReq::Print(std::ostream& os) const
640{
641 NS_LOG_FUNCTION(this);
642 os << "DevStatusReq()";
643}
644
645//////////////////
646// DevStatusAns //
647//////////////////
648
655
656DevStatusAns::DevStatusAns(uint8_t battery, uint8_t margin)
657 : m_battery(battery),
658 m_margin(margin)
659{
660 NS_LOG_FUNCTION(this << unsigned(battery) << unsigned(margin));
661 NS_ASSERT_MSG(!(margin & 0xC0), "margin > 6 bits");
664}
665
666void
668{
669 NS_LOG_FUNCTION(this);
670 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
671 start.WriteU8(m_battery);
672 start.WriteU8(m_margin);
673}
674
675uint8_t
677{
678 NS_LOG_FUNCTION(this);
679 start.ReadU8(); // Consume the CID
680 m_battery = start.ReadU8();
681 m_margin = start.ReadU8();
682 return m_serializedSize;
683}
684
685void
686DevStatusAns::Print(std::ostream& os) const
687{
688 NS_LOG_FUNCTION(this);
689 os << "DevStatusAns(";
690 os << "Battery=" << unsigned(m_battery);
691 os << ", Margin=" << unsigned(m_margin);
692 os << ")";
693}
694
695uint8_t
697{
698 NS_LOG_FUNCTION(this);
699 return m_battery;
700}
701
702uint8_t
704{
705 NS_LOG_FUNCTION(this);
706 return m_margin;
707}
708
709//////////////////
710// NewChannelReq //
711//////////////////
712
719
721 uint32_t frequencyHz,
722 uint8_t minDataRate,
723 uint8_t maxDataRate)
724 : m_chIndex(chIndex),
725 m_frequencyHz(frequencyHz),
726 m_minDataRate(minDataRate),
727 m_maxDataRate(maxDataRate)
728{
729 NS_LOG_FUNCTION(this);
730 NS_ASSERT_MSG(!(minDataRate & 0xF0), "minDataRate > 4 bits");
731 NS_ASSERT_MSG(!(maxDataRate & 0xF0), "maxDataRate > 4 bits");
734}
735
736void
738{
739 NS_LOG_FUNCTION(this);
740 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
741 start.WriteU8(m_chIndex);
742 uint32_t encodedFrequency = m_frequencyHz / 100;
743 // Frequency is in little endian (lsb -> msb)
744 start.WriteU8(encodedFrequency); // Least significant byte
745 start.WriteU8(encodedFrequency >> 8); // Middle byte
746 start.WriteU8(encodedFrequency >> 16); // Most significant byte
747 start.WriteU8((m_maxDataRate << 4) | (m_minDataRate & 0xf));
748}
749
750uint8_t
752{
753 NS_LOG_FUNCTION(this);
754 start.ReadU8(); // Consume the CID
755 m_chIndex = start.ReadU8();
756 uint32_t encodedFrequency = 0;
757 // Frequency is in little endian (lsb -> msb)
758 encodedFrequency += start.ReadU8(); // Least significant byte
759 encodedFrequency += start.ReadU8() << 8; // Middle byte
760 encodedFrequency += start.ReadU8() << 16; // Most significant byte
761 m_frequencyHz = encodedFrequency * 100;
762 uint8_t dataRateByte = start.ReadU8();
763 m_maxDataRate = dataRateByte >> 4;
764 m_minDataRate = dataRateByte & 0xf;
765 return m_serializedSize;
766}
767
768void
769NewChannelReq::Print(std::ostream& os) const
770{
771 NS_LOG_FUNCTION(this);
772 os << "NewChannelReq(";
773 os << "ChIndex=" << unsigned(m_chIndex);
774 os << ", Frequency=" << uint32_t(m_frequencyHz);
775 os << ", MaxDR=" << unsigned(m_maxDataRate);
776 os << ", MinDR=" << unsigned(m_minDataRate);
777 os << ")";
778}
779
780uint8_t
782{
783 NS_LOG_FUNCTION(this);
784 return m_chIndex;
785}
786
789{
790 NS_LOG_FUNCTION(this);
791 return m_frequencyHz;
792}
793
794uint8_t
796{
797 NS_LOG_FUNCTION(this);
798 return m_minDataRate;
799}
800
801uint8_t
803{
804 NS_LOG_FUNCTION(this);
805 return m_maxDataRate;
806}
807
808///////////////////
809// NewChannelAns //
810///////////////////
811
818
819NewChannelAns::NewChannelAns(bool dataRateRangeOk, bool channelFrequencyOk)
820 : m_dataRateRangeOk(dataRateRangeOk),
821 m_channelFrequencyOk(channelFrequencyOk)
822{
823 NS_LOG_FUNCTION(this);
826}
827
828void
830{
831 NS_LOG_FUNCTION(this);
832 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
833 start.WriteU8((uint8_t(m_dataRateRangeOk) << 1) | uint8_t(m_channelFrequencyOk));
834}
835
836uint8_t
838{
839 NS_LOG_FUNCTION(this);
840 start.ReadU8(); // Consume the CID
841 uint8_t byte = start.ReadU8(); // Read the data
842 m_dataRateRangeOk = (byte & 0b10) >> 1;
843 m_channelFrequencyOk = (byte & 0b1);
844 return m_serializedSize;
845}
846
847void
848NewChannelAns::Print(std::ostream& os) const
849{
850 NS_LOG_FUNCTION(this);
851 os << "NewChannelAns(";
852 os << "DataRateRangeOk=" << m_dataRateRangeOk;
853 os << ", ChannelFrequencyOk=" << m_channelFrequencyOk;
854 os << ")";
855}
856
857bool
863
864bool
870
871//////////////////////
872// RxTimingSetupReq //
873//////////////////////
874
881
883 : m_delay(delay)
884{
885 NS_LOG_FUNCTION(this);
886 NS_ASSERT_MSG(!(delay & 0xF0), "delay field > 4 bits");
889}
890
891void
893{
894 NS_LOG_FUNCTION(this);
895 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
896 start.WriteU8(m_delay & 0xF); // Write the data
897}
898
899uint8_t
901{
902 NS_LOG_FUNCTION(this);
903 start.ReadU8(); // Consume the CID
904 m_delay = start.ReadU8() & 0xF; // Read the data
905 return m_serializedSize;
906}
907
908void
909RxTimingSetupReq::Print(std::ostream& os) const
910{
911 NS_LOG_FUNCTION(this);
912 os << "RxTimingSetupReq()";
913}
914
915Time
917{
918 NS_LOG_FUNCTION(this);
919 return Seconds((m_delay) ? m_delay : 0);
920}
921
922//////////////////
923// RxTimingSetupAns //
924//////////////////
925
932
933void
935{
936 NS_LOG_FUNCTION(this);
937 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
938}
939
940uint8_t
942{
943 NS_LOG_FUNCTION(this);
944 start.ReadU8(); // Consume the CID
945 return m_serializedSize;
946}
947
948void
949RxTimingSetupAns::Print(std::ostream& os) const
950{
951 NS_LOG_FUNCTION(this);
952 os << "RxTimingSetupAns()";
953}
954
955//////////////////
956// DlChannelAns //
957//////////////////
958
965
966void
968{
969 NS_LOG_FUNCTION(this);
970 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
971}
972
973uint8_t
975{
976 NS_LOG_FUNCTION(this);
977 start.ReadU8(); // Consume the CID
978 return m_serializedSize;
979}
980
981void
982DlChannelAns::Print(std::ostream& os) const
983{
984 NS_LOG_FUNCTION(this);
985 os << "DlChannelAns()";
986}
987
988//////////////////
989// TxParamSetupReq //
990//////////////////
991
998
999void
1001{
1002 NS_LOG_FUNCTION(this);
1003 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
1004}
1005
1006uint8_t
1008{
1009 NS_LOG_FUNCTION(this);
1010 start.ReadU8(); // Consume the CID
1011 return m_serializedSize;
1012}
1013
1014void
1015TxParamSetupReq::Print(std::ostream& os) const
1016{
1017 NS_LOG_FUNCTION(this);
1018 os << "TxParamSetupReq()";
1019}
1020
1021//////////////////
1022// TxParamSetupAns //
1023//////////////////
1024
1031
1032void
1034{
1035 NS_LOG_FUNCTION(this);
1036 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
1037}
1038
1039uint8_t
1041{
1042 NS_LOG_FUNCTION(this);
1043 start.ReadU8(); // Consume the CID
1044 return m_serializedSize;
1045}
1046
1047void
1048TxParamSetupAns::Print(std::ostream& os) const
1049{
1050 NS_LOG_FUNCTION(this);
1051 os << "TxParamSetupAns()";
1052}
1053
1054} // namespace lorawan
1055} // namespace ns3
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 uint8_t GetSerializedSize() const
Get serialized length of this MAC command.
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 ~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.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:194
#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 ",...
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1273
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.