A Discrete-Event Network Simulator
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
18namespace ns3
19{
20
21namespace zigbee
22{
23
24/**
25 * Zigbee Specification r22.1.0, Values of the frame Type Sub-field (Table 3-46)
26 */
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 */
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 */
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 */
57class ZigbeeNwkHeader : public Header
58{
59 public:
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 */
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 */
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 */
183
184 /**
185 * Get the destination IEEE address
186 * @return The destination IEEE address (64bits)
187 */
189
190 /**
191 * Set the source IEEE address
192 * @param src The source IEEE address
193 */
195
196 /**
197 * Get the source IEEE address
198 * @return The source IEEE address (64bits)
199 */
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 */
iterator in a Buffer instance
Definition buffer.h:89
Protocol header serialization and deserialization.
Definition header.h:33
This class can contain 16 bit addresses.
an EUI-64 address
a unique identifier for an interface.
Definition type-id.h:49
Represent the NWK Header with the Frame Control and Routing fields Zigbee Specification r22....
uint8_t GetMulticastControl() const
Get The Multicast control field.
void SetMulticast()
Set to true the value of the multicast flag in the frame control field.
void SetDstIeeeAddr(Mac64Address dst)
Set the destination IEEE address.
bool GetEndDeviceInitiator() const
Get whether or not the source of this message was an end device.
void SetDiscoverRoute(enum DiscoverRouteType discoverRoute)
Suppress or enable route discovery for this frame.
void SetSrcAddr(Mac16Address addr)
Set Source address.
void SetFrameControl(uint16_t frameControl)
Set the Frame control field.
uint8_t m_radius
Radius (1 Octet)
void SetEndDeviceInitiator()
This flag is used by the NWK to indicate if the the initiator device of the message is an end device ...
bool m_fctrlDstIEEEAddr
Destination IEEE address flag (Bit 11)
bool m_fctrlSecurity
Security flag (Bit 9)
Mac64Address m_srcIeeeAddr
Source IEEE address (0 or 8 Octets)
uint8_t m_fctrlPrtVer
Protocol version (Bit 2-5)
uint8_t m_maxNonMemberRadius
Max non member radius sub-field (Bit 5-7)
bool m_fctrlSrcRoute
Source route flag (Bit 10)
uint32_t GetSerializedSize() const override
uint32_t Deserialize(Buffer::Iterator start) override
DiscoverRouteType m_fctrlDscvRoute
Discover route (Bit 6-7)
uint16_t GetFrameControl() const
Get the Frame control field.
void SetProtocolVer(uint8_t ver)
Set the Protocol version.
static TypeId GetTypeId()
Get the type ID.
bool m_fctrlEndDevIni
End device initiator flag (Bit 13)
bool IsMulticast() const
Inform whether or not the current frame is used in multicast.
void SetSeqNum(uint8_t seqNum)
Set the Sequence number.
uint8_t m_nonMemberRadius
Non member radius sub-field (Bits 2-4)
uint8_t GetRadius() const
Get the Radius.
Mac64Address GetDstIeeeAddr() const
Get the destination IEEE address.
bool IsSecurityEnabled() const
Inform whether or not security is enabled.
uint8_t GetSeqNum() const
Get the frame Sequence number.
bool m_fctrlMcst
Multicast flag (Bit 8)
Mac64Address GetSrcIeeeAddr() const
Get the source IEEE address.
uint8_t m_seqNum
Sequence number (1 Octet)
Mac16Address m_dstAddr
Destination address (2 Octets)
void SetSrcIeeeAddr(Mac64Address src)
Set the source IEEE address.
NwkType GetFrameType() const
Set the Frame Control field "Frame Type" bits.
void Serialize(Buffer::Iterator start) const override
void SetRadius(uint8_t radius)
Set the Radius.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void SetFrameType(enum NwkType nwkType)
Set the Frame type used (Data or Command)
Mac64Address m_dstIeeeAddr
Destination IEEE address (0 or 8 Octets)
NwkType m_fctrlFrmType
Frame type (Bit 0-1)
Mac16Address GetDstAddr() const
Get the Destination address.
void SetDstAddr(Mac16Address addr)
Set Destination address.
uint8_t GetProtocolVer() const
Get Frame protocol version.
DiscoverRouteType GetDiscoverRoute() const
Get the status of frame discovery route (suppress or enabled)
Mac16Address m_srcAddr
Source address (2 Octets)
Mac16Address GetSrcAddr() const
Get the Source address.
void Print(std::ostream &os) const override
MulticastMode m_mcstMode
Multicast mode sub-field (Bits 0-1)
void SetMulticastControl(uint8_t multicastControl)
Set the Multicast control field.
bool m_fctrlSrcIEEEAddr
Source IEEE address flag (Bit 12)
DiscoverRouteType
Zigbee Specification r22.1.0, Values of the discover route sub-field (Table 3-47)
@ SUPPRESS_ROUTE_DISCOVERY
Suppress route discovery.
@ ENABLE_ROUTE_DISCOVERY
Enable route discovery.
NwkType
Zigbee Specification r22.1.0, Values of the frame Type Sub-field (Table 3-46)
@ NWK_COMMAND
Network command frame type.
@ DATA
Data frame type.
@ INTER_PAN
Inter-Pan frame type.
MulticastMode
Zigbee Specification r22.1.0, Multicast Mode Sub-Field (Table 3-7)
@ MEMBER
Member multicast mode.
@ NONMEMBER
Non member multicast mode.
Every class exported by the ns3 library is enclosed in the ns3 namespace.