A Discrete-Event Network Simulator
API
wifi-mode.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006,2007 INRIA
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  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * S├ębastien Deronne <sebastien.deronne@gmail.com>
20  */
21 
22 #ifndef WIFI_MODE_H
23 #define WIFI_MODE_H
24 
25 #include "wifi-phy-common.h"
26 #include "ns3/attribute-helper.h"
27 #include "ns3/callback.h"
28 #include <vector>
29 
30 namespace ns3 {
31 
32 #define SU_STA_ID 65535
33 
34 class WifiTxVector;
35 
47 class WifiMode
48 {
49 public:
56  bool IsAllowed (uint16_t channelWidth, uint8_t nss) const;
68  uint64_t GetPhyRate (uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const;
78  uint64_t GetPhyRate (const WifiTxVector& txVector, uint16_t staId = SU_STA_ID) const;
84  uint64_t GetPhyRate (uint16_t channelWidth) const;
93  uint64_t GetDataRate (uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const;
100  uint64_t GetDataRate (const WifiTxVector& txVector, uint16_t staId = SU_STA_ID) const;
106  uint64_t GetDataRate (uint16_t channelWidth) const;
107 
111  WifiCodeRate GetCodeRate (void) const;
115  uint16_t GetConstellationSize (void) const;
119  uint8_t GetMcsValue (void) const;
124  std::string GetUniqueName (void) const;
129  bool IsMandatory (void) const;
137  uint32_t GetUid (void) const;
152  uint64_t GetNonHtReferenceRate (void) const;
158  bool IsHigherCodeRate (WifiMode mode) const;
164  bool IsHigherDataRate (WifiMode mode) const;
165 
172  WifiMode ();
179  WifiMode (std::string name);
180 
181 
182 private:
184  friend class WifiModeFactory;
190  WifiMode (uint32_t uid);
191  uint32_t m_uid;
192 };
193 
203 bool operator == (const WifiMode &a, const WifiMode &b);
204 
214 bool operator != (const WifiMode &a, const WifiMode &b);
215 
225 bool operator < (const WifiMode &a, const WifiMode &b);
226 
235 std::ostream & operator << (std::ostream & os, const WifiMode &mode);
244 std::istream & operator >> (std::istream &is, WifiMode &mode);
245 
247 
254 typedef std::vector<WifiMode> WifiModeList;
258 typedef WifiModeList::const_iterator WifiModeListIterator;
259 
267 {
268 public:
269  // Typedefs for callbacks used by WifiModeItem
288  typedef Callback<uint64_t, uint16_t /* channelWidth */, uint16_t /* guardInterval */, uint8_t /* nss */> PhyRateCallback;
298  typedef Callback<uint64_t, const WifiTxVector& /* txVector */, uint16_t /* staId */> PhyRateFromTxVectorCallback;
307  typedef Callback<uint64_t, uint16_t /* channelWidth */, uint16_t /* guardInterval */, uint8_t /* nss */> DataRateCallback;
317  typedef Callback<uint64_t, const WifiTxVector& /* txVector */, uint16_t /* staId */> DataRateFromTxVectorCallback;
334  typedef Callback<bool, uint16_t /* channelWidth */, uint8_t /* nss */> ModeAllowedCallback;
335 
364  static WifiMode CreateWifiMode (std::string uniqueName,
365  WifiModulationClass modClass,
366  bool isMandatory,
367  CodeRateCallback codeRateCallback,
368  ConstellationSizeCallback constellationSizeCallback,
369  PhyRateCallback phyRateCallback,
370  PhyRateFromTxVectorCallback phyRateFromTxVectorCallback,
371  DataRateCallback dataRateCallback,
372  DataRateFromTxVectorCallback dataRateFromTxVectorCallback,
373  ModeAllowedCallback isModeAllowedCallback);
374 
402  static WifiMode CreateWifiMcs (std::string uniqueName,
403  uint8_t mcsValue,
404  WifiModulationClass modClass,
405  CodeRateCallback codeRateCallback,
406  ConstellationSizeCallback constellationSizeCallback,
407  PhyRateCallback phyRateCallback,
408  PhyRateFromTxVectorCallback phyRateFromTxVectorCallback,
409  DataRateCallback dataRateCallback,
410  DataRateFromTxVectorCallback dataRateFromTxVectorCallback,
411  NonHtReferenceRateCallback nonHtReferenceRateCallback,
412  ModeAllowedCallback isModeAllowedCallback);
413 
414 
415 private:
417  friend class WifiMode;
418  friend std::istream & operator >> (std::istream &is, WifiMode &mode);
419 
425  static WifiModeFactory* GetFactory ();
426  WifiModeFactory ();
427 
434  {
435  std::string uniqueUid;
437  bool isMandatory;
438  uint8_t mcsValue;
447  };
448 
456  WifiMode Search (std::string name) const;
464  uint32_t AllocateUid (std::string uniqueUid);
472  WifiModeItem* Get (uint32_t uid);
473 
477  typedef std::vector<WifiModeItem> WifiModeItemList;
479 };
480 
481 } //namespace ns3
482 
483 #endif /* WIFI_MODE_H */
ns3::WifiModeFactory::WifiModeItem::GetPhyRateCallback
PhyRateCallback GetPhyRateCallback
Callback to calculate PHY rate in bps of this WifiModeItem.
Definition: wifi-mode.h:441
ns3::WifiModeFactory::WifiModeItemList
std::vector< WifiModeItem > WifiModeItemList
typedef for a vector of WifiModeItem.
Definition: wifi-mode.h:477
ns3::WifiModeFactory::Get
WifiModeItem * Get(uint32_t uid)
Return a WifiModeItem at the given UID index.
Definition: wifi-mode.cc:381
ns3::WifiModeList
std::vector< WifiMode > WifiModeList
In various parts of the code, folk are interested in maintaining a list of transmission modes.
Definition: wifi-mode.h:254
ns3::WifiMode::IsHigherCodeRate
bool IsHigherCodeRate(WifiMode mode) const
Definition: wifi-mode.cc:174
ns3::WifiModeFactory::WifiModeItem
This is the data associated to a unique WifiMode.
Definition: wifi-mode.h:434
ns3::WifiModeFactory::DataRateCallback
Callback< uint64_t, uint16_t, uint16_t, uint8_t > DataRateCallback
Typedef for callback used to calculate data rate of a WifiMode.
Definition: wifi-mode.h:307
ns3::WifiMode::IsMandatory
bool IsMandatory(void) const
Definition: wifi-mode.cc:130
ns3::WifiModeFactory::PhyRateFromTxVectorCallback
Callback< uint64_t, const WifiTxVector &, uint16_t > PhyRateFromTxVectorCallback
Typedef for callback used to calculate PHY rate of a WifiMode from a TXVECTOR.
Definition: wifi-mode.h:298
ns3::Callback< WifiCodeRate >
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WifiModeFactory::WifiModeItem::uniqueUid
std::string uniqueUid
unique UID
Definition: wifi-mode.h:435
ns3::WifiModeFactory::WifiModeItem::modClass
WifiModulationClass modClass
modulation class
Definition: wifi-mode.h:436
ns3::WifiModeFactory::WifiModeItem::GetDataRateCallback
DataRateCallback GetDataRateCallback
Callback to calculate data rate in bps of this WifiModeItem.
Definition: wifi-mode.h:443
ns3::WifiMode::IsHigherDataRate
bool IsHigherDataRate(WifiMode mode) const
Definition: wifi-mode.cc:181
ns3::WifiModeFactory::DataRateFromTxVectorCallback
Callback< uint64_t, const WifiTxVector &, uint16_t > DataRateFromTxVectorCallback
Typedef for callback used to calculate data rate of a WifiMode from a TXVECTOR.
Definition: wifi-mode.h:317
ns3::operator<
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:160
ns3::WifiMode::GetCodeRate
WifiCodeRate GetCodeRate(void) const
Definition: wifi-mode.cc:108
ns3::WifiModeFactory::WifiModeItem::GetNonHtReferenceRateCallback
NonHtReferenceRateCallback GetNonHtReferenceRateCallback
Callback to calculate non-HT reference rate of this WifiModeItem.
Definition: wifi-mode.h:445
ns3::WifiMode::GetModulationClass
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:159
wifi-phy-common.h
Declaration of the following enums:
ns3::WifiModeFactory::WifiModeItem::GetConstellationSizeCallback
ConstellationSizeCallback GetConstellationSizeCallback
Callback to retrieve constellation size of this WifiModeItem.
Definition: wifi-mode.h:440
ns3::WifiTxVector
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition: wifi-tx-vector.h:71
ns3::WifiModeFactory::ModeAllowedCallback
Callback< bool, uint16_t, uint8_t > ModeAllowedCallback
Typedef for callback used to check whether the combination of <current WifiMode, channel width (in MH...
Definition: wifi-mode.h:334
ns3::WifiModeFactory::PhyRateCallback
Callback< uint64_t, uint16_t, uint16_t, uint8_t > PhyRateCallback
Typedef for callback used to calculate PHY rate of a WifiMode.
Definition: wifi-mode.h:288
ns3::WifiCodeRate
uint16_t WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
Definition: wifi-phy-common.h:45
ns3::WifiMode
represent a single transmission mode
Definition: wifi-mode.h:48
ns3::WifiModeFactory::NonHtReferenceRateCallback
Callback< uint64_t > NonHtReferenceRateCallback
Typedef for callback used to calculate Non-HT Reference Rate of an MCS defined in HT or later amendme...
Definition: wifi-mode.h:325
ns3::WifiModeFactory::CreateWifiMode
static WifiMode CreateWifiMode(std::string uniqueName, WifiModulationClass modClass, bool isMandatory, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, PhyRateFromTxVectorCallback phyRateFromTxVectorCallback, DataRateCallback dataRateCallback, DataRateFromTxVectorCallback dataRateFromTxVectorCallback, ModeAllowedCallback isModeAllowedCallback)
Definition: wifi-mode.cc:242
ns3::WifiModeFactory::Search
WifiMode Search(std::string name) const
Search and return WifiMode from a given name.
Definition: wifi-mode.cc:328
ns3::WifiModeFactory::AllocateUid
uint32_t AllocateUid(std::string uniqueUid)
Allocate a WifiModeItem from a given uniqueUid.
Definition: wifi-mode.cc:363
ns3::WifiMode::GetNonHtReferenceRate
uint64_t GetNonHtReferenceRate(void) const
Definition: wifi-mode.cc:166
SU_STA_ID
#define SU_STA_ID
Definition: wifi-mode.h:32
ns3::WifiModeFactory::CreateWifiMcs
static WifiMode CreateWifiMcs(std::string uniqueName, uint8_t mcsValue, WifiModulationClass modClass, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, PhyRateFromTxVectorCallback phyRateFromTxVectorCallback, DataRateCallback dataRateCallback, DataRateFromTxVectorCallback dataRateFromTxVectorCallback, NonHtReferenceRateCallback nonHtReferenceRateCallback, ModeAllowedCallback isModeAllowedCallback)
Definition: wifi-mode.cc:291
ns3::WifiMode::GetUniqueName
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:122
ns3::WifiMode::WifiMode
WifiMode()
Create an invalid WifiMode.
Definition: wifi-mode.cc:220
ns3::operator==
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:142
ns3::WifiMode::GetPhyRate
uint64_t GetPhyRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:73
ns3::WifiModeFactory::m_itemList
WifiModeItemList m_itemList
item list
Definition: wifi-mode.h:478
ns3::WifiModeFactory::ConstellationSizeCallback
Callback< uint16_t > ConstellationSizeCallback
Typedef for callback used to retrieve constellation size of a WifiMode.
Definition: wifi-mode.h:279
ns3::WifiModeFactory::CodeRateCallback
Callback< WifiCodeRate > CodeRateCallback
Typedef for callback used to retrieve code rate of a WifiMode.
Definition: wifi-mode.h:274
ns3::WifiModeFactory::WifiModeFactory
WifiModeFactory()
Definition: wifi-mode.cc:237
ns3::WifiModeFactory::WifiModeItem::isMandatory
bool isMandatory
flag to indicate whether this mode is mandatory
Definition: wifi-mode.h:437
ns3::WifiModeFactory::WifiModeItem::IsModeAllowedCallback
ModeAllowedCallback IsModeAllowedCallback
Callback to check whether the combination of <MCS, channel width (MHz), NSS> is allowed.
Definition: wifi-mode.h:446
ns3::WifiModeFactory::WifiModeItem::mcsValue
uint8_t mcsValue
MCS value.
Definition: wifi-mode.h:438
ns3::WifiMode::GetUid
uint32_t GetUid(void) const
Definition: wifi-mode.cc:153
ns3::operator!=
bool operator!=(Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > a, Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > b)
Inequality test.
Definition: callback.h:1606
ns3::WifiMode::m_uid
uint32_t m_uid
UID.
Definition: wifi-mode.h:191
ns3::WifiModeFactory::GetFactory
static WifiModeFactory * GetFactory()
Return a WifiModeFactory.
Definition: wifi-mode.cc:388
ns3::WifiModeFactory::WifiModeItem::GetCodeRateCallback
CodeRateCallback GetCodeRateCallback
Callback to retrieve code rate of this WifiModeItem.
Definition: wifi-mode.h:439
ns3::WifiModeFactory::WifiModeItem::GetDataRateFromTxVectorCallback
DataRateFromTxVectorCallback GetDataRateFromTxVectorCallback
Callback to calculate data rate in bps of this WifiModeItem using a TXVECTOR as input.
Definition: wifi-mode.h:444
ns3::WifiMode::GetDataRate
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:100
ns3::WifiModeFactory
create WifiMode class instances and keep track of them.
Definition: wifi-mode.h:267
ns3::WifiModeFactory::operator>>
friend std::istream & operator>>(std::istream &is, WifiMode &mode)
Serialize WifiMode from istream (human-readable).
Definition: wifi-mode.cc:51
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
ns3::WifiModeFactory::WifiModeItem::GetPhyRateFromTxVectorCallback
PhyRateFromTxVectorCallback GetPhyRateFromTxVectorCallback
Callback to calculate PHY rate in bps of this WifiModeItem using a TXVECTOR as input.
Definition: wifi-mode.h:442
ns3::WifiModeListIterator
WifiModeList::const_iterator WifiModeListIterator
An iterator for WifiModeList vector.
Definition: wifi-mode.h:258
ns3::WifiMode::IsAllowed
bool IsAllowed(uint16_t channelWidth, uint8_t nss) const
Definition: wifi-mode.cc:60
ns3::WifiMode::GetConstellationSize
uint16_t GetConstellationSize(void) const
Definition: wifi-mode.cc:115
ns3::WifiModulationClass
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
Definition: wifi-phy-common.h:122
ATTRIBUTE_HELPER_HEADER
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type
Definition: attribute-helper.h:390
ns3::WifiMode::GetMcsValue
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:137
ns3::operator>>
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:160