A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
lorawan-mac-header.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2017 University of Padova
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Davide Magrin <magrinda@dei.unipd.it>
7
*/
8
9
#ifndef LORAWAN_MAC_HEADER_H
10
#define LORAWAN_MAC_HEADER_H
11
12
#include "ns3/header.h"
13
14
namespace
ns3
15
{
16
namespace
lorawan
17
{
18
19
/**
20
* \ingroup lorawan
21
*
22
* This class represents the Mac header of a LoRaWAN packet.
23
*/
24
class
LorawanMacHeader
:
public
Header
25
{
26
public
:
27
/**
28
* The message type.
29
*
30
* The enum value corresponds to the value that will be written in the header
31
* by the Serialize method.
32
*/
33
enum
MType
34
{
35
JOIN_REQUEST
= 0,
36
JOIN_ACCEPT
= 1,
37
UNCONFIRMED_DATA_UP
= 2,
38
UNCONFIRMED_DATA_DOWN
= 3,
39
CONFIRMED_DATA_UP
= 4,
40
CONFIRMED_DATA_DOWN
= 5,
41
PROPRIETARY
= 7
42
};
43
44
/**
45
* Register this type.
46
* \return The object TypeId.
47
*/
48
static
TypeId
GetTypeId
();
49
50
LorawanMacHeader
();
//!< Default constructor
51
~LorawanMacHeader
()
override
;
//!< Destructor
52
53
// Pure virtual methods from Header that need to be implemented by this class
54
TypeId
GetInstanceTypeId
()
const override
;
55
uint32_t
GetSerializedSize
()
const override
;
56
57
/**
58
* Serialize the header.
59
*
60
* See Page 15 of LoRaWAN specification for a representation of fields.
61
*
62
* \param start A pointer to the buffer that will be filled with the
63
* serialization.
64
*/
65
void
Serialize
(
Buffer::Iterator
start)
const override
;
66
67
/**
68
* Deserialize the header.
69
*
70
* \param start A pointer to the buffer we need to deserialize.
71
* \return The number of consumed bytes.
72
*/
73
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
74
75
/**
76
* Print the header in a human readable format.
77
*
78
* \param os The std::ostream on which to print the header.
79
*/
80
void
Print
(std::ostream& os)
const override
;
81
82
/**
83
* Set the message type.
84
*
85
* \param mtype The message type of this header.
86
*/
87
void
SetMType
(
enum
MType mtype);
88
89
/**
90
* Get the message type from the header.
91
*
92
* \return The uint8_t corresponding to this header's message type.
93
*/
94
uint8_t
GetMType
()
const
;
95
96
/**
97
* Set the major version of this header.
98
*
99
* \param major The uint8_t corresponding to this header's major version.
100
*/
101
void
SetMajor
(uint8_t major);
102
103
/**
104
* Get the major version from the header.
105
*
106
* \return The uint8_t corresponding to this header's major version.
107
*/
108
uint8_t
GetMajor
()
const
;
109
110
/**
111
* Check whether this header is for an uplink message.
112
*
113
* \return True if the message is meant to be sent from an end device to a gateway, false
114
* otherwise.
115
*/
116
bool
IsUplink
()
const
;
117
118
/**
119
* Check whether this header is for a confirmed message, i.e. a message asking from
120
* reception acknowledgment from the received.
121
*
122
* \return True is the message MType is of the confirmed variant, false otherwise.
123
*/
124
bool
IsConfirmed
()
const
;
125
126
private
:
127
/**
128
* The Message Type.
129
*/
130
uint8_t
m_mtype
;
131
132
/**
133
* The major version this header is using.
134
*/
135
uint8_t
m_major
;
136
};
137
}
// namespace lorawan
138
139
}
// namespace ns3
140
#endif
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::lorawan::LorawanMacHeader
This class represents the Mac header of a LoRaWAN packet.
Definition
lorawan-mac-header.h:25
ns3::lorawan::LorawanMacHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
lorawan-mac-header.cc:40
ns3::lorawan::LorawanMacHeader::SetMajor
void SetMajor(uint8_t major)
Set the major version of this header.
Definition
lorawan-mac-header.cc:118
ns3::lorawan::LorawanMacHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the header.
Definition
lorawan-mac-header.cc:76
ns3::lorawan::LorawanMacHeader::GetMType
uint8_t GetMType() const
Get the message type from the header.
Definition
lorawan-mac-header.cc:110
ns3::lorawan::LorawanMacHeader::IsUplink
bool IsUplink() const
Check whether this header is for an uplink message.
Definition
lorawan-mac-header.cc:136
ns3::lorawan::LorawanMacHeader::LorawanMacHeader
LorawanMacHeader()
Default constructor.
Definition
lorawan-mac-header.cc:22
ns3::lorawan::LorawanMacHeader::~LorawanMacHeader
~LorawanMacHeader() override
Destructor.
Definition
lorawan-mac-header.cc:27
ns3::lorawan::LorawanMacHeader::m_major
uint8_t m_major
The major version this header is using.
Definition
lorawan-mac-header.h:135
ns3::lorawan::LorawanMacHeader::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
lorawan-mac-header.cc:32
ns3::lorawan::LorawanMacHeader::Print
void Print(std::ostream &os) const override
Print the header in a human readable format.
Definition
lorawan-mac-header.cc:95
ns3::lorawan::LorawanMacHeader::m_mtype
uint8_t m_mtype
The Message Type.
Definition
lorawan-mac-header.h:130
ns3::lorawan::LorawanMacHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the header.
Definition
lorawan-mac-header.cc:54
ns3::lorawan::LorawanMacHeader::IsConfirmed
bool IsConfirmed() const
Check whether this header is for a confirmed message, i.e.
Definition
lorawan-mac-header.cc:145
ns3::lorawan::LorawanMacHeader::SetMType
void SetMType(enum MType mtype)
Set the message type.
Definition
lorawan-mac-header.cc:102
ns3::lorawan::LorawanMacHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
lorawan-mac-header.cc:46
ns3::lorawan::LorawanMacHeader::GetMajor
uint8_t GetMajor() const
Get the major version from the header.
Definition
lorawan-mac-header.cc:128
ns3::lorawan::LorawanMacHeader::MType
MType
The message type.
Definition
lorawan-mac-header.h:34
ns3::lorawan::LorawanMacHeader::JOIN_REQUEST
@ JOIN_REQUEST
Definition
lorawan-mac-header.h:35
ns3::lorawan::LorawanMacHeader::CONFIRMED_DATA_UP
@ CONFIRMED_DATA_UP
Definition
lorawan-mac-header.h:39
ns3::lorawan::LorawanMacHeader::UNCONFIRMED_DATA_DOWN
@ UNCONFIRMED_DATA_DOWN
Definition
lorawan-mac-header.h:38
ns3::lorawan::LorawanMacHeader::PROPRIETARY
@ PROPRIETARY
Definition
lorawan-mac-header.h:41
ns3::lorawan::LorawanMacHeader::CONFIRMED_DATA_DOWN
@ CONFIRMED_DATA_DOWN
Definition
lorawan-mac-header.h:40
ns3::lorawan::LorawanMacHeader::JOIN_ACCEPT
@ JOIN_ACCEPT
Definition
lorawan-mac-header.h:36
ns3::lorawan::LorawanMacHeader::UNCONFIRMED_DATA_UP
@ UNCONFIRMED_DATA_UP
Definition
lorawan-mac-header.h:37
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
lorawan
model
lorawan-mac-header.h
Generated on Fri Nov 8 2024 13:59:02 for ns-3 by
1.11.0