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
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Davide Magrin <magrinda@dei.unipd.it>
18
*/
19
20
#ifndef LORAWAN_MAC_HEADER_H
21
#define LORAWAN_MAC_HEADER_H
22
23
#include "ns3/header.h"
24
25
namespace
ns3
26
{
27
namespace
lorawan
28
{
29
30
/**
31
* \ingroup lorawan
32
*
33
* This class represents the Mac header of a LoRaWAN packet.
34
*/
35
class
LorawanMacHeader
:
public
Header
36
{
37
public
:
38
/**
39
* The message type.
40
*
41
* The enum value corresponds to the value that will be written in the header
42
* by the Serialize method.
43
*/
44
enum
MType
45
{
46
JOIN_REQUEST
= 0,
47
JOIN_ACCEPT
= 1,
48
UNCONFIRMED_DATA_UP
= 2,
49
UNCONFIRMED_DATA_DOWN
= 3,
50
CONFIRMED_DATA_UP
= 4,
51
CONFIRMED_DATA_DOWN
= 5,
52
PROPRIETARY
= 7
53
};
54
55
/**
56
* Register this type.
57
* \return The object TypeId.
58
*/
59
static
TypeId
GetTypeId
();
60
61
LorawanMacHeader
();
//!< Default constructor
62
~LorawanMacHeader
()
override
;
//!< Destructor
63
64
// Pure virtual methods from Header that need to be implemented by this class
65
TypeId
GetInstanceTypeId
()
const override
;
66
uint32_t
GetSerializedSize
()
const override
;
67
68
/**
69
* Serialize the header.
70
*
71
* See Page 15 of LoRaWAN specification for a representation of fields.
72
*
73
* \param start A pointer to the buffer that will be filled with the
74
* serialization.
75
*/
76
void
Serialize
(
Buffer::Iterator
start)
const override
;
77
78
/**
79
* Deserialize the header.
80
*
81
* \param start A pointer to the buffer we need to deserialize.
82
* \return The number of consumed bytes.
83
*/
84
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
85
86
/**
87
* Print the header in a human readable format.
88
*
89
* \param os The std::ostream on which to print the header.
90
*/
91
void
Print
(std::ostream& os)
const override
;
92
93
/**
94
* Set the message type.
95
*
96
* \param mtype The message type of this header.
97
*/
98
void
SetMType
(
enum
MType
mtype);
99
100
/**
101
* Get the message type from the header.
102
*
103
* \return The uint8_t corresponding to this header's message type.
104
*/
105
uint8_t
GetMType
()
const
;
106
107
/**
108
* Set the major version of this header.
109
*
110
* \param major The uint8_t corresponding to this header's major version.
111
*/
112
void
SetMajor
(uint8_t major);
113
114
/**
115
* Get the major version from the header.
116
*
117
* \return The uint8_t corresponding to this header's major version.
118
*/
119
uint8_t
GetMajor
()
const
;
120
121
/**
122
* Check whether this header is for an uplink message.
123
*
124
* \return True if the message is meant to be sent from an end device to a gateway, false
125
* otherwise.
126
*/
127
bool
IsUplink
()
const
;
128
129
/**
130
* Check whether this header is for a confirmed message, i.e. a message asking from
131
* reception acknowledgment from the received.
132
*
133
* \return True is the message MType is of the confirmed variant, false otherwise.
134
*/
135
bool
IsConfirmed
()
const
;
136
137
private
:
138
/**
139
* The Message Type.
140
*/
141
uint8_t
m_mtype
;
142
143
/**
144
* The major version this header is using.
145
*/
146
uint8_t
m_major
;
147
};
148
}
// namespace lorawan
149
150
}
// namespace ns3
151
#endif
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition:
buffer.h:100
ns3::Header
Protocol header serialization and deserialization.
Definition:
header.h:44
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::lorawan::LorawanMacHeader
This class represents the Mac header of a LoRaWAN packet.
Definition:
lorawan-mac-header.h:36
ns3::lorawan::LorawanMacHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition:
lorawan-mac-header.cc:51
ns3::lorawan::LorawanMacHeader::SetMajor
void SetMajor(uint8_t major)
Set the major version of this header.
Definition:
lorawan-mac-header.cc:129
ns3::lorawan::LorawanMacHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the header.
Definition:
lorawan-mac-header.cc:87
ns3::lorawan::LorawanMacHeader::GetMType
uint8_t GetMType() const
Get the message type from the header.
Definition:
lorawan-mac-header.cc:121
ns3::lorawan::LorawanMacHeader::IsUplink
bool IsUplink() const
Check whether this header is for an uplink message.
Definition:
lorawan-mac-header.cc:147
ns3::lorawan::LorawanMacHeader::LorawanMacHeader
LorawanMacHeader()
Default constructor.
Definition:
lorawan-mac-header.cc:33
ns3::lorawan::LorawanMacHeader::~LorawanMacHeader
~LorawanMacHeader() override
Destructor.
Definition:
lorawan-mac-header.cc:38
ns3::lorawan::LorawanMacHeader::m_major
uint8_t m_major
The major version this header is using.
Definition:
lorawan-mac-header.h:146
ns3::lorawan::LorawanMacHeader::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition:
lorawan-mac-header.cc:43
ns3::lorawan::LorawanMacHeader::Print
void Print(std::ostream &os) const override
Print the header in a human readable format.
Definition:
lorawan-mac-header.cc:106
ns3::lorawan::LorawanMacHeader::m_mtype
uint8_t m_mtype
The Message Type.
Definition:
lorawan-mac-header.h:141
ns3::lorawan::LorawanMacHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the header.
Definition:
lorawan-mac-header.cc:65
ns3::lorawan::LorawanMacHeader::IsConfirmed
bool IsConfirmed() const
Check whether this header is for a confirmed message, i.e.
Definition:
lorawan-mac-header.cc:156
ns3::lorawan::LorawanMacHeader::SetMType
void SetMType(enum MType mtype)
Set the message type.
Definition:
lorawan-mac-header.cc:113
ns3::lorawan::LorawanMacHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition:
lorawan-mac-header.cc:57
ns3::lorawan::LorawanMacHeader::GetMajor
uint8_t GetMajor() const
Get the major version from the header.
Definition:
lorawan-mac-header.cc:139
ns3::lorawan::LorawanMacHeader::MType
MType
The message type.
Definition:
lorawan-mac-header.h:45
ns3::lorawan::LorawanMacHeader::JOIN_REQUEST
@ JOIN_REQUEST
Definition:
lorawan-mac-header.h:46
ns3::lorawan::LorawanMacHeader::CONFIRMED_DATA_UP
@ CONFIRMED_DATA_UP
Definition:
lorawan-mac-header.h:50
ns3::lorawan::LorawanMacHeader::UNCONFIRMED_DATA_DOWN
@ UNCONFIRMED_DATA_DOWN
Definition:
lorawan-mac-header.h:49
ns3::lorawan::LorawanMacHeader::PROPRIETARY
@ PROPRIETARY
Definition:
lorawan-mac-header.h:52
ns3::lorawan::LorawanMacHeader::CONFIRMED_DATA_DOWN
@ CONFIRMED_DATA_DOWN
Definition:
lorawan-mac-header.h:51
ns3::lorawan::LorawanMacHeader::JOIN_ACCEPT
@ JOIN_ACCEPT
Definition:
lorawan-mac-header.h:47
ns3::lorawan::LorawanMacHeader::UNCONFIRMED_DATA_UP
@ UNCONFIRMED_DATA_UP
Definition:
lorawan-mac-header.h:48
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 Mon Aug 12 2024 11:16:15 for ns-3 by
1.9.6