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 *
81 * @param nwkCmd the command frame type
82 */
83 void SetCmdType(enum NwkCommandType nwkCmd);
84
85 /**
86 * Get the command frame type
87 *
88 * @return The command type from the command payload header
89 */
91
92 private:
93 NwkCommandType m_nwkCmdType; //!< The network command Type
94};
95
96/**
97 * @ingroup zigbee
98 * Represent a variable portion of the zigbee payload header that includes
99 * the route request command.
100 * See Zigbee specification r22.1.0, Section 3.4.1
101 */
103{
104 public:
106 /**
107 * @brief Get the type ID.
108 * @return the object TypeId
109 */
110 static TypeId GetTypeId();
111 TypeId GetInstanceTypeId() const override;
112 uint32_t GetSerializedSize() const override;
113 void Serialize(Buffer::Iterator start) const override;
114 uint32_t Deserialize(Buffer::Iterator start) override;
115 void Print(std::ostream& os) const override;
116
117 /**
118 * Set the command option field Many To One
119 *
120 * @param manyToOne The Many To One field ()
121 */
122 void SetCmdOptManyToOneField(enum ManyToOne manyToOne);
123
124 /**
125 * Get the command option field Many To One
126 *
127 * @return The command option field
128 */
129 uint8_t GetCmdOptManyToOneField() const;
130
131 /**
132 * Set the Route request identifier
133 *
134 * @param id the route request identifier
135 */
136 void SetRouteReqId(uint8_t id);
137
138 /**
139 * Get the Route request identifier
140 *
141 * @return the route request identifier
142 */
143 uint8_t GetRouteReqId() const;
144
145 /**
146 * Set Destination address
147 *
148 * @param addr The destination address (16 bit)
149 */
150 void SetDstAddr(Mac16Address addr);
151
152 /**
153 * Get the Destination address
154 *
155 * @return the Destination address (16bits)
156 */
157 Mac16Address GetDstAddr() const;
158
159 /**
160 * Set the path cost
161 *
162 * @param cost the path cost
163 */
164 void SetPathCost(uint8_t cost);
165
166 /**
167 * Set the path cost
168 *
169 * @return the path cost
170 */
171 uint8_t GetPathCost() const;
172
173 /**
174 * Describe whether or not the destination IEEE Address field is present in the Route Request
175 *
176 * @return True if the command option destination IEEE Address field is active
177 */
178 bool IsDstIeeeAddressPresent() const;
179
180 /**
181 * Set the destination IEEE address, also automatically
182 * sets the command option DstIeeeAddr field
183 *
184 * @param dst The destination IEEE address (64 bits)
185 */
187
188 /**
189 * Get the destination IEEE address (64-bit) contained in the
190 * route request command.
191 *
192 * @return The destination IEEE address (64bits)
193 */
195
196 /**
197 * Set the command option multicast field
198 *
199 * @param mcst True if the command option multicast field is active
200 */
201 void SetMulticastField(bool mcst);
202
203 /**
204 * Get the command option multicast field
205 *
206 * @return True if the command option multicast field is active
207 */
208 bool GetMulticastField() const;
209
210 private:
211 /**
212 * Set the complete command option field of the route request command.
213 * @param cmdOptionField The 8 bits representing the complete command option field.
214 */
215 void SetCmdOptionField(uint8_t cmdOptionField);
216
217 /**
218 * Get the 8bits representing the complete command option field of the route request command.
219 * @return The command option field (8 bits)
220 */
221 uint8_t GetCmdOptionField() const;
222
223 /* Command options field (1 Octet) */
224 ManyToOne m_cmdOptManyToOne; //!< Many to One Subfield (Bits 3-4)
225 bool m_cmdOptDstIeeeAddr; //!< Destination IEEE Address Flag (Bit 5)
226 bool m_cmdOptMcst; //!< Multicast Flag (Bit 6)
227 // Bits 0-2,7 reserved
228
229 /* Route Request command fields */
230 uint8_t m_routeReqId; //!< Route request identifier (1 Octet)
231 Mac16Address m_dstAddr; //!< Destination address (2 Octets)
232 uint8_t m_pathCost; //!< Path Cost (1 Octet)
233 Mac64Address m_dstIeeeAddr; //!< Destination IEEE address (0-8 Octets)
234};
235
236/**
237 * @ingroup zigbee
238 * Represent a variable portion of the zigbee payload header that includes
239 * the route reply command.
240 * See Zigbee specification r22.1.0, Section 3.4.2
241 */
243{
244 public:
246
247 /**
248 * @brief Get the type ID.
249 * @return the object TypeId
250 */
251 static TypeId GetTypeId();
252 TypeId GetInstanceTypeId() const override;
253 uint32_t GetSerializedSize() const override;
254 void Serialize(Buffer::Iterator start) const override;
255 uint32_t Deserialize(Buffer::Iterator start) override;
256 void Print(std::ostream& os) const override;
257
258 /**
259 * Set the command option
260 * @param option the command option
261 */
262 void SetCmdOption(uint8_t option);
263 /**
264 * Get the command option
265 * @return the command option
266 */
267 uint8_t GetCmdOption() const;
268 /**
269 * Set the Route request identifier
270 * @param rid the route request identifier
271 */
272 void SetRouteReqId(uint8_t rid);
273 /**
274 * Get the Route request identifier
275 * @return the Radius
276 */
277 uint8_t GetRouteReqId() const;
278 /**
279 * Set Originator address
280 * @param addr The originator address (16 bit)
281 */
282 void SetOrigAddr(Mac16Address addr);
283 /**
284 * Get the Originator address
285 * @return the originator address (16bits)
286 */
288 /**
289 * Set Responder address
290 * @param addr the responder address (16 bit)
291 */
292 void SetRespAddr(Mac16Address addr);
293 /**
294 * Get the Responder address
295 * @return the responder address (16bits)
296 */
298 /**
299 * Set the path cost
300 * @param cost the path cost
301 */
302 void SetPathCost(uint8_t cost);
303 /**
304 * Get the path cost
305 * @return the path cost
306 */
307 uint8_t GetPathCost() const;
308 /**
309 * Set the Originator IEEE address
310 * @param orig The originator IEEE address (64 bits)
311 */
312 void SetOrigIeeeAddr(Mac64Address orig);
313 /**
314 * Get the Originator IEEE address
315 * @return The originator IEEE address (64bits)
316 */
318 /**
319 * Set the Responder IEEE address
320 * @param resp The responder IEEE address (64 bits)
321 */
322 void SetRespIeeeAddr(Mac64Address resp);
323 /**
324 * Get the Responder IEEE address
325 * @return The responder IEEE address (64bits)
326 */
328
329 private:
330 /* Command options field (1 Octet) */
331 bool m_cmdOptOrigIeeeAddr; //!< Originator IEEE address flag (Bit 4)
332 bool m_cmdOptRespIeeeAddr; //!< Responder IEEE address flag (Bit 5)
333 bool m_cmdOptMcst; //!< Multicast flag (Bit 6)
334 // Bits 0-3,7 reserved
335
336 /* Route Reply command fields */
337 uint8_t m_routeReqId; //!< Route request identifier (1 Octet)
338 Mac16Address m_origAddr; //!< Originator address (2 Octets)
339 Mac16Address m_respAddr; //!< Responder address (2 Octets)
340 uint8_t m_pathCost; //!< Path cost (1 Octet)
341 Mac64Address m_origIeeeAddr; //!< Originator IEEE address (0-8 Octets)
342 Mac64Address m_respIeeeAddr; //!< Responder IEEE address (0-8 Octets)
343};
344
345/**
346 * @ingroup zigbee
347 * Represents the payload portion of a beacon frame.
348 * See Zigbee specification r22.1.0, Table 3-71 (NWK layer Information fields)
349 */
351{
352 public:
354
355 /**
356 * @brief Get the type ID.
357 * @return the object TypeId
358 */
359 static TypeId GetTypeId();
360 TypeId GetInstanceTypeId() const override;
361 uint32_t GetSerializedSize() const override;
362 void Serialize(Buffer::Iterator start) const override;
363 uint32_t Deserialize(Buffer::Iterator start) override;
364 void Print(std::ostream& os) const override;
365
366 /**
367 * Set the network profile identifier.
368 *
369 * @param stackProfile the stack Profile in use
370 */
371 void SetStackProfile(uint8_t stackProfile);
372
373 /**
374 * Get the Protocol Id used.
375 * In this standard this value is always 0.
376 *
377 * @return The protocol id used in this standard.
378 */
379 uint8_t GetProtocolId() const;
380
381 /**
382 * Get the Stack Profile used.
383 *
384 * @return The stack profile identifier used.
385 */
386 uint8_t GetStackProfile() const;
387
388 /**
389 * Set the Router Capacity capability
390 * True = The device is able to accept join.request
391 * from router-capable devices
392 *
393 * @param routerCapacity The router capacity capability
394 */
395 void SetRouterCapacity(bool routerCapacity);
396
397 /**
398 * Get the router capacity capability.
399 *
400 * @return Whether or not is capable of accepting join request
401 * from router-capable devices.
402 */
403 bool GetRouterCapacity() const;
404
405 /**
406 * Set the cevice depth object
407 *
408 * @param deviceDepth The current device depth.
409 */
410 void SetDeviceDepth(uint8_t deviceDepth);
411
412 /**
413 * Get the device depth.
414 *
415 * @return The device depth
416 */
417 uint8_t GetDeviceDepth() const;
418
419 /**
420 * Set the end device Capacity
421 *
422 * @param endDevCapacity The end device capacity
423 */
424 void SetEndDevCapacity(bool endDevCapacity);
425
426 /**
427 * Get the end dev capacity
428 *
429 * @return Whether or not the device is capable of accepting
430 * join requests from end devices.
431 */
432 bool GetEndDevCapacity() const;
433
434 /**
435 * Set the extended PAN id. This should be the value of the
436 * zigbee coordinator EUI-64 address (IEEE address).
437 *
438 * @param extPanId The extended PAN id
439 */
440 void SetExtPanId(uint64_t extPanId);
441
442 /**
443 * Get the extended PAN identifier
444 *
445 * @return The extended PAN identifier
446 */
447 uint64_t GetExtPanId() const;
448
449 /**
450 * Set the Tx Offset time in symbols
451 *
452 * @param txOffset The Tx offset time in symbols
453 */
454 void SetTxOffset(uint32_t txOffset);
455
456 /**
457 * Get the Tx Offset time in symbols
458 *
459 * @return uint32_t The Tx offset time in symbols
460 */
461 uint32_t GetTxOffset() const;
462
463 /**
464 * Set the value of the nwkUpdateId to this beacon payload
465 *
466 * @param nwkUpdateId The nwkUpdateId to set to the beacon payload.
467 */
468 void SetNwkUpdateId(uint8_t nwkUpdateId);
469
470 /**
471 * Get the value of the nwkUpdateId set to this beacon payload
472 *
473 * @return The value of the nwkUpdateId in the beacon payload.
474 */
475 uint8_t GetNwkUpdateId() const;
476
477 private:
478 uint8_t m_protocolId{0}; //!< Identifies the network layer in use, in this specification this
479 //!< value is always 0.
480 uint8_t m_stackProfile; //!< The zigbee stack profile identifier.
481 uint8_t m_protocolVer; //!< The version of the zigbee protocol.
482 bool m_routerCapacity{false}; //!< True if this device is capable of accepting
483 //!< join requests from router capable devices.
484 //!< This value should match the value of RoutersAllowed for the
485 //!< MAC interface this beacon is being sent from.
486 uint8_t m_deviceDepth; //!< The network depth of this device.
487 //!< 0x00 indicates this device is the ZC.
488 bool m_endDevCapacity{false}; //!< True if the device is capable of accepting join request from
489 //!< end devices seeking to join the network.
490 uint64_t m_extPanId; //!< The globally unique id for the PAN. By default this is the EUI-64 bit
491 //!< (IEEE address) of the Zigbee coordinator that formed the network.
492 uint32_t m_txOffset; //!< This indicates the difference in time, measured in symbols, between
493 //!< the beacon transmission time of its parent
494 uint8_t m_nwkUpdateId; //!< The value of nwkUpdateId from the NIB.
495};
496
497} // namespace zigbee
498} // namespace ns3
499
500#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 (64-bit) contained in the route request command.
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 SetMulticastField(bool mcst)
Set the command option multicast field.
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.
bool GetMulticastField() const
Get the command option multicast field.
Mac64Address m_dstIeeeAddr
Destination IEEE address (0-8 Octets)
void SetDstIeeeAddr(Mac64Address dst)
Set the destination IEEE address, also automatically sets the command option DstIeeeAddr field.
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.