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
zigbee-nwk-header.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2024 Tokushima University, Japan
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Authors:
7
* Ryo Okuda <c611901200@tokushima-u.ac.jp>
8
* Alberto Gallegos Ramonet <alramonet@is.tokushima-u.ac.jp>
9
*/
10
11
#ifndef ZIGBEE_NWK_HEADER_H
12
#define ZIGBEE_NWK_HEADER_H
13
14
#include "ns3/header.h"
15
#include "ns3/mac16-address.h"
16
#include "ns3/mac64-address.h"
17
18
namespace
ns3
19
{
20
21
namespace
zigbee
22
{
23
24
/**
25
* Zigbee Specification r22.1.0, Values of the frame Type Sub-field (Table 3-46)
26
*/
27
enum
NwkType
28
{
29
DATA
= 0,
//!< Data frame type
30
NWK_COMMAND
= 1,
//!< Network command frame type
31
INTER_PAN
= 3
//!< Inter-Pan frame type
32
};
33
34
/**
35
* Zigbee Specification r22.1.0, Values of the discover route sub-field (Table 3-47)
36
*/
37
enum
DiscoverRouteType
38
{
39
SUPPRESS_ROUTE_DISCOVERY
= 0x00,
//!< Suppress route discovery
40
ENABLE_ROUTE_DISCOVERY
= 0x01
//!< Enable route discovery
41
};
42
43
/**
44
* Zigbee Specification r22.1.0, Multicast Mode Sub-Field (Table 3-7)
45
*/
46
enum
MulticastMode
47
{
48
NONMEMBER
= 0,
//!< Non member multicast mode
49
MEMBER
= 1,
//!< Member multicast mode
50
};
51
52
/**
53
* @ingroup zigbee
54
* Represent the NWK Header with the Frame Control and Routing fields
55
* Zigbee Specification r22.1.0, General NPDU Frame Format (Section 3.3.1)
56
*/
57
class
ZigbeeNwkHeader
:
public
Header
58
{
59
public
:
60
ZigbeeNwkHeader
();
61
62
~ZigbeeNwkHeader
()
override
;
63
64
/**
65
* Set the Frame type used (Data or Command)
66
* @param nwkType The frame type
67
*/
68
void
SetFrameType
(
enum
NwkType
nwkType);
69
70
/**
71
* Set the Frame Control field "Frame Type" bits
72
* @return The frame type
73
*/
74
NwkType
GetFrameType
()
const
;
75
76
/**
77
* Set the Protocol version
78
* @param ver The protocol version
79
*/
80
void
SetProtocolVer
(uint8_t ver);
81
82
/**
83
* Get Frame protocol version
84
* @return The protocol version used by the frame
85
*/
86
uint8_t
GetProtocolVer
()
const
;
87
88
/**
89
* Suppress or enable route discovery for this frame
90
* @param discoverRoute Suppress or enable route discovery
91
*/
92
void
SetDiscoverRoute
(
enum
DiscoverRouteType
discoverRoute);
93
94
/**
95
* Get the status of frame discovery route (suppress or enabled)
96
* @return The discovery route status
97
*/
98
DiscoverRouteType
GetDiscoverRoute
()
const
;
99
100
/**
101
* Set to true the value of the multicast flag in the frame control field.
102
*/
103
void
SetMulticast
();
104
105
/**
106
* Inform whether or not the current frame is used in multicast.
107
* @return True = MCST false = UCST or BCST
108
*/
109
bool
IsMulticast
()
const
;
110
111
/**
112
* Inform whether or not security is enabled.
113
* @return True security enabled.
114
*/
115
bool
IsSecurityEnabled
()
const
;
116
117
/**
118
* This flag is used by the NWK to indicate if the the initiator device of the
119
* message is an end device and the nwkParentInformation field of the NIB has other value than
120
* 0.
121
*/
122
void
SetEndDeviceInitiator
();
123
124
/**
125
* Get whether or not the source of this message was an end device.
126
* @return True of the source of the message was an end device.
127
*/
128
bool
GetEndDeviceInitiator
()
const
;
129
130
/**
131
* Set Destination address
132
* @param addr The destination address (16 bit)
133
*/
134
void
SetDstAddr
(
Mac16Address
addr);
135
136
/**
137
* Get the Destination address
138
* @return the Destination address (16bits)
139
*/
140
Mac16Address
GetDstAddr
()
const
;
141
142
/**
143
* Set Source address
144
* @param addr The source address (16 bit)
145
*/
146
void
SetSrcAddr
(
Mac16Address
addr);
147
148
/**
149
* Get the Source address
150
* @return the Source address (16bits)
151
*/
152
Mac16Address
GetSrcAddr
()
const
;
153
154
/**
155
* Set the Radius
156
* @param radius radius
157
*/
158
void
SetRadius
(uint8_t radius);
159
160
/**
161
* Get the Radius
162
* @return the Radius
163
*/
164
uint8_t
GetRadius
()
const
;
165
166
/**
167
* Set the Sequence number
168
* @param seqNum sequence number
169
*/
170
void
SetSeqNum
(uint8_t seqNum);
171
172
/**
173
* Get the frame Sequence number
174
* @return the sequence number
175
*/
176
uint8_t
GetSeqNum
()
const
;
177
178
/**
179
* Set the destination IEEE address
180
* @param dst The destination IEEE address (64 bits)
181
*/
182
void
SetDstIeeeAddr
(
Mac64Address
dst);
183
184
/**
185
* Get the destination IEEE address
186
* @return The destination IEEE address (64bits)
187
*/
188
Mac64Address
GetDstIeeeAddr
()
const
;
189
190
/**
191
* Set the source IEEE address
192
* @param src The source IEEE address
193
*/
194
void
SetSrcIeeeAddr
(
Mac64Address
src);
195
196
/**
197
* Get the source IEEE address
198
* @return The source IEEE address (64bits)
199
*/
200
Mac64Address
GetSrcIeeeAddr
()
const
;
201
202
void
Serialize
(
Buffer::Iterator
start)
const override
;
203
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
204
uint32_t
GetSerializedSize
()
const override
;
205
/**
206
* Get the type ID.
207
*
208
* @return the object TypeId
209
*/
210
static
TypeId
GetTypeId
();
211
TypeId
GetInstanceTypeId
()
const override
;
212
void
Print
(std::ostream& os)
const override
;
213
214
private
:
215
/**
216
* Set the Frame control field
217
* @param frameControl 16 bits representing the frame control
218
*/
219
void
SetFrameControl
(uint16_t frameControl);
220
/**
221
* Get the Frame control field
222
* @return The 16 bits of the Frame control field
223
*/
224
uint16_t
GetFrameControl
()
const
;
225
/**
226
* Set the Multicast control field
227
* @param multicastControl 8 bits representing the multicast control field
228
*/
229
void
SetMulticastControl
(uint8_t multicastControl);
230
/**
231
* Get The Multicast control field
232
* @return The 8 bits representing the multicast control field
233
*/
234
uint8_t
GetMulticastControl
()
const
;
235
236
/* Frame Control (2 Octets) */
237
238
NwkType
m_fctrlFrmType
;
//!< Frame type (Bit 0-1)
239
uint8_t
m_fctrlPrtVer
;
//!< Protocol version (Bit 2-5)
240
DiscoverRouteType
m_fctrlDscvRoute
;
//!< Discover route (Bit 6-7)
241
bool
m_fctrlMcst
;
//!< Multicast flag (Bit 8)
242
bool
m_fctrlSecurity
;
//!< Security flag (Bit 9)
243
bool
m_fctrlSrcRoute
;
//!< Source route flag (Bit 10)
244
bool
m_fctrlDstIEEEAddr
;
//!< Destination IEEE address flag (Bit 11)
245
bool
m_fctrlSrcIEEEAddr
;
//!< Source IEEE address flag (Bit 12)
246
bool
m_fctrlEndDevIni
;
//!< End device initiator flag (Bit 13)
247
// Reserved (Bits 14-15)
248
249
/* Routing Fields (variable) */
250
251
Mac16Address
m_dstAddr
;
//!< Destination address (2 Octets)
252
Mac16Address
m_srcAddr
;
//!< Source address (2 Octets)
253
uint8_t
m_radius
;
//!< Radius (1 Octet)
254
uint8_t
m_seqNum
;
//!< Sequence number (1 Octet)
255
Mac64Address
m_dstIeeeAddr
;
//!< Destination IEEE address (0 or 8 Octets)
256
Mac64Address
m_srcIeeeAddr
;
//!< Source IEEE address (0 or 8 Octets)
257
// Multicast Control (1 Octet)
258
MulticastMode
m_mcstMode
{
NONMEMBER
};
//!< Multicast mode sub-field (Bits 0-1)
259
uint8_t
m_nonMemberRadius
;
//!< Non member radius sub-field (Bits 2-4)
260
uint8_t
m_maxNonMemberRadius
;
//!< Max non member radius sub-field (Bit 5-7)
261
262
// TODO: Add source route subframe
263
// uint8_t m_relayCount; //!< Relay Count Sub-Field
264
// uint8_t m_relayIndex; //!< Relay Index
265
// TODO: Add Relay List when supported
266
};
267
}
// namespace zigbee
268
}
// namespace ns3
269
270
#endif
/* ZIGBEE_NWK_HEADER_H */
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::Mac16Address
This class can contain 16 bit addresses.
Definition
mac16-address.h:33
ns3::Mac64Address
an EUI-64 address
Definition
mac64-address.h:35
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
ns3::zigbee::ZigbeeNwkHeader
Represent the NWK Header with the Frame Control and Routing fields Zigbee Specification r22....
Definition
zigbee-nwk-header.h:58
ns3::zigbee::ZigbeeNwkHeader::GetMulticastControl
uint8_t GetMulticastControl() const
Get The Multicast control field.
Definition
zigbee-nwk-header.cc:218
ns3::zigbee::ZigbeeNwkHeader::SetMulticast
void SetMulticast()
Set to true the value of the multicast flag in the frame control field.
Definition
zigbee-nwk-header.cc:74
ns3::zigbee::ZigbeeNwkHeader::SetDstIeeeAddr
void SetDstIeeeAddr(Mac64Address dst)
Set the destination IEEE address.
Definition
zigbee-nwk-header.cc:152
ns3::zigbee::ZigbeeNwkHeader::GetEndDeviceInitiator
bool GetEndDeviceInitiator() const
Get whether or not the source of this message was an end device.
Definition
zigbee-nwk-header.cc:98
ns3::zigbee::ZigbeeNwkHeader::SetDiscoverRoute
void SetDiscoverRoute(enum DiscoverRouteType discoverRoute)
Suppress or enable route discovery for this frame.
Definition
zigbee-nwk-header.cc:62
ns3::zigbee::ZigbeeNwkHeader::SetSrcAddr
void SetSrcAddr(Mac16Address addr)
Set Source address.
Definition
zigbee-nwk-header.cc:116
ns3::zigbee::ZigbeeNwkHeader::~ZigbeeNwkHeader
~ZigbeeNwkHeader() override
Definition
zigbee-nwk-header.cc:33
ns3::zigbee::ZigbeeNwkHeader::SetFrameControl
void SetFrameControl(uint16_t frameControl)
Set the Frame control field.
Definition
zigbee-nwk-header.cc:178
ns3::zigbee::ZigbeeNwkHeader::m_radius
uint8_t m_radius
Radius (1 Octet)
Definition
zigbee-nwk-header.h:253
ns3::zigbee::ZigbeeNwkHeader::ZigbeeNwkHeader
ZigbeeNwkHeader()
Definition
zigbee-nwk-header.cc:20
ns3::zigbee::ZigbeeNwkHeader::SetEndDeviceInitiator
void SetEndDeviceInitiator()
This flag is used by the NWK to indicate if the the initiator device of the message is an end device ...
Definition
zigbee-nwk-header.cc:92
ns3::zigbee::ZigbeeNwkHeader::m_fctrlDstIEEEAddr
bool m_fctrlDstIEEEAddr
Destination IEEE address flag (Bit 11)
Definition
zigbee-nwk-header.h:244
ns3::zigbee::ZigbeeNwkHeader::m_fctrlSecurity
bool m_fctrlSecurity
Security flag (Bit 9)
Definition
zigbee-nwk-header.h:242
ns3::zigbee::ZigbeeNwkHeader::m_srcIeeeAddr
Mac64Address m_srcIeeeAddr
Source IEEE address (0 or 8 Octets)
Definition
zigbee-nwk-header.h:256
ns3::zigbee::ZigbeeNwkHeader::m_fctrlPrtVer
uint8_t m_fctrlPrtVer
Protocol version (Bit 2-5)
Definition
zigbee-nwk-header.h:239
ns3::zigbee::ZigbeeNwkHeader::m_maxNonMemberRadius
uint8_t m_maxNonMemberRadius
Max non member radius sub-field (Bit 5-7)
Definition
zigbee-nwk-header.h:260
ns3::zigbee::ZigbeeNwkHeader::m_fctrlSrcRoute
bool m_fctrlSrcRoute
Source route flag (Bit 10)
Definition
zigbee-nwk-header.h:243
ns3::zigbee::ZigbeeNwkHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
zigbee-nwk-header.cc:293
ns3::zigbee::ZigbeeNwkHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
zigbee-nwk-header.cc:261
ns3::zigbee::ZigbeeNwkHeader::m_fctrlDscvRoute
DiscoverRouteType m_fctrlDscvRoute
Discover route (Bit 6-7)
Definition
zigbee-nwk-header.h:240
ns3::zigbee::ZigbeeNwkHeader::GetFrameControl
uint16_t GetFrameControl() const
Get the Frame control field.
Definition
zigbee-nwk-header.cc:192
ns3::zigbee::ZigbeeNwkHeader::SetProtocolVer
void SetProtocolVer(uint8_t ver)
Set the Protocol version.
Definition
zigbee-nwk-header.cc:50
ns3::zigbee::ZigbeeNwkHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
zigbee-nwk-header.cc:334
ns3::zigbee::ZigbeeNwkHeader::m_fctrlEndDevIni
bool m_fctrlEndDevIni
End device initiator flag (Bit 13)
Definition
zigbee-nwk-header.h:246
ns3::zigbee::ZigbeeNwkHeader::IsMulticast
bool IsMulticast() const
Inform whether or not the current frame is used in multicast.
Definition
zigbee-nwk-header.cc:80
ns3::zigbee::ZigbeeNwkHeader::SetSeqNum
void SetSeqNum(uint8_t seqNum)
Set the Sequence number.
Definition
zigbee-nwk-header.cc:140
ns3::zigbee::ZigbeeNwkHeader::m_nonMemberRadius
uint8_t m_nonMemberRadius
Non member radius sub-field (Bits 2-4)
Definition
zigbee-nwk-header.h:259
ns3::zigbee::ZigbeeNwkHeader::GetRadius
uint8_t GetRadius() const
Get the Radius.
Definition
zigbee-nwk-header.cc:134
ns3::zigbee::ZigbeeNwkHeader::GetDstIeeeAddr
Mac64Address GetDstIeeeAddr() const
Get the destination IEEE address.
Definition
zigbee-nwk-header.cc:159
ns3::zigbee::ZigbeeNwkHeader::IsSecurityEnabled
bool IsSecurityEnabled() const
Inform whether or not security is enabled.
Definition
zigbee-nwk-header.cc:86
ns3::zigbee::ZigbeeNwkHeader::GetSeqNum
uint8_t GetSeqNum() const
Get the frame Sequence number.
Definition
zigbee-nwk-header.cc:146
ns3::zigbee::ZigbeeNwkHeader::m_fctrlMcst
bool m_fctrlMcst
Multicast flag (Bit 8)
Definition
zigbee-nwk-header.h:241
ns3::zigbee::ZigbeeNwkHeader::GetSrcIeeeAddr
Mac64Address GetSrcIeeeAddr() const
Get the source IEEE address.
Definition
zigbee-nwk-header.cc:172
ns3::zigbee::ZigbeeNwkHeader::m_seqNum
uint8_t m_seqNum
Sequence number (1 Octet)
Definition
zigbee-nwk-header.h:254
ns3::zigbee::ZigbeeNwkHeader::m_dstAddr
Mac16Address m_dstAddr
Destination address (2 Octets)
Definition
zigbee-nwk-header.h:251
ns3::zigbee::ZigbeeNwkHeader::SetSrcIeeeAddr
void SetSrcIeeeAddr(Mac64Address src)
Set the source IEEE address.
Definition
zigbee-nwk-header.cc:165
ns3::zigbee::ZigbeeNwkHeader::GetFrameType
NwkType GetFrameType() const
Set the Frame Control field "Frame Type" bits.
Definition
zigbee-nwk-header.cc:44
ns3::zigbee::ZigbeeNwkHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
zigbee-nwk-header.cc:230
ns3::zigbee::ZigbeeNwkHeader::SetRadius
void SetRadius(uint8_t radius)
Set the Radius.
Definition
zigbee-nwk-header.cc:128
ns3::zigbee::ZigbeeNwkHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition
zigbee-nwk-header.cc:344
ns3::zigbee::ZigbeeNwkHeader::SetFrameType
void SetFrameType(enum NwkType nwkType)
Set the Frame type used (Data or Command)
Definition
zigbee-nwk-header.cc:38
ns3::zigbee::ZigbeeNwkHeader::m_dstIeeeAddr
Mac64Address m_dstIeeeAddr
Destination IEEE address (0 or 8 Octets)
Definition
zigbee-nwk-header.h:255
ns3::zigbee::ZigbeeNwkHeader::m_fctrlFrmType
NwkType m_fctrlFrmType
Frame type (Bit 0-1)
Definition
zigbee-nwk-header.h:238
ns3::zigbee::ZigbeeNwkHeader::GetDstAddr
Mac16Address GetDstAddr() const
Get the Destination address.
Definition
zigbee-nwk-header.cc:110
ns3::zigbee::ZigbeeNwkHeader::SetDstAddr
void SetDstAddr(Mac16Address addr)
Set Destination address.
Definition
zigbee-nwk-header.cc:104
ns3::zigbee::ZigbeeNwkHeader::GetProtocolVer
uint8_t GetProtocolVer() const
Get Frame protocol version.
Definition
zigbee-nwk-header.cc:56
ns3::zigbee::ZigbeeNwkHeader::GetDiscoverRoute
DiscoverRouteType GetDiscoverRoute() const
Get the status of frame discovery route (suppress or enabled)
Definition
zigbee-nwk-header.cc:68
ns3::zigbee::ZigbeeNwkHeader::m_srcAddr
Mac16Address m_srcAddr
Source address (2 Octets)
Definition
zigbee-nwk-header.h:252
ns3::zigbee::ZigbeeNwkHeader::GetSrcAddr
Mac16Address GetSrcAddr() const
Get the Source address.
Definition
zigbee-nwk-header.cc:122
ns3::zigbee::ZigbeeNwkHeader::Print
void Print(std::ostream &os) const override
Definition
zigbee-nwk-header.cc:350
ns3::zigbee::ZigbeeNwkHeader::m_mcstMode
MulticastMode m_mcstMode
Multicast mode sub-field (Bits 0-1)
Definition
zigbee-nwk-header.h:258
ns3::zigbee::ZigbeeNwkHeader::SetMulticastControl
void SetMulticastControl(uint8_t multicastControl)
Set the Multicast control field.
Definition
zigbee-nwk-header.cc:210
ns3::zigbee::ZigbeeNwkHeader::m_fctrlSrcIEEEAddr
bool m_fctrlSrcIEEEAddr
Source IEEE address flag (Bit 12)
Definition
zigbee-nwk-header.h:245
uint32_t
ns3::zigbee::DiscoverRouteType
DiscoverRouteType
Zigbee Specification r22.1.0, Values of the discover route sub-field (Table 3-47)
Definition
zigbee-nwk-header.h:38
ns3::zigbee::SUPPRESS_ROUTE_DISCOVERY
@ SUPPRESS_ROUTE_DISCOVERY
Suppress route discovery.
Definition
zigbee-nwk-header.h:39
ns3::zigbee::ENABLE_ROUTE_DISCOVERY
@ ENABLE_ROUTE_DISCOVERY
Enable route discovery.
Definition
zigbee-nwk-header.h:40
ns3::zigbee::NwkType
NwkType
Zigbee Specification r22.1.0, Values of the frame Type Sub-field (Table 3-46)
Definition
zigbee-nwk-header.h:28
ns3::zigbee::NWK_COMMAND
@ NWK_COMMAND
Network command frame type.
Definition
zigbee-nwk-header.h:30
ns3::zigbee::DATA
@ DATA
Data frame type.
Definition
zigbee-nwk-header.h:29
ns3::zigbee::INTER_PAN
@ INTER_PAN
Inter-Pan frame type.
Definition
zigbee-nwk-header.h:31
ns3::zigbee::MulticastMode
MulticastMode
Zigbee Specification r22.1.0, Multicast Mode Sub-Field (Table 3-7)
Definition
zigbee-nwk-header.h:47
ns3::zigbee::MEMBER
@ MEMBER
Member multicast mode.
Definition
zigbee-nwk-header.h:49
ns3::zigbee::NONMEMBER
@ NONMEMBER
Non member multicast mode.
Definition
zigbee-nwk-header.h:48
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
zigbee
model
zigbee-nwk-header.h
Generated on Tue Feb 18 2025 18:20:56 for ns-3 by
1.11.0