This class represents the Mac header of a LoRaWAN packet. More...
#include "lorawan-mac-header.h"
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. | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
This class represents the Mac header of a LoRaWAN packet.
Definition at line 35 of file lorawan-mac-header.h.
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.
ns3::lorawan::LorawanMacHeader::LorawanMacHeader | ( | ) |
Default constructor.
Definition at line 33 of file lorawan-mac-header.cc.
|
override |
Destructor.
Definition at line 38 of file lorawan-mac-header.cc.
|
overridevirtual |
Deserialize the header.
start | A pointer to the buffer we need to deserialize. |
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().
|
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.
Implements ns3::ObjectBase.
Definition at line 51 of file lorawan-mac-header.cc.
References GetTypeId().
uint8_t ns3::lorawan::LorawanMacHeader::GetMajor | ( | ) | const |
Get the major version from the header.
Definition at line 139 of file lorawan-mac-header.cc.
References m_major, and NS_LOG_FUNCTION_NOARGS.
Referenced by HeaderTest::DoRun().
uint8_t ns3::lorawan::LorawanMacHeader::GetMType | ( | ) | const |
Get the message type from the header.
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().
|
overridevirtual |
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().
|
static |
Register this type.
Definition at line 43 of file lorawan-mac-header.cc.
References ns3::TypeId::SetParent().
Referenced by GetInstanceTypeId().
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.
Definition at line 156 of file lorawan-mac-header.cc.
References CONFIRMED_DATA_DOWN, CONFIRMED_DATA_UP, m_mtype, and NS_LOG_FUNCTION_NOARGS.
bool ns3::lorawan::LorawanMacHeader::IsUplink | ( | ) | const |
Check whether this header is for an uplink message.
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().
|
overridevirtual |
Print the header in a human readable format.
os | The std::ostream on which to print the header. |
Implements ns3::Header.
Definition at line 106 of file lorawan-mac-header.cc.
|
overridevirtual |
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. |
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().
void ns3::lorawan::LorawanMacHeader::SetMajor | ( | uint8_t | major | ) |
Set the major version of this header.
major | The 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().
void ns3::lorawan::LorawanMacHeader::SetMType | ( | enum MType | mtype | ) |
Set the message type.
mtype | The 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().
|
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().
|
private |
The Message Type.
Definition at line 141 of file lorawan-mac-header.h.
Referenced by Deserialize(), GetMType(), IsConfirmed(), IsUplink(), Print(), Serialize(), and SetMType().