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{
37
43{
44 RFD = 0,
45 FFD = 1
46};
47
54{
55 public:
57
64 SuperframeField(uint16_t bitmap);
69 void SetSuperframe(uint16_t superFrm);
74 void SetBeaconOrder(uint8_t bcnOrder);
79 void SetSuperframeOrder(uint8_t frmOrder);
84 void SetFinalCapSlot(uint8_t capSlot);
90 void SetBattLifeExt(bool battLifeExt);
96 void SetPanCoor(bool panCoor);
102 void SetAssocPermit(bool assocPermit);
107 uint8_t GetBeaconOrder() const;
112 uint8_t GetFrameOrder() const;
117 uint8_t GetFinalCapSlot() const;
122 bool IsBattLifeExt() const;
127 bool IsPanCoor() const;
132 bool IsAssocPermit() const;
137 uint16_t GetSuperframe() const;
138
139 private:
140 // Superframe Specification field
141 // See IEEE 802.14.15-2011 5.2.2.1.2
149};
150
158std::ostream& operator<<(std::ostream& os, const SuperframeField& superframeField);
159
166{
167 public:
168 GtsFields();
173 uint8_t GetGtsSpecField() const;
178 uint8_t GetGtsDirectionField() const;
183 void SetGtsSpecField(uint8_t gtsSpec);
188 void SetGtsDirectionField(uint8_t gtsDir);
193 bool GetGtsPermit() const;
212
213 private:
218 {
222 };
223
224 // GTS specification field
226 // GTS specification field Reserved (Not necessary) (Bit 3-6)
228 // GTS Direction field
229 uint8_t m_gtsDirMask;
230 // GTS Direction field Reserved (Not Necessary) (Bit 7)
231 // GTS List
233};
234
242std::ostream& operator<<(std::ostream& os, const GtsFields& gtsFields);
243
250{
251 public:
257 void AddAddress(Mac16Address shortAddr);
262 void AddAddress(Mac64Address extAddr);
268 bool SearchAddress(Mac16Address shortAddr);
274 bool SearchAddress(Mac64Address extAddr);
279 uint8_t GetPndAddrSpecField() const;
284 uint8_t GetNumShortAddr() const;
290 uint8_t GetNumExtAddr() const;
291
297 void SetPndAddrSpecField(uint8_t pndAddrSpecField);
315
316 private:
317 // Pending Address Specification Field
324 // Address List
325 std::array<Mac16Address, 7> m_shortAddrList;
326 std::array<Mac64Address, 7> m_extAddrList;
327};
328
336std::ostream& operator<<(std::ostream& os, const PendingAddrFields& pendingAddrFields);
337
345{
346 public:
348
354 CapabilityField(uint8_t bitmap);
355
361 uint8_t GetCapability() const;
362
368 void SetCapability(uint8_t bitmap);
369
377 bool IsDeviceTypeFfd() const;
378
384 bool IsPowSrcAvailable() const;
385
392 bool IsReceiverOnWhenIdle() const;
393
401 bool IsSecurityCapability() const;
402
410 bool IsShortAddrAllocOn() const;
411
418 void SetFfdDevice(bool devType);
419
425 void SetPowSrcAvailable(bool pow);
426
432 void SetRxOnWhenIdle(bool rxIdle);
433
439 void SetSecurityCap(bool sec);
440
447 void SetShortAddrAllocOn(bool addrAlloc);
448
449 private:
457};
458
459std::ostream& operator<<(std::ostream& os, const CapabilityField& capabilityField);
460
461} // end namespace ns3
462
463#endif /* LR_WPAN_FIELDS_H */
iterator in a Buffer instance
Definition: buffer.h:100
Represent the Capability Information Field.
uint8_t GetCapability() const
Get the bitmap representing the device capability.
bool m_securityCap
Capability Information Field, Security Capability (bit 6)
void SetCapability(uint8_t bitmap)
Set the bitmap representing the device capability.
bool m_allocAddr
Capability Information Field, Allocate Address (bit 7)
void SetPowSrcAvailable(bool pow)
Set the Power Source available flag in the Capability Information Field.
void SetShortAddrAllocOn(bool addrAlloc)
Set the Short Address Flag in the Capability Information Field.
bool IsDeviceTypeFfd() const
True if the device type is a Full Functional Device (FFD) false if is a Reduced Functional Device (RF...
bool m_reservedBit0
Capability Information Field, Reserved (bit 0)
uint8_t m_reservedBit45
Capability Information Field, Reserved (bit 4 & 5)
void SetSecurityCap(bool sec)
Set the Security Capability flag in the Capability Information Field.
bool IsSecurityCapability() const
True if the device is capable of sending and receiving cryptographically protected MAC frames.
bool IsPowSrcAvailable() const
True if the device is receiving power from alternating current mains.
void SetRxOnWhenIdle(bool rxIdle)
Indicate if the receiver is On on Idle.
bool IsReceiverOnWhenIdle() const
True if the device does not disable its receiver to conserve power during idle periods.
bool IsShortAddrAllocOn() const
True if the device wishes the coordinator to allocate a short address as result of the association pr...
bool m_deviceType
Capability Information Field, Device Type (bit 1)
bool m_powerSource
Capability Information Field, Power Source (bit 2)
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)
Represent the GTS information fields.
void SetGtsSpecField(uint8_t gtsSpec)
Set the GTS Specification Field to the GTS Fields.
void SetGtsDirectionField(uint8_t gtsDir)
Set the GTS direction field to the GTS Fields.
GtsDescriptor m_gtsList[7]
GTS List field (maximum descriptors stored == 7)
bool GetGtsPermit() const
Get the GTS Specification Permit.
uint8_t m_gtsSpecPermit
GTS specification field GTS Permit (Bit 7)
uint8_t m_gtsSpecDescCount
GTS specification field Descriptor Count (Bit 0-2)
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize the entire GTS fields.
uint32_t GetSerializedSize() const
Get the size of the serialized GTS fields.
uint8_t GetGtsDirectionField() const
Get the GTS Direction Field from the 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)
uint8_t GetGtsSpecField() const
Get the GTS Specification Field from the GTS Fields.
This class can contain 16 bit addresses.
Definition: mac16-address.h:44
an EUI-64 address
Definition: mac64-address.h:46
Represent the Pending Address Specification field.
std::array< Mac64Address, 7 > m_extAddrList
Pending Extended Address List.
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize the all the Pending Address Fields.
uint8_t GetNumExtAddr() const
Get the number of Extended Pending Address indicated in the Pending Address Specification Field.
uint32_t GetSerializedSize() const
Get the size of the serialized Pending Address Fields.
uint8_t GetPndAddrSpecField() const
Get the whole Pending Address Specification Field from the Pending Address Fields.
uint8_t m_pndAddrSpecNumShortAddr
Pending Address Specification field Number of Short Address (Bits 0-2) Pending Address Specification ...
uint8_t m_pndAddrSpecNumExtAddr
Pending Address Specification field Number of Extended Address (Bits 4-6) Pending Address Specificati...
std::array< Mac16Address, 7 > m_shortAddrList
Pending Short Address List.
bool SearchAddress(Mac16Address shortAddr)
Search for the short Pending Address in the Address List.
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize the entire Pending Address Fields.
void AddAddress(Mac16Address shortAddr)
Add a short Pending Address to the Address List.
uint8_t GetNumShortAddr() const
Get the number of Short Pending Address indicated in the Pending Address Specification Field.
void SetPndAddrSpecField(uint8_t pndAddrSpecField)
Set the whole Pending Address Specification field.
Represent the Superframe Specification information field.
bool m_sspecBatLifeExt
Superframe Specification field Battery Life Extension (Bit 12)
bool m_sspecAssocPermit
Superframe Specification field Association Permit (Bit 15)
uint8_t GetFinalCapSlot() const
Get the the Final CAP Slot.
uint16_t GetSuperframe() const
Get the Superframe specification information field.
bool m_sspecPanCoor
Superframe Specification field PAN Coordinator (Bit 14)
uint8_t m_sspecFnlCapSlot
Superframe Specification field Final CAP slot (Bit 8-11)
void SetAssocPermit(bool assocPermit)
Set the Superframe Specification Association Permit field.
uint8_t m_sspecBcnOrder
Superframe Specification field Beacon Order (Bit 0-3)
void SetBattLifeExt(bool battLifeExt)
Set the Superframe Specification Battery Life Extension (BLE).
uint8_t GetBeaconOrder() const
Get the Superframe Specification Beacon Order field.
uint8_t m_sspecSprFrmOrder
Superframe Specification field Superframe Order (Bit 4-7)
bool IsBattLifeExt() const
Check if the Battery Life Extension bit is enabled.
void SetFinalCapSlot(uint8_t capSlot)
Set the superframe specification Final CAP slot field.
void SetSuperframeOrder(uint8_t frmOrder)
Set the superframe specification Superframe Order field.
void SetPanCoor(bool panCoor)
Set the Superframe Specification PAN coordinator field.
void SetBeaconOrder(uint8_t bcnOrder)
Set the superframe specification Beacon Order 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.
void SetSuperframe(uint16_t superFrm)
Set the whole Superframe Specification Information field.
DeviceType
The device Capabilities.
@ RFD
Reduced Functional Device (RFD)
@ FFD
Full Functional Device (FFD)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
uint8_t m_gtsDescLength
GTS Descriptor GTS Length (Bit 20-23)
uint8_t m_gtsDescStartSlot
GTS Descriptor GTS Starting Slot(Bit 16-19)
Mac16Address m_gtsDescDevShortAddr
GTS Descriptor Device Short Address (Bit 0-15)