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 "ns3/log.h"
12
13#include <bitset>
14#include <cmath>
15
16namespace ns3
17{
18namespace lorawan
19{
20
21NS_LOG_COMPONENT_DEFINE("MacCommand");
22
27
31
34{
35 NS_LOG_FUNCTION(this);
36 return m_commandType;
37}
38
39uint8_t
45
46uint8_t
48{
50 switch (commandType)
51 {
52 case (INVALID): {
53 return 0x0;
54 }
55 case (LINK_CHECK_REQ):
56 case (LINK_CHECK_ANS): {
57 return 0x02;
58 }
59 case (LINK_ADR_REQ):
60 case (LINK_ADR_ANS): {
61 return 0x03;
62 }
63 case (DUTY_CYCLE_REQ):
64 case (DUTY_CYCLE_ANS): {
65 return 0x04;
66 }
67 case (RX_PARAM_SETUP_REQ):
68 case (RX_PARAM_SETUP_ANS): {
69 return 0x05;
70 }
71 case (DEV_STATUS_REQ):
72 case (DEV_STATUS_ANS): {
73 return 0x06;
74 }
75 case (NEW_CHANNEL_REQ):
76 case (NEW_CHANNEL_ANS): {
77 return 0x07;
78 }
80 case (RX_TIMING_SETUP_ANS): {
81 return 0x08;
82 }
83 case (TX_PARAM_SETUP_REQ):
84 case (TX_PARAM_SETUP_ANS): {
85 return 0x09;
86 }
87 case (DL_CHANNEL_REQ):
88 case (DL_CHANNEL_ANS): {
89 return 0x0A;
90 }
91 }
92 return 0;
93}
94
95//////////////////
96// LinkCheckReq //
97//////////////////
98
105
106void
108{
109 NS_LOG_FUNCTION(this);
110 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
111}
112
113uint8_t
115{
116 NS_LOG_FUNCTION(this);
117 start.ReadU8(); // Consume the CID
118 return m_serializedSize;
119}
120
121void
122LinkCheckReq::Print(std::ostream& os) const
123{
124 NS_LOG_FUNCTION(this);
125 os << "LinkCheckReq()";
126}
127
128//////////////////
129// LinkCheckAns //
130//////////////////
131
138
139LinkCheckAns::LinkCheckAns(uint8_t margin, uint8_t gwCnt)
140 : m_margin(margin),
141 m_gwCnt(gwCnt)
142{
143 NS_LOG_FUNCTION(this << unsigned(margin) << unsigned(gwCnt));
146}
147
148void
150{
151 NS_LOG_FUNCTION(this);
152 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
153 start.WriteU8(m_margin); // Write the margin
154 start.WriteU8(m_gwCnt); // Write the gwCnt
155}
156
157uint8_t
159{
160 NS_LOG_FUNCTION(this);
161 start.ReadU8(); // Consume the CID
162 m_margin = start.ReadU8();
163 m_gwCnt = start.ReadU8();
164 return m_serializedSize;
165}
166
167void
168LinkCheckAns::Print(std::ostream& os) const
169{
170 NS_LOG_FUNCTION(this);
171 os << "LinkCheckAns(";
172 os << "Margin=" << unsigned(m_margin);
173 os << ", GwCnt=" << unsigned(m_gwCnt);
174 os << ")";
175}
176
177uint8_t
179{
180 NS_LOG_FUNCTION(this);
181 return m_margin;
182}
183
184uint8_t
186{
187 NS_LOG_FUNCTION(this);
188
189 return m_gwCnt;
190}
191
192////////////////
193// LinkAdrReq //
194////////////////
195
202
203LinkAdrReq::LinkAdrReq(uint8_t dataRate,
204 uint8_t txPower,
205 uint16_t chMask,
206 uint8_t chMaskCntl,
207 uint8_t nbTrans)
208 : m_dataRate(dataRate),
209 m_txPower(txPower),
210 m_chMask(chMask),
211 m_chMaskCntl(chMaskCntl),
212 m_nbTrans(nbTrans)
213{
214 NS_LOG_FUNCTION(this);
215 NS_ASSERT_MSG(!(dataRate & 0xF0), "dataRate field > 4 bits");
216 NS_ASSERT_MSG(!(txPower & 0xF0), "txPower field > 4 bits");
217 NS_ASSERT_MSG(!(chMaskCntl & 0xF8), "chMaskCntl field > 3 bits");
218 NS_ASSERT_MSG(!(nbTrans & 0xF0), "nbTrans field > 4 bits");
221}
222
223void
225{
226 NS_LOG_FUNCTION(this);
227 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
228 start.WriteU8(m_dataRate << 4 | (m_txPower & 0b1111));
229 start.WriteU16(m_chMask);
230 start.WriteU8(m_chMaskCntl << 4 | (m_nbTrans & 0b1111));
231}
232
233uint8_t
235{
236 NS_LOG_FUNCTION(this);
237 start.ReadU8(); // Consume the CID
238 uint8_t firstByte = start.ReadU8();
239 m_dataRate = firstByte >> 4;
240 m_txPower = firstByte & 0b1111;
241 m_chMask = start.ReadU16();
242 uint8_t fourthByte = start.ReadU8();
243 m_chMaskCntl = fourthByte >> 4;
244 m_nbTrans = fourthByte & 0b1111;
245 return m_serializedSize;
246}
247
248void
249LinkAdrReq::Print(std::ostream& os) const
250{
251 NS_LOG_FUNCTION(this);
252 os << "LinkAdrReq(";
253 os << "DataRate=" << unsigned(m_dataRate);
254 os << ", TXPower=" << unsigned(m_txPower);
255 os << ", ChMask=" << std::bitset<16>(m_chMask);
256 os << ", ChMaskCntl=" << unsigned(m_chMaskCntl);
257 os << ", NbTrans=" << unsigned(m_nbTrans);
258 os << ")";
259}
260
261uint8_t
263{
264 NS_LOG_FUNCTION(this);
265 return m_dataRate;
266}
267
268uint8_t
270{
271 NS_LOG_FUNCTION(this);
272 return m_txPower;
273}
274
275uint16_t
277{
278 NS_LOG_FUNCTION(this);
279 return m_chMask;
280}
281
282uint8_t
284{
285 NS_LOG_FUNCTION(this);
286 return m_chMaskCntl;
287}
288
289uint8_t
291{
292 NS_LOG_FUNCTION(this);
293 return m_nbTrans;
294}
295
296////////////////
297// LinkAdrAns //
298////////////////
299
306
307LinkAdrAns::LinkAdrAns(bool powerAck, bool dataRateAck, bool channelMaskAck)
308 : m_powerAck(powerAck),
309 m_dataRateAck(dataRateAck),
310 m_channelMaskAck(channelMaskAck)
311{
312 NS_LOG_FUNCTION(this);
315}
316
317void
319{
320 NS_LOG_FUNCTION(this);
321 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
322 start.WriteU8((uint8_t(m_powerAck) << 2) | (uint8_t(m_dataRateAck) << 1) |
323 uint8_t(m_channelMaskAck));
324}
325
326uint8_t
328{
329 NS_LOG_FUNCTION(this);
330 start.ReadU8(); // Consume the CID
331 uint8_t byte = start.ReadU8();
332 m_powerAck = byte & 0b100;
333 m_dataRateAck = byte & 0b10;
334 m_channelMaskAck = byte & 0b1;
335 return m_serializedSize;
336}
337
338void
339LinkAdrAns::Print(std::ostream& os) const
340{
341 NS_LOG_FUNCTION(this);
342 os << "LinkAdrAns(";
343 os << "PowerACK=" << m_powerAck;
344 os << ", DataRateACK=" << m_dataRateAck;
345 os << ", ChannelMaskACK=" << m_channelMaskAck;
346 os << ")";
347}
348
349bool
351{
352 NS_LOG_FUNCTION(this);
353 return m_powerAck;
354}
355
356bool
358{
359 NS_LOG_FUNCTION(this);
360 return m_dataRateAck;
361}
362
363bool
365{
366 NS_LOG_FUNCTION(this);
367 return m_channelMaskAck;
368}
369
370//////////////////
371// DutyCycleReq //
372//////////////////
373
380
381DutyCycleReq::DutyCycleReq(uint8_t maxDutyCycle)
382{
383 NS_LOG_FUNCTION(this << unsigned(maxDutyCycle));
384 NS_ASSERT_MSG(!(maxDutyCycle & 0xF0), "maxDutyCycle > 4 bits");
385 m_maxDutyCycle = maxDutyCycle;
388}
389
390void
392{
393 NS_LOG_FUNCTION(this);
394 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
395 start.WriteU8(m_maxDutyCycle);
396}
397
398uint8_t
400{
401 NS_LOG_FUNCTION(this);
402 start.ReadU8(); // Consume the CID
403 m_maxDutyCycle = start.ReadU8();
404 return m_serializedSize;
405}
406
407void
408DutyCycleReq::Print(std::ostream& os) const
409{
410 NS_LOG_FUNCTION(this);
411 os << "DutyCycleReq(";
412 os << "MaxDutyCycle=" << unsigned(m_maxDutyCycle);
413 os << ")";
414}
415
416uint8_t
418{
419 NS_LOG_FUNCTION(this);
420 return m_maxDutyCycle;
421}
422
423//////////////////
424// DutyCycleAns //
425//////////////////
426
433
434void
436{
437 NS_LOG_FUNCTION(this);
438 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
439}
440
441uint8_t
443{
444 NS_LOG_FUNCTION(this);
445 start.ReadU8(); // Consume the CID
446 return m_serializedSize;
447}
448
449void
450DutyCycleAns::Print(std::ostream& os) const
451{
452 NS_LOG_FUNCTION(this);
453 os << "DutyCycleAns()";
454}
455
456/////////////////////
457// RxParamSetupReq //
458/////////////////////
459
466
467RxParamSetupReq::RxParamSetupReq(uint8_t rx1DrOffset, uint8_t rx2DataRate, uint32_t frequencyHz)
468 : m_rx1DrOffset(rx1DrOffset),
469 m_rx2DataRate(rx2DataRate),
470 m_frequencyHz(frequencyHz)
471{
472 NS_LOG_FUNCTION(this << unsigned(rx1DrOffset) << unsigned(rx2DataRate) << frequencyHz);
473 NS_ASSERT_MSG(!(rx1DrOffset & 0xF8), "rx1DrOffset > 3 bits");
474 NS_ASSERT_MSG(!(rx2DataRate & 0xF0), "rx2DataRate > 4 bits");
477}
478
479void
481{
482 NS_LOG_FUNCTION(this);
483 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
484 start.WriteU8((m_rx1DrOffset & 0b111) << 4 | (m_rx2DataRate & 0b1111));
485 uint32_t encodedFrequency = m_frequencyHz / 100;
486 // Frequency is in little endian (lsb -> msb)
487 start.WriteU8(encodedFrequency); // Least significant byte
488 start.WriteU8(encodedFrequency >> 8); // Middle byte
489 start.WriteU8(encodedFrequency >> 16); // Most significant byte
490}
491
492uint8_t
494{
495 NS_LOG_FUNCTION(this);
496 start.ReadU8(); // Consume the CID
497 uint8_t firstByte = start.ReadU8();
498 m_rx1DrOffset = (firstByte & 0b1110000) >> 4;
499 m_rx2DataRate = firstByte & 0b1111;
500 uint32_t encodedFrequency = 0;
501 // Frequency is in little endian (lsb -> msb)
502 encodedFrequency += start.ReadU8(); // Least significant byte
503 encodedFrequency += start.ReadU8() << 8; // Middle byte
504 encodedFrequency += start.ReadU8() << 16; // Most significant byte
505 m_frequencyHz = encodedFrequency * 100;
506 return m_serializedSize;
507}
508
509void
510RxParamSetupReq::Print(std::ostream& os) const
511{
512 NS_LOG_FUNCTION(this);
513 os << "RxParamSetupReq(";
514 os << "RX1DROffset=" << unsigned(m_rx1DrOffset);
515 os << ", RX2DataRate=" << unsigned(m_rx2DataRate);
516 os << ", Frequency=" << m_frequencyHz;
517 os << ")";
518}
519
520uint8_t
526
527uint8_t
533
540
541/////////////////////
542// RxParamSetupAns //
543/////////////////////
544
551
552RxParamSetupAns::RxParamSetupAns(bool rx1DrOffsetAck, bool rx2DataRateAck, bool channelAck)
553 : m_rx1DrOffsetAck(rx1DrOffsetAck),
554 m_rx2DataRateAck(rx2DataRateAck),
555 m_channelAck(channelAck)
556{
557 NS_LOG_FUNCTION(this << rx1DrOffsetAck << rx2DataRateAck << channelAck);
560}
561
562void
564{
565 NS_LOG_FUNCTION(this);
566 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
567 start.WriteU8(uint8_t(m_rx1DrOffsetAck) << 2 | uint8_t(m_rx2DataRateAck) << 1 |
568 uint8_t(m_channelAck));
569}
570
571uint8_t
573{
574 NS_LOG_FUNCTION(this);
575 start.ReadU8(); // Consume the CID
576 uint8_t byte = start.ReadU8();
577 m_rx1DrOffsetAck = (byte & 0b100) >> 2;
578 m_rx2DataRateAck = (byte & 0b10) >> 1;
579 m_channelAck = byte & 0b1;
580 return m_serializedSize;
581}
582
583void
584RxParamSetupAns::Print(std::ostream& os) const
585{
586 NS_LOG_FUNCTION(this);
587 os << "RxParamSetupAns(";
588 os << "RX1DROffsetACK=" << m_rx1DrOffsetAck;
589 os << ", RX2DataRateACK=" << m_rx2DataRateAck;
590 os << ", ChannelACK=" << m_channelAck;
591 os << ")";
592}
593
594bool
600
601bool
607
608bool
610{
611 NS_LOG_FUNCTION(this);
612 return m_channelAck;
613}
614
615//////////////////
616// DevStatusReq //
617//////////////////
618
625
626void
628{
629 NS_LOG_FUNCTION(this);
630 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
631}
632
633uint8_t
635{
636 NS_LOG_FUNCTION(this);
637 start.ReadU8(); // Consume the CID
638 return m_serializedSize;
639}
640
641void
642DevStatusReq::Print(std::ostream& os) const
643{
644 NS_LOG_FUNCTION(this);
645 os << "DevStatusReq()";
646}
647
648//////////////////
649// DevStatusAns //
650//////////////////
651
658
659DevStatusAns::DevStatusAns(uint8_t battery, uint8_t margin)
660 : m_battery(battery),
661 m_margin(margin)
662{
663 NS_LOG_FUNCTION(this << unsigned(battery) << unsigned(margin));
664 NS_ASSERT_MSG(!(margin & 0xC0), "margin > 6 bits");
667}
668
669void
671{
672 NS_LOG_FUNCTION(this);
673 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
674 start.WriteU8(m_battery);
675 start.WriteU8(m_margin);
676}
677
678uint8_t
680{
681 NS_LOG_FUNCTION(this);
682 start.ReadU8(); // Consume the CID
683 m_battery = start.ReadU8();
684 m_margin = start.ReadU8();
685 return m_serializedSize;
686}
687
688void
689DevStatusAns::Print(std::ostream& os) const
690{
691 NS_LOG_FUNCTION(this);
692 os << "DevStatusAns(";
693 os << "Battery=" << unsigned(m_battery);
694 os << ", Margin=" << unsigned(m_margin);
695 os << ")";
696}
697
698uint8_t
700{
701 NS_LOG_FUNCTION(this);
702 return m_battery;
703}
704
705uint8_t
707{
708 NS_LOG_FUNCTION(this);
709 return m_margin;
710}
711
712//////////////////
713// NewChannelReq //
714//////////////////
715
722
724 uint32_t frequencyHz,
725 uint8_t minDataRate,
726 uint8_t maxDataRate)
727 : m_chIndex(chIndex),
728 m_frequencyHz(frequencyHz),
729 m_minDataRate(minDataRate),
730 m_maxDataRate(maxDataRate)
731{
732 NS_LOG_FUNCTION(this);
733 NS_ASSERT_MSG(!(minDataRate & 0xF0), "minDataRate > 4 bits");
734 NS_ASSERT_MSG(!(maxDataRate & 0xF0), "maxDataRate > 4 bits");
737}
738
739void
741{
742 NS_LOG_FUNCTION(this);
743 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
744 start.WriteU8(m_chIndex);
745 uint32_t encodedFrequency = m_frequencyHz / 100;
746 // Frequency is in little endian (lsb -> msb)
747 start.WriteU8(encodedFrequency); // Least significant byte
748 start.WriteU8(encodedFrequency >> 8); // Middle byte
749 start.WriteU8(encodedFrequency >> 16); // Most significant byte
750 start.WriteU8((m_maxDataRate << 4) | (m_minDataRate & 0xf));
751}
752
753uint8_t
755{
756 NS_LOG_FUNCTION(this);
757 start.ReadU8(); // Consume the CID
758 m_chIndex = start.ReadU8();
759 uint32_t encodedFrequency = 0;
760 // Frequency is in little endian (lsb -> msb)
761 encodedFrequency += start.ReadU8(); // Least significant byte
762 encodedFrequency += start.ReadU8() << 8; // Middle byte
763 encodedFrequency += start.ReadU8() << 16; // Most significant byte
764 m_frequencyHz = encodedFrequency * 100;
765 uint8_t dataRateByte = start.ReadU8();
766 m_maxDataRate = dataRateByte >> 4;
767 m_minDataRate = dataRateByte & 0xf;
768 return m_serializedSize;
769}
770
771void
772NewChannelReq::Print(std::ostream& os) const
773{
774 NS_LOG_FUNCTION(this);
775 os << "NewChannelReq(";
776 os << "ChIndex=" << unsigned(m_chIndex);
777 os << ", Frequency=" << uint32_t(m_frequencyHz);
778 os << ", MaxDR=" << unsigned(m_maxDataRate);
779 os << ", MinDR=" << unsigned(m_minDataRate);
780 os << ")";
781}
782
783uint8_t
785{
786 NS_LOG_FUNCTION(this);
787 return m_chIndex;
788}
789
792{
793 NS_LOG_FUNCTION(this);
794 return m_frequencyHz;
795}
796
797uint8_t
799{
800 NS_LOG_FUNCTION(this);
801 return m_minDataRate;
802}
803
804uint8_t
806{
807 NS_LOG_FUNCTION(this);
808 return m_maxDataRate;
809}
810
811///////////////////
812// NewChannelAns //
813///////////////////
814
821
822NewChannelAns::NewChannelAns(bool dataRateRangeOk, bool channelFrequencyOk)
823 : m_dataRateRangeOk(dataRateRangeOk),
824 m_channelFrequencyOk(channelFrequencyOk)
825{
826 NS_LOG_FUNCTION(this);
829}
830
831void
833{
834 NS_LOG_FUNCTION(this);
835 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
836 start.WriteU8((uint8_t(m_dataRateRangeOk) << 1) | uint8_t(m_channelFrequencyOk));
837}
838
839uint8_t
841{
842 NS_LOG_FUNCTION(this);
843 start.ReadU8(); // Consume the CID
844 uint8_t byte = start.ReadU8(); // Read the data
845 m_dataRateRangeOk = (byte & 0b10) >> 1;
846 m_channelFrequencyOk = (byte & 0b1);
847 return m_serializedSize;
848}
849
850void
851NewChannelAns::Print(std::ostream& os) const
852{
853 NS_LOG_FUNCTION(this);
854 os << "NewChannelAns(";
855 os << "DataRateRangeOk=" << m_dataRateRangeOk;
856 os << ", ChannelFrequencyOk=" << m_channelFrequencyOk;
857 os << ")";
858}
859
860bool
866
867bool
873
874//////////////////////
875// RxTimingSetupReq //
876//////////////////////
877
884
886 : m_delay(delay)
887{
888 NS_LOG_FUNCTION(this);
889 NS_ASSERT_MSG(!(delay & 0xF0), "delay field > 4 bits");
892}
893
894void
896{
897 NS_LOG_FUNCTION(this);
898 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
899 start.WriteU8(m_delay & 0xF); // Write the data
900}
901
902uint8_t
904{
905 NS_LOG_FUNCTION(this);
906 start.ReadU8(); // Consume the CID
907 m_delay = start.ReadU8() & 0xF; // Read the data
908 return m_serializedSize;
909}
910
911void
912RxTimingSetupReq::Print(std::ostream& os) const
913{
914 NS_LOG_FUNCTION(this);
915 os << "RxTimingSetupReq()";
916}
917
918Time
920{
921 NS_LOG_FUNCTION(this);
922 return Seconds((m_delay) ? m_delay : 0);
923}
924
925//////////////////
926// RxTimingSetupAns //
927//////////////////
928
935
936void
938{
939 NS_LOG_FUNCTION(this);
940 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
941}
942
943uint8_t
945{
946 NS_LOG_FUNCTION(this);
947 start.ReadU8(); // Consume the CID
948 return m_serializedSize;
949}
950
951void
952RxTimingSetupAns::Print(std::ostream& os) const
953{
954 NS_LOG_FUNCTION(this);
955 os << "RxTimingSetupAns()";
956}
957
958//////////////////
959// DlChannelAns //
960//////////////////
961
968
969void
971{
972 NS_LOG_FUNCTION(this);
973 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
974}
975
976uint8_t
978{
979 NS_LOG_FUNCTION(this);
980 start.ReadU8(); // Consume the CID
981 return m_serializedSize;
982}
983
984void
985DlChannelAns::Print(std::ostream& os) const
986{
987 NS_LOG_FUNCTION(this);
988 os << "DlChannelAns()";
989}
990
991//////////////////
992// TxParamSetupReq //
993//////////////////
994
1001
1002void
1004{
1005 NS_LOG_FUNCTION(this);
1006 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
1007}
1008
1009uint8_t
1011{
1012 NS_LOG_FUNCTION(this);
1013 start.ReadU8(); // Consume the CID
1014 return m_serializedSize;
1015}
1016
1017void
1018TxParamSetupReq::Print(std::ostream& os) const
1019{
1020 NS_LOG_FUNCTION(this);
1021 os << "TxParamSetupReq()";
1022}
1023
1024//////////////////
1025// TxParamSetupAns //
1026//////////////////
1027
1034
1035void
1037{
1038 NS_LOG_FUNCTION(this);
1039 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
1040}
1041
1042uint8_t
1044{
1045 NS_LOG_FUNCTION(this);
1046 start.ReadU8(); // Consume the CID
1047 return m_serializedSize;
1048}
1049
1050void
1051TxParamSetupAns::Print(std::ostream& os) const
1052{
1053 NS_LOG_FUNCTION(this);
1054 os << "TxParamSetupAns()";
1055}
1056
1057} // namespace lorawan
1058} // namespace ns3
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 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:191
#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:1345
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.