This class represents the Frame header (FHDR) used in a LoraWAN network. More...
#include "lora-frame-header.h"
Public Member Functions | |
LoraFrameHeader () | |
~LoraFrameHeader () | |
void | AddCommand (Ptr< LorawanMacCommand > macCommand) |
Add a predefined command to the list. More... | |
void | AddDevStatusReq () |
Add a DevStatusReq command. More... | |
void | AddDutyCycleAns (void) |
Add a DutyCycleAns command. More... | |
void | AddDutyCycleReq (uint8_t dutyCycle) |
Add a DutyCycleReq command. More... | |
void | AddLinkAdrAns (bool powerAck, bool dataRateAck, bool channelMaskAck) |
Add a LinkAdrAns command. More... | |
void | AddLinkAdrReq (uint8_t dataRate, uint8_t txPower, std::list< int > enabledChannels, int repetitions) |
Add a LinkAdrReq command. More... | |
void | AddLinkCheckAns (uint8_t margin, uint8_t gwCnt) |
Add a LinkCheckAns command. More... | |
void | AddLinkCheckReq (void) |
Add a LinkCheckReq command. More... | |
void | AddNewChannelReq (uint8_t chIndex, double frequency, uint8_t minDataRate, uint8_t maxDataRate) |
Add a NewChannelReq command. More... | |
void | AddRxParamSetupAns () |
Add a RxParamSetupAns command. More... | |
void | AddRxParamSetupReq (uint8_t rx1DrOffset, uint8_t rx2DataRate, double frequency) |
Add a RxParamSetupReq command. More... | |
virtual uint32_t | Deserialize (Buffer::Iterator start) |
Deserialize the contents of the buffer into a LoraFrameHeader object. More... | |
bool | GetAck (void) const |
Get the Ack bit value. More... | |
LoraDeviceAddress | GetAddress (void) const |
Get this header's device address value. More... | |
bool | GetAdr (void) const |
Get the Adr value. More... | |
bool | GetAdrAckReq (void) const |
Get the AdrAckReq value. More... | |
std::list< Ptr< LorawanMacCommand > > | GetCommands (void) |
Return a list of pointers to all the MAC commands saved in this header. More... | |
uint16_t | GetFCnt (void) const |
Get the FCnt value. More... | |
uint8_t | GetFOptsLen (void) const |
Get the FOptsLen value. More... | |
bool | GetFPending (void) const |
Get the FPending value. More... | |
uint8_t | GetFPort (void) const |
Get the FPort value. More... | |
virtual TypeId | GetInstanceTypeId (void) const |
template<typename T > | |
Ptr< T > | GetLorawanMacCommand (void) |
Return a pointer to a LorawanMacCommand, or 0 if the LorawanMacCommand does not exist in this header. More... | |
virtual uint32_t | GetSerializedSize (void) const |
Return the size required for serialization of this header. More... | |
virtual void | Print (std::ostream &os) const |
Print the header in a human-readable format. More... | |
virtual void | Serialize (Buffer::Iterator start) const |
Serialize the header. More... | |
void | SetAck (bool ack) |
Set the Ack bit. More... | |
void | SetAddress (LoraDeviceAddress address) |
Set the address. More... | |
void | SetAdr (bool adr) |
Set the Adr value. More... | |
void | SetAdrAckReq (bool adrAckReq) |
Set the AdrAckReq value. More... | |
void | SetAsDownlink (void) |
State that this is a downlink message. More... | |
void | SetAsUplink (void) |
State that this is an uplink message. More... | |
void | SetFCnt (uint16_t fCnt) |
Set the FCnt value. More... | |
void | SetFPending (bool fPending) |
Set the FPending value. More... | |
void | SetFPort (uint8_t fPort) |
Set the FPort value. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
Private Attributes | |
bool | m_ack |
LoraDeviceAddress | m_address |
bool | m_adr |
bool | m_adrAckReq |
uint16_t | m_fCnt |
Buffer | m_fOpts |
uint8_t | m_fOptsLen |
bool | m_fPending |
uint8_t | m_fPort |
bool | m_isUplink |
std::list< Ptr< LorawanMacCommand > > | m_macCommands |
List containing all the LorawanMacCommand instances that are contained in this LoraFrameHeader. More... | |
This class represents the Frame header (FHDR) used in a LoraWAN network.
Although the specification divides the FHDR from the FPort field, this implementation considers them as a unique entity (i.e., FPort is treated as if it were a part of FHDR).
Definition at line 48 of file lora-frame-header.h.
ns3::LoraFrameHeader::LoraFrameHeader | ( | ) |
Definition at line 36 of file lora-frame-header.cc.
ns3::LoraFrameHeader::~LoraFrameHeader | ( | ) |
Definition at line 48 of file lora-frame-header.cc.
void ns3::LoraFrameHeader::AddCommand | ( | Ptr< LorawanMacCommand > | macCommand | ) |
Add a predefined command to the list.
Definition at line 582 of file lora-frame-header.cc.
References m_fOptsLen, and m_macCommands.
Referenced by ns3::LoraEndDeviceStatus::AddMACCommand(), and ns3::LorawanMacEndDevice::ApplyNecessaryOptions().
void ns3::LoraFrameHeader::AddDevStatusReq | ( | void | ) |
Add a DevStatusReq command.
Definition at line 546 of file lora-frame-header.cc.
References m_fOptsLen, and m_macCommands.
void ns3::LoraFrameHeader::AddDutyCycleAns | ( | void | ) |
Add a DutyCycleAns command.
Definition at line 507 of file lora-frame-header.cc.
References m_fOptsLen, and m_macCommands.
void ns3::LoraFrameHeader::AddDutyCycleReq | ( | uint8_t | dutyCycle | ) |
Add a DutyCycleReq command.
This command accepts an 8-bit integer as dutyCycle. The actual dutyCycle that will be implemented in the end-device will then be, in fraction form, 1/2^(dutyCycle).
dutyCycle | The dutyCycle in 8-bit form. |
Definition at line 495 of file lora-frame-header.cc.
References m_fOptsLen, and m_macCommands.
void ns3::LoraFrameHeader::AddLinkAdrAns | ( | bool | powerAck, |
bool | dataRateAck, | ||
bool | channelMaskAck | ||
) |
Add a LinkAdrAns command.
powerAck | Whether the power can be set or not. |
dataRateAck | Whether the data rate can be set or not. |
channelMaskAck | Whether the channel mask is coherent with the device's current state or not. |
Definition at line 484 of file lora-frame-header.cc.
References m_fOptsLen, and m_macCommands.
void ns3::LoraFrameHeader::AddLinkAdrReq | ( | uint8_t | dataRate, |
uint8_t | txPower, | ||
std::list< int > | enabledChannels, | ||
int | repetitions | ||
) |
Add a LinkAdrReq command.
dataRate | The data rate at which the receiver should transmit. |
txPower | The power at which the receiver should transmit, encoded according to the LoRaWAN specification of the region. |
enabledChannels | A list containing the indices of channels enabled by this command. |
repetitions | The number of repetitions the receiver should send when transmitting. |
Definition at line 457 of file lora-frame-header.cc.
References m_fOptsLen, and m_macCommands.
void ns3::LoraFrameHeader::AddLinkCheckAns | ( | uint8_t | margin, |
uint8_t | gwCnt | ||
) |
Add a LinkCheckAns command.
margin | The demodulation margin the LinkCheckReq packet was received with. |
gwCnt | The number of gateways the LinkCheckReq packet was received by. |
Definition at line 446 of file lora-frame-header.cc.
References m_fOptsLen, and m_macCommands.
void ns3::LoraFrameHeader::AddLinkCheckReq | ( | void | ) |
Add a LinkCheckReq command.
Definition at line 434 of file lora-frame-header.cc.
References m_fOptsLen, and m_macCommands.
void ns3::LoraFrameHeader::AddNewChannelReq | ( | uint8_t | chIndex, |
double | frequency, | ||
uint8_t | minDataRate, | ||
uint8_t | maxDataRate | ||
) |
Add a NewChannelReq command.
Definition at line 558 of file lora-frame-header.cc.
References m_fOptsLen, and m_macCommands.
void ns3::LoraFrameHeader::AddRxParamSetupAns | ( | void | ) |
Add a RxParamSetupAns command.
Definition at line 534 of file lora-frame-header.cc.
References m_fOptsLen, and m_macCommands.
void ns3::LoraFrameHeader::AddRxParamSetupReq | ( | uint8_t | rx1DrOffset, |
uint8_t | rx2DataRate, | ||
double | frequency | ||
) |
Add a RxParamSetupReq command.
rx1DrOffset | The requested data rate offset for the first receive window. |
rx2DataRate | The requested data rate for the second receive window. |
frequency | The frequency at which to listen for the second receive window. |
Definition at line 519 of file lora-frame-header.cc.
References m_fOptsLen, and m_macCommands.
|
virtual |
Deserialize the contents of the buffer into a LoraFrameHeader object.
start | A pointer to the buffer we need to deserialize. |
Definition at line 112 of file lora-frame-header.cc.
References m_ack, m_address, m_adr, m_adrAckReq, m_fCnt, m_fOptsLen, m_fPending, m_fPort, m_isUplink, m_macCommands, ns3::LoraDeviceAddress::Print(), and ns3::LoraDeviceAddress::Set().
bool ns3::LoraFrameHeader::GetAck | ( | void | ) | const |
Get the Ack bit value.
Definition at line 391 of file lora-frame-header.cc.
References m_ack.
Referenced by ns3::LorawanMacEndDevice::ParseCommands().
LoraDeviceAddress ns3::LoraFrameHeader::GetAddress | ( | void | ) | const |
Get this header's device address value.
Definition at line 353 of file lora-frame-header.cc.
References m_address.
Referenced by ns3::LoraNetworkStatus::GetEndDeviceStatus(), ns3::LoraNetworkScheduler::OnReceivedPacket(), ns3::LoraNetworkStatus::OnReceivedPacket(), ns3::LoraConfirmedMessagesComponent::OnReceivedPacket(), and ns3::LorawanMacEndDeviceClassA::Receive().
bool ns3::LoraFrameHeader::GetAdr | ( | void | ) | const |
Get the Adr value.
Definition at line 366 of file lora-frame-header.cc.
References m_adr.
Referenced by ns3::LoraAdrComponent::BeforeSendingReply().
bool ns3::LoraFrameHeader::GetAdrAckReq | ( | void | ) | const |
Get the AdrAckReq value.
Definition at line 378 of file lora-frame-header.cc.
References m_adrAckReq.
std::list< Ptr< LorawanMacCommand > > ns3::LoraFrameHeader::GetCommands | ( | void | ) |
Return a list of pointers to all the MAC commands saved in this header.
Definition at line 574 of file lora-frame-header.cc.
References m_macCommands.
Referenced by ns3::LorawanMacEndDevice::ParseCommands().
uint16_t ns3::LoraFrameHeader::GetFCnt | ( | void | ) | const |
Get the FCnt value.
Definition at line 428 of file lora-frame-header.cc.
References m_fCnt.
Referenced by ns3::LoraEndDeviceStatus::GetCompleteReplyPacket(), and ns3::LoraEndDeviceStatus::InsertReceivedPacket().
uint8_t ns3::LoraFrameHeader::GetFOptsLen | ( | void | ) | const |
Get the FOptsLen value.
Definition at line 409 of file lora-frame-header.cc.
References m_macCommands.
bool ns3::LoraFrameHeader::GetFPending | ( | void | ) | const |
Get the FPending value.
Definition at line 403 of file lora-frame-header.cc.
References m_fPending.
uint8_t ns3::LoraFrameHeader::GetFPort | ( | void | ) | const |
Get the FPort value.
Definition at line 341 of file lora-frame-header.cc.
References m_fPort.
|
virtual |
Definition at line 61 of file lora-frame-header.cc.
References GetTypeId().
|
inline |
Return a pointer to a LorawanMacCommand, or 0 if the LorawanMacCommand does not exist in this header.
Definition at line 336 of file lora-frame-header.h.
References m_macCommands.
Referenced by ns3::LoraLinkCheckComponent::BeforeSendingReply().
|
virtual |
Return the size required for serialization of this header.
Definition at line 67 of file lora-frame-header.cc.
References m_fOptsLen.
Referenced by ns3::LorawanMacEndDevice::DoSend().
|
static |
Definition at line 53 of file lora-frame-header.cc.
Referenced by GetInstanceTypeId().
|
virtual |
Print the header in a human-readable format.
os | The std::ostream on which to print the header. |
Definition at line 298 of file lora-frame-header.cc.
References m_ack, m_address, m_adr, m_adrAckReq, m_fCnt, m_fOptsLen, m_fPending, m_fPort, m_macCommands, and ns3::LoraDeviceAddress::Print().
|
virtual |
Serialize the header.
See Page 15 of LoraWAN specification for a representation of fields.
start | A pointer to the buffer that will be filled with the serialization. |
Definition at line 81 of file lora-frame-header.cc.
References ns3::LoraDeviceAddress::Get(), m_ack, m_address, m_adr, m_adrAckReq, m_fCnt, m_fOptsLen, m_fPending, m_fPort, and m_macCommands.
void ns3::LoraFrameHeader::SetAck | ( | bool | ack | ) |
Set the Ack bit.
ack | Whether or not to set the ACK bit. |
Definition at line 384 of file lora-frame-header.cc.
References m_ack.
void ns3::LoraFrameHeader::SetAddress | ( | LoraDeviceAddress | address | ) |
Set the address.
address | The LoraDeviceAddress to set. |
Definition at line 347 of file lora-frame-header.cc.
References m_address.
Referenced by ns3::LorawanMacEndDevice::ApplyNecessaryOptions(), and ns3::LoraEndDeviceStatus::GetCompleteReplyPacket().
void ns3::LoraFrameHeader::SetAdr | ( | bool | adr | ) |
Set the Adr value.
Adr | The Adr to set. |
Definition at line 359 of file lora-frame-header.cc.
References m_adr.
Referenced by ns3::LorawanMacEndDevice::ApplyNecessaryOptions().
void ns3::LoraFrameHeader::SetAdrAckReq | ( | bool | adrAckReq | ) |
Set the AdrAckReq value.
adrAckReq | The AdrAckReq to set. |
Definition at line 372 of file lora-frame-header.cc.
References m_adrAckReq.
Referenced by ns3::LorawanMacEndDevice::ApplyNecessaryOptions().
void ns3::LoraFrameHeader::SetAsDownlink | ( | void | ) |
State that this is a downlink message.
This method needs to be called at least once before any serialization or deserialization.
Definition at line 327 of file lora-frame-header.cc.
References m_isUplink.
Referenced by ns3::LorawanMacEndDeviceClassA::Receive().
void ns3::LoraFrameHeader::SetAsUplink | ( | void | ) |
State that this is an uplink message.
This method needs to be called at least once before any serialization or deserialization.
Definition at line 319 of file lora-frame-header.cc.
References m_isUplink.
Referenced by ns3::LorawanMacEndDevice::ApplyNecessaryOptions(), ns3::LoraAdrComponent::BeforeSendingReply(), ns3::LoraLinkCheckComponent::BeforeSendingReply(), ns3::LoraEndDeviceStatus::GetCompleteReplyPacket(), ns3::LoraEndDeviceStatus::InsertReceivedPacket(), ns3::LoraNetworkScheduler::OnReceivedPacket(), ns3::LoraNetworkStatus::OnReceivedPacket(), and ns3::LoraConfirmedMessagesComponent::OnReceivedPacket().
void ns3::LoraFrameHeader::SetFCnt | ( | uint16_t | fCnt | ) |
Set the FCnt value.
FCnt | The FCnt to set. |
Definition at line 422 of file lora-frame-header.cc.
References m_fCnt.
Referenced by ns3::LorawanMacEndDevice::ApplyNecessaryOptions(), and ns3::LoraEndDeviceStatus::GetCompleteReplyPacket().
void ns3::LoraFrameHeader::SetFPending | ( | bool | fPending | ) |
Set the FPending value.
fPending | The FPending to set. |
Definition at line 397 of file lora-frame-header.cc.
References m_fPending.
void ns3::LoraFrameHeader::SetFPort | ( | uint8_t | fPort | ) |
Set the FPort value.
fPort | The FPort to set. |
Definition at line 335 of file lora-frame-header.cc.
References m_fPort.
Referenced by ns3::LorawanMacEndDevice::ApplyNecessaryOptions().
|
private |
Definition at line 317 of file lora-frame-header.h.
Referenced by Deserialize(), GetAck(), Print(), Serialize(), and SetAck().
|
private |
Definition at line 313 of file lora-frame-header.h.
Referenced by Deserialize(), GetAddress(), Print(), Serialize(), and SetAddress().
|
private |
Definition at line 315 of file lora-frame-header.h.
Referenced by Deserialize(), GetAdr(), Print(), Serialize(), and SetAdr().
|
private |
Definition at line 316 of file lora-frame-header.h.
Referenced by Deserialize(), GetAdrAckReq(), Print(), Serialize(), and SetAdrAckReq().
|
private |
Definition at line 321 of file lora-frame-header.h.
Referenced by Deserialize(), GetFCnt(), Print(), Serialize(), and SetFCnt().
|
private |
Definition at line 323 of file lora-frame-header.h.
|
private |
Definition at line 319 of file lora-frame-header.h.
Referenced by AddCommand(), AddDevStatusReq(), AddDutyCycleAns(), AddDutyCycleReq(), AddLinkAdrAns(), AddLinkAdrReq(), AddLinkCheckAns(), AddLinkCheckReq(), AddNewChannelReq(), AddRxParamSetupAns(), AddRxParamSetupReq(), Deserialize(), GetSerializedSize(), Print(), and Serialize().
|
private |
Definition at line 318 of file lora-frame-header.h.
Referenced by Deserialize(), GetFPending(), Print(), Serialize(), and SetFPending().
|
private |
Definition at line 311 of file lora-frame-header.h.
Referenced by Deserialize(), GetFPort(), Print(), Serialize(), and SetFPort().
|
private |
Definition at line 331 of file lora-frame-header.h.
Referenced by Deserialize(), SetAsDownlink(), and SetAsUplink().
|
private |
List containing all the LorawanMacCommand instances that are contained in this LoraFrameHeader.
Definition at line 329 of file lora-frame-header.h.
Referenced by AddCommand(), AddDevStatusReq(), AddDutyCycleAns(), AddDutyCycleReq(), AddLinkAdrAns(), AddLinkAdrReq(), AddLinkCheckAns(), AddLinkCheckReq(), AddNewChannelReq(), AddRxParamSetupAns(), AddRxParamSetupReq(), Deserialize(), GetCommands(), GetFOptsLen(), GetLorawanMacCommand(), Print(), and Serialize().