30 NS_LOG_COMPONENT_DEFINE(
"LoraFrameHeader");
53 TypeId(
"LoraFrameHeader").SetParent<Header>().AddConstructor<LoraFrameHeader>();
66 NS_LOG_FUNCTION_NOARGS();
72 NS_LOG_INFO(
"LoraFrameHeader serialized size: " << size);
80 NS_LOG_FUNCTION_NOARGS();
87 fCtrl |= uint8_t(
m_adr << 6 & 0b1000000);
89 fCtrl |= uint8_t(
m_ack << 4 & 0b10000);
100 NS_LOG_DEBUG(
"Serializing a MAC command");
101 (*it)->Serialize(start);
111 NS_LOG_FUNCTION_NOARGS();
118 uint8_t fCtl = start.ReadU8();
119 m_adr = (fCtl >> 6) & 0b1;
121 m_ack = (fCtl >> 4) & 0b1;
126 NS_LOG_DEBUG(
"Deserialized data: ");
128 NS_LOG_DEBUG(
"ADR: " <<
unsigned(
m_adr));
129 NS_LOG_DEBUG(
"ADRAckReq: " <<
unsigned(
m_adrAckReq));
130 NS_LOG_DEBUG(
"Ack: " <<
unsigned(
m_ack));
131 NS_LOG_DEBUG(
"fPending: " <<
unsigned(
m_fPending));
132 NS_LOG_DEBUG(
"fOptsLen: " <<
unsigned(
m_fOptsLen));
133 NS_LOG_DEBUG(
"fCnt: " <<
unsigned(
m_fCnt));
136 NS_LOG_DEBUG(
"Starting deserialization of MAC commands");
137 for (uint8_t byteNumber = 0; byteNumber <
m_fOptsLen;)
139 uint8_t cid = start.PeekU8();
140 NS_LOG_DEBUG(
"CID: " <<
unsigned(cid));
153 NS_LOG_DEBUG(
"Creating a LinkCheckReq command");
154 Ptr<LinkCheckReq> command = Create<LinkCheckReq>();
155 byteNumber += command->Deserialize(start);
160 NS_LOG_DEBUG(
"Creating a LinkAdrAns command");
161 Ptr<LinkAdrAns> command = Create<LinkAdrAns>();
162 byteNumber += command->Deserialize(start);
167 NS_LOG_DEBUG(
"Creating a DutyCycleAns command");
168 Ptr<DutyCycleAns> command = Create<DutyCycleAns>();
169 byteNumber += command->Deserialize(start);
174 NS_LOG_DEBUG(
"Creating a RxParamSetupAns command");
175 Ptr<RxParamSetupAns> command = Create<RxParamSetupAns>();
176 byteNumber += command->Deserialize(start);
181 NS_LOG_DEBUG(
"Creating a DevStatusAns command");
182 Ptr<DevStatusAns> command = Create<DevStatusAns>();
183 byteNumber += command->Deserialize(start);
188 NS_LOG_DEBUG(
"Creating a NewChannelAns command");
189 Ptr<NewChannelAns> command = Create<NewChannelAns>();
190 byteNumber += command->Deserialize(start);
195 NS_LOG_DEBUG(
"Creating a RxTimingSetupAns command");
196 Ptr<RxTimingSetupAns> command = Create<RxTimingSetupAns>();
197 byteNumber += command->Deserialize(start);
202 NS_LOG_DEBUG(
"Creating a TxParamSetupAns command");
203 Ptr<TxParamSetupAns> command = Create<TxParamSetupAns>();
204 byteNumber += command->Deserialize(start);
209 NS_LOG_DEBUG(
"Creating a DlChannelAns command");
210 Ptr<DlChannelAns> command = Create<DlChannelAns>();
211 byteNumber += command->Deserialize(start);
216 NS_LOG_ERROR(
"CID not recognized during deserialization");
227 NS_LOG_DEBUG(
"Creating a LinkCheckAns command");
228 Ptr<LinkCheckAns> command = Create<LinkCheckAns>();
229 byteNumber += command->Deserialize(start);
234 NS_LOG_DEBUG(
"Creating a LinkAdrReq command");
235 Ptr<LinkAdrReq> command = Create<LinkAdrReq>();
236 byteNumber += command->Deserialize(start);
241 NS_LOG_DEBUG(
"Creating a DutyCycleReq command");
242 Ptr<DutyCycleReq> command = Create<DutyCycleReq>();
243 byteNumber += command->Deserialize(start);
248 NS_LOG_DEBUG(
"Creating a RxParamSetupReq command");
249 Ptr<RxParamSetupReq> command = Create<RxParamSetupReq>();
250 byteNumber += command->Deserialize(start);
255 NS_LOG_DEBUG(
"Creating a DevStatusReq command");
256 Ptr<DevStatusReq> command = Create<DevStatusReq>();
257 byteNumber += command->Deserialize(start);
262 NS_LOG_DEBUG(
"Creating a NewChannelReq command");
263 Ptr<NewChannelReq> command = Create<NewChannelReq>();
264 byteNumber += command->Deserialize(start);
269 NS_LOG_DEBUG(
"Creating a RxTimingSetupReq command");
270 Ptr<RxTimingSetupReq> command = Create<RxTimingSetupReq>();
271 byteNumber += command->Deserialize(start);
276 NS_LOG_DEBUG(
"Creating a TxParamSetupReq command");
277 Ptr<TxParamSetupReq> command = Create<TxParamSetupReq>();
278 byteNumber += command->Deserialize(start);
283 NS_LOG_ERROR(
"CID not recognized during deserialization");
289 m_fPort = uint8_t(start.ReadU8());
297 NS_LOG_FUNCTION_NOARGS();
300 os <<
"ADR=" <<
m_adr << std::endl;
302 os <<
"ACK=" <<
m_ack << std::endl;
304 os <<
"FOptsLen=" << unsigned(
m_fOptsLen) << std::endl;
305 os <<
"FCnt=" << unsigned(
m_fCnt) << std::endl;
312 os <<
"FPort=" << unsigned(
m_fPort) << std::endl;
318 NS_LOG_FUNCTION_NOARGS();
326 NS_LOG_FUNCTION_NOARGS();
358 NS_LOG_FUNCTION(
this << adr);
383 NS_LOG_FUNCTION(
this << ack);
409 uint8_t fOptsLen = 0;
410 std::list<Ptr<LorawanMacCommand>>::const_iterator it;
413 fOptsLen = fOptsLen + (*it)->GetSerializedSize();
433 NS_LOG_FUNCTION_NOARGS();
435 Ptr<LinkCheckReq> command = Create<LinkCheckReq>();
438 NS_LOG_DEBUG(
"Command SerializedSize: " <<
unsigned(command->GetSerializedSize()));
445 NS_LOG_FUNCTION(
this <<
unsigned(margin) <<
unsigned(gwCnt));
447 Ptr<LinkCheckAns> command = Create<LinkCheckAns>(margin, gwCnt);
456 std::list<int> enabledChannels,
459 NS_LOG_FUNCTION(
this <<
unsigned(dataRate) << txPower << repetitions);
461 uint16_t channelMask = 0;
462 for (
auto it = enabledChannels.begin(); it != enabledChannels.end(); it++)
464 NS_ASSERT((*it) < 16 && (*it) > -1);
466 channelMask |= 0b1 << (*it);
471 NS_LOG_DEBUG(
"Creating LinkAdrReq with: DR = " <<
unsigned(dataRate)
472 <<
" and txPower = " <<
unsigned(txPower));
474 Ptr<LinkAdrReq> command = Create<LinkAdrReq>(dataRate, txPower, channelMask, 0, repetitions);
483 NS_LOG_FUNCTION(
this << powerAck << dataRateAck << channelMaskAck);
485 Ptr<LinkAdrAns> command = Create<LinkAdrAns>(powerAck, dataRateAck, channelMaskAck);
494 NS_LOG_FUNCTION(
this <<
unsigned(dutyCycle));
496 Ptr<DutyCycleReq> command = Create<DutyCycleReq>(dutyCycle);
506 NS_LOG_FUNCTION(
this);
508 Ptr<DutyCycleAns> command = Create<DutyCycleAns>();
518 NS_LOG_FUNCTION(
this <<
unsigned(rx1DrOffset) <<
unsigned(rx2DataRate) << frequency);
521 NS_ASSERT(0 <= rx1DrOffset && rx1DrOffset <= 5);
523 Ptr<RxParamSetupReq> command = Create<RxParamSetupReq>(rx1DrOffset, rx2DataRate, frequency);
533 NS_LOG_FUNCTION(
this);
535 Ptr<RxParamSetupAns> command = Create<RxParamSetupAns>();
545 NS_LOG_FUNCTION(
this);
547 Ptr<DevStatusReq> command = Create<DevStatusReq>();
560 NS_LOG_FUNCTION(
this);
562 Ptr<NewChannelReq> command =
563 Create<NewChannelReq>(chIndex, frequency, minDataRate, maxDataRate);
570 std::list<Ptr<LorawanMacCommand>>
573 NS_LOG_FUNCTION_NOARGS();
581 NS_LOG_FUNCTION(
this << macCommand);
584 m_fOptsLen += macCommand->GetSerializedSize();
This class represents the device address of a LoraWAN End Device.
void Set(uint32_t address)
Set the address as a 32 bit integer.
uint32_t Get(void) const
Get the address in 32-bit integer form.
std::string Print(void) const
Print the address bit-by-bit to a human-readable string.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.