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;
62  bool IsAllowed (const WifiTxVector& txVector) const;
74  uint64_t GetPhyRate (uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const;
84  uint64_t GetPhyRate (const WifiTxVector& txVector, uint16_t staId = SU_STA_ID) const;
90  uint64_t GetPhyRate (uint16_t channelWidth) const;
99  uint64_t GetDataRate (uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const;
106  uint64_t GetDataRate (const WifiTxVector& txVector, uint16_t staId = SU_STA_ID) const;
112  uint64_t GetDataRate (uint16_t channelWidth) const;
113 
117  WifiCodeRate GetCodeRate (void) const;
121  uint16_t GetConstellationSize (void) const;
125  uint8_t GetMcsValue (void) const;
130  std::string GetUniqueName (void) const;
135  bool IsMandatory (void) const;
143  uint32_t GetUid (void) const;
158  uint64_t GetNonHtReferenceRate (void) const;
164  bool IsHigherCodeRate (WifiMode mode) const;
170  bool IsHigherDataRate (WifiMode mode) const;
171 
178  WifiMode ();
185  WifiMode (std::string name);
186 
187 
188 private:
190  friend class WifiModeFactory;
196  WifiMode (uint32_t uid);
197  uint32_t m_uid;
198 };
199 
209 bool operator == (const WifiMode &a, const WifiMode &b);
210 
220 bool operator != (const WifiMode &a, const WifiMode &b);
221 
231 bool operator < (const WifiMode &a, const WifiMode &b);
232 
241 std::ostream & operator << (std::ostream & os, const WifiMode &mode);
250 std::istream & operator >> (std::istream &is, WifiMode &mode);
251 
253 
260 typedef std::vector<WifiMode> WifiModeList;
264 typedef WifiModeList::const_iterator WifiModeListIterator;
265 
273 {
274 public:
275  // Typedefs for callbacks used by WifiModeItem
294  typedef Callback<uint64_t, const WifiTxVector& /* txVector */, uint16_t /* staId */> PhyRateCallback;
303  typedef Callback<uint64_t, const WifiTxVector& /* txVector */, uint16_t /* staId */> DataRateCallback;
318  typedef Callback<bool, const WifiTxVector& /* txVector */> AllowedCallback;
319 
343  static WifiMode CreateWifiMode (std::string uniqueName,
344  WifiModulationClass modClass,
345  bool isMandatory,
346  CodeRateCallback codeRateCallback,
347  ConstellationSizeCallback constellationSizeCallback,
348  PhyRateCallback phyRateCallback,
349  DataRateCallback dataRateCallback,
350  AllowedCallback isAllowedCallback);
351 
374  static WifiMode CreateWifiMcs (std::string uniqueName,
375  uint8_t mcsValue,
376  WifiModulationClass modClass,
377  CodeRateCallback codeRateCallback,
378  ConstellationSizeCallback constellationSizeCallback,
379  PhyRateCallback phyRateCallback,
380  DataRateCallback dataRateCallback,
381  NonHtReferenceRateCallback nonHtReferenceRateCallback,
382  AllowedCallback isAllowedCallback);
383 
384 
385 private:
387  friend class WifiMode;
388  friend std::istream & operator >> (std::istream &is, WifiMode &mode);
389 
395  static WifiModeFactory* GetFactory ();
396  WifiModeFactory ();
397 
404  {
405  std::string uniqueUid;
407  bool isMandatory;
408  uint8_t mcsValue;
415  };
416 
424  WifiMode Search (std::string name) const;
432  uint32_t AllocateUid (std::string uniqueUid);
440  WifiModeItem* Get (uint32_t uid);
441 
445  typedef std::vector<WifiModeItem> WifiModeItemList;
447 };
448 
449 } //namespace ns3
450 
451 #endif /* WIFI_MODE_H */
ns3::WifiModeFactory::WifiModeItem::GetPhyRateCallback
PhyRateCallback GetPhyRateCallback
Callback to calculate PHY rate in bps of this WifiModeItem.
Definition: wifi-mode.h:411
ns3::WifiModeFactory::WifiModeItemList
std::vector< WifiModeItem > WifiModeItemList
typedef for a vector of WifiModeItem.
Definition: wifi-mode.h:445
ns3::WifiModeFactory::Get
WifiModeItem * Get(uint32_t uid)
Return a WifiModeItem at the given UID index.
Definition: wifi-mode.cc:391
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:260
ns3::WifiMode::IsHigherCodeRate
bool IsHigherCodeRate(WifiMode mode) const
Definition: wifi-mode.cc:192
ns3::WifiModeFactory::WifiModeItem
This is the data associated to a unique WifiMode.
Definition: wifi-mode.h:404
ns3::WifiMode::IsMandatory
bool IsMandatory(void) const
Definition: wifi-mode.cc:148
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:405
ns3::WifiModeFactory::WifiModeItem::modClass
WifiModulationClass modClass
modulation class
Definition: wifi-mode.h:406
ns3::WifiModeFactory::WifiModeItem::GetDataRateCallback
DataRateCallback GetDataRateCallback
Callback to calculate data rate in bps of this WifiModeItem.
Definition: wifi-mode.h:412
ns3::WifiMode::IsHigherDataRate
bool IsHigherDataRate(WifiMode mode) const
Definition: wifi-mode.cc:199
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:126
ns3::WifiModeFactory::WifiModeItem::GetNonHtReferenceRateCallback
NonHtReferenceRateCallback GetNonHtReferenceRateCallback
Callback to calculate non-HT reference rate of this WifiModeItem.
Definition: wifi-mode.h:413
ns3::WifiMode::GetModulationClass
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:177
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:410
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::DataRateCallback
Callback< uint64_t, const WifiTxVector &, uint16_t > DataRateCallback
Typedef for callback used to calculate data rate of a WifiMode from a TXVECTOR.
Definition: wifi-mode.h:303
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:311
ns3::WifiModeFactory::Search
WifiMode Search(std::string name) const
Search and return WifiMode from a given name.
Definition: wifi-mode.cc:338
ns3::WifiModeFactory::AllocateUid
uint32_t AllocateUid(std::string uniqueUid)
Allocate a WifiModeItem from a given uniqueUid.
Definition: wifi-mode.cc:373
ns3::WifiModeFactory::AllowedCallback
Callback< bool, const WifiTxVector & > AllowedCallback
Typedef for callback used to check whether a given combination is allowed.
Definition: wifi-mode.h:318
ns3::WifiModeFactory::PhyRateCallback
Callback< uint64_t, const WifiTxVector &, uint16_t > PhyRateCallback
Typedef for callback used to calculate PHY rate of a WifiMode from a TXVECTOR.
Definition: wifi-mode.h:294
ns3::WifiMode::GetNonHtReferenceRate
uint64_t GetNonHtReferenceRate(void) const
Definition: wifi-mode.cc:184
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, DataRateCallback dataRateCallback, NonHtReferenceRateCallback nonHtReferenceRateCallback, AllowedCallback isAllowedCallback)
Definition: wifi-mode.cc:305
ns3::WifiMode::GetUniqueName
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:140
ns3::WifiMode::WifiMode
WifiMode()
Create an invalid WifiMode.
Definition: wifi-mode.cc:238
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:83
ns3::WifiModeFactory::m_itemList
WifiModeItemList m_itemList
item list
Definition: wifi-mode.h:446
ns3::WifiModeFactory::ConstellationSizeCallback
Callback< uint16_t > ConstellationSizeCallback
Typedef for callback used to retrieve constellation size of a WifiMode.
Definition: wifi-mode.h:285
ns3::WifiModeFactory::CodeRateCallback
Callback< WifiCodeRate > CodeRateCallback
Typedef for callback used to retrieve code rate of a WifiMode.
Definition: wifi-mode.h:280
ns3::WifiModeFactory::WifiModeFactory
WifiModeFactory()
Definition: wifi-mode.cc:255
ns3::WifiModeFactory::WifiModeItem::isMandatory
bool isMandatory
flag to indicate whether this mode is mandatory
Definition: wifi-mode.h:407
ns3::WifiModeFactory::WifiModeItem::IsAllowedCallback
AllowedCallback IsAllowedCallback
Callback to check whether a given combination of is allowed.
Definition: wifi-mode.h:414
ns3::WifiModeFactory::WifiModeItem::mcsValue
uint8_t mcsValue
MCS value.
Definition: wifi-mode.h:408
ns3::WifiMode::GetUid
uint32_t GetUid(void) const
Definition: wifi-mode.cc:171
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:197
ns3::WifiModeFactory::GetFactory
static WifiModeFactory * GetFactory()
Return a WifiModeFactory.
Definition: wifi-mode.cc:398
ns3::WifiModeFactory::WifiModeItem::GetCodeRateCallback
CodeRateCallback GetCodeRateCallback
Callback to retrieve code rate of this WifiModeItem.
Definition: wifi-mode.h:409
ns3::WifiMode::GetDataRate
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:114
ns3::WifiModeFactory::CreateWifiMode
static WifiMode CreateWifiMode(std::string uniqueName, WifiModulationClass modClass, bool isMandatory, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, DataRateCallback dataRateCallback, AllowedCallback isAllowedCallback)
Definition: wifi-mode.cc:260
ns3::WifiModeFactory
create WifiMode class instances and keep track of them.
Definition: wifi-mode.h:273
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::WifiModeListIterator
WifiModeList::const_iterator WifiModeListIterator
An iterator for WifiModeList vector.
Definition: wifi-mode.h:264
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:133
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:155
ns3::operator>>
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:160