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 
44 {
55 };
56 
68 class WifiMode
69 {
70 public:
77  bool IsAllowed (uint16_t channelWidth, uint8_t nss) const;
89  uint64_t GetPhyRate (uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const;
99  uint64_t GetPhyRate (const WifiTxVector& txVector, uint16_t staId = SU_STA_ID) const;
105  uint64_t GetPhyRate (uint16_t channelWidth) const;
114  uint64_t GetDataRate (uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const;
121  uint64_t GetDataRate (const WifiTxVector& txVector, uint16_t staId = SU_STA_ID) const;
127  uint64_t GetDataRate (uint16_t channelWidth) const;
128 
132  WifiCodeRate GetCodeRate (void) const;
136  uint16_t GetConstellationSize (void) const;
140  uint8_t GetMcsValue (void) const;
145  std::string GetUniqueName (void) const;
150  bool IsMandatory (void) const;
158  uint32_t GetUid (void) const;
173  uint64_t GetNonHtReferenceRate (void) const;
179  bool IsHigherCodeRate (WifiMode mode) const;
185  bool IsHigherDataRate (WifiMode mode) const;
186 
193  WifiMode ();
200  WifiMode (std::string name);
201 
202 
203 private:
205  friend class WifiModeFactory;
211  WifiMode (uint32_t uid);
212  uint32_t m_uid;
213 };
214 
224 bool operator == (const WifiMode &a, const WifiMode &b);
234 bool operator < (const WifiMode &a, const WifiMode &b);
243 std::ostream & operator << (std::ostream & os, const WifiMode &mode);
252 std::istream & operator >> (std::istream &is, WifiMode &mode);
253 
255 
262 typedef std::vector<WifiMode> WifiModeList;
266 typedef WifiModeList::const_iterator WifiModeListIterator;
267 
275 {
276 public:
277  // Typedefs for callbacks used by WifiModeItem
296  typedef Callback<uint64_t, uint16_t /* channelWidth */, uint16_t /* guardInterval */, uint8_t /* nss */> PhyRateCallback;
306  typedef Callback<uint64_t, const WifiTxVector& /* txVector */, uint16_t /* staId */> PhyRateFromTxVectorCallback;
315  typedef Callback<uint64_t, uint16_t /* channelWidth */, uint16_t /* guardInterval */, uint8_t /* nss */> DataRateCallback;
325  typedef Callback<uint64_t, const WifiTxVector& /* txVector */, uint16_t /* staId */> DataRateFromTxVectorCallback;
342  typedef Callback<bool, uint16_t /* channelWidth */, uint8_t /* nss */> ModeAllowedCallback;
343 
372  static WifiMode CreateWifiMode (std::string uniqueName,
373  WifiModulationClass modClass,
374  bool isMandatory,
375  CodeRateCallback codeRateCallback,
376  ConstellationSizeCallback constellationSizeCallback,
377  PhyRateCallback phyRateCallback,
378  PhyRateFromTxVectorCallback phyRateFromTxVectorCallback,
379  DataRateCallback dataRateCallback,
380  DataRateFromTxVectorCallback dataRateFromTxVectorCallback,
381  ModeAllowedCallback isModeAllowedCallback);
382 
410  static WifiMode CreateWifiMcs (std::string uniqueName,
411  uint8_t mcsValue,
412  WifiModulationClass modClass,
413  CodeRateCallback codeRateCallback,
414  ConstellationSizeCallback constellationSizeCallback,
415  PhyRateCallback phyRateCallback,
416  PhyRateFromTxVectorCallback phyRateFromTxVectorCallback,
417  DataRateCallback dataRateCallback,
418  DataRateFromTxVectorCallback dataRateFromTxVectorCallback,
419  NonHtReferenceRateCallback nonHtReferenceRateCallback,
420  ModeAllowedCallback isModeAllowedCallback);
421 
422 
423 private:
425  friend class WifiMode;
426  friend std::istream & operator >> (std::istream &is, WifiMode &mode);
427 
433  static WifiModeFactory* GetFactory ();
434  WifiModeFactory ();
435 
442  {
443  std::string uniqueUid;
445  bool isMandatory;
446  uint8_t mcsValue;
455  };
456 
464  WifiMode Search (std::string name) const;
472  uint32_t AllocateUid (std::string uniqueUid);
480  WifiModeItem* Get (uint32_t uid);
481 
485  typedef std::vector<WifiModeItem> WifiModeItemList;
487 };
488 
489 } //namespace ns3
490 
491 #endif /* WIFI_MODE_H */
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802...
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:48
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:342
WifiMode()
Create an invalid WifiMode.
Definition: wifi-mode.cc:215
CodeRateCallback GetCodeRateCallback
Callback to retrieve code rate of this WifiModeItem.
Definition: wifi-mode.h:447
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:296
WifiCodeRate
This enumeration defines the various convolutional coding rates used for the OFDM transmission modes ...
Definition: wifi-mode.h:43
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:306
bool IsAllowed(uint16_t channelWidth, uint8_t nss) const
Definition: wifi-mode.cc:55
DataRateFromTxVectorCallback GetDataRateFromTxVectorCallback
Callback to calculate data rate in bps of this WifiModeItem using a TXVECTOR as input.
Definition: wifi-mode.h:452
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:68
uint32_t GetUid(void) const
Definition: wifi-mode.cc:148
bool IsMandatory(void) const
Definition: wifi-mode.cc:125
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:323
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:286
Callback< uint16_t > ConstellationSizeCallback
Typedef for callback used to retrieve constellation size of a WifiMode.
Definition: wifi-mode.h:287
PhyRateCallback GetPhyRateCallback
Callback to calculate PHY rate in bps of this WifiModeItem.
Definition: wifi-mode.h:449
uint32_t m_uid
UID.
Definition: wifi-mode.h:212
NonHtReferenceRateCallback GetNonHtReferenceRateCallback
Callback to calculate non-HT reference rate of this WifiModeItem.
Definition: wifi-mode.h:453
WifiModeItemList m_itemList
item list
Definition: wifi-mode.h:486
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:154
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:117
WifiModulationClass modClass
modulation class
Definition: wifi-mode.h:444
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:315
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
PhyRateFromTxVectorCallback GetPhyRateFromTxVectorCallback
Callback to calculate PHY rate in bps of this WifiModeItem using a TXVECTOR as input.
Definition: wifi-mode.h:450
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:237
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsHigherCodeRate(WifiMode mode) const
Definition: wifi-mode.cc:169
WifiModeList::const_iterator WifiModeListIterator
An iterator for WifiModeList vector.
Definition: wifi-mode.h:266
std::vector< WifiMode > WifiModeList
In various parts of the code, folk are interested in maintaining a list of transmission modes...
Definition: wifi-mode.h:262
uint16_t GetConstellationSize(void) const
Definition: wifi-mode.cc:110
uint64_t GetNonHtReferenceRate(void) const
Definition: wifi-mode.cc:161
No explicit coding (e.g., DSSS rates)
Definition: wifi-mode.h:46
create WifiMode class instances and keep track of them.
Definition: wifi-mode.h:274
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:325
Callback< WifiCodeRate > CodeRateCallback
Typedef for callback used to retrieve code rate of a WifiMode.
Definition: wifi-mode.h:282
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:68
static WifiModeFactory * GetFactory()
Return a WifiModeFactory.
Definition: wifi-mode.cc:383
ModeAllowedCallback IsModeAllowedCallback
Callback to check whether the combination of <MCS, channel width (MHz), NSS> is allowed.
Definition: wifi-mode.h:454
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:333
uint32_t AllocateUid(std::string uniqueUid)
Allocate a WifiModeItem from a given uniqueUid.
Definition: wifi-mode.cc:358
WifiCodeRate GetCodeRate(void) const
Definition: wifi-mode.cc:103
std::vector< WifiModeItem > WifiModeItemList
typedef for a vector of WifiModeItem.
Definition: wifi-mode.h:485
WifiModeItem * Get(uint32_t uid)
Return a WifiModeItem at the given UID index.
Definition: wifi-mode.cc:376
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:132
bool isMandatory
flag to indicate whether this mode is mandatory
Definition: wifi-mode.h:445
friend std::istream & operator>>(std::istream &is, WifiMode &mode)
Serialize WifiMode from istream (human-readable).
Definition: wifi-mode.cc:46
bool IsHigherDataRate(WifiMode mode) const
Definition: wifi-mode.cc:176
#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:448
#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:95
This is the data associated to a unique WifiMode.
Definition: wifi-mode.h:441
std::string uniqueUid
unique UID
Definition: wifi-mode.h:443
DataRateCallback GetDataRateCallback
Callback to calculate data rate in bps of this WifiModeItem.
Definition: wifi-mode.h:451