A Discrete-Event Network Simulator
API
lr-wpan-fields.h
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2019 Ritsumeikan University, Shiga, Japan.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Alberto Gallegos Ramonet <ramonet@fc.ritsumei.ac.jp>
19  *
20  * This file implements Information Fields present in IEEE 802.15.4-2011.
21  * Information Fields are in practice similar to the Information Elements(IE)
22  * introduced in later revisions of the standard, however, they lack
23  * descriptors and common format unlike the IEs. To keep this implementation
24  * consistent with the IEEE 802.15.4-2011 std. the present file implements
25  * Information Fields not Information Elements.
26  */
27 #ifndef LR_WPAN_FIELDS_H
28 #define LR_WPAN_FIELDS_H
29 
30 
31 #include <ns3/mac16-address.h>
32 #include <ns3/mac64-address.h>
33 #include "ns3/buffer.h"
34 #include <array>
35 
36 
37 namespace ns3 {
38 
44 {
45  RFD = 0,
46  FFD = 1
47 };
48 
55 {
56 
57 public:
58  SuperframeField ();
63  void SetSuperframe (uint16_t superFrm);
68  void SetBeaconOrder (uint8_t bcnOrder);
73  void SetSuperframeOrder (uint8_t frmOrder);
78  void SetFinalCapSlot (uint8_t capSlot);
83  void SetBattLifeExt (bool battLifeExt);
88  void SetPanCoor (bool panCoor);
93  void SetAssocPermit (bool assocPermit);
98  uint8_t GetBeaconOrder (void) const;
103  uint8_t GetFrameOrder (void) const;
108  uint8_t GetFinalCapSlot (void) const;
113  bool IsBattLifeExt (void) const;
118  bool IsPanCoor (void) const;
123  bool IsAssocPermit (void) const;
128  uint16_t GetSuperframe (void) const;
133  uint32_t GetSerializedSize (void) const;
146 
147 
148 private:
149  // Superframe Specification field
150  // See IEEE 802.14.15-2011 5.2.2.1.2
151  uint8_t m_sspecBcnOrder;
155  bool m_sspecPanCoor;
158 
159 };
160 
168 std::ostream &operator << (std::ostream &os, const SuperframeField &superframeField);
169 
176 {
177 
178 public:
179  GtsFields ();
184  uint8_t GetGtsSpecField (void) const;
189  uint8_t GetGtsDirectionField (void) const;
194  void SetGtsSpecField (uint8_t gtsSpec);
199  void SetGtsDirectionField (uint8_t gtsDir);
204  uint32_t GetSerializedSize (void) const;
217 
218 private:
223  {
226  uint8_t m_gtsDescLength;
227  };
228 
229  //GTS specification field
231  // GTS specification field Reserved (Not necessary) (Bit 3-6)
232  uint8_t m_gtsSpecPermit;
233  //GTS Direction field
234  uint8_t m_gtsDirMask;
235  // GTS Direction field Reserved (Not Necessary) (Bit 7)
236  //GTS List
238 };
239 
240 
248 std::ostream &operator << (std::ostream &os, const GtsFields &gtsFields);
249 
250 
251 
258 {
259 
260 public:
266  void AddAddress (Mac16Address shortAddr);
271  void AddAddress (Mac64Address extAddr);
277  bool SearchAddress (Mac16Address shortAddr);
283  bool SearchAddress (Mac64Address extAddr);
288  uint8_t GetPndAddrSpecField (void) const;
293  uint8_t GetNumShortAddr (void) const;
298  uint8_t GetNumExtAddr (void) const;
299 
305  void SetPndAddrSpecField (uint8_t pndAddrSpecField);
310  uint32_t GetSerializedSize (void) const;
323 
324 private:
325  // Pending Address Specification Field
327  uint8_t m_pndAddrSpecNumExtAddr;
329  // Address List
331  std::array <Mac16Address,7> m_shortAddrList;
332  std::array<Mac64Address,7> m_extAddrList;
333 
334 };
335 
343 std::ostream &operator << (std::ostream &os, const PendingAddrFields &pendingAddrFields);
344 
345 
346 } //end namespace ns3
347 
348 #endif /* LR_WPAN_FIELDS_H */
ns3::SuperframeField::SetFinalCapSlot
void SetFinalCapSlot(uint8_t capSlot)
Set the superframe specification Final CAP slot field.
Definition: lr-wpan-fields.cc:78
ns3::PendingAddrFields::GetNumShortAddr
uint8_t GetNumShortAddr(void) const
Get the number of Short Pending Address indicated in the Pending Address Specification Field.
Definition: lr-wpan-fields.cc:327
ns3::SuperframeField::GetBeaconOrder
uint8_t GetBeaconOrder(void) const
Get the Superframe Specification Beacon Order field.
Definition: lr-wpan-fields.cc:109
ns3::SuperframeField::IsBattLifeExt
bool IsBattLifeExt(void) const
Check if the Battery Life Extension bit is enabled.
Definition: lr-wpan-fields.cc:127
ns3::SuperframeField::m_sspecBatLifeExt
bool m_sspecBatLifeExt
Superframe Specification field Battery Life Extension (Bit 12) Superframe Specification field Reserve...
Definition: lr-wpan-fields.h:154
ns3::SuperframeField::SetBattLifeExt
void SetBattLifeExt(bool battLifeExt)
Set the Superframe Specification Battery Life Extension (BLE).
Definition: lr-wpan-fields.cc:91
ns3::SuperframeField::m_sspecPanCoor
bool m_sspecPanCoor
Superframe Specification field PAN Coordinator (Bit 14)
Definition: lr-wpan-fields.h:156
ns3::PendingAddrFields::GetPndAddrSpecField
uint8_t GetPndAddrSpecField(void) const
Get the whole Pending Address Specification Field from the Pending Address Fields.
Definition: lr-wpan-fields.cc:340
ns3::GtsFields::m_gtsList
gtsDescriptor m_gtsList[7]
GTS List field (maximum descriptors stored == 7)
Definition: lr-wpan-fields.h:237
ns3::SuperframeField::m_sspecBcnOrder
uint8_t m_sspecBcnOrder
Superframe Specification field Beacon Order (Bit 0-3)
Definition: lr-wpan-fields.h:151
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::SuperframeField::SetSuperframeOrder
void SetSuperframeOrder(uint8_t frmOrder)
Set the superframe specification Superframe Order field.
Definition: lr-wpan-fields.cc:65
ns3::PendingAddrFields
Represent the Pending Address Specification field.
Definition: lr-wpan-fields.h:258
ns3::SuperframeField::SuperframeField
SuperframeField()
Definition: lr-wpan-fields.cc:29
ns3::Mac16Address
This class can contain 16 bit addresses.
Definition: mac16-address.h:42
ns3::SuperframeField::GetFrameOrder
uint8_t GetFrameOrder(void) const
Get the Superframe Specification Frame Order field.
Definition: lr-wpan-fields.cc:115
ns3::SuperframeField::SetBeaconOrder
void SetBeaconOrder(uint8_t bcnOrder)
Set the superframe specification Beacon Order field.
Definition: lr-wpan-fields.cc:52
ns3::GtsFields::SetGtsSpecField
void SetGtsSpecField(uint8_t gtsSpec)
Set the GTS Specification Field to the GTS Fields.
Definition: lr-wpan-fields.cc:230
ns3::GtsFields::m_gtsSpecPermit
uint8_t m_gtsSpecPermit
GTS specification field GTS Permit (Bit 7)
Definition: lr-wpan-fields.h:232
ns3::SuperframeField
Represent the Superframe Specification information field.
Definition: lr-wpan-fields.h:55
ns3::SuperframeField::GetSerializedSize
uint32_t GetSerializedSize(void) const
Get the size of the serialized Superframe specification information field.
Definition: lr-wpan-fields.cc:161
ns3::PendingAddrFields::SetPndAddrSpecField
void SetPndAddrSpecField(uint8_t pndAddrSpecField)
Set the whole Pending Address Specification field.
Definition: lr-wpan-fields.cc:415
ns3::PendingAddrFields::m_pndAddrSpecNumExtAddr
uint8_t m_pndAddrSpecNumExtAddr
Pending Address Specification field Number of Extended Address (Bits 4-6) Pending Address Specificati...
Definition: lr-wpan-fields.h:328
ns3::SuperframeField::m_sspecFnlCapSlot
uint8_t m_sspecFnlCapSlot
Superframe Specification field Final CAP slot (Bit 8-11)
Definition: lr-wpan-fields.h:153
ns3::Mac64Address
an EUI-64 address
Definition: mac64-address.h:44
ns3::SuperframeField::SetPanCoor
void SetPanCoor(bool panCoor)
Set the Superframe Specification PAN coordinator field.
Definition: lr-wpan-fields.cc:97
ns3::RFD
@ RFD
Reduced Functional Device (RFD)
Definition: lr-wpan-fields.h:45
ns3::PendingAddrFields::Serialize
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize the entire Pending Address Fields.
Definition: lr-wpan-fields.cc:437
ns3::GtsFields::gtsDescriptor
GTS Descriptor.
Definition: lr-wpan-fields.h:223
ns3::GtsFields::SetGtsDirectionField
void SetGtsDirectionField(uint8_t gtsDir)
Set the GTS direction field to the GTS Fields.
Definition: lr-wpan-fields.cc:238
ns3::PendingAddrFields::Deserialize
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize the all the Pending Address Fields.
Definition: lr-wpan-fields.cc:455
ns3::SuperframeField::SetSuperframe
void SetSuperframe(uint16_t superFrm)
Set the whole Superframe Specification Information field.
Definition: lr-wpan-fields.cc:40
ns3::DeviceType
DeviceType
The device Capabilities.
Definition: lr-wpan-fields.h:44
ns3::SuperframeField::IsPanCoor
bool IsPanCoor(void) const
Check if the PAN Coordinator bit is enabled.
Definition: lr-wpan-fields.cc:133
ns3::PendingAddrFields::m_pndAddrSpecNumShortAddr
uint8_t m_pndAddrSpecNumShortAddr
Pending Address Specification field Number of Short Address (Bits 0-2) Pending Address Specification ...
Definition: lr-wpan-fields.h:326
ns3::SuperframeField::m_sspecSprFrmOrder
uint8_t m_sspecSprFrmOrder
Superframe Specification field Superframe Order (Bit 4-7)
Definition: lr-wpan-fields.h:152
ns3::GtsFields::Deserialize
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize the entire GTS fields.
Definition: lr-wpan-fields.cc:283
ns3::SuperframeField::m_sspecAssocPermit
bool m_sspecAssocPermit
Superframe Specification field Association Permit (Bit 15)
Definition: lr-wpan-fields.h:157
ns3::GtsFields::GetGtsDirectionField
uint8_t GetGtsDirectionField(void) const
Get the GTS Direction Field from the GTS Fields.
Definition: lr-wpan-fields.cc:220
ns3::GtsFields
Represent the GTS information fields.
Definition: lr-wpan-fields.h:176
ns3::SuperframeField::Serialize
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize the entire superframe specification field.
Definition: lr-wpan-fields.cc:167
ns3::PendingAddrFields::GetSerializedSize
uint32_t GetSerializedSize(void) const
Get the size of the serialized Pending Address Fields.
Definition: lr-wpan-fields.cc:425
ns3::FFD
@ FFD
Full Functional Device (FFD)
Definition: lr-wpan-fields.h:46
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition: buffer.h:99
ns3::GtsFields::Serialize
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize the entire GTS fields.
Definition: lr-wpan-fields.cc:260
ns3::SuperframeField::Deserialize
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize the entire superframe specification field.
Definition: lr-wpan-fields.cc:174
ns3::PendingAddrFields::SearchAddress
bool SearchAddress(Mac16Address shortAddr)
Search for the short Pending Address in the Address List.
Definition: lr-wpan-fields.cc:385
ns3::GtsFields::gtsDescriptor::m_gtsDescDevShortAddr
Mac16Address m_gtsDescDevShortAddr
GTS Descriptor Device Short Address (Bit 0-15)
Definition: lr-wpan-fields.h:224
ns3::SuperframeField::SetAssocPermit
void SetAssocPermit(bool assocPermit)
Set the Superframe Specification Association Permit field.
Definition: lr-wpan-fields.cc:103
ns3::GtsFields::gtsDescriptor::m_gtsDescLength
uint8_t m_gtsDescLength
GTS Descriptor GTS Length (Bit 20-23)
Definition: lr-wpan-fields.h:226
ns3::PendingAddrFields::AddAddress
void AddAddress(Mac16Address shortAddr)
Add a short Pending Address to the Address List.
Definition: lr-wpan-fields.cc:353
ns3::GtsFields::m_gtsDirMask
uint8_t m_gtsDirMask
GTS Direction field Directions Mask (Bit 0-6)
Definition: lr-wpan-fields.h:234
ns3::GtsFields::gtsDescriptor::m_gtsDescStartSlot
uint8_t m_gtsDescStartSlot
GTS Descriptor GTS Starting Slot(Bit 16-19)
Definition: lr-wpan-fields.h:225
ns3::GtsFields::m_gtsSpecDescCount
uint8_t m_gtsSpecDescCount
GTS specification field Descriptor Count (Bit 0-2)
Definition: lr-wpan-fields.h:230
ns3::PendingAddrFields::m_shortAddrList
std::array< Mac16Address, 7 > m_shortAddrList
Pending Short Address List.
Definition: lr-wpan-fields.h:331
ns3::PendingAddrFields::m_extAddrList
std::array< Mac64Address, 7 > m_extAddrList
Pending Extended Address List.
Definition: lr-wpan-fields.h:332
ns3::SuperframeField::GetFinalCapSlot
uint8_t GetFinalCapSlot(void) const
Get the the Final CAP Slot.
Definition: lr-wpan-fields.cc:121
ns3::GtsFields::GetGtsSpecField
uint8_t GetGtsSpecField(void) const
Get the GTS Specification Field from the GTS Fields.
Definition: lr-wpan-fields.cc:208
ns3::PendingAddrFields::GetNumExtAddr
uint8_t GetNumExtAddr(void) const
Get the number of Extended Pending Address indicated in the Pending Address Specification Field.
Definition: lr-wpan-fields.cc:334
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
ns3::GtsFields::GetSerializedSize
uint32_t GetSerializedSize(void) const
Get the size of the serialized GTS fields.
Definition: lr-wpan-fields.cc:245
ns3::SuperframeField::IsAssocPermit
bool IsAssocPermit(void) const
Check if the Association Permit bit is enabled.
Definition: lr-wpan-fields.cc:139
ns3::SuperframeField::GetSuperframe
uint16_t GetSuperframe(void) const
Get the Superframe specification information field.
Definition: lr-wpan-fields.cc:145
ns3::GtsFields::GtsFields
GtsFields()
Definition: lr-wpan-fields.cc:198
ns3::PendingAddrFields::PendingAddrFields
PendingAddrFields()
Definition: lr-wpan-fields.cc:319