33 NS_LOG_COMPONENT_DEFINE(
"LoraFrameHeader");
56 TypeId(
"LoraFrameHeader").SetParent<Header>().AddConstructor<LoraFrameHeader>();
69 NS_LOG_FUNCTION_NOARGS();
75 NS_LOG_INFO(
"LoraFrameHeader serialized size: " << size);
83 NS_LOG_FUNCTION_NOARGS();
90 fCtrl |= uint8_t(
m_adr << 6 & 0b1000000);
92 fCtrl |= uint8_t(
m_ack << 4 & 0b10000);
103 NS_LOG_DEBUG(
"Serializing a MAC command");
104 (*it)->Serialize(start);
114 NS_LOG_FUNCTION_NOARGS();
121 uint8_t fCtl = start.ReadU8();
122 m_adr = (fCtl >> 6) & 0b1;
124 m_ack = (fCtl >> 4) & 0b1;
129 NS_LOG_DEBUG(
"Deserialized data: ");
131 NS_LOG_DEBUG(
"ADR: " <<
unsigned(
m_adr));
132 NS_LOG_DEBUG(
"ADRAckReq: " <<
unsigned(
m_adrAckReq));
133 NS_LOG_DEBUG(
"Ack: " <<
unsigned(
m_ack));
134 NS_LOG_DEBUG(
"fPending: " <<
unsigned(
m_fPending));
135 NS_LOG_DEBUG(
"fOptsLen: " <<
unsigned(
m_fOptsLen));
136 NS_LOG_DEBUG(
"fCnt: " <<
unsigned(
m_fCnt));
139 NS_LOG_DEBUG(
"Starting deserialization of MAC commands");
140 for (uint8_t byteNumber = 0; byteNumber <
m_fOptsLen;)
142 uint8_t cid = start.PeekU8();
143 NS_LOG_DEBUG(
"CID: " <<
unsigned(cid));
156 NS_LOG_DEBUG(
"Creating a LinkCheckReq command");
157 Ptr<LinkCheckReq> command = Create<LinkCheckReq>();
158 byteNumber += command->Deserialize(start);
163 NS_LOG_DEBUG(
"Creating a LinkAdrAns command");
164 Ptr<LinkAdrAns> command = Create<LinkAdrAns>();
165 byteNumber += command->Deserialize(start);
170 NS_LOG_DEBUG(
"Creating a DutyCycleAns command");
171 Ptr<DutyCycleAns> command = Create<DutyCycleAns>();
172 byteNumber += command->Deserialize(start);
177 NS_LOG_DEBUG(
"Creating a RxParamSetupAns command");
178 Ptr<RxParamSetupAns> command = Create<RxParamSetupAns>();
179 byteNumber += command->Deserialize(start);
184 NS_LOG_DEBUG(
"Creating a DevStatusAns command");
185 Ptr<DevStatusAns> command = Create<DevStatusAns>();
186 byteNumber += command->Deserialize(start);
191 NS_LOG_DEBUG(
"Creating a NewChannelAns command");
192 Ptr<NewChannelAns> command = Create<NewChannelAns>();
193 byteNumber += command->Deserialize(start);
198 NS_LOG_DEBUG(
"Creating a RxTimingSetupAns command");
199 Ptr<RxTimingSetupAns> command = Create<RxTimingSetupAns>();
200 byteNumber += command->Deserialize(start);
205 NS_LOG_DEBUG(
"Creating a TxParamSetupAns command");
206 Ptr<TxParamSetupAns> command = Create<TxParamSetupAns>();
207 byteNumber += command->Deserialize(start);
212 NS_LOG_DEBUG(
"Creating a DlChannelAns command");
213 Ptr<DlChannelAns> command = Create<DlChannelAns>();
214 byteNumber += command->Deserialize(start);
219 NS_LOG_ERROR(
"CID not recognized during deserialization");
230 NS_LOG_DEBUG(
"Creating a LinkCheckAns command");
231 Ptr<LinkCheckAns> command = Create<LinkCheckAns>();
232 byteNumber += command->Deserialize(start);
237 NS_LOG_DEBUG(
"Creating a LinkAdrReq command");
238 Ptr<LinkAdrReq> command = Create<LinkAdrReq>();
239 byteNumber += command->Deserialize(start);
244 NS_LOG_DEBUG(
"Creating a DutyCycleReq command");
245 Ptr<DutyCycleReq> command = Create<DutyCycleReq>();
246 byteNumber += command->Deserialize(start);
251 NS_LOG_DEBUG(
"Creating a RxParamSetupReq command");
252 Ptr<RxParamSetupReq> command = Create<RxParamSetupReq>();
253 byteNumber += command->Deserialize(start);
258 NS_LOG_DEBUG(
"Creating a DevStatusReq command");
259 Ptr<DevStatusReq> command = Create<DevStatusReq>();
260 byteNumber += command->Deserialize(start);
265 NS_LOG_DEBUG(
"Creating a NewChannelReq command");
266 Ptr<NewChannelReq> command = Create<NewChannelReq>();
267 byteNumber += command->Deserialize(start);
272 NS_LOG_DEBUG(
"Creating a RxTimingSetupReq command");
273 Ptr<RxTimingSetupReq> command = Create<RxTimingSetupReq>();
274 byteNumber += command->Deserialize(start);
279 NS_LOG_DEBUG(
"Creating a TxParamSetupReq command");
280 Ptr<TxParamSetupReq> command = Create<TxParamSetupReq>();
281 byteNumber += command->Deserialize(start);
286 NS_LOG_ERROR(
"CID not recognized during deserialization");
292 m_fPort = uint8_t(start.ReadU8());
300 NS_LOG_FUNCTION_NOARGS();
303 os <<
"ADR=" <<
m_adr << std::endl;
305 os <<
"ACK=" <<
m_ack << std::endl;
307 os <<
"FOptsLen=" << unsigned(
m_fOptsLen) << std::endl;
308 os <<
"FCnt=" << unsigned(
m_fCnt) << std::endl;
315 os <<
"FPort=" << unsigned(
m_fPort) << std::endl;
321 NS_LOG_FUNCTION_NOARGS();
329 NS_LOG_FUNCTION_NOARGS();
361 NS_LOG_FUNCTION(
this << adr);
386 NS_LOG_FUNCTION(
this << ack);
412 uint8_t fOptsLen = 0;
413 std::list<Ptr<LorawanMacCommand>>::const_iterator it;
416 fOptsLen = fOptsLen + (*it)->GetSerializedSize();
436 NS_LOG_FUNCTION_NOARGS();
438 Ptr<LinkCheckReq> command = Create<LinkCheckReq>();
441 NS_LOG_DEBUG(
"Command SerializedSize: " <<
unsigned(command->GetSerializedSize()));
448 NS_LOG_FUNCTION(
this <<
unsigned(margin) <<
unsigned(gwCnt));
450 Ptr<LinkCheckAns> command = Create<LinkCheckAns>(margin, gwCnt);
459 std::list<int> enabledChannels,
462 NS_LOG_FUNCTION(
this <<
unsigned(dataRate) << txPower << repetitions);
464 uint16_t channelMask = 0;
465 for (
auto it = enabledChannels.begin(); it != enabledChannels.end(); it++)
467 NS_ASSERT((*it) < 16 && (*it) > -1);
469 channelMask |= 0b1 << (*it);
474 NS_LOG_DEBUG(
"Creating LinkAdrReq with: DR = " <<
unsigned(dataRate)
475 <<
" and txPower = " <<
unsigned(txPower));
477 Ptr<LinkAdrReq> command = Create<LinkAdrReq>(dataRate, txPower, channelMask, 0, repetitions);
486 NS_LOG_FUNCTION(
this << powerAck << dataRateAck << channelMaskAck);
488 Ptr<LinkAdrAns> command = Create<LinkAdrAns>(powerAck, dataRateAck, channelMaskAck);
497 NS_LOG_FUNCTION(
this <<
unsigned(dutyCycle));
499 Ptr<DutyCycleReq> command = Create<DutyCycleReq>(dutyCycle);
509 NS_LOG_FUNCTION(
this);
511 Ptr<DutyCycleAns> command = Create<DutyCycleAns>();
521 NS_LOG_FUNCTION(
this <<
unsigned(rx1DrOffset) <<
unsigned(rx2DataRate) << frequency);
524 NS_ASSERT(0 <= rx1DrOffset && rx1DrOffset <= 5);
526 Ptr<RxParamSetupReq> command = Create<RxParamSetupReq>(rx1DrOffset, rx2DataRate, frequency);
536 NS_LOG_FUNCTION(
this);
538 Ptr<RxParamSetupAns> command = Create<RxParamSetupAns>();
548 NS_LOG_FUNCTION(
this);
550 Ptr<DevStatusReq> command = Create<DevStatusReq>();
563 NS_LOG_FUNCTION(
this);
565 Ptr<NewChannelReq> command =
566 Create<NewChannelReq>(chIndex, frequency, minDataRate, maxDataRate);
573 std::list<Ptr<LorawanMacCommand>>
576 NS_LOG_FUNCTION_NOARGS();
584 NS_LOG_FUNCTION(
this << macCommand);
587 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.