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
24
25TypeId
27{
28 static TypeId tid = TypeId("ns3::MacCommand").SetParent<Object>().SetGroupName("lorawan");
29 return tid;
30}
31
36
41
49
50uint8_t
57
58uint8_t
60{
62
63 switch (commandType)
64 {
65 case (INVALID): {
66 return 0x0;
67 }
68 case (LINK_CHECK_REQ):
69 case (LINK_CHECK_ANS): {
70 return 0x02;
71 }
72 case (LINK_ADR_REQ):
73 case (LINK_ADR_ANS): {
74 return 0x03;
75 }
76 case (DUTY_CYCLE_REQ):
77 case (DUTY_CYCLE_ANS): {
78 return 0x04;
79 }
80 case (RX_PARAM_SETUP_REQ):
81 case (RX_PARAM_SETUP_ANS): {
82 return 0x05;
83 }
84 case (DEV_STATUS_REQ):
85 case (DEV_STATUS_ANS): {
86 return 0x06;
87 }
88 case (NEW_CHANNEL_REQ):
89 case (NEW_CHANNEL_ANS): {
90 return 0x07;
91 }
93 case (RX_TIMING_SETUP_ANS): {
94 return 0x08;
95 }
96 case (TX_PARAM_SETUP_REQ):
97 case (TX_PARAM_SETUP_ANS): {
98 return 0x09;
99 }
100 case (DL_CHANNEL_REQ):
101 case (DL_CHANNEL_ANS): {
102 return 0x0A;
103 }
104 }
105 return 0;
106}
107
108//////////////////
109// LinkCheckReq //
110//////////////////
111
118
123
124void
126{
128
129 // Write the CID and we're done
130 uint8_t cid = GetCIDFromMacCommand(m_commandType);
131 start.WriteU8(cid);
132 NS_LOG_DEBUG("Serialized LinkCheckReq: " << unsigned(cid));
133}
134
135uint8_t
137{
139
140 // Read the CID
141 start.ReadU8();
142
143 return m_serializedSize;
144}
145
146void
147LinkCheckReq::Print(std::ostream& os) const
148{
150
151 os << "LinkCheckReq" << std::endl;
152}
153
154//////////////////
155// LinkCheckAns //
156//////////////////
157
159 : m_margin(0),
160 m_gwCnt(0)
161{
162 NS_LOG_FUNCTION(this);
163
166}
167
168LinkCheckAns::LinkCheckAns(uint8_t margin, uint8_t gwCnt)
169 : m_margin(margin),
170 m_gwCnt(gwCnt)
171{
172 NS_LOG_FUNCTION(this << unsigned(margin) << unsigned(gwCnt));
173
176}
177
178void
180{
182
183 // Write the CID
184 start.WriteU8(GetCIDFromMacCommand(m_commandType));
185 // Write the margin
186 start.WriteU8(m_margin);
187 // Write the gwCnt
188 start.WriteU8(m_gwCnt);
189}
190
191uint8_t
193{
195
196 // Consume the CID
197 start.ReadU8();
198 m_margin = start.ReadU8();
199 m_gwCnt = start.ReadU8();
200 return m_serializedSize;
201}
202
203void
204LinkCheckAns::Print(std::ostream& os) const
205{
207
208 os << "LinkCheckAns" << std::endl;
209 os << "margin: " << unsigned(m_margin) << std::endl;
210 os << "gwCnt: " << unsigned(m_gwCnt) << std::endl;
211}
212
213void
215{
216 NS_LOG_FUNCTION(this << unsigned(margin));
217
218 m_margin = margin;
219}
220
221uint8_t
223{
224 NS_LOG_FUNCTION(this);
225
226 return m_margin;
227}
228
229void
231{
232 NS_LOG_FUNCTION(this << unsigned(gwCnt));
233
234 m_gwCnt = gwCnt;
235}
236
237uint8_t
239{
240 NS_LOG_FUNCTION(this);
241
242 return m_gwCnt;
243}
244
245void
247{
248 NS_LOG_FUNCTION(this);
249
250 m_gwCnt++;
251}
252
253////////////////
254// LinkAdrReq //
255////////////////
256
264
265LinkAdrReq::LinkAdrReq(uint8_t dataRate,
266 uint8_t txPower,
267 uint16_t channelMask,
268 uint8_t chMaskCntl,
269 uint8_t nbRep)
270 : m_dataRate(dataRate),
271 m_txPower(txPower),
272 m_channelMask(channelMask),
273 m_chMaskCntl(chMaskCntl),
274 m_nbRep(nbRep)
275{
276 NS_LOG_FUNCTION(this);
277
280}
281
282void
284{
286
287 // Write the CID
288 start.WriteU8(GetCIDFromMacCommand(m_commandType));
289 start.WriteU8(m_dataRate << 4 | (m_txPower & 0b1111));
290 start.WriteU16(m_channelMask);
291 start.WriteU8(m_chMaskCntl << 4 | (m_nbRep & 0b1111));
292}
293
294uint8_t
296{
298
299 // Consume the CID
300 start.ReadU8();
301 uint8_t firstByte = start.ReadU8();
302 m_dataRate = firstByte >> 4;
303 m_txPower = firstByte & 0b1111;
304 m_channelMask = start.ReadU16();
305 uint8_t fourthByte = start.ReadU8();
306 m_chMaskCntl = fourthByte >> 4;
307 m_nbRep = fourthByte & 0b1111;
308
309 return m_serializedSize;
310}
311
312void
313LinkAdrReq::Print(std::ostream& os) const
314{
316
317 os << "LinkAdrReq" << std::endl;
318 os << "dataRate: " << unsigned(m_dataRate) << std::endl;
319 os << "txPower: " << unsigned(m_txPower) << std::endl;
320 os << "channelMask: " << std::bitset<16>(m_channelMask) << std::endl;
321 os << "chMaskCntl: " << unsigned(m_chMaskCntl) << std::endl;
322 os << "nbRep: " << unsigned(m_nbRep) << std::endl;
323}
324
325uint8_t
327{
328 NS_LOG_FUNCTION(this);
329
330 return m_dataRate;
331}
332
333uint8_t
335{
336 NS_LOG_FUNCTION(this);
337
338 return m_txPower;
339}
340
341std::list<int>
343{
344 NS_LOG_FUNCTION(this);
345
346 std::list<int> channelIndices;
347 for (int i = 0; i < 16; i++)
348 {
349 if (m_channelMask & (0b1 << i)) // Take channel mask's i-th bit
350 {
351 NS_LOG_DEBUG("Adding channel index " << i);
352 channelIndices.push_back(i);
353 }
354 }
355
356 return channelIndices;
357}
358
359int
361{
362 NS_LOG_FUNCTION(this);
363
364 return m_nbRep;
365}
366
367////////////////
368// LinkAdrAns //
369////////////////
370
378
379LinkAdrAns::LinkAdrAns(bool powerAck, bool dataRateAck, bool channelMaskAck)
380 : m_powerAck(powerAck),
381 m_dataRateAck(dataRateAck),
382 m_channelMaskAck(channelMaskAck)
383{
384 NS_LOG_FUNCTION(this);
385
388}
389
390void
392{
394
395 // Write the CID
396 start.WriteU8(GetCIDFromMacCommand(m_commandType));
397 // We can assume that true will be converted to 1 and that false will be
398 // converted to 0 on any C++ compiler
399 start.WriteU8((uint8_t(m_powerAck) << 2) | (uint8_t(m_dataRateAck) << 1) |
400 uint8_t(m_channelMaskAck));
401}
402
403uint8_t
405{
407
408 // Consume the CID
409 start.ReadU8();
410
411 uint8_t byte = start.ReadU8();
412
413 m_powerAck = byte & 0b100;
414 m_dataRateAck = byte & 0b10;
415 m_channelMaskAck = byte & 0b1;
416
417 return m_serializedSize;
418}
419
420void
421LinkAdrAns::Print(std::ostream& os) const
422{
424
425 os << "LinkAdrAns" << std::endl;
426}
427
428//////////////////
429// DutyCycleReq //
430//////////////////
431
439
441 : m_maxDCycle(dutyCycle)
442{
443 NS_LOG_FUNCTION(this);
444
447}
448
449void
451{
453
454 // Write the CID
455 start.WriteU8(GetCIDFromMacCommand(m_commandType));
456 start.WriteU8(m_maxDCycle);
457}
458
459uint8_t
461{
463
464 // Consume the CID
465 start.ReadU8();
466 m_maxDCycle = start.ReadU8();
467
468 return m_serializedSize;
469}
470
471void
472DutyCycleReq::Print(std::ostream& os) const
473{
475
476 os << "DutyCycleReq" << std::endl;
477 os << "maxDCycle: " << unsigned(m_maxDCycle) << std::endl;
478 os << "maxDCycle (fraction): " << GetMaximumAllowedDutyCycle() << std::endl;
479}
480
481double
483{
484 NS_LOG_FUNCTION(this);
485
486 // Check if we need to turn off completely
487 if (m_maxDCycle == 255)
488 {
489 return 0;
490 }
491
492 if (m_maxDCycle == 0)
493 {
494 return 1;
495 }
496
497 return 1 / std::pow(2, double(m_maxDCycle));
498}
499
500//////////////////
501// DutyCycleAns //
502//////////////////
503
511
512void
514{
516
517 // Write the CID
518 start.WriteU8(GetCIDFromMacCommand(m_commandType));
519}
520
521uint8_t
523{
525
526 // Consume the CID
527 start.ReadU8();
528 return m_serializedSize;
529}
530
531void
532DutyCycleAns::Print(std::ostream& os) const
533{
535
536 os << "DutyCycleAns" << std::endl;
537}
538
539//////////////////
540// RxParamSetupReq //
541//////////////////
542
550
551RxParamSetupReq::RxParamSetupReq(uint8_t rx1DrOffset, uint8_t rx2DataRate, double frequency)
552 : m_rx1DrOffset(rx1DrOffset),
553 m_rx2DataRate(rx2DataRate),
554 m_frequency(frequency)
555{
556 NS_LOG_FUNCTION(this << unsigned(rx1DrOffset) << unsigned(rx2DataRate) << frequency);
557
558 if ((rx1DrOffset & 0b11111000) != 0)
559 {
561 "Warning: received an rx1DrOffset greater than 7. Actual value will be different.");
562 }
563 if ((rx2DataRate & 0b11110000) != 0)
564 {
566 "Warning: received a rx2DataRate greater than 15. Actual value will be different.");
567 }
568
571}
572
573void
575{
577
578 // Write the CID
579 start.WriteU8(GetCIDFromMacCommand(m_commandType));
580 // Data serialization
581 start.WriteU8((m_rx1DrOffset & 0b111) << 4 | (m_rx2DataRate & 0b1111));
582 uint32_t encodedFrequency = m_frequency / 100;
583 NS_LOG_DEBUG(unsigned(encodedFrequency));
584 NS_LOG_DEBUG(std::bitset<32>(encodedFrequency));
585 start.WriteU8((encodedFrequency & 0xff0000) >> 16); // Most significant byte
586 start.WriteU8((encodedFrequency & 0xff00) >> 8); // Middle byte
587 start.WriteU8(encodedFrequency & 0xff); // Least significant byte
588}
589
590uint8_t
592{
594
595 // Consume the CID
596 start.ReadU8();
597 // Data serialization
598 uint8_t firstByte = start.ReadU8();
599 m_rx1DrOffset = (firstByte & 0b1110000) >> 4;
600 m_rx2DataRate = firstByte & 0b1111;
601 uint32_t secondByte = start.ReadU8();
602 uint32_t thirdByte = start.ReadU8();
603 uint32_t fourthByte = start.ReadU8();
604 uint32_t encodedFrequency = (secondByte << 16) | (thirdByte << 8) | fourthByte;
605 NS_LOG_DEBUG(std::bitset<32>(encodedFrequency));
606 m_frequency = double(encodedFrequency) * 100;
607
608 return m_serializedSize;
609}
610
611void
612RxParamSetupReq::Print(std::ostream& os) const
613{
615
616 os << "RxParamSetupReq" << std::endl;
617 os << "rx1DrOffset: " << unsigned(m_rx1DrOffset) << std::endl;
618 os << "rx2DataRate: " << unsigned(m_rx2DataRate) << std::endl;
619 os << "frequency: " << m_frequency << std::endl;
620}
621
622uint8_t
624{
625 NS_LOG_FUNCTION(this);
626
627 return m_rx1DrOffset;
628}
629
630uint8_t
632{
633 NS_LOG_FUNCTION(this);
634
635 return m_rx2DataRate;
636}
637
638double
640{
641 NS_LOG_FUNCTION(this);
642
643 return m_frequency;
644}
645
646/////////////////////
647// RxParamSetupAns //
648/////////////////////
649
657
658RxParamSetupAns::RxParamSetupAns(bool rx1DrOffsetAck, bool rx2DataRateAck, bool channelAck)
659 : m_rx1DrOffsetAck(rx1DrOffsetAck),
660 m_rx2DataRateAck(rx2DataRateAck),
661 m_channelAck(channelAck)
662{
663 NS_LOG_FUNCTION(this << rx1DrOffsetAck << rx2DataRateAck << channelAck);
664
667}
668
669void
671{
673
674 // Write the CID
675 start.WriteU8(GetCIDFromMacCommand(m_commandType));
676 // Data serialization
677 start.WriteU8(uint8_t(m_rx1DrOffsetAck) << 2 | uint8_t(m_rx2DataRateAck) << 1 |
678 uint8_t(m_channelAck));
679}
680
681uint8_t
683{
685
686 // Consume the CID
687 start.ReadU8();
688
689 uint8_t byte = start.ReadU8();
690
691 m_rx1DrOffsetAck = (byte & 0b100) >> 2;
692 m_rx2DataRateAck = (byte & 0b10) >> 1;
693 m_channelAck = byte & 0b1;
694
695 return m_serializedSize;
696}
697
698void
699RxParamSetupAns::Print(std::ostream& os) const
700{
702
703 os << "RxParamSetupAns" << std::endl;
704 os << "m_rx1DrOffsetAck: " << m_rx1DrOffsetAck << std::endl;
705 os << "m_rx2DataRateAck: " << m_rx2DataRateAck << std::endl;
706 os << "m_channelAck: " << m_channelAck << std::endl;
707}
708
709//////////////////
710// DevStatusReq //
711//////////////////
712
720
721void
723{
725
726 // Write the CID
727 start.WriteU8(GetCIDFromMacCommand(m_commandType));
728}
729
730uint8_t
732{
734
735 // Consume the CID
736 start.ReadU8();
737
738 return m_serializedSize;
739}
740
741void
742DevStatusReq::Print(std::ostream& os) const
743{
745
746 os << "DevStatusReq" << std::endl;
747}
748
749//////////////////
750// DevStatusAns //
751//////////////////
752
760
761DevStatusAns::DevStatusAns(uint8_t battery, uint8_t margin)
762 : m_battery(battery),
763 m_margin(margin)
764{
765 NS_LOG_FUNCTION(this << unsigned(battery) << unsigned(margin));
766
769}
770
771void
773{
775
776 // Write the CID
777 start.WriteU8(GetCIDFromMacCommand(m_commandType));
778 start.WriteU8(m_battery);
779 start.WriteU8(m_margin);
780}
781
782uint8_t
784{
786
787 // Consume the CID
788 start.ReadU8();
789 m_battery = start.ReadU8();
790 m_margin = start.ReadU8() & 0b111111;
791
792 return m_serializedSize;
793}
794
795void
796DevStatusAns::Print(std::ostream& os) const
797{
799
800 os << "DevStatusAns" << std::endl;
801 os << "Battery: " << unsigned(m_battery) << std::endl;
802 os << "Margin: " << unsigned(m_margin) << std::endl;
803}
804
805uint8_t
807{
809
810 return m_battery;
811}
812
813uint8_t
815{
817
818 return m_margin;
819}
820
821//////////////////
822// NewChannelReq //
823//////////////////
824
832
834 double frequency,
835 uint8_t minDataRate,
836 uint8_t maxDataRate)
837 : m_chIndex(chIndex),
838 m_frequency(frequency),
839 m_minDataRate(minDataRate),
840 m_maxDataRate(maxDataRate)
841{
842 NS_LOG_FUNCTION(this);
843
846}
847
848void
850{
852
853 // Write the CID
854 start.WriteU8(GetCIDFromMacCommand(m_commandType));
855
856 start.WriteU8(m_chIndex);
857 uint32_t encodedFrequency = m_frequency / 100;
858 start.WriteU8((encodedFrequency & 0xff0000) >> 16);
859 start.WriteU8((encodedFrequency & 0xff00) >> 8);
860 start.WriteU8(encodedFrequency & 0xff);
861 start.WriteU8((m_maxDataRate << 4) | (m_minDataRate & 0xf));
862}
863
864uint8_t
866{
868
869 // Consume the CID
870 start.ReadU8();
871 // Read the data
872 m_chIndex = start.ReadU8();
873 uint32_t encodedFrequency = 0;
874 encodedFrequency |= uint32_t(start.ReadU16()) << 8;
875 encodedFrequency |= uint32_t(start.ReadU8());
876 m_frequency = double(encodedFrequency) * 100;
877 uint8_t dataRateByte = start.ReadU8();
878 m_maxDataRate = dataRateByte >> 4;
879 m_minDataRate = dataRateByte & 0xf;
880
881 return m_serializedSize;
882}
883
884void
885NewChannelReq::Print(std::ostream& os) const
886{
888
889 os << "NewChannelReq" << std::endl;
890}
891
892uint8_t
894{
896
897 return m_chIndex;
898}
899
900double
902{
904
905 return m_frequency;
906}
907
908uint8_t
915
916uint8_t
923
924///////////////////
925// NewChannelAns //
926///////////////////
927
935
936NewChannelAns::NewChannelAns(bool dataRateRangeOk, bool channelFrequencyOk)
937 : m_dataRateRangeOk(dataRateRangeOk),
938 m_channelFrequencyOk(channelFrequencyOk)
939{
940 NS_LOG_FUNCTION(this);
941
944}
945
946void
948{
950
951 // Write the CID
952 start.WriteU8(GetCIDFromMacCommand(m_commandType));
953
954 start.WriteU8((uint8_t(m_dataRateRangeOk) << 1) | uint8_t(m_channelFrequencyOk));
955}
956
957uint8_t
959{
961
962 // Consume the CID
963 start.ReadU8();
964 // Read the data
965 uint8_t byte = start.ReadU8();
966 m_dataRateRangeOk = (byte & 0b10) >> 1;
967 m_channelFrequencyOk = (byte & 0b1);
968
969 return m_serializedSize;
970}
971
972void
973NewChannelAns::Print(std::ostream& os) const
974{
976
977 os << "NewChannelAns" << std::endl;
978 os << "DataRateRangeOk: " << m_dataRateRangeOk << std::endl;
979 os << "ChannelFrequencyOk: " << m_channelFrequencyOk << std::endl;
980}
981
982//////////////////////
983// RxTimingSetupReq //
984//////////////////////
985
993
995 : m_delay(delay)
996{
997 NS_LOG_FUNCTION(this);
998
1000 m_serializedSize = 2;
1001}
1002
1003void
1005{
1007
1008 // Write the CID
1009 start.WriteU8(GetCIDFromMacCommand(m_commandType));
1010 // Write the data
1011 start.WriteU8(m_delay & 0xf);
1012}
1013
1014uint8_t
1016{
1018
1019 // Consume the CID
1020 start.ReadU8();
1021 // Read the data
1022 m_delay = start.ReadU8() & 0xf;
1023
1024 return m_serializedSize;
1025}
1026
1027void
1028RxTimingSetupReq::Print(std::ostream& os) const
1029{
1031
1032 os << "RxTimingSetupReq" << std::endl;
1033}
1034
1035Time
1037{
1038 NS_LOG_FUNCTION(this);
1039
1040 if (m_delay == 0)
1041 {
1042 return Seconds(1);
1043 }
1044 return Seconds(m_delay);
1045}
1046
1047//////////////////
1048// RxTimingSetupAns //
1049//////////////////
1050
1058
1059void
1061{
1063
1064 // Write the CID
1065 start.WriteU8(GetCIDFromMacCommand(m_commandType));
1066}
1067
1068uint8_t
1070{
1072
1073 // Consume the CID
1074 start.ReadU8();
1075
1076 return m_serializedSize;
1077}
1078
1079void
1080RxTimingSetupAns::Print(std::ostream& os) const
1081{
1083
1084 os << "RxTimingSetupAns" << std::endl;
1085}
1086
1087//////////////////
1088// DlChannelAns //
1089//////////////////
1090
1098
1099void
1101{
1103
1104 // Write the CID
1105 start.WriteU8(GetCIDFromMacCommand(m_commandType));
1106}
1107
1108uint8_t
1110{
1112
1113 // Consume the CID
1114 start.ReadU8();
1115
1116 return m_serializedSize;
1117}
1118
1119void
1120DlChannelAns::Print(std::ostream& os) const
1121{
1123
1124 os << "DlChannelAns" << std::endl;
1125}
1126
1127//////////////////
1128// TxParamSetupReq //
1129//////////////////
1130
1138
1139void
1141{
1143
1144 // Write the CID
1145 start.WriteU8(GetCIDFromMacCommand(m_commandType));
1146}
1147
1148uint8_t
1150{
1152
1153 // Consume the CID
1154 start.ReadU8();
1155
1156 return m_serializedSize;
1157}
1158
1159void
1160TxParamSetupReq::Print(std::ostream& os) const
1161{
1163
1164 os << "TxParamSetupReq" << std::endl;
1165}
1166
1167//////////////////
1168// TxParamSetupAns //
1169//////////////////
1170
1178
1179void
1181{
1183
1184 // Write the CID
1185 start.WriteU8(GetCIDFromMacCommand(m_commandType));
1186}
1187
1188uint8_t
1190{
1192
1193 // Consume the CID
1194 start.ReadU8();
1195
1196 return m_serializedSize;
1197}
1198
1199void
1200TxParamSetupAns::Print(std::ostream& os) const
1201{
1203
1204 os << "TxParamSetupAns" << std::endl;
1205}
1206
1207} // namespace lorawan
1208} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
A base class which provides memory management and object aggregation.
Definition object.h:78
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
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.
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.
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.
double GetMaximumAllowedDutyCycle() const
Get the maximum duty cycle prescribed by this Mac command, in fraction form.
uint8_t m_maxDCycle
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.
static TypeId GetTypeId()
Register this type.
~MacCommand() override
Destructor.
MacCommand()
Default constructor.
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.
double m_frequency
The Frequency field, in Hz.
uint8_t GetMinDataRate() const
Get the the MinDR field contained in this MAC command.
uint8_t GetMaxDataRate() const
Get the the MaxDR field contained in this MAC command.
uint8_t m_maxDataRate
The MaxDR field.
double GetFrequency() const
Get the the Frequency field contained in this MAC command.
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.
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.
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.
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 m_rx1DrOffsetAck
The RX1DROffsetACK 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.
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.
double GetFrequency()
Get this command's frequency.
uint8_t m_rx1DrOffset
The RX1DROffset field.
double m_frequency
The Frequency field, in Hz
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.
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.
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.
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_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#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 ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition log.h:250
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
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.