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 */
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802...
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
WifiMode()
Create an invalid WifiMode.
Definition: wifi-mode.cc:220
CodeRateCallback GetCodeRateCallback
Callback to retrieve code rate of this WifiModeItem.
Definition: wifi-mode.h:439
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
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
Declaration of the following enums:
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
bool IsAllowed(uint16_t channelWidth, uint8_t nss) const
Definition: wifi-mode.cc:60
DataRateFromTxVectorCallback GetDataRateFromTxVectorCallback
Callback to calculate data rate in bps of this WifiModeItem using a TXVECTOR as input.
Definition: wifi-mode.h:444
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:160
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:47
uint32_t GetUid(void) const
Definition: wifi-mode.cc:153
bool IsMandatory(void) const
Definition: wifi-mode.cc:130
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:160
WifiMode Search(std::string name) const
Search and return WifiMode from a given name.
Definition: wifi-mode.cc:328
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
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
Callback< uint16_t > ConstellationSizeCallback
Typedef for callback used to retrieve constellation size of a WifiMode.
Definition: wifi-mode.h:279
PhyRateCallback GetPhyRateCallback
Callback to calculate PHY rate in bps of this WifiModeItem.
Definition: wifi-mode.h:441
uint32_t m_uid
UID.
Definition: wifi-mode.h:191
NonHtReferenceRateCallback GetNonHtReferenceRateCallback
Callback to calculate non-HT reference rate of this WifiModeItem.
Definition: wifi-mode.h:445
WifiModeItemList m_itemList
item list
Definition: wifi-mode.h:478
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:159
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:122
WifiModulationClass modClass
modulation class
Definition: wifi-mode.h:436
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
uint16_t WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
PhyRateFromTxVectorCallback GetPhyRateFromTxVectorCallback
Callback to calculate PHY rate in bps of this WifiModeItem using a TXVECTOR as input.
Definition: wifi-mode.h:442
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
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsHigherCodeRate(WifiMode mode) const
Definition: wifi-mode.cc:174
WifiModeList::const_iterator WifiModeListIterator
An iterator for WifiModeList vector.
Definition: wifi-mode.h:258
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
uint16_t GetConstellationSize(void) const
Definition: wifi-mode.cc:115
uint64_t GetNonHtReferenceRate(void) const
Definition: wifi-mode.cc:166
create WifiMode class instances and keep track of them.
Definition: wifi-mode.h:266
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
Callback< WifiCodeRate > CodeRateCallback
Typedef for callback used to retrieve code rate of a WifiMode.
Definition: wifi-mode.h:274
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:142
uint64_t GetPhyRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:73
static WifiModeFactory * GetFactory()
Return a WifiModeFactory.
Definition: wifi-mode.cc:388
ModeAllowedCallback IsModeAllowedCallback
Callback to check whether the combination of <MCS, channel width (MHz), NSS> is allowed.
Definition: wifi-mode.h:446
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
uint32_t AllocateUid(std::string uniqueUid)
Allocate a WifiModeItem from a given uniqueUid.
Definition: wifi-mode.cc:363
WifiCodeRate GetCodeRate(void) const
Definition: wifi-mode.cc:108
std::vector< WifiModeItem > WifiModeItemList
typedef for a vector of WifiModeItem.
Definition: wifi-mode.h:477
WifiModeItem * Get(uint32_t uid)
Return a WifiModeItem at the given UID index.
Definition: wifi-mode.cc:381
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:137
bool isMandatory
flag to indicate whether this mode is mandatory
Definition: wifi-mode.h:437
friend std::istream & operator>>(std::istream &is, WifiMode &mode)
Serialize WifiMode from istream (human-readable).
Definition: wifi-mode.cc:51
bool IsHigherDataRate(WifiMode mode) const
Definition: wifi-mode.cc:181
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type
ConstellationSizeCallback GetConstellationSizeCallback
Callback to retrieve constellation size of this WifiModeItem.
Definition: wifi-mode.h:440
#define SU_STA_ID
Definition: wifi-mode.h:32
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:100
This is the data associated to a unique WifiMode.
Definition: wifi-mode.h:433
std::string uniqueUid
unique UID
Definition: wifi-mode.h:435
DataRateCallback GetDataRateCallback
Callback to calculate data rate in bps of this WifiModeItem.
Definition: wifi-mode.h:443