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