A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
zigbee-nwk-fields.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Tokushima University, Japan
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Alberto Gallegos Ramonet <alramonet@is.tokushima-u.ac.jp>
7 *
8 */
9
10#ifndef ZIGBEE_NWK_FIELDS_H
11#define ZIGBEE_NWK_FIELDS_H
12
13#include "ns3/buffer.h"
14
15#include <array>
16
17namespace ns3
18{
19namespace zigbee
20{
21
22/**
23 * @ingroup zigbee
24 * The device Type
25 * Zigbee Specification r22.1.0 (Table 3-62 or Table 3-63)
26 */
28{
29 ENDDEVICE = 0, //!< End device or router treated as an end device.
30 ROUTER = 1 //!< Router device.
31};
32
33/**
34 * @ingroup zigbee
35 * The power source capabilities.
36 * Zigbee Specification r22.1.0 (Table 3-62)
37 */
39{
40 OTHER_POWER_SOURCE = 0, //!< Other power source.
41 MAINPOWER = 1 //!< Mains-powered device.
42};
43
44/**
45 * @ingroup zigbee
46 * Requested Timeout Field
47 * See Zigbee Specification r22.1.0, 3.4.11.3.1
48 *
49 * List the requested timeout values in minutes
50 */
51static const double RequestedTimeoutField
52 [15]{0.166667, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384};
53
54/**
55 * @ingroup zigbee
56 * Represent the the Capability Information Bit fields
57 * See zigbe Specification r22.1.0, Table 3-62
58 */
60{
61 public:
63
64 /**
65 * Constructor using the capability in a bitmap form.
66 *
67 * @param bitmap The bitmap representing the capability.
68 */
69 CapabilityInformation(uint8_t bitmap);
70
71 /**
72 * Used to obtain the complete capability information bit map.
73 *
74 * @return The bit map with the capability information
75 */
76 uint8_t GetCapability() const;
77
78 /**
79 * This field will always have a value of false in implementations of
80 * this specification.
81 *
82 * @return false for implementations of this specification.
83 */
84 bool IsAlternatePanCoord() const;
85
86 /**
87 * This field will have a value of ROUTER if the joining device is a
88 * Zigbee router. It will have a value of ENDDEVICE if the devices is a
89 * Zigbee end device or else a router-capable device that is joining as
90 * an end device.
91 *
92 * @return The device type used
93 */
95
96 /**
97 * This field will be set to the value of lowest-order bit of the
98 * PowerSource parameter passed to the NLME-JOIN.request primitive.
99 *
100 * @return MAINPOWER or OTHER_POWER_SOURCE
101 */
103
104 /**
105 * This field will be set to the value of the lowest-order bit of the
106 * RxOnWhenIdle parameter passed to the NLME-JOIN.request primitive
107 *
108 * @return True Rx enabled when the device is idle | False = the receiver is disabled when idle.
109 *
110 */
111 bool IsReceiverOnWhenIdle() const;
112
113 /**
114 * This field will have a value of true in implementations of this specification,
115 * indicating that the joining device must be issued a 16 bit network address,
116 * except in the case where a device has self-selected its address while using the
117 * NWK rejoin command to join a network for the first time in a secure manner.
118 * In this case, it shall have a value of false.
119 *
120 * @return True = The device require a 16 bit address allocation, False = otherwise.
121 */
122 bool IsAllocateAddrOn() const;
123
124 /**
125 * Set the Capability Information bit map
126 *
127 * @param capability The 8 bit map representing the full capability
128 */
129 void SetCapability(uint8_t capability);
130
131 /**
132 * Set the device type bit for the capability information field.
133 *
134 * @param devType The device type field to set in the capability information.
135 */
136 void SetDeviceType(MacDeviceType devType);
137
138 /**
139 * Set the power source bit for the capability information field.
140 *
141 * @param powerSource The power source field to set in the capability information.
142 */
143 void SetPowerSource(PowerSource powerSource);
144
145 /**
146 * Set the Receiver On When Idle bit for the capability information field.
147 *
148 * @param value True if the receiver should remain on when idle.
149 */
150 void SetReceiverOnWhenIdle(bool value);
151
152 /**
153 * Set the Allocate Addr On for the capability information field.
154 *
155 * @param value True if the device requires to have its 16 bit network address allocated.
156 */
157 void SetAllocateAddrOn(bool value);
158
159 private:
160 bool m_alternatePanCoord{false}; //!< (Bit 0) The alternate PAN coordinator bit field.
161 MacDeviceType m_deviceType{ROUTER}; //!< (Bit 1) The device type bit field.
162 PowerSource m_powerSource{MAINPOWER}; //!< (Bit 2) The power source bits field.
163 bool m_receiverOnWhenIdle{true}; //!< (Bit 3) The receiver on when idle bit field.
164 bool m_securityCapability{false}; //!< (Bit 6) The security capability bit field.
165 bool m_allocateAddr{true}; //!< (Bit 7) The allocate address bit field.
166};
167
168/**
169 * @ingroup lr-wpan
170 * Represent the Superframe Specification information field.
171 * See IEEE 802.15.4-2011 Section 5.2.2.1.2 Figure 41
172 */
174{
175 public:
177
178 /**
179 * Create a superframe Specification Information field with
180 * the information specified in the bitmap.
181 *
182 * @param bitmap The superframe in bitmap form
183 */
184 SuperframeInformation(uint16_t bitmap);
185
186 /**
187 * Set the whole Superframe Specification Information field.
188 * @param superFrm The Superframe Specification information field.
189 */
190 void SetSuperframe(uint16_t superFrm);
191
192 /**
193 * Get the Superframe Specification Beacon Order field.
194 * @return the Superframe Specification Beacon Order field.
195 */
196 uint8_t GetBeaconOrder() const;
197
198 /**
199 * Get the Superframe Specification Frame Order field.
200 * @return The Superframe Specification Frame Order field.
201 */
202 uint8_t GetFrameOrder() const;
203
204 /**
205 * Check if the PAN Coordinator bit is enabled.
206 * @returns true if the PAN Coordinator bit is enabled
207 */
208 bool IsPanCoor() const;
209
210 /**
211 * Check if the Association Permit bit is enabled.
212 * @returns true if the Association Permit bit is enabled
213 */
214 bool IsAssocPermit() const;
215
216 private:
217 // Superframe Specification field
218 // See IEEE 802.14.15-2011 5.2.2.1.2
219 uint8_t m_sspecBcnOrder; //!< Superframe Specification field Beacon Order (Bit 0-3)
220 uint8_t m_sspecSprFrmOrder; //!< Superframe Specification field Superframe Order (Bit 4-7)
221
222 bool m_sspecPanCoor; //!< Superframe Specification field PAN Coordinator (Bit 14)
223 bool m_sspecAssocPermit; //!< Superframe Specification field Association Permit (Bit 15)
224};
225
226} // namespace zigbee
227} // namespace ns3
228
229#endif /* ZIGBEE_NWK_FIELDS_H */
Represent the the Capability Information Bit fields See zigbe Specification r22.1....
uint8_t GetCapability() const
Used to obtain the complete capability information bit map.
PowerSource GetPowerSource() const
This field will be set to the value of lowest-order bit of the PowerSource parameter passed to the NL...
void SetCapability(uint8_t capability)
Set the Capability Information bit map.
bool m_alternatePanCoord
(Bit 0) The alternate PAN coordinator bit field.
void SetPowerSource(PowerSource powerSource)
Set the power source bit for the capability information field.
bool m_receiverOnWhenIdle
(Bit 3) The receiver on when idle bit field.
PowerSource m_powerSource
(Bit 2) The power source bits field.
MacDeviceType GetDeviceType() const
This field will have a value of ROUTER if the joining device is a Zigbee router.
bool IsReceiverOnWhenIdle() const
This field will be set to the value of the lowest-order bit of the RxOnWhenIdle parameter passed to t...
bool IsAlternatePanCoord() const
This field will always have a value of false in implementations of this specification.
void SetDeviceType(MacDeviceType devType)
Set the device type bit for the capability information field.
void SetAllocateAddrOn(bool value)
Set the Allocate Addr On for the capability information field.
bool m_securityCapability
(Bit 6) The security capability bit field.
MacDeviceType m_deviceType
(Bit 1) The device type bit field.
void SetReceiverOnWhenIdle(bool value)
Set the Receiver On When Idle bit for the capability information field.
bool IsAllocateAddrOn() const
This field will have a value of true in implementations of this specification, indicating that the jo...
bool m_allocateAddr
(Bit 7) The allocate address bit field.
Represent the Superframe Specification information field.
bool IsPanCoor() const
Check if the PAN Coordinator bit is enabled.
bool IsAssocPermit() const
Check if the Association Permit bit is enabled.
uint8_t GetFrameOrder() const
Get the Superframe Specification Frame Order field.
uint8_t GetBeaconOrder() const
Get the Superframe Specification Beacon Order field.
void SetSuperframe(uint16_t superFrm)
Set the whole Superframe Specification Information field.
uint8_t m_sspecSprFrmOrder
Superframe Specification field Superframe Order (Bit 4-7)
bool m_sspecAssocPermit
Superframe Specification field Association Permit (Bit 15)
bool m_sspecPanCoor
Superframe Specification field PAN Coordinator (Bit 14)
uint8_t m_sspecBcnOrder
Superframe Specification field Beacon Order (Bit 0-3)
PowerSource
The power source capabilities.
MacDeviceType
The device Type Zigbee Specification r22.1.0 (Table 3-62 or Table 3-63)
static const double RequestedTimeoutField[15]
Requested Timeout Field See Zigbee Specification r22.1.0, 3.4.11.3.1.
@ MAINPOWER
Mains-powered device.
@ OTHER_POWER_SOURCE
Other power source.
@ ENDDEVICE
End device or router treated as an end device.
@ ROUTER
Router device.
Every class exported by the ns3 library is enclosed in the ns3 namespace.