ns3::LoraFrameHeader Class Reference

This class represents the Frame header (FHDR) used in a LoraWAN network. More...

#include "lora-frame-header.h"

+ Inheritance diagram for ns3::LoraFrameHeader:
+ Collaboration diagram for ns3::LoraFrameHeader:

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...
 

Detailed Description

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).

Remarks
Prior to using it, this class needs to be informed of whether the header is for an uplink or downlink message. This is necessary due to the fact that UL and DL messages have subtly different structure and, hence, serialization and deserialization schemes.

Definition at line 44 of file lora-frame-header.h.

Constructor & Destructor Documentation

◆ LoraFrameHeader()

ns3::LoraFrameHeader::LoraFrameHeader ( )

Definition at line 33 of file lora-frame-header.cc.

◆ ~LoraFrameHeader()

ns3::LoraFrameHeader::~LoraFrameHeader ( )

Definition at line 45 of file lora-frame-header.cc.

Member Function Documentation

◆ AddCommand()

void ns3::LoraFrameHeader::AddCommand ( Ptr< LorawanMacCommand macCommand)

Add a predefined command to the list.

Definition at line 579 of file lora-frame-header.cc.

References m_fOptsLen, and m_macCommands.

Referenced by ns3::LoraEndDeviceStatus::AddMACCommand(), and ns3::LorawanMacEndDevice::ApplyNecessaryOptions().

+ Here is the caller graph for this function:

◆ AddDevStatusReq()

void ns3::LoraFrameHeader::AddDevStatusReq ( void  )

Add a DevStatusReq command.

Definition at line 543 of file lora-frame-header.cc.

References m_fOptsLen, and m_macCommands.

◆ AddDutyCycleAns()

void ns3::LoraFrameHeader::AddDutyCycleAns ( void  )

Add a DutyCycleAns command.

Definition at line 504 of file lora-frame-header.cc.

References m_fOptsLen, and m_macCommands.

◆ AddDutyCycleReq()

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).

Parameters
dutyCycleThe dutyCycle in 8-bit form.

Definition at line 492 of file lora-frame-header.cc.

References m_fOptsLen, and m_macCommands.

◆ AddLinkAdrAns()

void ns3::LoraFrameHeader::AddLinkAdrAns ( bool  powerAck,
bool  dataRateAck,
bool  channelMaskAck 
)

Add a LinkAdrAns command.

Parameters
powerAckWhether the power can be set or not.
dataRateAckWhether the data rate can be set or not.
channelMaskAckWhether the channel mask is coherent with the device's current state or not.

Definition at line 481 of file lora-frame-header.cc.

References m_fOptsLen, and m_macCommands.

◆ AddLinkAdrReq()

void ns3::LoraFrameHeader::AddLinkAdrReq ( uint8_t  dataRate,
uint8_t  txPower,
std::list< int >  enabledChannels,
int  repetitions 
)

Add a LinkAdrReq command.

Parameters
dataRateThe data rate at which the receiver should transmit.
txPowerThe power at which the receiver should transmit, encoded according to the LoRaWAN specification of the region.
enabledChannelsA list containing the indices of channels enabled by this command.
repetitionsThe number of repetitions the receiver should send when transmitting.

Definition at line 454 of file lora-frame-header.cc.

References m_fOptsLen, and m_macCommands.

◆ AddLinkCheckAns()

void ns3::LoraFrameHeader::AddLinkCheckAns ( uint8_t  margin,
uint8_t  gwCnt 
)

Add a LinkCheckAns command.

Parameters
marginThe demodulation margin the LinkCheckReq packet was received with.
gwCntThe number of gateways the LinkCheckReq packet was received by.

Definition at line 443 of file lora-frame-header.cc.

References m_fOptsLen, and m_macCommands.

◆ AddLinkCheckReq()

void ns3::LoraFrameHeader::AddLinkCheckReq ( void  )

Add a LinkCheckReq command.

Definition at line 431 of file lora-frame-header.cc.

References m_fOptsLen, and m_macCommands.

◆ AddNewChannelReq()

void ns3::LoraFrameHeader::AddNewChannelReq ( uint8_t  chIndex,
double  frequency,
uint8_t  minDataRate,
uint8_t  maxDataRate 
)

Add a NewChannelReq command.

Definition at line 555 of file lora-frame-header.cc.

References m_fOptsLen, and m_macCommands.

◆ AddRxParamSetupAns()

void ns3::LoraFrameHeader::AddRxParamSetupAns ( void  )

Add a RxParamSetupAns command.

Definition at line 531 of file lora-frame-header.cc.

References m_fOptsLen, and m_macCommands.

◆ AddRxParamSetupReq()

void ns3::LoraFrameHeader::AddRxParamSetupReq ( uint8_t  rx1DrOffset,
uint8_t  rx2DataRate,
double  frequency 
)

Add a RxParamSetupReq command.

Parameters
rx1DrOffsetThe requested data rate offset for the first receive window.
rx2DataRateThe requested data rate for the second receive window.
frequencyThe frequency at which to listen for the second receive window.

Definition at line 516 of file lora-frame-header.cc.

References m_fOptsLen, and m_macCommands.

◆ Deserialize()

uint32_t ns3::LoraFrameHeader::Deserialize ( Buffer::Iterator  start)
virtual

Deserialize the contents of the buffer into a LoraFrameHeader object.

Parameters
startA pointer to the buffer we need to deserialize.
Returns
The number of consumed bytes.

Definition at line 109 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().

+ Here is the call graph for this function:

◆ GetAck()

bool ns3::LoraFrameHeader::GetAck ( void  ) const

Get the Ack bit value.

Returns
True if the ACK bit is set, false otherwise.

Definition at line 388 of file lora-frame-header.cc.

References m_ack.

Referenced by ns3::LorawanMacEndDevice::ParseCommands().

+ Here is the caller graph for this function:

◆ GetAddress()

LoraDeviceAddress ns3::LoraFrameHeader::GetAddress ( void  ) const

Get this header's device address value.

Returns
The address value stored in this header.

Definition at line 350 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().

+ Here is the caller graph for this function:

◆ GetAdr()

bool ns3::LoraFrameHeader::GetAdr ( void  ) const

Get the Adr value.

Returns
The Adr value.

Definition at line 363 of file lora-frame-header.cc.

References m_adr.

Referenced by ns3::LoraAdrComponent::BeforeSendingReply().

+ Here is the caller graph for this function:

◆ GetAdrAckReq()

bool ns3::LoraFrameHeader::GetAdrAckReq ( void  ) const

Get the AdrAckReq value.

Returns
The AdrAckReq value.

Definition at line 375 of file lora-frame-header.cc.

References m_adrAckReq.

◆ GetCommands()

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 571 of file lora-frame-header.cc.

References m_macCommands.

Referenced by ns3::LorawanMacEndDevice::ParseCommands().

+ Here is the caller graph for this function:

◆ GetFCnt()

uint16_t ns3::LoraFrameHeader::GetFCnt ( void  ) const

Get the FCnt value.

Returns
The FCnt value.

Definition at line 425 of file lora-frame-header.cc.

References m_fCnt.

Referenced by ns3::LoraEndDeviceStatus::GetCompleteReplyPacket(), and ns3::LoraEndDeviceStatus::InsertReceivedPacket().

+ Here is the caller graph for this function:

◆ GetFOptsLen()

uint8_t ns3::LoraFrameHeader::GetFOptsLen ( void  ) const

Get the FOptsLen value.

Remarks
This value cannot be set since it's directly extracted from the number and kind of MAC commands.
Returns
The FOptsLen value.

Definition at line 406 of file lora-frame-header.cc.

References m_macCommands.

◆ GetFPending()

bool ns3::LoraFrameHeader::GetFPending ( void  ) const

Get the FPending value.

Returns
The FPending value.

Definition at line 400 of file lora-frame-header.cc.

References m_fPending.

◆ GetFPort()

uint8_t ns3::LoraFrameHeader::GetFPort ( void  ) const

Get the FPort value.

Returns
The FPort value.

Definition at line 338 of file lora-frame-header.cc.

References m_fPort.

◆ GetInstanceTypeId()

TypeId ns3::LoraFrameHeader::GetInstanceTypeId ( void  ) const
virtual

Definition at line 58 of file lora-frame-header.cc.

References GetTypeId().

+ Here is the call graph for this function:

◆ GetLorawanMacCommand()

template<typename T >
Ptr< T > ns3::LoraFrameHeader::GetLorawanMacCommand ( void  )
inline

Return a pointer to a LorawanMacCommand, or 0 if the LorawanMacCommand does not exist in this header.

Definition at line 332 of file lora-frame-header.h.

References m_macCommands.

Referenced by ns3::LoraLinkCheckComponent::BeforeSendingReply().

+ Here is the caller graph for this function:

◆ GetSerializedSize()

uint32_t ns3::LoraFrameHeader::GetSerializedSize ( void  ) const
virtual

Return the size required for serialization of this header.

Returns
The serialized size in bytes

Definition at line 64 of file lora-frame-header.cc.

References m_fOptsLen.

Referenced by ns3::LorawanMacEndDevice::DoSend().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::LoraFrameHeader::GetTypeId ( void  )
static

Definition at line 50 of file lora-frame-header.cc.

Referenced by GetInstanceTypeId().

+ Here is the caller graph for this function:

◆ Print()

void ns3::LoraFrameHeader::Print ( std::ostream &  os) const
virtual

Print the header in a human-readable format.

Parameters
osThe std::ostream on which to print the header.

Definition at line 295 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().

+ Here is the call graph for this function:

◆ Serialize()

void ns3::LoraFrameHeader::Serialize ( Buffer::Iterator  start) const
virtual

Serialize the header.

See Page 15 of LoraWAN specification for a representation of fields.

Parameters
startA pointer to the buffer that will be filled with the serialization.

Definition at line 78 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.

+ Here is the call graph for this function:

◆ SetAck()

void ns3::LoraFrameHeader::SetAck ( bool  ack)

Set the Ack bit.

Parameters
ackWhether or not to set the ACK bit.

Definition at line 381 of file lora-frame-header.cc.

References m_ack.

◆ SetAddress()

void ns3::LoraFrameHeader::SetAddress ( LoraDeviceAddress  address)

Set the address.

Parameters
addressThe LoraDeviceAddress to set.

Definition at line 344 of file lora-frame-header.cc.

References m_address.

Referenced by ns3::LorawanMacEndDevice::ApplyNecessaryOptions(), and ns3::LoraEndDeviceStatus::GetCompleteReplyPacket().

+ Here is the caller graph for this function:

◆ SetAdr()

void ns3::LoraFrameHeader::SetAdr ( bool  adr)

Set the Adr value.

Parameters
AdrThe Adr to set.

Definition at line 356 of file lora-frame-header.cc.

References m_adr.

Referenced by ns3::LorawanMacEndDevice::ApplyNecessaryOptions().

+ Here is the caller graph for this function:

◆ SetAdrAckReq()

void ns3::LoraFrameHeader::SetAdrAckReq ( bool  adrAckReq)

Set the AdrAckReq value.

Parameters
adrAckReqThe AdrAckReq to set.

Definition at line 369 of file lora-frame-header.cc.

References m_adrAckReq.

Referenced by ns3::LorawanMacEndDevice::ApplyNecessaryOptions().

+ Here is the caller graph for this function:

◆ SetAsDownlink()

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 324 of file lora-frame-header.cc.

References m_isUplink.

Referenced by ns3::LorawanMacEndDeviceClassA::Receive().

+ Here is the caller graph for this function:

◆ SetAsUplink()

void ns3::LoraFrameHeader::SetAsUplink ( void  )

◆ SetFCnt()

void ns3::LoraFrameHeader::SetFCnt ( uint16_t  fCnt)

Set the FCnt value.

Parameters
FCntThe FCnt to set.

Definition at line 419 of file lora-frame-header.cc.

References m_fCnt.

Referenced by ns3::LorawanMacEndDevice::ApplyNecessaryOptions(), and ns3::LoraEndDeviceStatus::GetCompleteReplyPacket().

+ Here is the caller graph for this function:

◆ SetFPending()

void ns3::LoraFrameHeader::SetFPending ( bool  fPending)

Set the FPending value.

Parameters
fPendingThe FPending to set.

Definition at line 394 of file lora-frame-header.cc.

References m_fPending.

◆ SetFPort()

void ns3::LoraFrameHeader::SetFPort ( uint8_t  fPort)

Set the FPort value.

Parameters
fPortThe FPort to set.

Definition at line 332 of file lora-frame-header.cc.

References m_fPort.

Referenced by ns3::LorawanMacEndDevice::ApplyNecessaryOptions().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_ack

bool ns3::LoraFrameHeader::m_ack
private

Definition at line 313 of file lora-frame-header.h.

Referenced by Deserialize(), GetAck(), Print(), Serialize(), and SetAck().

◆ m_address

LoraDeviceAddress ns3::LoraFrameHeader::m_address
private

Definition at line 309 of file lora-frame-header.h.

Referenced by Deserialize(), GetAddress(), Print(), Serialize(), and SetAddress().

◆ m_adr

bool ns3::LoraFrameHeader::m_adr
private

Definition at line 311 of file lora-frame-header.h.

Referenced by Deserialize(), GetAdr(), Print(), Serialize(), and SetAdr().

◆ m_adrAckReq

bool ns3::LoraFrameHeader::m_adrAckReq
private

Definition at line 312 of file lora-frame-header.h.

Referenced by Deserialize(), GetAdrAckReq(), Print(), Serialize(), and SetAdrAckReq().

◆ m_fCnt

uint16_t ns3::LoraFrameHeader::m_fCnt
private

Definition at line 317 of file lora-frame-header.h.

Referenced by Deserialize(), GetFCnt(), Print(), Serialize(), and SetFCnt().

◆ m_fOpts

Buffer ns3::LoraFrameHeader::m_fOpts
private

Definition at line 319 of file lora-frame-header.h.

◆ m_fOptsLen

◆ m_fPending

bool ns3::LoraFrameHeader::m_fPending
private

Definition at line 314 of file lora-frame-header.h.

Referenced by Deserialize(), GetFPending(), Print(), Serialize(), and SetFPending().

◆ m_fPort

uint8_t ns3::LoraFrameHeader::m_fPort
private

Definition at line 307 of file lora-frame-header.h.

Referenced by Deserialize(), GetFPort(), Print(), Serialize(), and SetFPort().

◆ m_isUplink

bool ns3::LoraFrameHeader::m_isUplink
private

Definition at line 327 of file lora-frame-header.h.

Referenced by Deserialize(), SetAsDownlink(), and SetAsUplink().

◆ m_macCommands


The documentation for this class was generated from the following files: