A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
zigbee-zdo.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 Tokushima University, Japan
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors:
7 *
8 * Alberto Gallegos Ramonet <alramonet@is.tokushima-u.ac.jp>
9 */
10
11#ifndef ZIGBEE_ZDO_H
12#define ZIGBEE_ZDO_H
13
14#include "ns3/event-id.h"
15#include "ns3/mac16-address.h"
16#include "ns3/mac64-address.h"
17#include "ns3/object.h"
18#include "ns3/random-variable-stream.h"
19#include "ns3/sequence-number.h"
20#include "ns3/traced-callback.h"
21#include "ns3/traced-value.h"
22#include "ns3/zigbee-aps.h"
23#include "ns3/zigbee-nwk.h"
24
25namespace ns3
26{
27namespace zigbee
28{
29
30/**
31 * Zigbee Device Profile (ZDP) enumeration of status codes.
32 * See Zigbee Specification 2023, Section 2.4.5, Table 2-129
33 * Note: A standardized list of status codes is not defined in
34 * the Zigbee Specification 2017, that is why we used the
35 * definitions later introduced on the Zigbee Specification 2023.
36 */
37enum class ZdpStatus : uint8_t
38{
39 SUCCESS = 0x00, //!< The request was successful.
40 INV_REQUESTTYPE = 0x80, //!< The request type is invalid or not supported.
41 DEVICE_NOT_FOUND = 0x81, //!< The device with the specified IEEE address was
42 //!< not found in the network.
43 INVALID_EP = 0x82, //!< The endpoint specified in the request is invalid
44 //!< or not supported.
45 NOT_ACTIVE = 0x83, //!< The device is not currently active in the network.
46 NOT_SUPPORTED = 0x84, //!< The requested operation is not supported by the device
47 //!< or the network.
48 TIMEOUT = 0x85, //!< The request timed out.
49 NO_MATCH = 0x86, //!< No matching entry was found for the request.
50 NO_ENTRY = 0x88, //!< The requested entry does not exist in the device's
51 //!< table or cache.
52 NO_DESCRIPTOR = 0x89, //!< The requested descriptor (e.g., node, power, simple)
53 //!< is not available or not found.
54 INSUFFICIENT_SPACE = 0x8A, //!< The device does not have enough space to store
55 //!< the requested information or entry.
56 NOT_PERMITTED = 0x8B, //!< The requested operation is not permitted due to
57 //!< security or policy restrictions.
58 TABLE_FULL = 0x8C, //!< The device's table (e.g., neighbor, routing, binding)
59 //!< is full and cannot accommodate new entries.
60 NOT_AUTHORIZED = 0x8D, //!< The device is not authorized to perform the requested
61 //!< operation, possibly due to security or access control
62 //!< restrictions.
63 INVALID_INDEX = 0x8F, //!< The index specified in the request is invalid or out of range.
64 FRAME_TOO_LARGE = 0x90, //!< The frame size of the request or response exceeds the maximum
65 //!< allowed size for the device or network.
66 BAD_KEY_NEGOTIATION_METHOD = 0x91, //!< The key negotiation method used in the request
67 //!< is not supported or is invalid.
68 TEMPORARY_FAILURE = 0x92 //!< A temporary failure occurred while processing
69 //!< the request, and the operation may be retried later.
70};
71
72/**
73 * @ingroup zigbee
74 *
75 * Zigbee Device Profile (ZDP) enumeration of request types for NWK_addr_req command.
76 */
77enum class NwkAddrRequestType : std::uint8_t
78{
79 SINGLE_DEVICE_RESPONSE = 0x00, //!< Request type for a single device response.
80 EXTENDED_RESPONSE = 0x02, //!< Request type for an extended response,
81 //!< not currently supported.
82};
83
84/**
85 * @ingroup zigbee
86 *
87 * ZDO Network Address Request Parameters.
88 */
90{
91 Mac16Address m_dstAddr; //!< The destination of the request, unicast or broadcast (0xFFFF).
92 Mac64Address m_ieeeAddr; //!< The known IEEE Address(64-bit address) of the device that we are
93 //!< request its network address (16-bit address).
95 //!< of this
96 //!< command
97 uint8_t m_startIndex{0}; //!< Placeholder, not supported.
98};
99
100/**
101 * @ingroup zigbee
102 *
103 * ZDO Network Address Response Parameters.
104 */
106{
107 Mac16Address m_dstAddr; //!< The destination of the response
108 //!< (the device that issued the NWK_addr_req).
109 uint8_t m_tsn{0}; //!< The transaction sequence number, must match the one used in the
110 //!< corresponding NWK_addr_req.
111 ZdpStatus m_status{ZdpStatus::INV_REQUESTTYPE}; //!< The status of the NWK_addr_req
112 //!< being responded to.
113 Mac64Address m_ieeeAddrRemoteDev; //!< The IEEE address (64-bit address) of the remote device
114 //!< matching the request.
115 Mac16Address m_nwkAddrRemoteDev; //!< The network address (16-bit address) of the remote device
116 //!< matching the request.
117 // TODO Add startIndex, numAssocDev, and associatedDevList when implementing extended response
118};
119
120/**
121 * @ingroup zigbee
122 *
123 * ZDO Network Address Response Indication Parameters.
124 * This structure or even its parameters are not standardized in the Zigbee Specification,
125 * however, these were chosen based on the parameters is by existing Zigbee stacks like TI's
126 * Z-Stack. See:
127 * https://software-dl.ti.com/simplelink/esd/simplelink_cc13x2_26x2_sdk/3.20.00.68/exports/docs/zigbee/doxygen/zigbee/html/struct__zstack__zdonwkaddrrspind__t.html
128 */
130{
131 ZdpStatus m_status{ZdpStatus::INV_REQUESTTYPE}; //!< The status of the NWK_addr_req
132 //!< being responded to.
133 Mac64Address m_ieeeAddrRemoteDev; //!< The IEEE address (64-bit address) of the remote device
134 //!< matching the request.
135 Mac16Address m_nwkAddrRemoteDev; //!< The network address (16-bit address) of the remote device
136 //!< matching the request.
137 // TODO Add startIndex, numAssocDev, and associatedDevList when implementing extended response
138};
139
140class ZigbeeZdo : public Object
141{
142 public:
143 /**
144 * Get the TypeId of ZigbeeZdo class.
145 *
146 * @return The TypeId of ZigbeeZdo class.
147 */
148 static TypeId GetTypeId();
149 ZigbeeZdo();
150 ~ZigbeeZdo() override;
151
152 /**
153 * This callback is called after a ASDU has successfully received and
154 * APS push it to deliver it to the next higher layer (typically the application framework).
155 */
157
158 /**
159 * Set the underlying APS to use in this Zigbee ZDO
160 *
161 * @param aps The pointer to the underlying Zigbee APS to set to this Zigbee ZDO
162 */
163 void SetAps(Ptr<ZigbeeAps> aps);
164
165 /**
166 * Get the underlying APS used by the current Zigbee ZDO.
167 *
168 * @return The pointer to the underlying APS object currently connected to the Zigbee ZDO.
169 */
170 Ptr<ZigbeeAps> GetAps() const;
171
172 /**
173 * Set the underlying NWK to use in this Zigbee ZDO
174 *
175 * @param nwk The pointer to the underlying Zigbee APS to set to this Zigbee ZDO
176 */
177 void SetNwk(Ptr<ZigbeeNwk> nwk);
178
179 /**
180 * Get the underlying APS used by the current Zigbee ZDO.
181 *
182 * @return The pointer to the underlying NWK object currently connected to the Zigbee ZDO.
183 */
184 Ptr<ZigbeeNwk> GetNwk() const;
185
186 /**
187 * This function is called when the Zigbee Stack receives an APSDE-DATA.indication
188 * with destination endpoint 0, which is the endpoint used by the Zigbee Device Object (ZDO).
189 *
190 * @param params The parameters of the APSDE-DATA.indication.
191 * @param p The packet received.
192 */
194
195 /**
196 * This function is used to send a Network Address (16-bit address)Request to a remote device
197 * when the IEEE address (64-bit address) of the device is known.
198 *
199 * @param params The parameters of the Network Address Request.
200 */
202
203 /**
204 * This function is used to send a Network Address (16-bit address) Response to a remote
205 * device in reply to a previously received NWK_addr_req.
206 *
207 * @param params The parameters of the Network Address Response.
208 */
210
211 /**
212 * Effect on Receipt (NWK_addr_req)
213 * See Zigbee Specification 2017, Section 2.4.3.1.1
214 *
215 * @param asdu The received packet containing the NWK_addr_req command.
216 * @param dataParams APSDE-DATA.indication parameters that carried the NWK_addr_req command.
217 */
219
220 /**
221 * Effect on Receipt (NWK_addr_rsp)
222 * See Zigbee Specification 2017, Section 2.4.4.2.1
223 *
224 * @param asdu The received packet containing the NWK_addr_rsp command.
225 * @param dataParams APSDE-DATA.indication parameters that carried the NWK_addr_rsp command.
226 */
228
229 /**
230 * Set the indication callback to be called when a response (NWK_addr_rsp) to
231 * an NWK_addr_req is received.
232 *
233 * @param c The callback to be called when a NWK_addr_rsp is received.
234 */
236
237 protected:
238 void DoInitialize() override;
239 void DoDispose() override;
240 void NotifyConstructionCompleted() override;
241
242 private:
243 /**
244 * This callback is used to to notify the result of a NWK_addr_req
245 * request in the ZDO to the Application framework (AF).
246 * This callback is not standardized in the Zigbee Specification, but
247 * similar solutions are often used in ZDO implementations.
248 */
250
251 Ptr<ZigbeeNwk> m_nwk; //!< Pointer to the Zigbee Network Layer (NWK) object.
252 Ptr<ZigbeeAps> m_aps; //!< Pointer to the Zigbee Application Support Sub-layer (APS) object.
253 SequenceNumber8 m_tsn; //!< The transaction sequence number
254};
255
256} // namespace zigbee
257} // namespace ns3
258
259#endif /* ZIGBEE_ZDO_H */
Callback template class.
Definition callback.h:428
This class can contain 16 bit addresses.
an EUI-64 address
Object()
Caller graph was not generated because of its size.
Definition object.cc:93
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
a unique identifier for an interface.
Definition type-id.h:50
Callback< void, NwkAddrRespIndParams > ZdoNwkAddrRspIndCallback
This callback is called after a ASDU has successfully received and APS push it to deliver it to the n...
Definition zigbee-zdo.h:156
void HandleNwkAddrRequest(Ptr< Packet > asdu, ApsdeDataIndicationParams dataParams)
Effect on Receipt (NWK_addr_req) See Zigbee Specification 2017, Section 2.4.3.1.1.
Ptr< ZigbeeNwk > m_nwk
Pointer to the Zigbee Network Layer (NWK) object.
Definition zigbee-zdo.h:251
Ptr< ZigbeeNwk > GetNwk() const
Get the underlying APS used by the current Zigbee ZDO.
Definition zigbee-zdo.cc:87
ZdoNwkAddrRspIndCallback m_zdoNwkAddrRspIndCallback
This callback is used to to notify the result of a NWK_addr_req request in the ZDO to the Application...
Definition zigbee-zdo.h:249
void NwkAddrRequest(NwkAddrRequestParams params)
This function is used to send a Network Address (16-bit address)Request to a remote device when the I...
void ApsDataIndication(ApsdeDataIndicationParams params, Ptr< Packet > p)
This function is called when the Zigbee Stack receives an APSDE-DATA.indication with destination endp...
Definition zigbee-zdo.cc:93
SequenceNumber8 m_tsn
The transaction sequence number.
Definition zigbee-zdo.h:253
void NotifyConstructionCompleted() override
Notifier called once the ObjectBase is fully constructed.
Definition zigbee-zdo.cc:45
void SetAps(Ptr< ZigbeeAps > aps)
Set the underlying APS to use in this Zigbee ZDO.
Definition zigbee-zdo.cc:69
void SetNwk(Ptr< ZigbeeNwk > nwk)
Set the underlying NWK to use in this Zigbee ZDO.
Definition zigbee-zdo.cc:81
void DoInitialize() override
Initialize() implementation.
Definition zigbee-zdo.cc:56
Ptr< ZigbeeAps > GetAps() const
Get the underlying APS used by the current Zigbee ZDO.
Definition zigbee-zdo.cc:75
void SetZdoNwkAddrRspIndCallback(ZdoNwkAddrRspIndCallback c)
Set the indication callback to be called when a response (NWK_addr_rsp) to an NWK_addr_req is receive...
void NwkAddrResponse(NwkAddrResponseParams params)
This function is used to send a Network Address (16-bit address) Response to a remote device in reply...
static TypeId GetTypeId()
Get the TypeId of ZigbeeZdo class.
Definition zigbee-zdo.cc:30
Ptr< ZigbeeAps > m_aps
Pointer to the Zigbee Application Support Sub-layer (APS) object.
Definition zigbee-zdo.h:252
void HandleNwkAddrResponse(Ptr< Packet > asdu, ApsdeDataIndicationParams dataParams)
Effect on Receipt (NWK_addr_rsp) See Zigbee Specification 2017, Section 2.4.4.2.1.
void DoDispose() override
Destructor implementation.
Definition zigbee-zdo.cc:63
SequenceNumber< uint8_t > SequenceNumber8
8 bit Sequence number.
NwkAddrRequestType
Zigbee Device Profile (ZDP) enumeration of request types for NWK_addr_req command.
Definition zigbee-zdo.h:78
@ EXTENDED_RESPONSE
Request type for an extended response, not currently supported.
Definition zigbee-zdo.h:80
@ SINGLE_DEVICE_RESPONSE
Request type for a single device response.
Definition zigbee-zdo.h:79
ZdpStatus
Zigbee Device Profile (ZDP) enumeration of status codes.
Definition zigbee-zdo.h:38
@ TIMEOUT
The request timed out.
Definition zigbee-zdo.h:48
@ NO_DESCRIPTOR
The requested descriptor (e.g., node, power, simple) is not available or not found.
Definition zigbee-zdo.h:52
@ TEMPORARY_FAILURE
A temporary failure occurred while processing the request, and the operation may be retried later.
Definition zigbee-zdo.h:68
@ NOT_ACTIVE
The device is not currently active in the network.
Definition zigbee-zdo.h:45
@ NO_ENTRY
The requested entry does not exist in the device's table or cache.
Definition zigbee-zdo.h:50
@ NOT_PERMITTED
The requested operation is not permitted due to security or policy restrictions.
Definition zigbee-zdo.h:56
@ NOT_SUPPORTED
The requested operation is not supported by the device or the network.
Definition zigbee-zdo.h:46
@ INVALID_EP
The endpoint specified in the request is invalid or not supported.
Definition zigbee-zdo.h:43
@ NO_MATCH
No matching entry was found for the request.
Definition zigbee-zdo.h:49
@ FRAME_TOO_LARGE
The frame size of the request or response exceeds the maximum allowed size for the device or network.
Definition zigbee-zdo.h:64
@ DEVICE_NOT_FOUND
The device with the specified IEEE address was not found in the network.
Definition zigbee-zdo.h:41
@ BAD_KEY_NEGOTIATION_METHOD
The key negotiation method used in the request is not supported or is invalid.
Definition zigbee-zdo.h:66
@ INV_REQUESTTYPE
The request type is invalid or not supported.
Definition zigbee-zdo.h:40
@ NOT_AUTHORIZED
The device is not authorized to perform the requested operation, possibly due to security or access c...
Definition zigbee-zdo.h:60
@ INSUFFICIENT_SPACE
The device does not have enough space to store the requested information or entry.
Definition zigbee-zdo.h:54
@ TABLE_FULL
Either the routing or neighbor table are full.
Definition zigbee-nwk.h:127
@ SUCCESS
The operation was completed successfully.
Definition zigbee-nwk.h:154
@ INVALID_INDEX
A MAC PIB write failed because specified index is out of range.
Definition zigbee-nwk.h:186
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Zigbee Specification r22.1.0, Section 2.2.4.1.3 APSDE-DATA.indications params.
Definition zigbee-aps.h:166
ZDO Network Address Request Parameters.
Definition zigbee-zdo.h:90
NwkAddrRequestType m_requestType
Request type of this command.
Definition zigbee-zdo.h:94
Mac16Address m_dstAddr
The destination of the request, unicast or broadcast (0xFFFF).
Definition zigbee-zdo.h:91
uint8_t m_startIndex
Placeholder, not supported.
Definition zigbee-zdo.h:97
Mac64Address m_ieeeAddr
The known IEEE Address(64-bit address) of the device that we are request its network address (16-bit ...
Definition zigbee-zdo.h:92
ZDO Network Address Response Indication Parameters.
Definition zigbee-zdo.h:130
Mac16Address m_nwkAddrRemoteDev
The network address (16-bit address) of the remote device matching the request.
Definition zigbee-zdo.h:135
Mac64Address m_ieeeAddrRemoteDev
The IEEE address (64-bit address) of the remote device matching the request.
Definition zigbee-zdo.h:133
ZdpStatus m_status
The status of the NWK_addr_req being responded to.
Definition zigbee-zdo.h:131
ZDO Network Address Response Parameters.
Definition zigbee-zdo.h:106
uint8_t m_tsn
The transaction sequence number, must match the one used in the corresponding NWK_addr_req.
Definition zigbee-zdo.h:109
Mac16Address m_nwkAddrRemoteDev
The network address (16-bit address) of the remote device matching the request.
Definition zigbee-zdo.h:115
Mac16Address m_dstAddr
The destination of the response (the device that issued the NWK_addr_req).
Definition zigbee-zdo.h:107
ZdpStatus m_status
The status of the NWK_addr_req being responded to.
Definition zigbee-zdo.h:111
Mac64Address m_ieeeAddrRemoteDev
The IEEE address (64-bit address) of the remote device matching the request.
Definition zigbee-zdo.h:113