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
FType
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 frame type.
84
*
85
* @param fType The frame type of this header.
86
*/
87
void
SetFType
(
enum
FType fType);
88
89
/**
90
* Get the frame type from the header.
91
*
92
* @return The uint8_t corresponding to this header's frame type.
93
*/
94
FType
GetFType
()
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 FType is of the confirmed variant, false otherwise.
123
*/
124
bool
IsConfirmed
()
const
;
125
126
private
:
127
/**
128
* The Frame Type.
129
*/
130
FType
m_fType
;
131
132
/**
133
* The major version this header is using.
134
*/
135
uint8_t
m_major
;
136
};
137
138
/**
139
* Allow logging of FType like any other data type.
140
*/
141
std::ostream&
operator<<
(std::ostream& os,
const
LorawanMacHeader::FType
& fType);
142
143
}
// namespace lorawan
144
}
// namespace ns3
145
146
#endif
/* LORAWAN_MAC_HEADER_H */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:98
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:36
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:50
ns3::lorawan::LorawanMacHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
lorawan-mac-header.cc:38
ns3::lorawan::LorawanMacHeader::SetMajor
void SetMajor(uint8_t major)
Set the major version of this header.
Definition
lorawan-mac-header.cc:116
ns3::lorawan::LorawanMacHeader::m_fType
FType m_fType
The Frame Type.
Definition
lorawan-mac-header.h:130
ns3::lorawan::LorawanMacHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the header.
Definition
lorawan-mac-header.cc:74
ns3::lorawan::LorawanMacHeader::IsUplink
bool IsUplink() const
Check whether this header is for an uplink message.
Definition
lorawan-mac-header.cc:134
ns3::lorawan::LorawanMacHeader::LorawanMacHeader
LorawanMacHeader()
Default constructor.
Definition
lorawan-mac-header.cc:20
ns3::lorawan::LorawanMacHeader::~LorawanMacHeader
~LorawanMacHeader() override
Destructor.
Definition
lorawan-mac-header.cc:25
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::SetFType
void SetFType(enum FType fType)
Set the frame type.
Definition
lorawan-mac-header.cc:100
ns3::lorawan::LorawanMacHeader::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
lorawan-mac-header.cc:30
ns3::lorawan::LorawanMacHeader::Print
void Print(std::ostream &os) const override
Print the header in a human readable format.
Definition
lorawan-mac-header.cc:93
ns3::lorawan::LorawanMacHeader::GetFType
FType GetFType() const
Get the frame type from the header.
Definition
lorawan-mac-header.cc:108
ns3::lorawan::LorawanMacHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Serialize the header.
Definition
lorawan-mac-header.cc:52
ns3::lorawan::LorawanMacHeader::IsConfirmed
bool IsConfirmed() const
Check whether this header is for a confirmed message, i.e.
Definition
lorawan-mac-header.cc:143
ns3::lorawan::LorawanMacHeader::FType
FType
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
ns3::lorawan::LorawanMacHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
lorawan-mac-header.cc:44
ns3::lorawan::LorawanMacHeader::GetMajor
uint8_t GetMajor() const
Get the major version from the header.
Definition
lorawan-mac-header.cc:126
uint32_t
ns3::lorawan
Definition
forwarder-helper.cc:19
ns3::lorawan::operator<<
std::ostream & operator<<(std::ostream &os, const EndDeviceLoraPhy::State &state)
Overloaded operator to print the value of a EndDeviceLoraPhy::State.
Definition
end-device-lora-phy.cc:285
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
lorawan
model
lorawan-mac-header.h
Generated on
for ns-3 by
1.16.1