A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
zigbee-nwk-payload-header.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Tokushima University, Tokushima, Japan.
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Ryo Okuda <c611901200@tokushima-u.ac.jp>
7 * Alberto Gallegos Ramonet <alramonet@is.tokushima-u.ac.jp>
8 */
9
10#ifndef ZIGBEE_PAYLOAD_HEADERS_H
11#define ZIGBEE_PAYLOAD_HEADERS_H
12
13#include "ns3/header.h"
14#include "ns3/mac16-address.h"
15#include "ns3/mac64-address.h"
16
17namespace ns3
18{
19namespace zigbee
20{
21
22/**
23 * Zigbee Specification, Payload command types
24 */
26{
27 ROUTE_REQ_CMD = 0x01, //!< Route request command
28 ROUTE_REP_CMD = 0x02, //!< Route response command
29 NWK_STATUS_CMD = 0X03, //!< Network status command
30 LEAVE_CMD = 0x04, //!< Leave network command
31 ROUTE_RECORD_CMD = 0x05, //!< Route record command
32 REJOIN_REQ_CMD = 0x06, //!< Rejoin request command
33 REJOIN_RESP_CMD = 0x07, //!< Rejoin response command
34 LINK_STATUS_CMD = 0x08, //!< Link status command
35 NWK_REPORT_CMD = 0x09, //!< Network report command
36 NWK_UPDATE_CMD = 0x0a, //!< Network update command
37 TIMEOUT_REQ_CMD = 0x0b, //!< Time out request command
38 TIMEOUT_RESP_CMD = 0x0c, //!< Time out response command
39 LINK_POWER_DELTA_CMD = 0x0d, //!< Link power delta command
40};
41
42/**
43 * Zigbee Specification 3.4.1.3.1 , Table 3-50
44 * Values of the many to one command option field.
45 */
52
53/**
54 * @ingroup zigbee
55 * Represent the static portion of the zigbee payload header that describes
56 * the payload command type.
57 */
59{
60 public:
62 /**
63 * Constructor
64 * @param nwkCmd the command type of this command header
65 */
67 /**
68 * @brief Get the type ID.
69 * @return the object TypeId
70 */
71 static TypeId GetTypeId();
72 TypeId GetInstanceTypeId() const override;
73 uint32_t GetSerializedSize() const override;
74 void Serialize(Buffer::Iterator start) const override;
76 void Print(std::ostream& os) const override;
77
78 /**
79 * Set the command frame type
80 * @param nwkCmd the command frame type
81 */
82 void SetCmdType(enum NwkCommandType nwkCmd);
83 /**
84 * Get the command frame type
85 * @return The command type from the command payload header
86 */
88
89 private:
90 NwkCommandType m_nwkCmdType; //!< The network command Type
91};
92
93/**
94 * @ingroup zigbee
95 * Represent a variable portion of the zigbee payload header that includes
96 * the route request command
97 */
99{
100 public:
102 /**
103 * @brief Get the type ID.
104 * @return the object TypeId
105 */
106 static TypeId GetTypeId();
107 TypeId GetInstanceTypeId() const override;
108 uint32_t GetSerializedSize() const override;
109 void Serialize(Buffer::Iterator start) const override;
110 uint32_t Deserialize(Buffer::Iterator start) override;
111 void Print(std::ostream& os) const override;
112
113 /**
114 * Set the command option field Many To One
115 *
116 * @param manyToOne The Many To One field ()
117 */
118 void SetCmdOptManyToOneField(enum ManyToOne manyToOne);
119
120 /**
121 * Get the command option field Many To One
122 *
123 * @return The command option field
124 */
125 uint8_t GetCmdOptManyToOneField() const;
126
127 /**
128 * Set the Route request identifier
129 * @param id the route request identifier
130 */
131 void SetRouteReqId(uint8_t id);
132
133 /**
134 * Get the Route request identifier
135 * @return the route request identifier
136 */
137 uint8_t GetRouteReqId() const;
138
139 /**
140 * Set Destination address
141 * @param addr The destination address (16 bit)
142 */
143 void SetDstAddr(Mac16Address addr);
144
145 /**
146 * Get the Destination address
147 * @return the Destination address (16bits)
148 */
149 Mac16Address GetDstAddr() const;
150
151 /**
152 * Set the path cost
153 * @param cost the path cost
154 */
155 void SetPathCost(uint8_t cost);
156
157 /**
158 * Set the path cost
159 * @return the path cost
160 */
161 uint8_t GetPathCost() const;
162
163 /**
164 * Describe whether or not the destination IEEE Address field is present in the Route Request
165 *
166 * @return True if the command option destination IEEE Address field is active
167 */
168 bool IsDstIeeeAddressPresent() const;
169
170 /**
171 * Set the destination IEEE address
172 * @param dst The destination IEEE address (64 bits)
173 */
175
176 /**
177 * Get the destination IEEE address
178 * @return The destination IEEE address (64bits)
179 */
181
182 private:
183 /**
184 * Set the complete command option field of the route request command.
185 * @param cmdOptionField The 8 bits representing the complete command option field.
186 */
187 void SetCmdOptionField(uint8_t cmdOptionField);
188
189 /**
190 * Get the 8bits representing the complete command option field of the route request command.
191 * @return The command option field (8 bits)
192 */
193 uint8_t GetCmdOptionField() const;
194
195 /* Command options field (1 Octet) */
196 ManyToOne m_cmdOptManyToOne; //!< Many to One Subfield (Bits 3-4)
197 bool m_cmdOptDstIeeeAddr; //!< Destination IEEE Address Flag (Bit 5)
198 bool m_cmdOptMcst; //!< Multicast Flag (Bit 6)
199 // Bits 0-2,7 reserved
200
201 /* Route Request command fields */
202 uint8_t m_routeReqId; //!< Route request identifier (1 Octet)
203 Mac16Address m_dstAddr; //!< Destination address (2 Octets)
204 uint8_t m_pathCost; //!< Path Cost (1 Octet)
205 Mac64Address m_dstIeeeAddr; //!< Destination IEEE address (0-8 Octets)
206};
207
208/**
209 * @ingroup zigbee
210 * Represent a variable portion of the zigbee payload header that includes
211 * the route reply command
212 */
214{
215 public:
217
218 /**
219 * @brief Get the type ID.
220 * @return the object TypeId
221 */
222 static TypeId GetTypeId();
223 TypeId GetInstanceTypeId() const override;
224 uint32_t GetSerializedSize() const override;
225 void Serialize(Buffer::Iterator start) const override;
226 uint32_t Deserialize(Buffer::Iterator start) override;
227 void Print(std::ostream& os) const override;
228
229 /**
230 * Set the command option
231 * @param option the command option
232 */
233 void SetCmdOption(uint8_t option);
234 /**
235 * Get the command option
236 * @return the command option
237 */
238 uint8_t GetCmdOption() const;
239 /**
240 * Set the Route request identifier
241 * @param rid the route request identifier
242 */
243 void SetRouteReqId(uint8_t rid);
244 /**
245 * Get the Route request identifier
246 * @return the Radius
247 */
248 uint8_t GetRouteReqId() const;
249 /**
250 * Set Originator address
251 * @param addr The originator address (16 bit)
252 */
253 void SetOrigAddr(Mac16Address addr);
254 /**
255 * Get the Originator address
256 * @return the originator address (16bits)
257 */
259 /**
260 * Set Responder address
261 * @param addr the responder address (16 bit)
262 */
263 void SetRespAddr(Mac16Address addr);
264 /**
265 * Get the Responder address
266 * @return the responder address (16bits)
267 */
269 /**
270 * Set the path cost
271 * @param cost the path cost
272 */
273 void SetPathCost(uint8_t cost);
274 /**
275 * Get the path cost
276 * @return the path cost
277 */
278 uint8_t GetPathCost() const;
279 /**
280 * Set the Originator IEEE address
281 * @param orig The originator IEEE address (64 bits)
282 */
283 void SetOrigIeeeAddr(Mac64Address orig);
284 /**
285 * Get the Originator IEEE address
286 * @return The originator IEEE address (64bits)
287 */
289 /**
290 * Set the Responder IEEE address
291 * @param resp The responder IEEE address (64 bits)
292 */
293 void SetRespIeeeAddr(Mac64Address resp);
294 /**
295 * Get the Responder IEEE address
296 * @return The responder IEEE address (64bits)
297 */
299
300 private:
301 /* Command options field (1 Octet) */
302 bool m_cmdOptOrigIeeeAddr; //!< Originator IEEE address flag (Bit 4)
303 bool m_cmdOptRespIeeeAddr; //!< Responder IEEE address flag (Bit 5)
304 bool m_cmdOptMcst; //!< Multicast flag (Bit 6)
305 // Bits 0-3,7 reserved
306
307 /* Route Reply command fields */
308 uint8_t m_routeReqId; //!< Route request identifier (1 Octet)
309 Mac16Address m_origAddr; //!< Originator address (2 Octets)
310 Mac16Address m_respAddr; //!< Responder address (2 Octets)
311 uint8_t m_pathCost; //!< Path cost (1 Octet)
312 Mac64Address m_origIeeeAddr; //!< Originator IEEE address (0-8 Octets)
313 Mac64Address m_respIeeeAddr; //!< Responder IEEE address (0-8 Octets)
314};
315
316/**
317 * @ingroup zigbee
318 * Represents the payload portion of a beacon frame.
319 * See Zigbee specification r22.1.0, Table 3-71 (NWK layer Information fields)
320 */
322{
323 public:
325
326 /**
327 * @brief Get the type ID.
328 * @return the object TypeId
329 */
330 static TypeId GetTypeId();
331 TypeId GetInstanceTypeId() const override;
332 uint32_t GetSerializedSize() const override;
333 void Serialize(Buffer::Iterator start) const override;
334 uint32_t Deserialize(Buffer::Iterator start) override;
335 void Print(std::ostream& os) const override;
336
337 /**
338 * Set the network profile identifier.
339 *
340 * @param stackProfile the stack Profile in use
341 */
342 void SetStackProfile(uint8_t stackProfile);
343
344 /**
345 * Get the Protocol Id used.
346 * In this standard this value is always 0.
347 *
348 * @return The protocol id used in this standard.
349 */
350 uint8_t GetProtocolId() const;
351
352 /**
353 * Get the Stack Profile used.
354 *
355 * @return The stack profile identifier used.
356 */
357 uint8_t GetStackProfile() const;
358
359 /**
360 * Set the Router Capacity capability
361 * True = The device is able to accept join.request
362 * from router-capable devices
363 *
364 * @param routerCapacity The router capacity capability
365 */
366 void SetRouterCapacity(bool routerCapacity);
367
368 /**
369 * Get the router capacity capability.
370 *
371 * @return Whether or not is capable of accepting join request
372 * from router-capable devices.
373 */
374 bool GetRouterCapacity() const;
375
376 /**
377 * Set the cevice depth object
378 *
379 * @param deviceDepth The current device depth.
380 */
381 void SetDeviceDepth(uint8_t deviceDepth);
382
383 /**
384 * Get the device depth.
385 *
386 * @return The device depth
387 */
388 uint8_t GetDeviceDepth() const;
389
390 /**
391 * Set the end device Capacity
392 *
393 * @param endDevCapacity The end device capacity
394 */
395 void SetEndDevCapacity(bool endDevCapacity);
396
397 /**
398 * Get the end dev capacity
399 *
400 * @return Whether or not the device is capable of accepting
401 * join requests from end devices.
402 */
403 bool GetEndDevCapacity() const;
404
405 /**
406 * Set the extended PAN id. This should be the value of the
407 * zigbee coordinator EUI-64 address (IEEE address).
408 *
409 * @param extPanId The extended PAN id
410 */
411 void SetExtPanId(uint64_t extPanId);
412
413 /**
414 * Get the extended PAN identifier
415 *
416 * @return The extended PAN identifier
417 */
418 uint64_t GetExtPanId() const;
419
420 /**
421 * Set the Tx Offset time in symbols
422 *
423 * @param txOffset The Tx offset time in symbols
424 */
425 void SetTxOffset(uint32_t txOffset);
426
427 /**
428 * Get the Tx Offset time in symbols
429 *
430 * @return uint32_t The Tx offset time in symbols
431 */
432 uint32_t GetTxOffset() const;
433
434 /**
435 * Set the value of the nwkUpdateId to this beacon payload
436 *
437 * @param nwkUpdateId The nwkUpdateId to set to the beacon payload.
438 */
439 void SetNwkUpdateId(uint8_t nwkUpdateId);
440
441 /**
442 * Get the value of the nwkUpdateId set to this beacon payload
443 *
444 * @return The value of the nwkUpdateId in the beacon payload.
445 */
446 uint8_t GetNwkUpdateId() const;
447
448 private:
449 uint8_t m_protocolId{0}; //!< Identifies the network layer in use, in this specification this
450 //!< value is always 0.
451 uint8_t m_stackProfile; //!< The zigbee stack profile identifier.
452 uint8_t m_protocolVer; //!< The version of the zigbee protocol.
453 bool m_routerCapacity{false}; //!< True if this device is capable of accepting
454 //!< join requests from router capable devices.
455 //!< This value should match the value of RoutersAllowed for the
456 //!< MAC interface this beacon is being sent from.
457 uint8_t m_deviceDepth; //!< The network depth of this device.
458 //!< 0x00 indicates this device is the ZC.
459 bool m_endDevCapacity{false}; //!< True if the device is capable of accepting join request from
460 //!< end devices seeking to join the network.
461 uint64_t m_extPanId; //!< The globally unique id for the PAN. By default this is the EUI-64 bit
462 //!< (IEEE address) of the Zigbee coordinator that formed the network.
463 uint32_t m_txOffset; //!< This indicates the difference in time, measured in symbols, between
464 //!< the beacon transmission time of its parent
465 uint8_t m_nwkUpdateId; //!< The value of nwkUpdateId from the NIB.
466};
467
468} // namespace zigbee
469} // namespace ns3
470
471#endif /* ZIGBEE_PAYLOAD_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
Represents the payload portion of a beacon frame.
bool GetRouterCapacity() const
Get the router capacity capability.
uint8_t GetNwkUpdateId() const
Get the value of the nwkUpdateId set to this beacon payload.
uint8_t m_protocolId
Identifies the network layer in use, in this specification this value is always 0.
void SetDeviceDepth(uint8_t deviceDepth)
Set the cevice depth object.
uint8_t GetProtocolId() const
Get the Protocol Id used.
uint32_t Deserialize(Buffer::Iterator start) override
uint8_t m_stackProfile
The zigbee stack profile identifier.
bool m_routerCapacity
True if this device is capable of accepting join requests from router capable devices.
uint8_t GetStackProfile() const
Get the Stack Profile used.
uint8_t m_nwkUpdateId
The value of nwkUpdateId from the NIB.
uint64_t m_extPanId
The globally unique id for the PAN.
static TypeId GetTypeId()
Get the type ID.
void SetRouterCapacity(bool routerCapacity)
Set the Router Capacity capability True = The device is able to accept join.request from router-capab...
void SetNwkUpdateId(uint8_t nwkUpdateId)
Set the value of the nwkUpdateId to this beacon payload.
uint64_t GetExtPanId() const
Get the extended PAN identifier.
uint8_t GetDeviceDepth() const
Get the device depth.
void SetStackProfile(uint8_t stackProfile)
Set the network profile identifier.
void Serialize(Buffer::Iterator start) const override
void SetEndDevCapacity(bool endDevCapacity)
Set the end device Capacity.
void Print(std::ostream &os) const override
bool GetEndDevCapacity() const
Get the end dev capacity.
uint32_t m_txOffset
This indicates the difference in time, measured in symbols, between the beacon transmission time of i...
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void SetTxOffset(uint32_t txOffset)
Set the Tx Offset time in symbols.
void SetExtPanId(uint64_t extPanId)
Set the extended PAN id.
uint8_t m_deviceDepth
The network depth of this device.
bool m_endDevCapacity
True if the device is capable of accepting join request from end devices seeking to join the network.
uint8_t m_protocolVer
The version of the zigbee protocol.
uint32_t GetTxOffset() const
Get the Tx Offset time in symbols.
Represent a variable portion of the zigbee payload header that includes the route reply command.
uint32_t Deserialize(Buffer::Iterator start) override
bool m_cmdOptRespIeeeAddr
Responder IEEE address flag (Bit 5)
void SetRouteReqId(uint8_t rid)
Set the Route request identifier.
void SetRespIeeeAddr(Mac64Address resp)
Set the Responder IEEE address.
void SetOrigIeeeAddr(Mac64Address orig)
Set the Originator IEEE address.
void SetCmdOption(uint8_t option)
Set the command option.
Mac64Address m_origIeeeAddr
Originator IEEE address (0-8 Octets)
Mac16Address GetRespAddr() const
Get the Responder address.
Mac16Address GetOrigAddr() const
Get the Originator address.
void SetRespAddr(Mac16Address addr)
Set Responder address.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void Serialize(Buffer::Iterator start) const override
bool m_cmdOptOrigIeeeAddr
Originator IEEE address flag (Bit 4)
uint8_t GetCmdOption() const
Get the command option.
Mac16Address m_origAddr
Originator address (2 Octets)
Mac64Address GetRespIeeeAddr() const
Get the Responder IEEE address.
uint8_t m_routeReqId
Route request identifier (1 Octet)
uint8_t GetRouteReqId() const
Get the Route request identifier.
Mac64Address GetOrigIeeeAddr() const
Get the Originator IEEE address.
void SetOrigAddr(Mac16Address addr)
Set Originator address.
void SetPathCost(uint8_t cost)
Set the path cost.
Mac16Address m_respAddr
Responder address (2 Octets)
Mac64Address m_respIeeeAddr
Responder IEEE address (0-8 Octets)
Represent a variable portion of the zigbee payload header that includes the route request command.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint8_t GetRouteReqId() const
Get the Route request identifier.
void Serialize(Buffer::Iterator start) const override
Mac64Address GetDstIeeeAddr() const
Get the destination IEEE address.
void SetCmdOptManyToOneField(enum ManyToOne manyToOne)
Set the command option field Many To One.
ManyToOne m_cmdOptManyToOne
Many to One Subfield (Bits 3-4)
bool m_cmdOptDstIeeeAddr
Destination IEEE Address Flag (Bit 5)
uint32_t Deserialize(Buffer::Iterator start) override
Mac16Address m_dstAddr
Destination address (2 Octets)
uint8_t GetCmdOptManyToOneField() const
Get the command option field Many To One.
void SetRouteReqId(uint8_t id)
Set the Route request identifier.
void SetDstAddr(Mac16Address addr)
Set Destination address.
Mac16Address GetDstAddr() const
Get the Destination address.
bool IsDstIeeeAddressPresent() const
Describe whether or not the destination IEEE Address field is present in the Route Request.
void SetCmdOptionField(uint8_t cmdOptionField)
Set the complete command option field of the route request command.
Mac64Address m_dstIeeeAddr
Destination IEEE address (0-8 Octets)
void SetDstIeeeAddr(Mac64Address dst)
Set the destination IEEE address.
uint8_t GetCmdOptionField() const
Get the 8bits representing the complete command option field of the route request command.
uint8_t m_routeReqId
Route request identifier (1 Octet)
Represent the static portion of the zigbee payload header that describes the payload command type.
static TypeId GetTypeId()
Get the type ID.
void SetCmdType(enum NwkCommandType nwkCmd)
Set the command frame type.
void Serialize(Buffer::Iterator start) const override
NwkCommandType m_nwkCmdType
The network command Type.
uint32_t Deserialize(Buffer::Iterator start) override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void Print(std::ostream &os) const override
NwkCommandType GetCmdType() const
Get the command frame type.
uint32_t GetSerializedSize() const override
ManyToOne
Zigbee Specification 3.4.1.3.1 , Table 3-50 Values of the many to one command option field.
NwkCommandType
Zigbee Specification, Payload command types.
@ TIMEOUT_REQ_CMD
Time out request command.
@ TIMEOUT_RESP_CMD
Time out response command.
@ ROUTE_REP_CMD
Route response command.
@ LINK_POWER_DELTA_CMD
Link power delta command.
@ REJOIN_REQ_CMD
Rejoin request command.
@ LINK_STATUS_CMD
Link status command.
@ NWK_UPDATE_CMD
Network update command.
@ NWK_STATUS_CMD
Network status command.
@ REJOIN_RESP_CMD
Rejoin response command.
@ ROUTE_REQ_CMD
Route request command.
@ LEAVE_CMD
Leave network command.
@ ROUTE_RECORD_CMD
Route record command.
@ NWK_REPORT_CMD
Network report command.
Every class exported by the ns3 library is enclosed in the ns3 namespace.