A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::lorawan::LorawanMacHeader Class Reference

This class represents the Mac header of a LoRaWAN packet. More...

#include "lorawan-mac-header.h"

+ Inheritance diagram for ns3::lorawan::LorawanMacHeader:
+ Collaboration diagram for ns3::lorawan::LorawanMacHeader:

Public Types

enum  MType {
  JOIN_REQUEST = 0 , JOIN_ACCEPT = 1 , UNCONFIRMED_DATA_UP = 2 , UNCONFIRMED_DATA_DOWN = 3 ,
  CONFIRMED_DATA_UP = 4 , CONFIRMED_DATA_DOWN = 5 , PROPRIETARY = 7
}
 The message type. More...
 

Public Member Functions

 LorawanMacHeader ()
 Default constructor.
 
 ~LorawanMacHeader () override
 Destructor.
 
uint32_t Deserialize (Buffer::Iterator start) override
 Deserialize the header.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
uint8_t GetMajor () const
 Get the major version from the header.
 
uint8_t GetMType () const
 Get the message type from the header.
 
uint32_t GetSerializedSize () const override
 
bool IsConfirmed () const
 Check whether this header is for a confirmed message, i.e.
 
bool IsUplink () const
 Check whether this header is for an uplink message.
 
void Print (std::ostream &os) const override
 Print the header in a human readable format.
 
void Serialize (Buffer::Iterator start) const override
 Serialize the header.
 
void SetMajor (uint8_t major)
 Set the major version of this header.
 
void SetMType (enum MType mtype)
 Set the message type.
 
- Public Member Functions inherited from ns3::Header
 ~Header () override
 
uint32_t Deserialize (Buffer::Iterator start) override=0
 
virtual uint32_t Deserialize (Buffer::Iterator start)=0
 Deserialize the object from a buffer iterator.
 
virtual uint32_t Deserialize (Buffer::Iterator start, Buffer::Iterator end)
 Deserialize the object from a buffer iterator.
 
virtual uint32_t GetSerializedSize () const =0
 
void Print (std::ostream &os) const override=0
 
virtual void Serialize (Buffer::Iterator start) const =0
 
virtual uint32_t Deserialize (Buffer::Iterator start)=0
 Deserialize the object from a buffer iterator.
 
virtual uint32_t Deserialize (Buffer::Iterator start, Buffer::Iterator end)
 Deserialize the object from a buffer iterator.
 
virtual void Print (std::ostream &os) const =0
 Print the object contents.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
virtual TypeId GetInstanceTypeId () const =0
 Get the most derived TypeId for this Object.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::Header
static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Chunk
static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Private Attributes

uint8_t m_major
 The major version this header is using.
 
uint8_t m_mtype
 The Message Type.
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Detailed Description

This class represents the Mac header of a LoRaWAN packet.

Definition at line 35 of file lorawan-mac-header.h.

Member Enumeration Documentation

◆ MType

The message type.

The enum value corresponds to the value that will be written in the header by the Serialize method.

Enumerator
JOIN_REQUEST 
JOIN_ACCEPT 
UNCONFIRMED_DATA_UP 
UNCONFIRMED_DATA_DOWN 
CONFIRMED_DATA_UP 
CONFIRMED_DATA_DOWN 
PROPRIETARY 

Definition at line 44 of file lorawan-mac-header.h.

Constructor & Destructor Documentation

◆ LorawanMacHeader()

ns3::lorawan::LorawanMacHeader::LorawanMacHeader ( )

Default constructor.

Definition at line 33 of file lorawan-mac-header.cc.

◆ ~LorawanMacHeader()

ns3::lorawan::LorawanMacHeader::~LorawanMacHeader ( )
override

Destructor.

Definition at line 38 of file lorawan-mac-header.cc.

Member Function Documentation

◆ Deserialize()

uint32_t ns3::lorawan::LorawanMacHeader::Deserialize ( Buffer::Iterator  start)
overridevirtual

Deserialize the header.

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

Implements ns3::Header.

Definition at line 87 of file lorawan-mac-header.cc.

References m_major, m_mtype, and NS_LOG_FUNCTION_NOARGS.

Referenced by HeaderTest::DoRun().

+ Here is the caller graph for this function:

◆ GetInstanceTypeId()

TypeId ns3::lorawan::LorawanMacHeader::GetInstanceTypeId ( ) const
overridevirtual

Get the most derived TypeId for this Object.

This method is typically implemented by ns3::Object::GetInstanceTypeId but some classes which derive from ns3::ObjectBase directly have to implement it themselves.

Returns
The TypeId associated to the most-derived type of this instance.

Implements ns3::ObjectBase.

Definition at line 51 of file lorawan-mac-header.cc.

References GetTypeId().

+ Here is the call graph for this function:

◆ GetMajor()

uint8_t ns3::lorawan::LorawanMacHeader::GetMajor ( ) const

Get the major version from the header.

Returns
The uint8_t corresponding to this header's major version.

Definition at line 139 of file lorawan-mac-header.cc.

References m_major, and NS_LOG_FUNCTION_NOARGS.

Referenced by HeaderTest::DoRun().

+ Here is the caller graph for this function:

◆ GetMType()

uint8_t ns3::lorawan::LorawanMacHeader::GetMType ( ) const

Get the message type from the header.

Returns
The uint8_t corresponding to this header's message type.

Definition at line 121 of file lorawan-mac-header.cc.

References m_mtype, and NS_LOG_FUNCTION_NOARGS.

Referenced by HeaderTest::DoRun(), and ns3::lorawan::ConfirmedMessagesComponent::OnReceivedPacket().

+ Here is the caller graph for this function:

◆ GetSerializedSize()

uint32_t ns3::lorawan::LorawanMacHeader::GetSerializedSize ( ) const
overridevirtual
Returns
the expected size of the header.

This method is used by Packet::AddHeader to store a header into the byte buffer of a packet. This method should return the number of bytes which are needed to store the full header data by Serialize.

Implements ns3::Header.

Definition at line 57 of file lorawan-mac-header.cc.

References NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::lorawan::EndDeviceLorawanMac::DoSend().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::lorawan::LorawanMacHeader::GetTypeId ( )
static

Register this type.

Returns
The object TypeId.

Definition at line 43 of file lorawan-mac-header.cc.

References ns3::TypeId::SetParent().

Referenced by GetInstanceTypeId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsConfirmed()

bool ns3::lorawan::LorawanMacHeader::IsConfirmed ( ) const

Check whether this header is for a confirmed message, i.e.

a message asking from reception acknowledgment from the received.

Returns
True is the message MType is of the confirmed variant, false otherwise.

Definition at line 156 of file lorawan-mac-header.cc.

References CONFIRMED_DATA_DOWN, CONFIRMED_DATA_UP, m_mtype, and NS_LOG_FUNCTION_NOARGS.

◆ IsUplink()

bool ns3::lorawan::LorawanMacHeader::IsUplink ( ) const

Check whether this header is for an uplink message.

Returns
True if the message is meant to be sent from an end device to a gateway, false otherwise.

Definition at line 147 of file lorawan-mac-header.cc.

References CONFIRMED_DATA_UP, JOIN_REQUEST, m_mtype, NS_LOG_FUNCTION_NOARGS, and UNCONFIRMED_DATA_UP.

Referenced by ns3::lorawan::LoraPacketTracker::IsUplink(), ns3::lorawan::ClassAEndDeviceLorawanMac::Receive(), and ns3::lorawan::GatewayLorawanMac::Receive().

+ Here is the caller graph for this function:

◆ Print()

void ns3::lorawan::LorawanMacHeader::Print ( std::ostream &  os) const
overridevirtual

Print the header in a human readable format.

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

Implements ns3::Header.

Definition at line 106 of file lorawan-mac-header.cc.

References m_major, and m_mtype.

◆ Serialize()

void ns3::lorawan::LorawanMacHeader::Serialize ( Buffer::Iterator  start) const
overridevirtual

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.

Implements ns3::Header.

Definition at line 65 of file lorawan-mac-header.cc.

References m_major, m_mtype, NS_LOG_DEBUG, and NS_LOG_FUNCTION_NOARGS.

Referenced by HeaderTest::DoRun().

+ Here is the caller graph for this function:

◆ SetMajor()

void ns3::lorawan::LorawanMacHeader::SetMajor ( uint8_t  major)

Set the major version of this header.

Parameters
majorThe uint8_t corresponding to this header's major version.

Definition at line 129 of file lorawan-mac-header.cc.

References m_major, NS_ASSERT, and NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::lorawan::EndDeviceLorawanMac::ApplyNecessaryOptions(), and HeaderTest::DoRun().

+ Here is the caller graph for this function:

◆ SetMType()

void ns3::lorawan::LorawanMacHeader::SetMType ( enum MType  mtype)

Set the message type.

Parameters
mtypeThe message type of this header.

Definition at line 113 of file lorawan-mac-header.cc.

References m_mtype, and NS_LOG_FUNCTION.

Referenced by ns3::lorawan::EndDeviceLorawanMac::ApplyNecessaryOptions(), HeaderTest::DoRun(), and ns3::lorawan::EndDeviceStatus::GetCompleteReplyPacket().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_major

uint8_t ns3::lorawan::LorawanMacHeader::m_major
private

The major version this header is using.

Definition at line 146 of file lorawan-mac-header.h.

Referenced by Deserialize(), GetMajor(), Print(), Serialize(), and SetMajor().

◆ m_mtype

uint8_t ns3::lorawan::LorawanMacHeader::m_mtype
private

The Message Type.

Definition at line 141 of file lorawan-mac-header.h.

Referenced by Deserialize(), GetMType(), IsConfirmed(), IsUplink(), Print(), Serialize(), and SetMType().


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