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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Davide Magrin <magrinda@dei.unipd.it>
18 */
19
20#include "mac-command.h"
21
22#include "ns3/log.h"
23
24#include <bitset>
25#include <cmath>
26
27namespace ns3
28{
29namespace lorawan
30{
31
32NS_LOG_COMPONENT_DEFINE("MacCommand");
33
35
36TypeId
38{
39 static TypeId tid = TypeId("ns3::MacCommand").SetParent<Object>().SetGroupName("lorawan");
40 return tid;
41}
42
44{
45 NS_LOG_FUNCTION(this);
46}
47
49{
50 NS_LOG_FUNCTION(this);
51}
52
55{
57
58 return m_commandType;
59}
60
61uint8_t
63{
65
66 return m_serializedSize;
67}
68
69uint8_t
71{
73
74 switch (commandType)
75 {
76 case (INVALID): {
77 return 0x0;
78 }
79 case (LINK_CHECK_REQ):
80 case (LINK_CHECK_ANS): {
81 return 0x02;
82 }
83 case (LINK_ADR_REQ):
84 case (LINK_ADR_ANS): {
85 return 0x03;
86 }
87 case (DUTY_CYCLE_REQ):
88 case (DUTY_CYCLE_ANS): {
89 return 0x04;
90 }
91 case (RX_PARAM_SETUP_REQ):
92 case (RX_PARAM_SETUP_ANS): {
93 return 0x05;
94 }
95 case (DEV_STATUS_REQ):
96 case (DEV_STATUS_ANS): {
97 return 0x06;
98 }
99 case (NEW_CHANNEL_REQ):
100 case (NEW_CHANNEL_ANS): {
101 return 0x07;
102 }
103 case (RX_TIMING_SETUP_REQ):
104 case (RX_TIMING_SETUP_ANS): {
105 return 0x08;
106 }
107 case (TX_PARAM_SETUP_REQ):
108 case (TX_PARAM_SETUP_ANS): {
109 return 0x09;
110 }
111 case (DL_CHANNEL_REQ):
112 case (DL_CHANNEL_ANS): {
113 return 0x0A;
114 }
115 }
116 return 0;
117}
118
119//////////////////
120// LinkCheckReq //
121//////////////////
122
124{
128}
129
131{
133}
134
135void
137{
139
140 // Write the CID and we're done
141 uint8_t cid = GetCIDFromMacCommand(m_commandType);
142 start.WriteU8(cid);
143 NS_LOG_DEBUG("Serialized LinkCheckReq: " << unsigned(cid));
144}
145
146uint8_t
148{
150
151 // Read the CID
152 start.ReadU8();
153
154 return m_serializedSize;
155}
156
157void
158LinkCheckReq::Print(std::ostream& os) const
159{
161
162 os << "LinkCheckReq" << std::endl;
163}
164
165//////////////////
166// LinkCheckAns //
167//////////////////
168
170 : m_margin(0),
171 m_gwCnt(0)
172{
173 NS_LOG_FUNCTION(this);
174
177}
178
179LinkCheckAns::LinkCheckAns(uint8_t margin, uint8_t gwCnt)
180 : m_margin(margin),
181 m_gwCnt(gwCnt)
182{
183 NS_LOG_FUNCTION(this << unsigned(margin) << unsigned(gwCnt));
184
187}
188
189void
191{
193
194 // Write the CID
195 start.WriteU8(GetCIDFromMacCommand(m_commandType));
196 // Write the margin
197 start.WriteU8(m_margin);
198 // Write the gwCnt
199 start.WriteU8(m_gwCnt);
200}
201
202uint8_t
204{
206
207 // Consume the CID
208 start.ReadU8();
209 m_margin = start.ReadU8();
210 m_gwCnt = start.ReadU8();
211 return m_serializedSize;
212}
213
214void
215LinkCheckAns::Print(std::ostream& os) const
216{
218
219 os << "LinkCheckAns" << std::endl;
220 os << "margin: " << unsigned(m_margin) << std::endl;
221 os << "gwCnt: " << unsigned(m_gwCnt) << std::endl;
222}
223
224void
226{
227 NS_LOG_FUNCTION(this << unsigned(margin));
228
229 m_margin = margin;
230}
231
232uint8_t
234{
235 NS_LOG_FUNCTION(this);
236
237 return m_margin;
238}
239
240void
242{
243 NS_LOG_FUNCTION(this << unsigned(gwCnt));
244
245 m_gwCnt = gwCnt;
246}
247
248uint8_t
250{
251 NS_LOG_FUNCTION(this);
252
253 return m_gwCnt;
254}
255
256void
258{
259 NS_LOG_FUNCTION(this);
260
261 m_gwCnt++;
262}
263
264////////////////
265// LinkAdrReq //
266////////////////
267
269{
270 NS_LOG_FUNCTION(this);
271
274}
275
276LinkAdrReq::LinkAdrReq(uint8_t dataRate,
277 uint8_t txPower,
278 uint16_t channelMask,
279 uint8_t chMaskCntl,
280 uint8_t nbRep)
281 : m_dataRate(dataRate),
282 m_txPower(txPower),
283 m_channelMask(channelMask),
284 m_chMaskCntl(chMaskCntl),
285 m_nbRep(nbRep)
286{
287 NS_LOG_FUNCTION(this);
288
291}
292
293void
295{
297
298 // Write the CID
299 start.WriteU8(GetCIDFromMacCommand(m_commandType));
300 start.WriteU8(m_dataRate << 4 | (m_txPower & 0b1111));
301 start.WriteU16(m_channelMask);
302 start.WriteU8(m_chMaskCntl << 4 | (m_nbRep & 0b1111));
303}
304
305uint8_t
307{
309
310 // Consume the CID
311 start.ReadU8();
312 uint8_t firstByte = start.ReadU8();
313 m_dataRate = firstByte >> 4;
314 m_txPower = firstByte & 0b1111;
315 m_channelMask = start.ReadU16();
316 uint8_t fourthByte = start.ReadU8();
317 m_chMaskCntl = fourthByte >> 4;
318 m_nbRep = fourthByte & 0b1111;
319
320 return m_serializedSize;
321}
322
323void
324LinkAdrReq::Print(std::ostream& os) const
325{
327
328 os << "LinkAdrReq" << std::endl;
329 os << "dataRate: " << unsigned(m_dataRate) << std::endl;
330 os << "txPower: " << unsigned(m_txPower) << std::endl;
331 os << "channelMask: " << std::bitset<16>(m_channelMask) << std::endl;
332 os << "chMaskCntl: " << unsigned(m_chMaskCntl) << std::endl;
333 os << "nbRep: " << unsigned(m_nbRep) << std::endl;
334}
335
336uint8_t
338{
339 NS_LOG_FUNCTION(this);
340
341 return m_dataRate;
342}
343
344uint8_t
346{
347 NS_LOG_FUNCTION(this);
348
349 return m_txPower;
350}
351
352std::list<int>
354{
355 NS_LOG_FUNCTION(this);
356
357 std::list<int> channelIndices;
358 for (int i = 0; i < 16; i++)
359 {
360 if (m_channelMask & (0b1 << i)) // Take channel mask's i-th bit
361 {
362 NS_LOG_DEBUG("Adding channel index " << i);
363 channelIndices.push_back(i);
364 }
365 }
366
367 return channelIndices;
368}
369
370int
372{
373 NS_LOG_FUNCTION(this);
374
375 return m_nbRep;
376}
377
378////////////////
379// LinkAdrAns //
380////////////////
381
383{
384 NS_LOG_FUNCTION(this);
385
388}
389
390LinkAdrAns::LinkAdrAns(bool powerAck, bool dataRateAck, bool channelMaskAck)
391 : m_powerAck(powerAck),
392 m_dataRateAck(dataRateAck),
393 m_channelMaskAck(channelMaskAck)
394{
395 NS_LOG_FUNCTION(this);
396
399}
400
401void
403{
405
406 // Write the CID
407 start.WriteU8(GetCIDFromMacCommand(m_commandType));
408 // We can assume that true will be converted to 1 and that false will be
409 // converted to 0 on any C++ compiler
410 start.WriteU8((uint8_t(m_powerAck) << 2) | (uint8_t(m_dataRateAck) << 1) |
411 uint8_t(m_channelMaskAck));
412}
413
414uint8_t
416{
418
419 // Consume the CID
420 start.ReadU8();
421
422 uint8_t byte = start.ReadU8();
423
424 m_powerAck = byte & 0b100;
425 m_dataRateAck = byte & 0b10;
426 m_channelMaskAck = byte & 0b1;
427
428 return m_serializedSize;
429}
430
431void
432LinkAdrAns::Print(std::ostream& os) const
433{
435
436 os << "LinkAdrAns" << std::endl;
437}
438
439//////////////////
440// DutyCycleReq //
441//////////////////
442
444{
445 NS_LOG_FUNCTION(this);
446
449}
450
452 : m_maxDCycle(dutyCycle)
453{
454 NS_LOG_FUNCTION(this);
455
458}
459
460void
462{
464
465 // Write the CID
466 start.WriteU8(GetCIDFromMacCommand(m_commandType));
467 start.WriteU8(m_maxDCycle);
468}
469
470uint8_t
472{
474
475 // Consume the CID
476 start.ReadU8();
477 m_maxDCycle = start.ReadU8();
478
479 return m_serializedSize;
480}
481
482void
483DutyCycleReq::Print(std::ostream& os) const
484{
486
487 os << "DutyCycleReq" << std::endl;
488 os << "maxDCycle: " << unsigned(m_maxDCycle) << std::endl;
489 os << "maxDCycle (fraction): " << GetMaximumAllowedDutyCycle() << std::endl;
490}
491
492double
494{
495 NS_LOG_FUNCTION(this);
496
497 // Check if we need to turn off completely
498 if (m_maxDCycle == 255)
499 {
500 return 0;
501 }
502
503 if (m_maxDCycle == 0)
504 {
505 return 1;
506 }
507
508 return 1 / std::pow(2, double(m_maxDCycle));
509}
510
511//////////////////
512// DutyCycleAns //
513//////////////////
514
516{
517 NS_LOG_FUNCTION(this);
518
521}
522
523void
525{
527
528 // Write the CID
529 start.WriteU8(GetCIDFromMacCommand(m_commandType));
530}
531
532uint8_t
534{
536
537 // Consume the CID
538 start.ReadU8();
539 return m_serializedSize;
540}
541
542void
543DutyCycleAns::Print(std::ostream& os) const
544{
546
547 os << "DutyCycleAns" << std::endl;
548}
549
550//////////////////
551// RxParamSetupReq //
552//////////////////
553
555{
556 NS_LOG_FUNCTION(this);
557
560}
561
562RxParamSetupReq::RxParamSetupReq(uint8_t rx1DrOffset, uint8_t rx2DataRate, double frequency)
563 : m_rx1DrOffset(rx1DrOffset),
564 m_rx2DataRate(rx2DataRate),
565 m_frequency(frequency)
566{
567 NS_LOG_FUNCTION(this << unsigned(rx1DrOffset) << unsigned(rx2DataRate) << frequency);
568
569 if ((rx1DrOffset & 0b11111000) != 0)
570 {
572 "Warning: received an rx1DrOffset greater than 7. Actual value will be different.");
573 }
574 if ((rx2DataRate & 0b11110000) != 0)
575 {
577 "Warning: received a rx2DataRate greater than 15. Actual value will be different.");
578 }
579
582}
583
584void
586{
588
589 // Write the CID
590 start.WriteU8(GetCIDFromMacCommand(m_commandType));
591 // Data serialization
592 start.WriteU8((m_rx1DrOffset & 0b111) << 4 | (m_rx2DataRate & 0b1111));
593 uint32_t encodedFrequency = m_frequency / 100;
594 NS_LOG_DEBUG(unsigned(encodedFrequency));
595 NS_LOG_DEBUG(std::bitset<32>(encodedFrequency));
596 start.WriteU8((encodedFrequency & 0xff0000) >> 16); // Most significant byte
597 start.WriteU8((encodedFrequency & 0xff00) >> 8); // Middle byte
598 start.WriteU8(encodedFrequency & 0xff); // Least significant byte
599}
600
601uint8_t
603{
605
606 // Consume the CID
607 start.ReadU8();
608 // Data serialization
609 uint8_t firstByte = start.ReadU8();
610 m_rx1DrOffset = (firstByte & 0b1110000) >> 4;
611 m_rx2DataRate = firstByte & 0b1111;
612 uint32_t secondByte = start.ReadU8();
613 uint32_t thirdByte = start.ReadU8();
614 uint32_t fourthByte = start.ReadU8();
615 uint32_t encodedFrequency = (secondByte << 16) | (thirdByte << 8) | fourthByte;
616 NS_LOG_DEBUG(std::bitset<32>(encodedFrequency));
617 m_frequency = double(encodedFrequency) * 100;
618
619 return m_serializedSize;
620}
621
622void
623RxParamSetupReq::Print(std::ostream& os) const
624{
626
627 os << "RxParamSetupReq" << std::endl;
628 os << "rx1DrOffset: " << unsigned(m_rx1DrOffset) << std::endl;
629 os << "rx2DataRate: " << unsigned(m_rx2DataRate) << std::endl;
630 os << "frequency: " << m_frequency << std::endl;
631}
632
633uint8_t
635{
636 NS_LOG_FUNCTION(this);
637
638 return m_rx1DrOffset;
639}
640
641uint8_t
643{
644 NS_LOG_FUNCTION(this);
645
646 return m_rx2DataRate;
647}
648
649double
651{
652 NS_LOG_FUNCTION(this);
653
654 return m_frequency;
655}
656
657/////////////////////
658// RxParamSetupAns //
659/////////////////////
660
662{
663 NS_LOG_FUNCTION(this);
664
667}
668
669RxParamSetupAns::RxParamSetupAns(bool rx1DrOffsetAck, bool rx2DataRateAck, bool channelAck)
670 : m_rx1DrOffsetAck(rx1DrOffsetAck),
671 m_rx2DataRateAck(rx2DataRateAck),
672 m_channelAck(channelAck)
673{
674 NS_LOG_FUNCTION(this << rx1DrOffsetAck << rx2DataRateAck << channelAck);
675
678}
679
680void
682{
684
685 // Write the CID
686 start.WriteU8(GetCIDFromMacCommand(m_commandType));
687 // Data serialization
688 start.WriteU8(uint8_t(m_rx1DrOffsetAck) << 2 | uint8_t(m_rx2DataRateAck) << 1 |
689 uint8_t(m_channelAck));
690}
691
692uint8_t
694{
696
697 // Consume the CID
698 start.ReadU8();
699
700 uint8_t byte = start.ReadU8();
701
702 m_rx1DrOffsetAck = (byte & 0b100) >> 2;
703 m_rx2DataRateAck = (byte & 0b10) >> 1;
704 m_channelAck = byte & 0b1;
705
706 return m_serializedSize;
707}
708
709void
710RxParamSetupAns::Print(std::ostream& os) const
711{
713
714 os << "RxParamSetupAns" << std::endl;
715 os << "m_rx1DrOffsetAck: " << m_rx1DrOffsetAck << std::endl;
716 os << "m_rx2DataRateAck: " << m_rx2DataRateAck << std::endl;
717 os << "m_channelAck: " << m_channelAck << std::endl;
718}
719
720//////////////////
721// DevStatusReq //
722//////////////////
723
725{
726 NS_LOG_FUNCTION(this);
727
730}
731
732void
734{
736
737 // Write the CID
738 start.WriteU8(GetCIDFromMacCommand(m_commandType));
739}
740
741uint8_t
743{
745
746 // Consume the CID
747 start.ReadU8();
748
749 return m_serializedSize;
750}
751
752void
753DevStatusReq::Print(std::ostream& os) const
754{
756
757 os << "DevStatusReq" << std::endl;
758}
759
760//////////////////
761// DevStatusAns //
762//////////////////
763
765{
766 NS_LOG_FUNCTION(this);
767
770}
771
772DevStatusAns::DevStatusAns(uint8_t battery, uint8_t margin)
773 : m_battery(battery),
774 m_margin(margin)
775{
776 NS_LOG_FUNCTION(this << unsigned(battery) << unsigned(margin));
777
780}
781
782void
784{
786
787 // Write the CID
788 start.WriteU8(GetCIDFromMacCommand(m_commandType));
789 start.WriteU8(m_battery);
790 start.WriteU8(m_margin);
791}
792
793uint8_t
795{
797
798 // Consume the CID
799 start.ReadU8();
800 m_battery = start.ReadU8();
801 m_margin = start.ReadU8() & 0b111111;
802
803 return m_serializedSize;
804}
805
806void
807DevStatusAns::Print(std::ostream& os) const
808{
810
811 os << "DevStatusAns" << std::endl;
812 os << "Battery: " << unsigned(m_battery) << std::endl;
813 os << "Margin: " << unsigned(m_margin) << std::endl;
814}
815
816uint8_t
818{
820
821 return m_battery;
822}
823
824uint8_t
826{
828
829 return m_margin;
830}
831
832//////////////////
833// NewChannelReq //
834//////////////////
835
837{
838 NS_LOG_FUNCTION(this);
839
842}
843
845 double frequency,
846 uint8_t minDataRate,
847 uint8_t maxDataRate)
848 : m_chIndex(chIndex),
849 m_frequency(frequency),
850 m_minDataRate(minDataRate),
851 m_maxDataRate(maxDataRate)
852{
853 NS_LOG_FUNCTION(this);
854
857}
858
859void
861{
863
864 // Write the CID
865 start.WriteU8(GetCIDFromMacCommand(m_commandType));
866
867 start.WriteU8(m_chIndex);
868 uint32_t encodedFrequency = m_frequency / 100;
869 start.WriteU8((encodedFrequency & 0xff0000) >> 16);
870 start.WriteU8((encodedFrequency & 0xff00) >> 8);
871 start.WriteU8(encodedFrequency & 0xff);
872 start.WriteU8((m_maxDataRate << 4) | (m_minDataRate & 0xf));
873}
874
875uint8_t
877{
879
880 // Consume the CID
881 start.ReadU8();
882 // Read the data
883 m_chIndex = start.ReadU8();
884 uint32_t encodedFrequency = 0;
885 encodedFrequency |= uint32_t(start.ReadU16()) << 8;
886 encodedFrequency |= uint32_t(start.ReadU8());
887 m_frequency = double(encodedFrequency) * 100;
888 uint8_t dataRateByte = start.ReadU8();
889 m_maxDataRate = dataRateByte >> 4;
890 m_minDataRate = dataRateByte & 0xf;
891
892 return m_serializedSize;
893}
894
895void
896NewChannelReq::Print(std::ostream& os) const
897{
899
900 os << "NewChannelReq" << std::endl;
901}
902
903uint8_t
905{
907
908 return m_chIndex;
909}
910
911double
913{
915
916 return m_frequency;
917}
918
919uint8_t
921{
923
924 return m_minDataRate;
925}
926
927uint8_t
929{
931
932 return m_maxDataRate;
933}
934
935///////////////////
936// NewChannelAns //
937///////////////////
938
940{
941 NS_LOG_FUNCTION(this);
942
945}
946
947NewChannelAns::NewChannelAns(bool dataRateRangeOk, bool channelFrequencyOk)
948 : m_dataRateRangeOk(dataRateRangeOk),
949 m_channelFrequencyOk(channelFrequencyOk)
950{
951 NS_LOG_FUNCTION(this);
952
955}
956
957void
959{
961
962 // Write the CID
963 start.WriteU8(GetCIDFromMacCommand(m_commandType));
964
965 start.WriteU8((uint8_t(m_dataRateRangeOk) << 1) | uint8_t(m_channelFrequencyOk));
966}
967
968uint8_t
970{
972
973 // Consume the CID
974 start.ReadU8();
975 // Read the data
976 uint8_t byte = start.ReadU8();
977 m_dataRateRangeOk = (byte & 0b10) >> 1;
978 m_channelFrequencyOk = (byte & 0b1);
979
980 return m_serializedSize;
981}
982
983void
984NewChannelAns::Print(std::ostream& os) const
985{
987
988 os << "NewChannelAns" << std::endl;
989 os << "DataRateRangeOk: " << m_dataRateRangeOk << std::endl;
990 os << "ChannelFrequencyOk: " << m_channelFrequencyOk << std::endl;
991}
992
993//////////////////////
994// RxTimingSetupReq //
995//////////////////////
996
998{
999 NS_LOG_FUNCTION(this);
1000
1002 m_serializedSize = 2;
1003}
1004
1006 : m_delay(delay)
1007{
1008 NS_LOG_FUNCTION(this);
1009
1011 m_serializedSize = 2;
1012}
1013
1014void
1016{
1018
1019 // Write the CID
1020 start.WriteU8(GetCIDFromMacCommand(m_commandType));
1021 // Write the data
1022 start.WriteU8(m_delay & 0xf);
1023}
1024
1025uint8_t
1027{
1029
1030 // Consume the CID
1031 start.ReadU8();
1032 // Read the data
1033 m_delay = start.ReadU8() & 0xf;
1034
1035 return m_serializedSize;
1036}
1037
1038void
1039RxTimingSetupReq::Print(std::ostream& os) const
1040{
1042
1043 os << "RxTimingSetupReq" << std::endl;
1044}
1045
1046Time
1048{
1049 NS_LOG_FUNCTION(this);
1050
1051 if (m_delay == 0)
1052 {
1053 return Seconds(1);
1054 }
1055 return Seconds(m_delay);
1056}
1057
1058//////////////////
1059// RxTimingSetupAns //
1060//////////////////
1061
1063{
1064 NS_LOG_FUNCTION(this);
1065
1067 m_serializedSize = 1;
1068}
1069
1070void
1072{
1074
1075 // Write the CID
1076 start.WriteU8(GetCIDFromMacCommand(m_commandType));
1077}
1078
1079uint8_t
1081{
1083
1084 // Consume the CID
1085 start.ReadU8();
1086
1087 return m_serializedSize;
1088}
1089
1090void
1091RxTimingSetupAns::Print(std::ostream& os) const
1092{
1094
1095 os << "RxTimingSetupAns" << std::endl;
1096}
1097
1098//////////////////
1099// DlChannelAns //
1100//////////////////
1101
1103{
1104 NS_LOG_FUNCTION(this);
1105
1107 m_serializedSize = 1;
1108}
1109
1110void
1112{
1114
1115 // Write the CID
1116 start.WriteU8(GetCIDFromMacCommand(m_commandType));
1117}
1118
1119uint8_t
1121{
1123
1124 // Consume the CID
1125 start.ReadU8();
1126
1127 return m_serializedSize;
1128}
1129
1130void
1131DlChannelAns::Print(std::ostream& os) const
1132{
1134
1135 os << "DlChannelAns" << std::endl;
1136}
1137
1138//////////////////
1139// TxParamSetupReq //
1140//////////////////
1141
1143{
1144 NS_LOG_FUNCTION(this);
1145
1147 m_serializedSize = 1;
1148}
1149
1150void
1152{
1154
1155 // Write the CID
1156 start.WriteU8(GetCIDFromMacCommand(m_commandType));
1157}
1158
1159uint8_t
1161{
1163
1164 // Consume the CID
1165 start.ReadU8();
1166
1167 return m_serializedSize;
1168}
1169
1170void
1171TxParamSetupReq::Print(std::ostream& os) const
1172{
1174
1175 os << "TxParamSetupReq" << std::endl;
1176}
1177
1178//////////////////
1179// TxParamSetupAns //
1180//////////////////
1181
1183{
1184 NS_LOG_FUNCTION(this);
1185
1187 m_serializedSize = 1;
1188}
1189
1190void
1192{
1194
1195 // Write the CID
1196 start.WriteU8(GetCIDFromMacCommand(m_commandType));
1197}
1198
1199uint8_t
1201{
1203
1204 // Consume the CID
1205 start.ReadU8();
1206
1207 return m_serializedSize;
1208}
1209
1210void
1211TxParamSetupAns::Print(std::ostream& os) const
1212{
1214
1215 os << "TxParamSetupAns" << std::endl;
1216}
1217
1218} // namespace lorawan
1219} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
A base class which provides memory management and object aggregation.
Definition: object.h:89
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
uint8_t GetMargin() const
Get the demodulation margin contained in this MAC command.
Definition: mac-command.cc:825
DevStatusAns()
Default constructor.
Definition: mac-command.cc:764
uint8_t m_battery
The Battery field.
Definition: mac-command.h:506
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
Definition: mac-command.cc:783
uint8_t GetBattery() const
Get the battery information contained in this MAC command.
Definition: mac-command.cc:817
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
Definition: mac-command.cc:794
uint8_t m_margin
The RadioStatus field.
Definition: mac-command.h:507
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
Definition: mac-command.cc:807
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
Definition: mac-command.cc:733
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
Definition: mac-command.cc:753
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
Definition: mac-command.cc:742
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.
Definition: mac-command.cc:524
DutyCycleAns()
Default constructor.
Definition: mac-command.cc:515
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
Definition: mac-command.cc:533
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
Definition: mac-command.cc:543
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
Definition: mac-command.cc:471
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
Definition: mac-command.cc:461
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
Definition: mac-command.cc:483
double GetMaximumAllowedDutyCycle() const
Get the maximum duty cycle prescribed by this Mac command, in fraction form.
Definition: mac-command.cc:493
uint8_t m_maxDCycle
The MaxDutyCycle field.
Definition: mac-command.h:353
virtual enum MacCommandType GetCommandType() const
Get the commandType of this MAC command.
Definition: mac-command.cc:54
virtual uint8_t GetSerializedSize() const
Get serialized length of this MAC command.
Definition: mac-command.cc:62
uint8_t m_serializedSize
This MAC command's serialized size.
Definition: mac-command.h:126
enum MacCommandType m_commandType
The type of this command.
Definition: mac-command.h:125
static uint8_t GetCIDFromMacCommand(enum MacCommandType commandType)
Get the CID that corresponds to a type of MAC command.
Definition: mac-command.cc:70
static TypeId GetTypeId()
Register this type.
Definition: mac-command.cc:37
~MacCommand() override
Destructor.
Definition: mac-command.cc:48
MacCommand()
Default constructor.
Definition: mac-command.cc:43
bool m_channelFrequencyOk
The Channel frequency ok field.
Definition: mac-command.h:595
NewChannelAns()
Default constructor.
Definition: mac-command.cc:939
bool m_dataRateRangeOk
The Data-rate range ok field.
Definition: mac-command.h:594
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
Definition: mac-command.cc:969
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
Definition: mac-command.cc:984
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
Definition: mac-command.cc:958
double m_frequency
The Frequency field, in Hz.
Definition: mac-command.h:564
uint8_t GetMinDataRate() const
Get the the MinDR field contained in this MAC command.
Definition: mac-command.cc:920
uint8_t GetMaxDataRate() const
Get the the MaxDR field contained in this MAC command.
Definition: mac-command.cc:928
uint8_t m_maxDataRate
The MaxDR field.
Definition: mac-command.h:566
double GetFrequency() const
Get the the Frequency field contained in this MAC command.
Definition: mac-command.cc:912
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
Definition: mac-command.cc:876
uint8_t m_minDataRate
The MinDR field.
Definition: mac-command.h:565
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
Definition: mac-command.cc:860
uint8_t GetChannelIndex() const
Get the the ChIndex field contained in this MAC command.
Definition: mac-command.cc:904
uint8_t m_chIndex
The ChIndex field.
Definition: mac-command.h:563
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
Definition: mac-command.cc:896
bool m_rx2DataRateAck
The RX2DataRateACK field.
Definition: mac-command.h:450
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
Definition: mac-command.cc:681
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
Definition: mac-command.cc:710
bool m_channelAck
The ChannelACK field.
Definition: mac-command.h:451
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
Definition: mac-command.cc:693
bool m_rx1DrOffsetAck
The RX1DROffsetACK field.
Definition: mac-command.h:449
uint8_t Deserialize(Buffer::Iterator &start) override
Deserialize the buffer into a MAC command.
Definition: mac-command.cc:602
void Print(std::ostream &os) const override
Print the contents of this MAC command in human-readable format.
Definition: mac-command.cc:623
uint8_t GetRx1DrOffset()
Get this command's Rx1DrOffset parameter.
Definition: mac-command.cc:634
uint8_t m_rx2DataRate
The RX2DataRate field.
Definition: mac-command.h:422
void Serialize(Buffer::Iterator &start) const override
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
Definition: mac-command.cc:585
uint8_t GetRx2DataRate()
Get this command's Rx2DataRate parameter.
Definition: mac-command.cc:642
double GetFrequency()
Get this command's frequency.
Definition: mac-command.cc:650
uint8_t m_rx1DrOffset
The RX1DROffset field.
Definition: mac-command.h:421
double m_frequency
The Frequency field, in Hz
Definition: mac-command.h:423
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.
Definition: mac-command.h:627
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:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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:261
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
MacCommandType
Enum for every possible command type.
Definition: mac-command.h:36
@ RX_PARAM_SETUP_REQ
Definition: mac-command.h:44
@ RX_PARAM_SETUP_ANS
Definition: mac-command.h:45
@ TX_PARAM_SETUP_ANS
Definition: mac-command.h:53
@ RX_TIMING_SETUP_REQ
Definition: mac-command.h:50
@ RX_TIMING_SETUP_ANS
Definition: mac-command.h:51
@ TX_PARAM_SETUP_REQ
Definition: mac-command.h:52
Every class exported by the ns3 library is enclosed in the ns3 namespace.