A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
zigbee-aps-tables.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 Tokushima University, Japan
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author:
7 * Alberto Gallegos Ramonet <alramonet@is.tokushima-u.ac.jp>
8 */
9
10#ifndef ZIGBEE_APS_TABLES_H
11#define ZIGBEE_APS_TABLES_H
12
13#include "ns3/mac16-address.h"
14#include "ns3/mac64-address.h"
15#include "ns3/output-stream-wrapper.h"
16#include "ns3/timer.h"
17
18#include <cassert>
19#include <deque>
20#include <stdint.h>
21#include <sys/types.h>
22
23namespace ns3
24{
25namespace zigbee
26{
27
28/**
29 * @ingroup zigbee
30 *
31 * APS Destination Address Mode for Binding
32 * Zigbee Specification r22.1.0, Table 2-6
33 * APSME-BIND.request Parameters
34 */
40
41/**
42 * @ingroup zigbee
43 *
44 * The status resulting of interactions with the binding table.
45 */
46enum class BindingTableStatus : std::uint8_t
47{
48 BOUND = 0,
49 UNBOUND = 1,
50 TABLE_FULL = 2,
51 ENTRY_EXISTS = 3,
53};
54
55/**
56 * @ingroup zigbee
57 *
58 * Binding Table entry: Source portion of the table.
59 * As described in Zigbee Specification r22.1.0, Table 2-134
60 */
61class SrcBindingEntry : public SimpleRefCount<SrcBindingEntry>
62{
63 public:
64 /**
65 * The default constructor of the source binding entry.
66 */
68
69 /**
70 * Constructor of the source binding entry.
71 *
72 * @param address The IEEE address to register, (typically the IEEE address of the source
73 * device).
74 * @param endPoint The source endpoint to register to the entry.
75 * @param clusterId The cluster ID to register to the entry.
76 */
77 SrcBindingEntry(Mac64Address address, uint8_t endPoint, uint16_t clusterId);
79
80 /**
81 * Set the source IEEE address to the entry.
82 *
83 * @param address The IEEE address (64-bit address) of the entry
84 */
85 void SetSrcAddress(Mac64Address address);
86
87 /**
88 * Set the source endpoint of the source binding entry.
89 * @param endPoint The source endpoint to set in the entry.
90 */
91 void SetSrcEndPoint(uint8_t endPoint);
92
93 /**
94 * Set the cluster ID of the source binding entry.
95 * @param clusterId The cluster ID to set in the entry.
96 */
97 void SetClusterId(uint16_t clusterId);
98
99 /**
100 * Get the IEEE address from the source binding entry.
101 * @return The IEEE address in the source binding entry.
102 */
104
105 /**
106 * Get the source endpoint from the source binding entry.
107 *
108 * @return The source endpoint.
109 */
110 uint8_t GetSrcEndPoint() const;
111
112 /**
113 * Get the cluster ID from the source binding entry.
114 * @return The cluster ID.
115 */
116 uint16_t GetClusterId() const;
117
118 private:
119 Mac64Address m_srcAddr; //!< The source IEEE address in the source entry.
120 uint8_t m_srcEndPoint{0}; //!< The source endpoint in the source entry.
121 uint16_t m_clusterId{0}; //!< The cluster ID in the source entry.
122};
123
124/**
125 * Binding Table entry: Destination portion of the table.
126 * As described in Zigbee Specification r22.1.0, Table 2-134
127 */
128class DstBindingEntry : public SimpleRefCount<DstBindingEntry>
129{
130 public:
131 /**
132 * The default constructor of the destination binding entry.
133 */
136
137 /**
138 * Set the destination address mode of the destination binding entry.
139 * @param mode The destination address mode to set.
140 */
142
143 /**
144 * Set the destination 16-bit address of the destination binding entry.
145 * @param address The 16-bit address of the destination binding entry.
146 */
147 void SetDstAddr16(Mac16Address address);
148
149 /**
150 * Set the destination IEEE Address (64-bit address) of the destination binding entry.
151 * @param address The destination IEEE address (64-bit address) to set
152 */
153 void SetDstAddr64(Mac64Address address);
154
155 /**
156 * Set the destination endppoint to the destination binding entry.
157 * @param endPoint The destination endpoint to set.
158 */
159 void SetDstEndPoint(uint8_t endPoint);
160
161 /**
162 * Get the destination address mode used by the destination entry.
163 * @return The destination address mode used by the entry.
164 */
166
167 /**
168 * Get the 16-bit address destination of the destination entry.
169 * @return The 16-bit address of the destination entry.
170 */
172
173 /**
174 * Get the 64-bit address destination of the destination entry.
175 * @return The IEEE address (64-bit address) destination
176 */
178
179 /**
180 * Get the destination endpoint of the destination entry.
181 * @return The destination endpoint.
182 */
183 uint8_t GetDstEndPoint() const;
184
185 private:
188 //!< used by the entry.
189 Mac16Address m_dstAddr16; //!< The destination 16-bit address in the destination entry.
191 m_dstAddr64; //!< The destination IEEE address (64-bit address) in the destination entry.
192 uint8_t m_dstEndPoint{0xF0}; //!< The destination endpoint in the destination entry.
193};
194
195/**
196 * APS Binding Table
197 * See Zigbee specification r22.1.0, Table 2-134
198 * Similar to the z-boss implementation, the binding table is divided in two portions:
199 * The source part and the destination part. A single source can have multiple destination
200 * entries as described by the Zigbee specification. This creates a relationship one to many
201 * (a source entry with multiple destination entries) which is both useful for 64 bit Address UCST
202 * or 16-bit groupcast destination bindings.
203 */
205{
206 public:
207 /**
208 * The constructor of the binding table.
209 */
210 BindingTable();
211
212 /**
213 * Add an entry to the binding table.
214 * In essence it binds the source entry portion to the table to one or more
215 * destination portion entries (one to many).
216 *
217 * @param src The source entry portion of the table.
218 * @param dst The destination entry portion of the table.
219 * @return The resulting status of the binding attempt.
220 */
222
223 /**
224 * Unbinds a destination entry portion of a binding table from a source entry portion.
225 *
226 * @param src The source entry portion of the table.
227 * @param dst The destination entry portion of the table.
228 * @return The resulting status of the unbinding attempt.
229 */
231
232 /**
233 * Look for destination entries binded to an specific source entry portion in the binding
234 * table.
235 *
236 * @param src The source entry portion of the table to search.
237 * @param dstEntries The resulting destination entries binded to the provided source entry
238 * portion
239 * @return True if at least one destination entry portion was retrieved.
240 */
241 bool LookUpEntries(const SrcBindingEntry& src, std::vector<DstBindingEntry>& dstEntries);
242
243 private:
244 /**
245 * Compare the equality of 2 source entries
246 *
247 * @param first The first source entry to compare.
248 * @param second The second source entry to compare.
249 * @return True if the destinations entries are identical
250 */
252
253 /**
254 * Compare the equality of 2 destination entries
255 *
256 * @param first The first destination entry to compare.
257 * @param second The second destination entry to compare.
258 * @return True if the destinations entries are identical
259 */
261
262 std::vector<std::pair<SrcBindingEntry,
263 std::vector<DstBindingEntry>>>
264 m_bindingTable; //!< The binding table object
265 uint8_t m_maxSrcEntries; //!< The maximum amount of source entries allowed in the table
266 uint8_t m_maxDstEntries; //!< The maximum amount of destination entries allowed in the table
267};
268
269} // namespace zigbee
270} // namespace ns3
271
272#endif /* ZIGBEE_APS_TABLES_H */
This class can contain 16 bit addresses.
an EUI-64 address
A template-based reference counting class.
APS Binding Table See Zigbee specification r22.1.0, Table 2-134 Similar to the z-boss implementation,...
bool CompareSources(const SrcBindingEntry &first, const SrcBindingEntry &second)
Compare the equality of 2 source entries.
uint8_t m_maxSrcEntries
The maximum amount of source entries allowed in the table.
bool LookUpEntries(const SrcBindingEntry &src, std::vector< DstBindingEntry > &dstEntries)
Look for destination entries binded to an specific source entry portion in the binding table.
BindingTableStatus Bind(const SrcBindingEntry &src, const DstBindingEntry &dst)
Add an entry to the binding table.
BindingTableStatus Unbind(const SrcBindingEntry &src, const DstBindingEntry &dst)
Unbinds a destination entry portion of a binding table from a source entry portion.
BindingTable()
The constructor of the binding table.
std::vector< std::pair< SrcBindingEntry, std::vector< DstBindingEntry > > > m_bindingTable
The binding table object.
bool CompareDestinations(const DstBindingEntry &first, const DstBindingEntry &second)
Compare the equality of 2 destination entries.
uint8_t m_maxDstEntries
The maximum amount of destination entries allowed in the table.
Binding Table entry: Destination portion of the table.
Mac64Address m_dstAddr64
The destination IEEE address (64-bit address) in the destination entry.
Mac16Address m_dstAddr16
The destination 16-bit address in the destination entry.
~DstBindingEntry()
DstBindingEntry()
The default constructor of the destination binding entry.
ApsDstAddressModeBind m_dstAddrMode
The destination address mode used by the entry.
Mac16Address GetDstAddr16() const
Get the 16-bit address destination of the destination entry.
Mac64Address GetDstAddr64() const
Get the 64-bit address destination of the destination entry.
uint8_t GetDstEndPoint() const
Get the destination endpoint of the destination entry.
void SetDstAddr64(Mac64Address address)
Set the destination IEEE Address (64-bit address) of the destination binding entry.
ApsDstAddressModeBind GetDstAddrMode() const
Get the destination address mode used by the destination entry.
uint8_t m_dstEndPoint
The destination endpoint in the destination entry.
void SetDstAddrMode(ApsDstAddressModeBind mode)
Set the destination address mode of the destination binding entry.
void SetDstEndPoint(uint8_t endPoint)
Set the destination endppoint to the destination binding entry.
void SetDstAddr16(Mac16Address address)
Set the destination 16-bit address of the destination binding entry.
Binding Table entry: Source portion of the table.
uint16_t GetClusterId() const
Get the cluster ID from the source binding entry.
uint8_t GetSrcEndPoint() const
Get the source endpoint from the source binding entry.
SrcBindingEntry()
The default constructor of the source binding entry.
void SetSrcEndPoint(uint8_t endPoint)
Set the source endpoint of the source binding entry.
~SrcBindingEntry()
uint8_t m_srcEndPoint
The source endpoint in the source entry.
void SetClusterId(uint16_t clusterId)
Set the cluster ID of the source binding entry.
Mac64Address m_srcAddr
The source IEEE address in the source entry.
void SetSrcAddress(Mac64Address address)
Set the source IEEE address to the entry.
Mac64Address GetSrcAddress() const
Get the IEEE address from the source binding entry.
uint16_t m_clusterId
The cluster ID in the source entry.
BindingTableStatus
The status resulting of interactions with the binding table.
ApsDstAddressModeBind
APS Destination Address Mode for Binding Zigbee Specification r22.1.0, Table 2-6 APSME-BIND....
Definition first.py:1
@ TABLE_FULL
Either the routing or neighbor table are full.
Definition zigbee-nwk.h:126
Every class exported by the ns3 library is enclosed in the ns3 namespace.