A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lr-wpan-fields.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Ritsumeikan University, Shiga, Japan.
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Alberto Gallegos Ramonet <ramonet@fc.ritsumei.ac.jp>
7 *
8 * This file implements Information Fields present in IEEE 802.15.4-2011.
9 * Information Fields are in practice similar to the Information Elements(IE)
10 * introduced in later revisions of the standard, however, they lack
11 * descriptors and common format unlike the IEs. To keep this implementation
12 * consistent with the IEEE 802.15.4-2011 std. the present file implements
13 * Information Fields not Information Elements.
14 */
15#ifndef LR_WPAN_FIELDS_H
16#define LR_WPAN_FIELDS_H
17
18#include "ns3/buffer.h"
19#include <ns3/mac16-address.h>
20#include <ns3/mac64-address.h>
21
22#include <array>
23
24namespace ns3
25{
26namespace lrwpan
27{
28
29/**
30 * \ingroup lr-wpan
31 * The device Capabilities.
32 */
34{
35 RFD = 0, //!< Reduced Functional Device (RFD)
36 FFD = 1 //!< Full Functional Device (FFD)
37};
38
39/**
40 * \ingroup lr-wpan
41 * Represent the Superframe Specification information field.
42 * See IEEE 802.15.4-2011 Section 5.2.2.1.2 Figure 41
43 */
45{
46 public:
48
49 /**
50 * Create a superframe Specification Information field with
51 * the information specified in the bitmap.
52 *
53 * \param bitmap The superframe in bitmap form
54 */
55 SuperframeField(uint16_t bitmap);
56 /**
57 * Set the whole Superframe Specification Information field.
58 * \param superFrm The Superframe Specification information field.
59 */
60 void SetSuperframe(uint16_t superFrm);
61 /**
62 * Set the superframe specification Beacon Order field.
63 * \param bcnOrder The beacon order value to set in the superframe.
64 */
65 void SetBeaconOrder(uint8_t bcnOrder);
66 /**
67 * Set the superframe specification Superframe Order field.
68 * \param frmOrder The frame Order value to set on the superframe.
69 */
70 void SetSuperframeOrder(uint8_t frmOrder);
71 /**
72 * Set the superframe specification Final CAP slot field.
73 * \param capSlot Set the final slot of the Contention Access Period (CAP).
74 */
75 void SetFinalCapSlot(uint8_t capSlot);
76 /**
77 * Set the Superframe Specification Battery Life Extension (BLE).
78 * \param battLifeExt Sets true or false the value of the Battery Life Extension flag of the
79 * superframe field.
80 */
81 void SetBattLifeExt(bool battLifeExt);
82 /**
83 * Set the Superframe Specification PAN coordinator field.
84 * \param panCoor set true or false the value for the PAN Coordinator flag of the superframe
85 * field.
86 */
87 void SetPanCoor(bool panCoor);
88 /**
89 * Set the Superframe Specification Association Permit field.
90 * \param assocPermit set true or false the value of the Association Permit flag of the
91 * superframe field.
92 */
93 void SetAssocPermit(bool assocPermit);
94 /**
95 * Get the Superframe Specification Beacon Order field.
96 * \return the Superframe Specification Beacon Order field.
97 */
98 uint8_t GetBeaconOrder() const;
99 /**
100 * Get the Superframe Specification Frame Order field.
101 * \return The Superframe Specification Frame Order field.
102 */
103 uint8_t GetFrameOrder() const;
104 /**
105 * Get the the Final CAP Slot.
106 * \returns The Final CAP Slot
107 */
108 uint8_t GetFinalCapSlot() const;
109 /**
110 * Check if the Battery Life Extension bit is enabled.
111 * \returns true if the Battery Life Extension bit is enabled
112 */
113 bool IsBattLifeExt() const;
114 /**
115 * Check if the PAN Coordinator bit is enabled.
116 * \returns true if the PAN Coordinator bit is enabled
117 */
118 bool IsPanCoor() const;
119 /**
120 * Check if the Association Permit bit is enabled.
121 * \returns true if the Association Permit bit is enabled
122 */
123 bool IsAssocPermit() const;
124 /**
125 * Get the Superframe specification information field.
126 * \return the Superframe Specification Information field bits.
127 */
128 uint16_t GetSuperframe() const;
129
130 private:
131 // Superframe Specification field
132 // See IEEE 802.14.15-2011 5.2.2.1.2
133 uint8_t m_sspecBcnOrder; //!< Superframe Specification field Beacon Order (Bit 0-3)
134 uint8_t m_sspecSprFrmOrder; //!< Superframe Specification field Superframe Order (Bit 4-7)
135 uint8_t m_sspecFnlCapSlot; //!< Superframe Specification field Final CAP slot (Bit 8-11)
136 bool m_sspecBatLifeExt; //!< Superframe Specification field Battery Life Extension (Bit 12)
137 //!< Superframe Specification field Reserved (not necessary) (Bit 13)
138 bool m_sspecPanCoor; //!< Superframe Specification field PAN Coordinator (Bit 14)
139 bool m_sspecAssocPermit; //!< Superframe Specification field Association Permit (Bit 15)
140};
141
142/**
143 * \brief Stream insertion operator.
144 *
145 * \param [in] os The reference to the output stream.
146 * \param [in] superframeField The Superframe fields.
147 * \returns The reference to the output stream.
148 */
149std::ostream& operator<<(std::ostream& os, const SuperframeField& superframeField);
150
151/**
152 * \ingroup lr-wpan
153 * Represent the GTS information fields.
154 * See IEEE 802.15.4-2011 Section 5.2.2 Figure 39
155 */
157{
158 public:
159 GtsFields();
160 /**
161 * Get the GTS Specification Field from the GTS Fields
162 * \return The GTS Specification Field
163 */
164 uint8_t GetGtsSpecField() const;
165 /**
166 * Get the GTS Direction Field from the GTS Fields
167 * \return The GTS Direction Field
168 */
169 uint8_t GetGtsDirectionField() const;
170 /**
171 * Set the GTS Specification Field to the GTS Fields
172 * \param gtsSpec The GTS Specification Field to set.
173 */
174 void SetGtsSpecField(uint8_t gtsSpec);
175 /**
176 * Set the GTS direction field to the GTS Fields
177 * \param gtsDir The GTS Direction Field to set
178 */
179 void SetGtsDirectionField(uint8_t gtsDir);
180 /**
181 * Get the GTS Specification Permit. TRUE if coordinator is accepting GTS requests.
182 * \return True if the coordinator is accepting GTS request.
183 */
184 bool GetGtsPermit() const;
185 /**
186 * Get the size of the serialized GTS fields.
187 * \return the size of the serialized fields.
188 */
190 /**
191 * Serialize the entire GTS fields.
192 * \param i an iterator which points to where the superframe specification field should be
193 * written.
194 * \return an iterator.
195 */
197 /**
198 * Deserialize the entire GTS fields.
199 * \param i an iterator which points to where the superframe specification field should be read.
200 * \return an iterator.
201 */
203
204 private:
205 /**
206 * GTS Descriptor
207 */
209 {
210 Mac16Address m_gtsDescDevShortAddr; //!< GTS Descriptor Device Short Address (Bit 0-15)
211 uint8_t m_gtsDescStartSlot; //!< GTS Descriptor GTS Starting Slot(Bit 16-19)
212 uint8_t m_gtsDescLength; //!< GTS Descriptor GTS Length (Bit 20-23)
213 };
214
215 // GTS specification field
216 uint8_t m_gtsSpecDescCount; //!< GTS specification field Descriptor Count (Bit 0-2)
217 // GTS specification field Reserved (Not necessary) (Bit 3-6)
218 uint8_t m_gtsSpecPermit; //!< GTS specification field GTS Permit (Bit 7)
219 // GTS Direction field
220 uint8_t m_gtsDirMask; //!< GTS Direction field Directions Mask (Bit 0-6)
221 // GTS Direction field Reserved (Not Necessary) (Bit 7)
222 // GTS List
223 GtsDescriptor m_gtsList[7]; //!< GTS List field (maximum descriptors stored == 7)
224};
225
226/**
227 * \brief Stream insertion operator.
228 *
229 * \param [in] os The reference to the output stream.
230 * \param [in] gtsFields The GTS fields.
231 * \returns The reference to the output stream.
232 */
233std::ostream& operator<<(std::ostream& os, const GtsFields& gtsFields);
234
235/**
236 * \ingroup lr-wpan
237 * Represent the Pending Address Specification field.
238 * See IEEE 802.15.4-2011 Section 5.2.2.1.6. Figure 45
239 */
241{
242 public:
244 /**
245 * Add a short Pending Address to the Address List.
246 * \param shortAddr The extended Pending Address List.
247 */
248 void AddAddress(Mac16Address shortAddr);
249 /**
250 * Add a extended Pending Address to the Address List.
251 * \param extAddr The extended Pending Address List.
252 */
253 void AddAddress(Mac64Address extAddr);
254 /**
255 * Search for the short Pending Address in the Address List.
256 * \param shortAddr The extended Address to look in the Address List.
257 * \return True if the address exist in the extended Address List.
258 */
259 bool SearchAddress(Mac16Address shortAddr);
260 /**
261 * Search for the extended Pending Address in the Address List.
262 * \param extAddr The extended Address to look in the Address List.
263 * \return True if the address exist in the extended Address List.
264 */
265 bool SearchAddress(Mac64Address extAddr);
266 /**
267 * Get the whole Pending Address Specification Field from the Pending Address Fields.
268 * \return The Pending Address Specification Field.
269 */
270 uint8_t GetPndAddrSpecField() const;
271 /**
272 * Get the number of Short Pending Address indicated in the Pending Address Specification Field.
273 * \return The number Short Pending Address.
274 */
275 uint8_t GetNumShortAddr() const;
276 /**
277 * Get the number of Extended Pending Address indicated in the Pending Address Specification
278 * Field.
279 * \return The number Short Pending Address.
280 */
281 uint8_t GetNumExtAddr() const;
282
283 /**
284 * Set the whole Pending Address Specification field. This field is part of the
285 * Pending Address Fields header.
286 * \param pndAddrSpecField The Pending Address Specification Field
287 */
288 void SetPndAddrSpecField(uint8_t pndAddrSpecField);
289 /**
290 * Get the size of the serialized Pending Address Fields.
291 * \return the size of the serialized fields.
292 */
294 /**
295 * Serialize the entire Pending Address Fields.
296 * \param i an iterator which points to where the Pending Address Fields should be written.
297 * \return an iterator.
298 */
300 /**
301 * Deserialize the all the Pending Address Fields.
302 * \param i an iterator which points to where the Pending Address Fields should be read.
303 * \return an iterator.
304 */
306
307 private:
308 // Pending Address Specification Field
309 uint8_t m_pndAddrSpecNumShortAddr; //!< Pending Address Specification field Number of Short
310 //!< Address (Bits 0-2) Pending Address Specification field
311 //!< Reserved (Not Necessary)(Bit 3)
312 uint8_t m_pndAddrSpecNumExtAddr; //!< Pending Address Specification field Number of Extended
313 //!< Address (Bits 4-6) Pending Address Specification field
314 //!< Reserved (Not Necessary) (Bit 7)
315 // Address List
316 std::array<Mac16Address, 7> m_shortAddrList; //!< Pending Short Address List
317 std::array<Mac64Address, 7> m_extAddrList; //!< Pending Extended Address List
318};
319
320/**
321 * \brief Stream insertion operator.
322 *
323 * \param [in] os The reference to the output stream.
324 * \param [in] pendingAddrFields The Pending Address fields.
325 * \returns The reference to the output stream.
326 */
327std::ostream& operator<<(std::ostream& os, const PendingAddrFields& pendingAddrFields);
328
329/**
330 * \ingroup lr-wpan
331 *
332 * Represent the Capability Information Field.
333 * See IEEE 802.15.4-2011 Section 5.3.1.2 Figure 50
334 */
336{
337 public:
339
340 /**
341 * Construct a Capability field based on a bitmap.
342 *
343 * \param bitmap The bitmap representing the capability
344 */
345 CapabilityField(uint8_t bitmap);
346
347 /**
348 * Get the bitmap representing the device capability.
349 *
350 * \return The bitmap representing the device capability.
351 */
352 uint8_t GetCapability() const;
353
354 /**
355 * Set the bitmap representing the device capability.
356 *
357 * \param bitmap The bitmap representing the capability
358 */
359 void SetCapability(uint8_t bitmap);
360
361 /**
362 * True if the device type is a Full Functional Device (FFD) false if is a Reduced Functional
363 * Device (RFD).
364 *
365 * \return True if the device type is a Full Functional Device (FFD) false if is a Reduced
366 * Functional Device (RFD).
367 */
368 bool IsDeviceTypeFfd() const;
369
370 /**
371 * True if the device is receiving power from alternating current mains.
372 *
373 * \return True if the device is receiving power from alternating current mains.
374 */
375 bool IsPowSrcAvailable() const;
376
377 /**
378 * True if the device does not disable its receiver to conserve power during idle periods.
379 *
380 * \return True if the device does not disable its receiver to conserve power during idle
381 * periods.
382 */
383 bool IsReceiverOnWhenIdle() const;
384
385 /**
386 * True if the device is capable of sending and receiving cryptographically protected MAC
387 * frames.
388 *
389 * \return True if the device is capable of sending and receiving cryptographically protected
390 * MAC frames.
391 */
392 bool IsSecurityCapability() const;
393
394 /**
395 * True if the device wishes the coordinator to allocate a short address as result of the
396 * association procedure.
397 *
398 * \return True if the device wishes the coordinator to allocate a short address as result of
399 * the association procedure.
400 */
401 bool IsShortAddrAllocOn() const;
402
403 /**
404 * Set the Device type in the Capability Information Field.
405 * True = full functional device (FFD) False = reduced functional device (RFD).
406 *
407 * \param devType The device type described in the Capability Information Field.
408 */
409 void SetFfdDevice(bool devType);
410
411 /**
412 * Set the Power Source available flag in the Capability Information Field.
413 *
414 * \param pow Set true if a Power Source is available in the Capability Information Field.
415 */
416 void SetPowSrcAvailable(bool pow);
417
418 /**
419 * Indicate if the receiver is On on Idle
420 *
421 * \param rxIdle Set true if the receiver is on when Idle
422 */
423 void SetRxOnWhenIdle(bool rxIdle);
424
425 /**
426 * Set the Security Capability flag in the Capability Information Field.
427 *
428 * \param sec Set true if the device have Security Capabilities.
429 */
430 void SetSecurityCap(bool sec);
431
432 /**
433 * Set the Short Address Flag in the Capability Information Field.
434 *
435 * \param addrAlloc Describes whether or not the coordinator should allocate a short
436 * address in the association process.
437 */
438 void SetShortAddrAllocOn(bool addrAlloc);
439
440 private:
441 bool m_reservedBit0; //!< Capability Information Field, Reserved (bit 0)
442 bool m_deviceType; //!< Capability Information Field, Device Type (bit 1)
443 bool m_powerSource; //!< Capability Information Field, Power Source (bit 2)
444 bool m_receiverOnWhenIdle; //!< Capability Information Field, Receiver On When Idle (bit 3)
445 uint8_t m_reservedBit45; //!< Capability Information Field, Reserved (bit 4 & 5)
446 bool m_securityCap; //!< Capability Information Field, Security Capability (bit 6)
447 bool m_allocAddr; //!< Capability Information Field, Allocate Address (bit 7)
448};
449
450std::ostream& operator<<(std::ostream& os, const CapabilityField& capabilityField);
451
452} // namespace lrwpan
453} // namespace ns3
454
455#endif /* LR_WPAN_FIELDS_H */
iterator in a Buffer instance
Definition buffer.h:89
This class can contain 16 bit addresses.
an EUI-64 address
Represent the Capability Information Field.
bool m_powerSource
Capability Information Field, Power Source (bit 2)
bool IsShortAddrAllocOn() const
True if the device wishes the coordinator to allocate a short address as result of the association pr...
bool IsSecurityCapability() const
True if the device is capable of sending and receiving cryptographically protected MAC frames.
bool m_allocAddr
Capability Information Field, Allocate Address (bit 7)
uint8_t GetCapability() const
Get the bitmap representing the device capability.
void SetCapability(uint8_t bitmap)
Set the bitmap representing the device capability.
bool IsDeviceTypeFfd() const
True if the device type is a Full Functional Device (FFD) false if is a Reduced Functional Device (RF...
void SetShortAddrAllocOn(bool addrAlloc)
Set the Short Address Flag in the Capability Information Field.
bool m_securityCap
Capability Information Field, Security Capability (bit 6)
bool m_reservedBit0
Capability Information Field, Reserved (bit 0)
uint8_t m_reservedBit45
Capability Information Field, Reserved (bit 4 & 5)
bool m_deviceType
Capability Information Field, Device Type (bit 1)
void SetPowSrcAvailable(bool pow)
Set the Power Source available flag in the Capability Information Field.
void SetRxOnWhenIdle(bool rxIdle)
Indicate if the receiver is On on Idle.
void SetSecurityCap(bool sec)
Set the Security Capability flag in the Capability Information Field.
void SetFfdDevice(bool devType)
Set the Device type in the Capability Information Field.
bool m_receiverOnWhenIdle
Capability Information Field, Receiver On When Idle (bit 3)
bool IsReceiverOnWhenIdle() const
True if the device does not disable its receiver to conserve power during idle periods.
bool IsPowSrcAvailable() const
True if the device is receiving power from alternating current mains.
Represent the GTS information fields.
GtsDescriptor m_gtsList[7]
GTS List field (maximum descriptors stored == 7)
uint32_t GetSerializedSize() const
Get the size of the serialized GTS fields.
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize the entire GTS fields.
uint8_t m_gtsDirMask
GTS Direction field Directions Mask (Bit 0-6)
void SetGtsSpecField(uint8_t gtsSpec)
Set the GTS Specification Field to the GTS Fields.
uint8_t m_gtsSpecDescCount
GTS specification field Descriptor Count (Bit 0-2)
uint8_t GetGtsDirectionField() const
Get the GTS Direction Field from the GTS Fields.
void SetGtsDirectionField(uint8_t gtsDir)
Set the GTS direction field to the GTS Fields.
bool GetGtsPermit() const
Get the GTS Specification Permit.
uint8_t GetGtsSpecField() const
Get the GTS Specification Field from the GTS Fields.
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize the entire GTS fields.
uint8_t m_gtsSpecPermit
GTS specification field GTS Permit (Bit 7)
Represent the Pending Address Specification field.
void SetPndAddrSpecField(uint8_t pndAddrSpecField)
Set the whole Pending Address Specification field.
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize the entire Pending Address Fields.
std::array< Mac16Address, 7 > m_shortAddrList
Pending Short Address List.
uint8_t GetPndAddrSpecField() const
Get the whole Pending Address Specification Field from the Pending Address Fields.
uint8_t GetNumExtAddr() const
Get the number of Extended Pending Address indicated in the Pending Address Specification Field.
uint8_t m_pndAddrSpecNumShortAddr
Pending Address Specification field Number of Short Address (Bits 0-2) Pending Address Specification ...
bool SearchAddress(Mac16Address shortAddr)
Search for the short Pending Address in the Address List.
void AddAddress(Mac16Address shortAddr)
Add a short Pending Address to the Address List.
uint32_t GetSerializedSize() const
Get the size of the serialized Pending Address Fields.
uint8_t GetNumShortAddr() const
Get the number of Short Pending Address indicated in the Pending Address Specification Field.
uint8_t m_pndAddrSpecNumExtAddr
Pending Address Specification field Number of Extended Address (Bits 4-6) Pending Address Specificati...
std::array< Mac64Address, 7 > m_extAddrList
Pending Extended Address List.
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize the all the Pending Address Fields.
Represent the Superframe Specification information field.
void SetPanCoor(bool panCoor)
Set the Superframe Specification PAN coordinator field.
bool m_sspecBatLifeExt
Superframe Specification field Battery Life Extension (Bit 12)
uint8_t GetFinalCapSlot() const
Get the the Final CAP Slot.
bool IsPanCoor() const
Check if the PAN Coordinator bit is enabled.
void SetAssocPermit(bool assocPermit)
Set the Superframe Specification Association Permit field.
bool m_sspecAssocPermit
Superframe Specification field Association Permit (Bit 15)
void SetBattLifeExt(bool battLifeExt)
Set the Superframe Specification Battery Life Extension (BLE).
bool IsBattLifeExt() const
Check if the Battery Life Extension bit is enabled.
bool m_sspecPanCoor
Superframe Specification field PAN Coordinator (Bit 14)
void SetSuperframe(uint16_t superFrm)
Set the whole Superframe Specification Information field.
uint8_t GetBeaconOrder() const
Get the Superframe Specification Beacon Order field.
uint8_t GetFrameOrder() const
Get the Superframe Specification Frame Order field.
bool IsAssocPermit() const
Check if the Association Permit bit is enabled.
uint16_t GetSuperframe() const
Get the Superframe specification information field.
uint8_t m_sspecSprFrmOrder
Superframe Specification field Superframe Order (Bit 4-7)
void SetFinalCapSlot(uint8_t capSlot)
Set the superframe specification Final CAP slot field.
uint8_t m_sspecBcnOrder
Superframe Specification field Beacon Order (Bit 0-3)
void SetBeaconOrder(uint8_t bcnOrder)
Set the superframe specification Beacon Order field.
uint8_t m_sspecFnlCapSlot
Superframe Specification field Final CAP slot (Bit 8-11)
void SetSuperframeOrder(uint8_t frmOrder)
Set the superframe specification Superframe Order field.
DeviceType
The device Capabilities.
@ RFD
Reduced Functional Device (RFD)
@ FFD
Full Functional Device (FFD)
std::ostream & operator<<(std::ostream &os, const SuperframeField &superframeField)
Stream insertion operator.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t m_gtsDescLength
GTS Descriptor GTS Length (Bit 20-23)
Mac16Address m_gtsDescDevShortAddr
GTS Descriptor Device Short Address (Bit 0-15)
uint8_t m_gtsDescStartSlot
GTS Descriptor GTS Starting Slot(Bit 16-19)