A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
zigbee-aps-header.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 * Authors:
7 * Alberto Gallegos Ramonet <alramonet@is.tokushima-u.ac.jp>
8 */
9
10#ifndef ZIGBEE_APS_HEADER_H
11#define ZIGBEE_APS_HEADER_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 * @ingroup zigbee
24 *
25 * Values of the Frame Type Sub-Field.
26 * Zigbee Specification r22.1.0, Table 2-20
27 */
28enum ApsFrameType : uint8_t
29{
30 APS_DATA = 0x00,
32 APS_ACK = 0x02,
33 APS_INTERPAN_APS = 0x03
34};
35
36/**
37 * @ingroup zigbee
38 *
39 * Values of the Delivery Mode Sub-Field.
40 * Zigbee Specification r22.1.0, Table 2-21
41 */
42enum ApsDeliveryMode : uint8_t
43{
44 APS_UCST = 0x00,
45 APS_BCST = 0x02,
47};
48
49/**
50 * @ingroup zigbee
51 *
52 * Table 2-22 Values of the Fragmentation Sub-Field
53 * Zigbee Specification r22.1.0, Table 2-22
54 */
55enum ApsFragmentation : uint8_t
56{
59 OTHER_FRAGMENT = 0x02
60};
61
62/**
63 * @ingroup zigbee
64 *
65 * Defines the APS header use by data transfer and commands issued from
66 * the APS layer. Zigbee Specification r22.1.0, Section 2.2.5.1.
67 *
68 */
69class ZigbeeApsHeader : public Header
70{
71 public:
73 ~ZigbeeApsHeader() override;
74
75 /**
76 * Set the Frame type defined in the APS layer
77 *
78 * @param frameType The frame type to set on the header
79 */
80 void SetFrameType(enum ApsFrameType frameType);
81
82 /**
83 * Get the frame time present in the header
84 *
85 * @return ApsFrameType
86 */
88
89 /**
90 * Defines the mode in which this frame should be transmitted.
91 *
92 * @param mode The delivery mode to set on the APS header
93 */
94 void SetDeliveryMode(enum ApsDeliveryMode mode);
95
96 /**
97 * Get the transmission mode set on the header.
98 *
99 * @return ApsDeliveryMode The delivery mode of the header
100 */
102
103 /**
104 * Set whether or not security should be used to transmit
105 * the frame.
106 *
107 * @param enabled True if security should be used
108 */
109 void SetSecurity(bool enabled);
110
111 /**
112 * Returns whether or not security is enabled for the present frame.alignas
113 *
114 * @return True if security is enabled for the frame.
115 */
116 bool IsSecurityEnabled() const;
117
118 /**
119 * Set the acknowledment flag in the APS header.
120 *
121 * @param request True if the frame should be acknowledged
122 */
123 void SetAckRequest(bool request);
124
125 /**
126 * Indicates if the present frame requires acknowledgment.
127 *
128 * @return True if the frame requires acknowledgment
129 */
130 bool IsAckRequested() const;
131
132 /**
133 * Enables or disables the usage of the extended header.
134 * Only used when fragmentation is used.
135 *
136 * @param present True if the extended header (fragmentation) is present.
137 */
138 void SetExtHeaderPresent(bool present);
139
140 /**
141 * Indicates whether or not the extended header is present in the frame.
142 * @return True if the extended header is present.
143 */
144 bool IsExtHeaderPresent() const;
145
146 /**
147 * Set the Bitmap representing the framecontrol portion of the APS header.
148 *
149 * @param frameControl The bitmap representing the framecontrol portion.
150 */
151 void SetFrameControl(uint8_t frameControl);
152
153 /**
154 * Get the frame control portion (bitmap) of the APS header.
155 *
156 * @return The frame control portion of the APS header.
157 */
158 uint8_t GetFrameControl() const;
159
160 /**
161 * Set the destination endpoint in the APS header.
162 *
163 * @param endpoint The destination endpoint.
164 */
165 void SetDstEndpoint(uint8_t endpoint);
166
167 /**
168 * Get the destination endpoint in the APS header.
169 *
170 * @return The destination endpoint.
171 */
172 uint8_t GetDstEndpoint() const;
173
174 /**
175 * Set the cluster id in the APS header.
176 *
177 * @param clusterId The cluster id
178 */
179 void SetClusterId(uint16_t clusterId);
180
181 /**
182 * Get the cluster id in the APS header.
183 * @return The cluster id.
184 */
185 uint16_t GetClusterId() const;
186
187 /**
188 * Set the profile ID in the APS header.
189 *
190 * @param profileId The profile ID.
191 */
192 void SetProfileId(uint16_t profileId);
193
194 /**
195 * Get the profile ID in the APS header.
196 * @return The profile ID.
197 */
198 uint16_t GetProfileId() const;
199
200 /**
201 * Set the source endpoint in the APS header.
202 *
203 * @param endpoint The source endpoint.
204 */
205 void SetSrcEndpoint(uint8_t endpoint);
206
207 /**
208 * Get the source endpoint in the APS header.
209 * @return The source endpoint.
210 */
211 uint8_t GetSrcEndpoint() const;
212
213 /**
214 * Set the value of the APS counter in the APS header.
215 * @param counter The APS counter value.
216 */
217 void SetApsCounter(uint8_t counter);
218
219 /**
220 * Get the APS counter value present in the APS header.
221 * @return The APS counter value.
222 */
223 uint8_t GetApsCounter() const;
224
225 /**
226 * @brief Get the type ID.
227 * @return the object TypeId
228 */
229 static TypeId GetTypeId();
230 TypeId GetInstanceTypeId() const override;
231
232 void Serialize(Buffer::Iterator start) const override;
233 uint32_t Deserialize(Buffer::Iterator start) override;
234 uint32_t GetSerializedSize() const override;
235 void Print(std::ostream& os) const override;
236
237 private:
238 // Frame Control field bits
239 ApsFrameType m_frameType; //!< Frame control field: Frame type
240 ApsDeliveryMode m_deliveryMode; //!< Frame control field: Delivery mode
241 bool m_ackFormat; //!< Frame control field: Acknowledgment format
242 bool m_security; //!< Frame control field: Security
243 bool m_ackRequest; //!< Frame control field: Acknowledge requested
244 bool m_extHeaderPresent; //!< Frame control field: Extended header present
245
246 // Addressing fields
247 uint8_t m_dstEndpoint; //!< Addressing field: Destination endpoint.
248 uint16_t m_groupAddress; //!< Addressing field: Group or 16-bit address.
249 uint16_t m_clusterId; //!< Addressing field: Cluster ID.
250 uint16_t m_profileId; //!< Addressing field: Profile ID.
251 uint8_t m_srcEndpoint; //!< Addressing field: Source endpoint.
252
253 uint8_t m_apsCounter; //!< APS counter field
254
255 // Extended header fields
256 ApsFragmentation m_fragmentation; //!< Extended header field: Fragmentation block type
257 uint8_t m_blockNumber; //!< Extended header field: Block number
258 uint8_t m_ackBitfield; //!< Extended header field: Acknowledgement bit field
259};
260
261} // namespace zigbee
262} // namespace ns3
263
264#endif // ZIGBEE_APS_HEADER_H
iterator in a Buffer instance
Definition buffer.h:89
Protocol header serialization and deserialization.
Definition header.h:33
a unique identifier for an interface.
Definition type-id.h:49
Defines the APS header use by data transfer and commands issued from the APS layer.
void SetSecurity(bool enabled)
Set whether or not security should be used to transmit the frame.
void SetDstEndpoint(uint8_t endpoint)
Set the destination endpoint in the APS header.
uint16_t GetClusterId() const
Get the cluster id in the APS header.
uint8_t GetFrameControl() const
Get the frame control portion (bitmap) of the APS header.
void SetDeliveryMode(enum ApsDeliveryMode mode)
Defines the mode in which this frame should be transmitted.
bool IsExtHeaderPresent() const
Indicates whether or not the extended header is present in the frame.
void SetFrameType(enum ApsFrameType frameType)
Set the Frame type defined in the APS layer.
uint8_t m_blockNumber
Extended header field: Block number.
bool IsSecurityEnabled() const
Returns whether or not security is enabled for the present frame.alignas.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint16_t m_groupAddress
Addressing field: Group or 16-bit address.
ApsFragmentation m_fragmentation
Extended header field: Fragmentation block type.
void SetSrcEndpoint(uint8_t endpoint)
Set the source endpoint in the APS header.
void SetExtHeaderPresent(bool present)
Enables or disables the usage of the extended header.
uint8_t m_srcEndpoint
Addressing field: Source endpoint.
uint16_t m_clusterId
Addressing field: Cluster ID.
ApsDeliveryMode m_deliveryMode
Frame control field: Delivery mode.
uint16_t m_profileId
Addressing field: Profile ID.
ApsDeliveryMode GetDeliveryMode() const
Get the transmission mode set on the header.
void SetFrameControl(uint8_t frameControl)
Set the Bitmap representing the framecontrol portion of the APS header.
bool m_extHeaderPresent
Frame control field: Extended header present.
uint8_t GetApsCounter() const
Get the APS counter value present in the APS header.
void SetApsCounter(uint8_t counter)
Set the value of the APS counter in the APS header.
void SetAckRequest(bool request)
Set the acknowledment flag in the APS header.
void SetClusterId(uint16_t clusterId)
Set the cluster id in the APS header.
bool m_ackFormat
Frame control field: Acknowledgment format.
uint32_t GetSerializedSize() const override
uint8_t GetSrcEndpoint() const
Get the source endpoint in the APS header.
uint8_t m_dstEndpoint
Addressing field: Destination endpoint.
uint32_t Deserialize(Buffer::Iterator start) override
uint8_t GetDstEndpoint() const
Get the destination endpoint in the APS header.
ApsFrameType GetFrameType() const
Get the frame time present in the header.
bool m_ackRequest
Frame control field: Acknowledge requested.
uint8_t m_apsCounter
APS counter field.
void Print(std::ostream &os) const override
bool m_security
Frame control field: Security.
uint8_t m_ackBitfield
Extended header field: Acknowledgement bit field.
bool IsAckRequested() const
Indicates if the present frame requires acknowledgment.
void SetProfileId(uint16_t profileId)
Set the profile ID in the APS header.
ApsFrameType m_frameType
Frame control field: Frame type.
void Serialize(Buffer::Iterator start) const override
static TypeId GetTypeId()
Get the type ID.
uint16_t GetProfileId() const
Get the profile ID in the APS header.
ApsFrameType
Values of the Frame Type Sub-Field.
ApsDeliveryMode
Values of the Delivery Mode Sub-Field.
ApsFragmentation
Table 2-22 Values of the Fragmentation Sub-Field Zigbee Specification r22.1.0, Table 2-22.
Every class exported by the ns3 library is enclosed in the ns3 namespace.