36 NS_LOG_COMPONENT_DEFINE(
"LorawanLorawanMacCommand");
38 NS_OBJECT_ENSURE_REGISTERED(LorawanMacCommand);
43 static TypeId tid = TypeId(
"ns3::LorawanMacCommand").SetParent<Object>();
49 NS_LOG_FUNCTION(
this);
54 NS_LOG_FUNCTION(
this);
60 NS_LOG_FUNCTION_NOARGS();
68 NS_LOG_FUNCTION_NOARGS();
76 NS_LOG_FUNCTION_NOARGS();
129 NS_LOG_FUNCTION_NOARGS();
136 NS_LOG_FUNCTION_NOARGS();
142 NS_LOG_FUNCTION_NOARGS();
147 NS_LOG_DEBUG(
"Serialized LinkCheckReq: " <<
unsigned(cid));
153 NS_LOG_FUNCTION_NOARGS();
164 NS_LOG_FUNCTION_NOARGS();
166 os <<
"LinkCheckReq" << std::endl;
177 NS_LOG_FUNCTION(
this);
187 NS_LOG_FUNCTION(
this <<
unsigned(margin) <<
unsigned(gwCnt));
196 NS_LOG_FUNCTION_NOARGS();
209 NS_LOG_FUNCTION_NOARGS();
221 NS_LOG_FUNCTION_NOARGS();
223 os <<
"LinkCheckAns" << std::endl;
224 os <<
"margin: " << unsigned(
m_margin) << std::endl;
225 os <<
"gwCnt: " << unsigned(
m_gwCnt) << std::endl;
231 NS_LOG_FUNCTION(
this <<
unsigned(margin));
239 NS_LOG_FUNCTION(
this);
247 NS_LOG_FUNCTION(
this <<
unsigned(gwCnt));
255 NS_LOG_FUNCTION(
this);
263 NS_LOG_FUNCTION(
this);
274 NS_LOG_FUNCTION(
this);
282 uint16_t channelMask,
285 : m_dataRate(dataRate),
287 m_channelMask(channelMask),
288 m_chMaskCntl(chMaskCntl),
291 NS_LOG_FUNCTION(
this);
300 NS_LOG_FUNCTION_NOARGS();
312 NS_LOG_FUNCTION_NOARGS();
316 uint8_t firstByte = start.ReadU8();
320 uint8_t fourthByte = start.ReadU8();
330 NS_LOG_FUNCTION_NOARGS();
332 os <<
"LinkAdrReq" << std::endl;
333 os <<
"dataRate: " << unsigned(
m_dataRate) << std::endl;
334 os <<
"txPower: " << unsigned(
m_txPower) << std::endl;
335 os <<
"channelMask: " << std::bitset<16>(
m_channelMask) << std::endl;
336 os <<
"chMaskCntl: " << unsigned(
m_chMaskCntl) << std::endl;
337 os <<
"nbRep: " << unsigned(
m_nbRep) << std::endl;
343 NS_LOG_FUNCTION(
this);
351 NS_LOG_FUNCTION(
this);
359 NS_LOG_FUNCTION(
this);
361 std::list<int> channelIndices;
362 for (
int i = 0; i < 16; i++)
366 NS_LOG_DEBUG(
"Adding channel index " << i);
367 channelIndices.push_back(i);
371 return channelIndices;
377 NS_LOG_FUNCTION(
this);
388 NS_LOG_FUNCTION(
this);
395 : m_powerAck(powerAck),
396 m_dataRateAck(dataRateAck),
397 m_channelMaskAck(channelMaskAck)
399 NS_LOG_FUNCTION(
this);
408 NS_LOG_FUNCTION_NOARGS();
421 NS_LOG_FUNCTION_NOARGS();
426 uint8_t
byte = start.ReadU8();
438 NS_LOG_FUNCTION_NOARGS();
440 os <<
"LinkAdrAns" << std::endl;
449 NS_LOG_FUNCTION(
this);
456 : m_maxDCycle(dutyCycle)
458 NS_LOG_FUNCTION(
this);
467 NS_LOG_FUNCTION_NOARGS();
477 NS_LOG_FUNCTION_NOARGS();
489 NS_LOG_FUNCTION_NOARGS();
491 os <<
"DutyCycleReq" << std::endl;
492 os <<
"maxDCycle: " << unsigned(
m_maxDCycle) << std::endl;
499 NS_LOG_FUNCTION(
this);
521 NS_LOG_FUNCTION(
this);
530 NS_LOG_FUNCTION_NOARGS();
539 NS_LOG_FUNCTION_NOARGS();
549 NS_LOG_FUNCTION_NOARGS();
551 os <<
"DutyCycleAns" << std::endl;
560 NS_LOG_FUNCTION(
this);
567 : m_rx1DrOffset(rx1DrOffset),
568 m_rx2DataRate(rx2DataRate),
569 m_frequency(frequency)
571 NS_LOG_FUNCTION(
this <<
unsigned(rx1DrOffset) <<
unsigned(rx2DataRate) << frequency);
573 if ((rx1DrOffset & 0b11111000) != 0)
576 "Warning: received an rx1DrOffset greater than 7. Actual value will be different.");
578 if ((rx2DataRate & 0b11110000) != 0)
581 "Warning: received a rx2DataRate greater than 15. Actual value will be different.");
591 NS_LOG_FUNCTION_NOARGS();
597 uint32_t encodedFrequency = uint32_t(
m_frequency / 100);
598 NS_LOG_DEBUG(
unsigned(encodedFrequency));
599 NS_LOG_DEBUG(std::bitset<32>(encodedFrequency));
600 start.WriteU8((encodedFrequency & 0xff0000) >> 16);
601 start.WriteU8((encodedFrequency & 0xff00) >> 8);
602 start.WriteU8(encodedFrequency & 0xff);
608 NS_LOG_FUNCTION_NOARGS();
613 uint8_t firstByte = start.ReadU8();
616 uint32_t secondByte = start.ReadU8();
617 uint32_t thirdByte = start.ReadU8();
618 uint32_t fourthByte = start.ReadU8();
619 uint32_t encodedFrequency = (secondByte << 16) | (thirdByte << 8) | fourthByte;
620 NS_LOG_DEBUG(std::bitset<32>(encodedFrequency));
629 NS_LOG_FUNCTION_NOARGS();
631 os <<
"RxParamSetupReq" << std::endl;
632 os <<
"rx1DrOffset: " << unsigned(
m_rx1DrOffset) << std::endl;
633 os <<
"rx2DataRate: " << unsigned(
m_rx2DataRate) << std::endl;
640 NS_LOG_FUNCTION(
this);
648 NS_LOG_FUNCTION(
this);
656 NS_LOG_FUNCTION(
this);
667 NS_LOG_FUNCTION(
this);
674 : m_rx1DrOffsetAck(rx1DrOffsetAck),
675 m_rx2DataRateAck(rx2DataRateAck),
676 m_channelAck(channelAck)
678 NS_LOG_FUNCTION(
this << rx1DrOffsetAck << rx2DataRateAck << channelAck);
687 NS_LOG_FUNCTION_NOARGS();
699 NS_LOG_FUNCTION_NOARGS();
704 uint8_t
byte = start.ReadU8();
716 NS_LOG_FUNCTION_NOARGS();
718 os <<
"RxParamSetupAns" << std::endl;
730 NS_LOG_FUNCTION(
this);
739 NS_LOG_FUNCTION_NOARGS();
748 NS_LOG_FUNCTION_NOARGS();
759 NS_LOG_FUNCTION_NOARGS();
761 os <<
"DevStatusReq" << std::endl;
770 NS_LOG_FUNCTION(
this);
777 : m_battery(battery),
780 NS_LOG_FUNCTION(
this <<
unsigned(battery) <<
unsigned(margin));
789 NS_LOG_FUNCTION_NOARGS();
800 NS_LOG_FUNCTION_NOARGS();
805 m_margin = start.ReadU8() & 0b111111;
813 NS_LOG_FUNCTION_NOARGS();
815 os <<
"DevStatusAns" << std::endl;
816 os <<
"Battery: " << unsigned(
m_battery) << std::endl;
817 os <<
"Margin: " << unsigned(
m_margin) << std::endl;
823 NS_LOG_FUNCTION_NOARGS();
831 NS_LOG_FUNCTION_NOARGS();
842 NS_LOG_FUNCTION(
this);
852 : m_chIndex(chIndex),
853 m_frequency(frequency),
854 m_minDataRate(minDataRate),
855 m_maxDataRate(maxDataRate)
857 NS_LOG_FUNCTION(
this);
866 NS_LOG_FUNCTION_NOARGS();
872 uint32_t encodedFrequency = uint32_t(
m_frequency / 100);
873 start.WriteU8((encodedFrequency & 0xff0000) >> 16);
874 start.WriteU8((encodedFrequency & 0xff00) >> 8);
875 start.WriteU8(encodedFrequency & 0xff);
882 NS_LOG_FUNCTION_NOARGS();
888 uint32_t encodedFrequency = 0;
889 encodedFrequency |= uint32_t(start.ReadU16()) << 8;
890 encodedFrequency |= uint32_t(start.ReadU8());
892 uint8_t dataRateByte = start.ReadU8();
902 NS_LOG_FUNCTION_NOARGS();
904 os <<
"NewChannelReq" << std::endl;
910 NS_LOG_FUNCTION_NOARGS();
918 NS_LOG_FUNCTION_NOARGS();
926 NS_LOG_FUNCTION_NOARGS();
934 NS_LOG_FUNCTION_NOARGS();
945 NS_LOG_FUNCTION(
this);
952 : m_dataRateRangeOk(dataRateRangeOk),
953 m_channelFrequencyOk(channelFrequencyOk)
955 NS_LOG_FUNCTION(
this);
964 NS_LOG_FUNCTION_NOARGS();
975 NS_LOG_FUNCTION_NOARGS();
980 uint8_t
byte = start.ReadU8();
990 NS_LOG_FUNCTION_NOARGS();
992 os <<
"NewChannelAns" << std::endl;
1003 NS_LOG_FUNCTION(
this);
1012 NS_LOG_FUNCTION(
this);
1021 NS_LOG_FUNCTION_NOARGS();
1032 NS_LOG_FUNCTION_NOARGS();
1037 m_delay = start.ReadU8() & 0xf;
1045 NS_LOG_FUNCTION_NOARGS();
1047 os <<
"RxTimingSetupReq" << std::endl;
1053 NS_LOG_FUNCTION(
this);
1068 NS_LOG_FUNCTION(
this);
1077 NS_LOG_FUNCTION_NOARGS();
1086 NS_LOG_FUNCTION_NOARGS();
1097 NS_LOG_FUNCTION_NOARGS();
1099 os <<
"RxTimingSetupAns" << std::endl;
1108 NS_LOG_FUNCTION(
this);
1117 NS_LOG_FUNCTION_NOARGS();
1126 NS_LOG_FUNCTION_NOARGS();
1137 NS_LOG_FUNCTION_NOARGS();
1139 os <<
"DlChannelAns" << std::endl;
1148 NS_LOG_FUNCTION(
this);
1157 NS_LOG_FUNCTION_NOARGS();
1166 NS_LOG_FUNCTION_NOARGS();
1177 NS_LOG_FUNCTION_NOARGS();
1179 os <<
"TxParamSetupReq" << std::endl;
1188 NS_LOG_FUNCTION(
this);
1197 NS_LOG_FUNCTION_NOARGS();
1206 NS_LOG_FUNCTION_NOARGS();
1217 NS_LOG_FUNCTION_NOARGS();
1219 os <<
"TxParamSetupAns" << std::endl;
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
uint8_t GetBattery(void)
Get the battery information contained in this MAC command.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
uint8_t GetMargin(void)
Get the demodulation margin contained in this MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
double GetMaximumAllowedDutyCycle(void) const
Get the maximum duty cycle prescribed by this Mac command, in fraction form.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
int GetRepetitions(void)
Get the number of repetitions prescribed by this MAC command.
std::list< int > GetEnabledChannelsList(void)
Get the list of enabled channels.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
uint8_t GetTxPower(void)
Get the transmission power prescribed by this MAC command.
uint8_t GetDataRate(void)
Return the data rate prescribed by this MAC command.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
uint8_t GetGwCnt(void) const
Get the gateway count value.
uint8_t GetMargin(void) const
Get the demodulation margin value.
uint8_t m_gwCnt
This MAC command's gateway count value.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
uint8_t m_margin
This MAC command's demodulation margin value.
void SetMargin(uint8_t margin)
Set the demodulation margin value.
void SetGwCnt(uint8_t gwCnt)
Set the gateway count value.
void IncrementGwCnt(void)
Increment this LorawanMacCommand's gwCnt value.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
static uint8_t GetCIDFromLorawanMacCommand(enum MacCommandType commandType)
Get the CID that corresponds to this MAC command.
enum MacCommandType m_commandType
The type of this command.
virtual uint8_t GetSerializedSize(void) const
Get serialized length of this MAC command.
static TypeId GetTypeId(void)
virtual enum MacCommandType GetCommandType(void) const
Get the commandType of this MAC command.
uint8_t m_serializedSize
This MAC command's serialized size.
virtual ~LorawanMacCommand()
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
bool m_channelFrequencyOk
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
double GetFrequency(void)
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
uint8_t GetMinDataRate(void)
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
uint8_t GetChannelIndex(void)
uint8_t GetMaxDataRate(void)
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
double m_frequency
The frequency in Hz
uint8_t GetRx1DrOffset(void)
Get this command's Rx1DrOffset parameter.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
uint8_t GetRx2DataRate(void)
Get this command's Rx2DataRate parameter.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
double GetFrequency(void)
Get this command's frequency.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
Time GetDelay(void)
Get the first window delay as a Time instance.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
virtual void Serialize(Buffer::Iterator &start) const
Serialize the contents of this MAC command into a buffer, according to the LoRaWAN standard.
virtual void Print(std::ostream &os) const
Print the contents of this MAC command in human-readable format.
virtual uint8_t Deserialize(Buffer::Iterator &start)
Deserialize the buffer into a MAC command.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
MacCommandType
Enum for every possible command type.