A Discrete-Event Network Simulator
API
wifi-mode.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005,2006,2007 INRIA
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18  * Sébastien Deronne <sebastien.deronne@gmail.com>
19  */
20 
21 #ifndef WIFI_MODE_H
22 #define WIFI_MODE_H
23 
24 #include "wifi-phy-common.h"
25 
26 #include "ns3/attribute-helper.h"
27 #include "ns3/callback.h"
28 
29 #include <vector>
30 
31 namespace ns3
32 {
33 
35 static constexpr uint16_t SU_STA_ID = 65535;
36 
37 class WifiTxVector;
38 
50 class WifiMode
51 {
52  public:
59  bool IsAllowed(uint16_t channelWidth, uint8_t nss) const;
65  bool IsAllowed(const WifiTxVector& txVector) const;
77  uint64_t GetPhyRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const;
87  uint64_t GetPhyRate(const WifiTxVector& txVector, uint16_t staId = SU_STA_ID) const;
93  uint64_t GetPhyRate(uint16_t channelWidth) const;
102  uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const;
109  uint64_t GetDataRate(const WifiTxVector& txVector, uint16_t staId = SU_STA_ID) const;
115  uint64_t GetDataRate(uint16_t channelWidth) const;
116 
120  WifiCodeRate GetCodeRate() const;
124  uint16_t GetConstellationSize() const;
128  uint8_t GetMcsValue() const;
133  std::string GetUniqueName() const;
138  bool IsMandatory() const;
146  uint32_t GetUid() const;
161  uint64_t GetNonHtReferenceRate() const;
167  bool IsHigherCodeRate(WifiMode mode) const;
173  bool IsHigherDataRate(WifiMode mode) const;
174 
181  WifiMode();
188  WifiMode(std::string name);
189 
190  private:
192  friend class WifiModeFactory;
198  WifiMode(uint32_t uid);
199  uint32_t m_uid;
200 };
201 
211 bool operator==(const WifiMode& a, const WifiMode& b);
212 
222 bool operator!=(const WifiMode& a, const WifiMode& b);
223 
233 bool operator<(const WifiMode& a, const WifiMode& b);
234 
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, const WifiTxVector& /* txVector */, uint16_t /* staId */>
306  typedef Callback<uint64_t, const WifiTxVector& /* txVector */, uint16_t /* staId */>
322  typedef Callback<bool, const WifiTxVector& /* txVector */> AllowedCallback;
323 
347  static WifiMode CreateWifiMode(std::string uniqueName,
348  WifiModulationClass modClass,
349  bool isMandatory,
350  CodeRateCallback codeRateCallback,
351  ConstellationSizeCallback constellationSizeCallback,
352  PhyRateCallback phyRateCallback,
353  DataRateCallback dataRateCallback,
354  AllowedCallback isAllowedCallback);
355 
379  static WifiMode CreateWifiMcs(std::string uniqueName,
380  uint8_t mcsValue,
381  WifiModulationClass modClass,
382  bool isMandatory,
383  CodeRateCallback codeRateCallback,
384  ConstellationSizeCallback constellationSizeCallback,
385  PhyRateCallback phyRateCallback,
386  DataRateCallback dataRateCallback,
387  NonHtReferenceRateCallback nonHtReferenceRateCallback,
388  AllowedCallback isAllowedCallback);
389 
390  private:
392  friend class WifiMode;
393  friend std::istream& operator>>(std::istream& is, WifiMode& mode);
394 
400  static WifiModeFactory* GetFactory();
401  WifiModeFactory();
402 
409  {
410  std::string uniqueUid;
412  bool isMandatory;
413  uint8_t mcsValue;
428  };
429 
437  WifiMode Search(std::string name) const;
445  uint32_t AllocateUid(std::string uniqueUid);
453  WifiModeItem* Get(uint32_t uid);
454 
458  typedef std::vector<WifiModeItem> WifiModeItemList;
460 };
461 
462 } // namespace ns3
463 
464 #endif /* WIFI_MODE_H */
create WifiMode class instances and keep track of them.
Definition: wifi-mode.h:275
friend std::istream & operator>>(std::istream &is, WifiMode &mode)
Serialize WifiMode from istream (human-readable).
Definition: wifi-mode.cc:59
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:297
WifiModeItem * Get(uint32_t uid)
Return a WifiModeItem at the given UID index.
Definition: wifi-mode.cc:400
Callback< WifiCodeRate > CodeRateCallback
Typedef for callback used to retrieve code rate of a WifiMode.
Definition: wifi-mode.h:282
static WifiMode CreateWifiMcs(std::string uniqueName, uint8_t mcsValue, WifiModulationClass modClass, bool isMandatory, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, DataRateCallback dataRateCallback, NonHtReferenceRateCallback nonHtReferenceRateCallback, AllowedCallback isAllowedCallback)
Definition: wifi-mode.cc:318
std::vector< WifiModeItem > WifiModeItemList
typedef for a vector of WifiModeItem.
Definition: wifi-mode.h:458
uint32_t AllocateUid(std::string uniqueUid)
Allocate a WifiModeItem from a given uniqueUid.
Definition: wifi-mode.cc:383
static WifiModeFactory * GetFactory()
Return a WifiModeFactory.
Definition: wifi-mode.cc:407
WifiModeItemList m_itemList
item list
Definition: wifi-mode.h:459
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:307
WifiMode Search(std::string name) const
Search and return WifiMode from a given name.
Definition: wifi-mode.cc:350
Callback< uint16_t > ConstellationSizeCallback
Typedef for callback used to retrieve constellation size of a WifiMode.
Definition: wifi-mode.h:287
Callback< bool, const WifiTxVector & > AllowedCallback
Typedef for callback used to check whether a given combination is allowed.
Definition: wifi-mode.h:322
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:315
static WifiMode CreateWifiMode(std::string uniqueName, WifiModulationClass modClass, bool isMandatory, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, DataRateCallback dataRateCallback, AllowedCallback isAllowedCallback)
Definition: wifi-mode.cc:270
represent a single transmission mode
Definition: wifi-mode.h:51
WifiMode()
Create an invalid WifiMode.
Definition: wifi-mode.cc:248
uint32_t GetUid() const
Definition: wifi-mode.cc:179
std::string GetUniqueName() const
Definition: wifi-mode.cc:148
bool IsHigherDataRate(WifiMode mode) const
Definition: wifi-mode.cc:208
uint16_t GetConstellationSize() const
Definition: wifi-mode.cc:141
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:185
uint64_t GetPhyRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:91
bool IsMandatory() const
Definition: wifi-mode.cc:156
uint64_t GetNonHtReferenceRate() const
Definition: wifi-mode.cc:192
WifiCodeRate GetCodeRate() const
Definition: wifi-mode.cc:134
uint32_t m_uid
UID.
Definition: wifi-mode.h:199
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:122
bool IsHigherCodeRate(WifiMode mode) const
Definition: wifi-mode.cc:201
bool IsAllowed(uint16_t channelWidth, uint8_t nss) const
Definition: wifi-mode.cc:68
uint8_t GetMcsValue() const
Definition: wifi-mode.cc:163
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Definition: callback.h:678
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:157
ATTRIBUTE_HELPER_HEADER(ValueClassTest)
WifiModeList::const_iterator WifiModeListIterator
An iterator for WifiModeList vector.
Definition: wifi-mode.h:266
bool operator<(const EventId &a, const EventId &b)
Definition: event-id.h:170
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:183
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
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
static constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
Definition: wifi-mode.h:35
WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
This is the data associated to a unique WifiMode.
Definition: wifi-mode.h:409
WifiModulationClass modClass
modulation class
Definition: wifi-mode.h:411
AllowedCallback IsAllowedCallback
Callback to check whether a given combination of is allowed.
Definition: wifi-mode.h:427
std::string uniqueUid
unique UID
Definition: wifi-mode.h:410
bool isMandatory
flag to indicate whether this mode is mandatory
Definition: wifi-mode.h:412
PhyRateCallback GetPhyRateCallback
Callback to calculate PHY rate in bps of this WifiModeItem.
Definition: wifi-mode.h:420
DataRateCallback GetDataRateCallback
Callback to calculate data rate in bps of this WifiModeItem.
Definition: wifi-mode.h:422
NonHtReferenceRateCallback GetNonHtReferenceRateCallback
Callback to calculate non-HT reference rate of this WifiModeItem.
Definition: wifi-mode.h:424
ConstellationSizeCallback GetConstellationSizeCallback
Callback to retrieve constellation size of this WifiModeItem.
Definition: wifi-mode.h:417
CodeRateCallback GetCodeRateCallback
Callback to retrieve code rate of this WifiModeItem.
Definition: wifi-mode.h:415
Declaration of the following enums: