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
44{
45 NS_LOG_FUNCTION(this);
46 return m_commandType;
47}
48
49uint8_t
55
56uint8_t
58{
60 switch (commandType)
61 {
62 case (INVALID): {
63 return 0x0;
64 }
65 case (LINK_CHECK_REQ):
66 case (LINK_CHECK_ANS): {
67 return 0x02;
68 }
69 case (LINK_ADR_REQ):
70 case (LINK_ADR_ANS): {
71 return 0x03;
72 }
73 case (DUTY_CYCLE_REQ):
74 case (DUTY_CYCLE_ANS): {
75 return 0x04;
76 }
77 case (RX_PARAM_SETUP_REQ):
78 case (RX_PARAM_SETUP_ANS): {
79 return 0x05;
80 }
81 case (DEV_STATUS_REQ):
82 case (DEV_STATUS_ANS): {
83 return 0x06;
84 }
85 case (NEW_CHANNEL_REQ):
86 case (NEW_CHANNEL_ANS): {
87 return 0x07;
88 }
90 case (RX_TIMING_SETUP_ANS): {
91 return 0x08;
92 }
93 case (TX_PARAM_SETUP_REQ):
94 case (TX_PARAM_SETUP_ANS): {
95 return 0x09;
96 }
97 case (DL_CHANNEL_REQ):
98 case (DL_CHANNEL_ANS): {
99 return 0x0A;
100 }
101 }
102 return 0;
103}
104
105//////////////////
106// LinkCheckReq //
107//////////////////
108
115
116void
118{
119 NS_LOG_FUNCTION(this);
120 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
121}
122
123uint8_t
125{
126 NS_LOG_FUNCTION(this);
127 start.ReadU8(); // Consume the CID
128 return m_serializedSize;
129}
130
131void
132LinkCheckReq::Print(std::ostream& os) const
133{
134 NS_LOG_FUNCTION(this);
135 os << "LinkCheckReq()";
136}
137
138//////////////////
139// LinkCheckAns //
140//////////////////
141
148
149LinkCheckAns::LinkCheckAns(uint8_t margin, uint8_t gwCnt)
150 : m_margin(margin),
151 m_gwCnt(gwCnt)
152{
153 NS_LOG_FUNCTION(this << unsigned(margin) << unsigned(gwCnt));
156}
157
158void
160{
161 NS_LOG_FUNCTION(this);
162 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
163 start.WriteU8(m_margin); // Write the margin
164 start.WriteU8(m_gwCnt); // Write the gwCnt
165}
166
167uint8_t
169{
170 NS_LOG_FUNCTION(this);
171 start.ReadU8(); // Consume the CID
172 m_margin = start.ReadU8();
173 m_gwCnt = start.ReadU8();
174 return m_serializedSize;
175}
176
177void
178LinkCheckAns::Print(std::ostream& os) const
179{
180 NS_LOG_FUNCTION(this);
181 os << "LinkCheckAns(";
182 os << "Margin=" << unsigned(m_margin);
183 os << ", GwCnt=" << unsigned(m_gwCnt);
184 os << ")";
185}
186
187uint8_t
189{
190 NS_LOG_FUNCTION(this);
191 return m_margin;
192}
193
194uint8_t
196{
197 NS_LOG_FUNCTION(this);
198
199 return m_gwCnt;
200}
201
202////////////////
203// LinkAdrReq //
204////////////////
205
212
213LinkAdrReq::LinkAdrReq(uint8_t dataRate,
214 uint8_t txPower,
215 uint16_t chMask,
216 uint8_t chMaskCntl,
217 uint8_t nbTrans)
218 : m_dataRate(dataRate),
219 m_txPower(txPower),
220 m_chMask(chMask),
221 m_chMaskCntl(chMaskCntl),
222 m_nbTrans(nbTrans)
223{
224 NS_LOG_FUNCTION(this);
225 NS_ASSERT_MSG(!(dataRate & 0xF0), "dataRate field > 4 bits");
226 NS_ASSERT_MSG(!(txPower & 0xF0), "txPower field > 4 bits");
227 NS_ASSERT_MSG(!(chMaskCntl & 0xF8), "chMaskCntl field > 3 bits");
228 NS_ASSERT_MSG(!(nbTrans & 0xF0), "nbTrans field > 4 bits");
231}
232
233void
235{
236 NS_LOG_FUNCTION(this);
237 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
238 start.WriteU8(m_dataRate << 4 | (m_txPower & 0b1111));
239 start.WriteU16(m_chMask);
240 start.WriteU8(m_chMaskCntl << 4 | (m_nbTrans & 0b1111));
241}
242
243uint8_t
245{
246 NS_LOG_FUNCTION(this);
247 start.ReadU8(); // Consume the CID
248 uint8_t firstByte = start.ReadU8();
249 m_dataRate = firstByte >> 4;
250 m_txPower = firstByte & 0b1111;
251 m_chMask = start.ReadU16();
252 uint8_t fourthByte = start.ReadU8();
253 m_chMaskCntl = fourthByte >> 4;
254 m_nbTrans = fourthByte & 0b1111;
255 return m_serializedSize;
256}
257
258void
259LinkAdrReq::Print(std::ostream& os) const
260{
261 NS_LOG_FUNCTION(this);
262 os << "LinkAdrReq(";
263 os << "DataRate=" << unsigned(m_dataRate);
264 os << ", TXPower=" << unsigned(m_txPower);
265 os << ", ChMask=" << std::bitset<16>(m_chMask);
266 os << ", ChMaskCntl=" << unsigned(m_chMaskCntl);
267 os << ", NbTrans=" << unsigned(m_nbTrans);
268 os << ")";
269}
270
271uint8_t
273{
274 NS_LOG_FUNCTION(this);
275 return m_dataRate;
276}
277
278uint8_t
280{
281 NS_LOG_FUNCTION(this);
282 return m_txPower;
283}
284
285uint16_t
287{
288 NS_LOG_FUNCTION(this);
289 return m_chMask;
290}
291
292uint8_t
294{
295 NS_LOG_FUNCTION(this);
296 return m_chMaskCntl;
297}
298
299uint8_t
301{
302 NS_LOG_FUNCTION(this);
303 return m_nbTrans;
304}
305
306////////////////
307// LinkAdrAns //
308////////////////
309
316
317LinkAdrAns::LinkAdrAns(bool powerAck, bool dataRateAck, bool channelMaskAck)
318 : m_powerAck(powerAck),
319 m_dataRateAck(dataRateAck),
320 m_channelMaskAck(channelMaskAck)
321{
322 NS_LOG_FUNCTION(this);
325}
326
327void
329{
330 NS_LOG_FUNCTION(this);
331 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
332 start.WriteU8((uint8_t(m_powerAck) << 2) | (uint8_t(m_dataRateAck) << 1) |
333 uint8_t(m_channelMaskAck));
334}
335
336uint8_t
338{
339 NS_LOG_FUNCTION(this);
340 start.ReadU8(); // Consume the CID
341 uint8_t byte = start.ReadU8();
342 m_powerAck = byte & 0b100;
343 m_dataRateAck = byte & 0b10;
344 m_channelMaskAck = byte & 0b1;
345 return m_serializedSize;
346}
347
348void
349LinkAdrAns::Print(std::ostream& os) const
350{
351 NS_LOG_FUNCTION(this);
352 os << "LinkAdrAns(";
353 os << "PowerACK=" << m_powerAck;
354 os << ", DataRateACK=" << m_dataRateAck;
355 os << ", ChannelMaskACK=" << m_channelMaskAck;
356 os << ")";
357}
358
359bool
361{
362 NS_LOG_FUNCTION(this);
363 return m_powerAck;
364}
365
366bool
368{
369 NS_LOG_FUNCTION(this);
370 return m_dataRateAck;
371}
372
373bool
375{
376 NS_LOG_FUNCTION(this);
377 return m_channelMaskAck;
378}
379
380//////////////////
381// DutyCycleReq //
382//////////////////
383
390
391DutyCycleReq::DutyCycleReq(uint8_t maxDutyCycle)
392{
393 NS_LOG_FUNCTION(this << unsigned(maxDutyCycle));
394 NS_ASSERT_MSG(!(maxDutyCycle & 0xF0), "maxDutyCycle > 4 bits");
395 m_maxDutyCycle = maxDutyCycle;
398}
399
400void
402{
403 NS_LOG_FUNCTION(this);
404 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
405 start.WriteU8(m_maxDutyCycle);
406}
407
408uint8_t
410{
411 NS_LOG_FUNCTION(this);
412 start.ReadU8(); // Consume the CID
413 m_maxDutyCycle = start.ReadU8();
414 return m_serializedSize;
415}
416
417void
418DutyCycleReq::Print(std::ostream& os) const
419{
420 NS_LOG_FUNCTION(this);
421 os << "DutyCycleReq(";
422 os << "MaxDutyCycle=" << unsigned(m_maxDutyCycle);
423 os << ")";
424}
425
426uint8_t
428{
429 NS_LOG_FUNCTION(this);
430 return m_maxDutyCycle;
431}
432
433//////////////////
434// DutyCycleAns //
435//////////////////
436
443
444void
446{
447 NS_LOG_FUNCTION(this);
448 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
449}
450
451uint8_t
453{
454 NS_LOG_FUNCTION(this);
455 start.ReadU8(); // Consume the CID
456 return m_serializedSize;
457}
458
459void
460DutyCycleAns::Print(std::ostream& os) const
461{
462 NS_LOG_FUNCTION(this);
463 os << "DutyCycleAns()";
464}
465
466/////////////////////
467// RxParamSetupReq //
468/////////////////////
469
476
477RxParamSetupReq::RxParamSetupReq(uint8_t rx1DrOffset, uint8_t rx2DataRate, uint32_t frequencyHz)
478 : m_rx1DrOffset(rx1DrOffset),
479 m_rx2DataRate(rx2DataRate),
480 m_frequencyHz(frequencyHz)
481{
482 NS_LOG_FUNCTION(this << unsigned(rx1DrOffset) << unsigned(rx2DataRate) << frequencyHz);
483 NS_ASSERT_MSG(!(rx1DrOffset & 0xF8), "rx1DrOffset > 3 bits");
484 NS_ASSERT_MSG(!(rx2DataRate & 0xF0), "rx2DataRate > 4 bits");
487}
488
489void
491{
492 NS_LOG_FUNCTION(this);
493 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
494 start.WriteU8((m_rx1DrOffset & 0b111) << 4 | (m_rx2DataRate & 0b1111));
495 uint32_t encodedFrequency = m_frequencyHz / 100;
496 // Frequency is in little endian (lsb -> msb)
497 start.WriteU8(encodedFrequency); // Least significant byte
498 start.WriteU8(encodedFrequency >> 8); // Middle byte
499 start.WriteU8(encodedFrequency >> 16); // Most significant byte
500}
501
502uint8_t
504{
505 NS_LOG_FUNCTION(this);
506 start.ReadU8(); // Consume the CID
507 uint8_t firstByte = start.ReadU8();
508 m_rx1DrOffset = (firstByte & 0b1110000) >> 4;
509 m_rx2DataRate = firstByte & 0b1111;
510 uint32_t encodedFrequency = 0;
511 // Frequency is in little endian (lsb -> msb)
512 encodedFrequency += start.ReadU8(); // Least significant byte
513 encodedFrequency += start.ReadU8() << 8; // Middle byte
514 encodedFrequency += start.ReadU8() << 16; // Most significant byte
515 m_frequencyHz = encodedFrequency * 100;
516 return m_serializedSize;
517}
518
519void
520RxParamSetupReq::Print(std::ostream& os) const
521{
522 NS_LOG_FUNCTION(this);
523 os << "RxParamSetupReq(";
524 os << "RX1DROffset=" << unsigned(m_rx1DrOffset);
525 os << ", RX2DataRate=" << unsigned(m_rx2DataRate);
526 os << ", Frequency=" << m_frequencyHz;
527 os << ")";
528}
529
530uint8_t
536
537uint8_t
543
550
551/////////////////////
552// RxParamSetupAns //
553/////////////////////
554
561
562RxParamSetupAns::RxParamSetupAns(bool rx1DrOffsetAck, bool rx2DataRateAck, bool channelAck)
563 : m_rx1DrOffsetAck(rx1DrOffsetAck),
564 m_rx2DataRateAck(rx2DataRateAck),
565 m_channelAck(channelAck)
566{
567 NS_LOG_FUNCTION(this << rx1DrOffsetAck << rx2DataRateAck << channelAck);
570}
571
572void
574{
575 NS_LOG_FUNCTION(this);
576 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
577 start.WriteU8(uint8_t(m_rx1DrOffsetAck) << 2 | uint8_t(m_rx2DataRateAck) << 1 |
578 uint8_t(m_channelAck));
579}
580
581uint8_t
583{
584 NS_LOG_FUNCTION(this);
585 start.ReadU8(); // Consume the CID
586 uint8_t byte = start.ReadU8();
587 m_rx1DrOffsetAck = (byte & 0b100) >> 2;
588 m_rx2DataRateAck = (byte & 0b10) >> 1;
589 m_channelAck = byte & 0b1;
590 return m_serializedSize;
591}
592
593void
594RxParamSetupAns::Print(std::ostream& os) const
595{
596 NS_LOG_FUNCTION(this);
597 os << "RxParamSetupAns(";
598 os << "RX1DROffsetACK=" << m_rx1DrOffsetAck;
599 os << ", RX2DataRateACK=" << m_rx2DataRateAck;
600 os << ", ChannelACK=" << m_channelAck;
601 os << ")";
602}
603
604bool
610
611bool
617
618bool
620{
621 NS_LOG_FUNCTION(this);
622 return m_channelAck;
623}
624
625//////////////////
626// DevStatusReq //
627//////////////////
628
635
636void
638{
639 NS_LOG_FUNCTION(this);
640 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
641}
642
643uint8_t
645{
646 NS_LOG_FUNCTION(this);
647 start.ReadU8(); // Consume the CID
648 return m_serializedSize;
649}
650
651void
652DevStatusReq::Print(std::ostream& os) const
653{
654 NS_LOG_FUNCTION(this);
655 os << "DevStatusReq()";
656}
657
658//////////////////
659// DevStatusAns //
660//////////////////
661
668
669DevStatusAns::DevStatusAns(uint8_t battery, uint8_t margin)
670 : m_battery(battery),
671 m_margin(margin)
672{
673 NS_LOG_FUNCTION(this << unsigned(battery) << unsigned(margin));
674 NS_ASSERT_MSG(!(margin & 0xC0), "margin > 6 bits");
677}
678
679void
681{
682 NS_LOG_FUNCTION(this);
683 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
684 start.WriteU8(m_battery);
685 start.WriteU8(m_margin);
686}
687
688uint8_t
690{
691 NS_LOG_FUNCTION(this);
692 start.ReadU8(); // Consume the CID
693 m_battery = start.ReadU8();
694 m_margin = start.ReadU8();
695 return m_serializedSize;
696}
697
698void
699DevStatusAns::Print(std::ostream& os) const
700{
701 NS_LOG_FUNCTION(this);
702 os << "DevStatusAns(";
703 os << "Battery=" << unsigned(m_battery);
704 os << ", Margin=" << unsigned(m_margin);
705 os << ")";
706}
707
708uint8_t
710{
711 NS_LOG_FUNCTION(this);
712 return m_battery;
713}
714
715uint8_t
717{
718 NS_LOG_FUNCTION(this);
719 return m_margin;
720}
721
722//////////////////
723// NewChannelReq //
724//////////////////
725
732
734 uint32_t frequencyHz,
735 uint8_t minDataRate,
736 uint8_t maxDataRate)
737 : m_chIndex(chIndex),
738 m_frequencyHz(frequencyHz),
739 m_minDataRate(minDataRate),
740 m_maxDataRate(maxDataRate)
741{
742 NS_LOG_FUNCTION(this);
743 NS_ASSERT_MSG(!(minDataRate & 0xF0), "minDataRate > 4 bits");
744 NS_ASSERT_MSG(!(maxDataRate & 0xF0), "maxDataRate > 4 bits");
747}
748
749void
751{
752 NS_LOG_FUNCTION(this);
753 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
754 start.WriteU8(m_chIndex);
755 uint32_t encodedFrequency = m_frequencyHz / 100;
756 // Frequency is in little endian (lsb -> msb)
757 start.WriteU8(encodedFrequency); // Least significant byte
758 start.WriteU8(encodedFrequency >> 8); // Middle byte
759 start.WriteU8(encodedFrequency >> 16); // Most significant byte
760 start.WriteU8((m_maxDataRate << 4) | (m_minDataRate & 0xf));
761}
762
763uint8_t
765{
766 NS_LOG_FUNCTION(this);
767 start.ReadU8(); // Consume the CID
768 m_chIndex = start.ReadU8();
769 uint32_t encodedFrequency = 0;
770 // Frequency is in little endian (lsb -> msb)
771 encodedFrequency += start.ReadU8(); // Least significant byte
772 encodedFrequency += start.ReadU8() << 8; // Middle byte
773 encodedFrequency += start.ReadU8() << 16; // Most significant byte
774 m_frequencyHz = encodedFrequency * 100;
775 uint8_t dataRateByte = start.ReadU8();
776 m_maxDataRate = dataRateByte >> 4;
777 m_minDataRate = dataRateByte & 0xf;
778 return m_serializedSize;
779}
780
781void
782NewChannelReq::Print(std::ostream& os) const
783{
784 NS_LOG_FUNCTION(this);
785 os << "NewChannelReq(";
786 os << "ChIndex=" << unsigned(m_chIndex);
787 os << ", Frequency=" << uint32_t(m_frequencyHz);
788 os << ", MaxDR=" << unsigned(m_maxDataRate);
789 os << ", MinDR=" << unsigned(m_minDataRate);
790 os << ")";
791}
792
793uint8_t
795{
796 NS_LOG_FUNCTION(this);
797 return m_chIndex;
798}
799
802{
803 NS_LOG_FUNCTION(this);
804 return m_frequencyHz;
805}
806
807uint8_t
809{
810 NS_LOG_FUNCTION(this);
811 return m_minDataRate;
812}
813
814uint8_t
816{
817 NS_LOG_FUNCTION(this);
818 return m_maxDataRate;
819}
820
821///////////////////
822// NewChannelAns //
823///////////////////
824
831
832NewChannelAns::NewChannelAns(bool dataRateRangeOk, bool channelFrequencyOk)
833 : m_dataRateRangeOk(dataRateRangeOk),
834 m_channelFrequencyOk(channelFrequencyOk)
835{
836 NS_LOG_FUNCTION(this);
839}
840
841void
843{
844 NS_LOG_FUNCTION(this);
845 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
846 start.WriteU8((uint8_t(m_dataRateRangeOk) << 1) | uint8_t(m_channelFrequencyOk));
847}
848
849uint8_t
851{
852 NS_LOG_FUNCTION(this);
853 start.ReadU8(); // Consume the CID
854 uint8_t byte = start.ReadU8(); // Read the data
855 m_dataRateRangeOk = (byte & 0b10) >> 1;
856 m_channelFrequencyOk = (byte & 0b1);
857 return m_serializedSize;
858}
859
860void
861NewChannelAns::Print(std::ostream& os) const
862{
863 NS_LOG_FUNCTION(this);
864 os << "NewChannelAns(";
865 os << "DataRateRangeOk=" << m_dataRateRangeOk;
866 os << ", ChannelFrequencyOk=" << m_channelFrequencyOk;
867 os << ")";
868}
869
870bool
876
877bool
883
884//////////////////////
885// RxTimingSetupReq //
886//////////////////////
887
894
896 : m_delay(delay)
897{
898 NS_LOG_FUNCTION(this);
899 NS_ASSERT_MSG(!(delay & 0xF0), "delay field > 4 bits");
902}
903
904void
906{
907 NS_LOG_FUNCTION(this);
908 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
909 start.WriteU8(m_delay & 0xF); // Write the data
910}
911
912uint8_t
914{
915 NS_LOG_FUNCTION(this);
916 start.ReadU8(); // Consume the CID
917 m_delay = start.ReadU8() & 0xF; // Read the data
918 return m_serializedSize;
919}
920
921void
922RxTimingSetupReq::Print(std::ostream& os) const
923{
924 NS_LOG_FUNCTION(this);
925 os << "RxTimingSetupReq()";
926}
927
928Time
930{
931 NS_LOG_FUNCTION(this);
932 return Seconds((m_delay) ? m_delay : 0);
933}
934
935//////////////////
936// RxTimingSetupAns //
937//////////////////
938
945
946void
948{
949 NS_LOG_FUNCTION(this);
950 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
951}
952
953uint8_t
955{
956 NS_LOG_FUNCTION(this);
957 start.ReadU8(); // Consume the CID
958 return m_serializedSize;
959}
960
961void
962RxTimingSetupAns::Print(std::ostream& os) const
963{
964 NS_LOG_FUNCTION(this);
965 os << "RxTimingSetupAns()";
966}
967
968//////////////////
969// DlChannelAns //
970//////////////////
971
978
979void
981{
982 NS_LOG_FUNCTION(this);
983 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
984}
985
986uint8_t
988{
989 NS_LOG_FUNCTION(this);
990 start.ReadU8(); // Consume the CID
991 return m_serializedSize;
992}
993
994void
995DlChannelAns::Print(std::ostream& os) const
996{
997 NS_LOG_FUNCTION(this);
998 os << "DlChannelAns()";
999}
1000
1001//////////////////
1002// TxParamSetupReq //
1003//////////////////
1004
1011
1012void
1014{
1015 NS_LOG_FUNCTION(this);
1016 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
1017}
1018
1019uint8_t
1021{
1022 NS_LOG_FUNCTION(this);
1023 start.ReadU8(); // Consume the CID
1024 return m_serializedSize;
1025}
1026
1027void
1028TxParamSetupReq::Print(std::ostream& os) const
1029{
1030 NS_LOG_FUNCTION(this);
1031 os << "TxParamSetupReq()";
1032}
1033
1034//////////////////
1035// TxParamSetupAns //
1036//////////////////
1037
1044
1045void
1047{
1048 NS_LOG_FUNCTION(this);
1049 start.WriteU8(GetCIDFromMacCommand(m_commandType)); // Write the CID
1050}
1051
1052uint8_t
1054{
1055 NS_LOG_FUNCTION(this);
1056 start.ReadU8(); // Consume the CID
1057 return m_serializedSize;
1058}
1059
1060void
1061TxParamSetupAns::Print(std::ostream& os) const
1062{
1063 NS_LOG_FUNCTION(this);
1064 os << "TxParamSetupAns()";
1065}
1066
1067} // namespace lorawan
1068} // 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:49
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.
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.
static TypeId GetTypeId()
Register this type.
~MacCommand() override
Destructor.
MacCommand()
Default constructor.
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 ",...
#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:1344
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.