24 #include "ns3/simulator.h"
25 #include "ns3/assert.h"
78 uint32_t dataRate, phyRate;
79 dataRate =
GetDataRate (channelWidth, isShortGuardInterval, nss);
83 phyRate = dataRate * 6 / 5;
86 phyRate = dataRate * 4 / 3;
89 phyRate = dataRate * 3 / 2;
92 phyRate = dataRate * 2 / 1;
114 uint64_t dataRate = 0;
125 double symbolRate = (1 / 4.0) * 1e6;
127 uint32_t usableSubCarriers;
128 switch (channelWidth)
132 usableSubCarriers = 48;
135 usableSubCarriers = 24;
138 usableSubCarriers = 12;
146 codingRate = (3.0 / 4.0);
149 codingRate = (2.0 / 3.0);
152 codingRate = (1.0 / 2.0);
156 NS_FATAL_ERROR (
"trying to get datarate for a mcs without any coding rate defined");
162 dataRate = lrint (ceil (symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate));
168 NS_ASSERT_MSG (channelWidth != 20,
"VHT MCS 9 forbidden at 20 MHz (only allowed when NSS = 3)");
172 NS_ASSERT_MSG (channelWidth != 80,
"VHT MCS 6 forbidden at 80 MHz when NSS = 3");
175 if (!isShortGuardInterval)
177 symbolRate = (1 / 4.0) * 1e6;
181 symbolRate = (1 / 3.6) * 1e6;
184 uint32_t usableSubCarriers;
185 switch (channelWidth)
189 usableSubCarriers = 52;
192 usableSubCarriers = 108;
195 usableSubCarriers = 234;
198 usableSubCarriers = 468;
206 codingRate = (5.0 / 6.0);
209 codingRate = (3.0 / 4.0);
212 codingRate = (2.0 / 3.0);
215 codingRate = (1.0 / 2.0);
219 NS_FATAL_ERROR (
"trying to get datarate for a mcs without any coding rate defined with nss: " << (uint16_t) nss);
225 dataRate = lrint (ceil (symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate));
229 NS_ASSERT (
"undefined datarate for the modulation class!");
406 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
414 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
422 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
430 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
436 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
444 NS_FATAL_ERROR (
"Trying to get reference rate for a non-HT rate");
552 uint16_t constellationSize)
571 NS_FATAL_ERROR (
"Error in creation of WifiMode named " << uniqueName << std::endl
572 <<
"Code rate must be WIFI_CODE_RATE_UNDEFINED iff Modulation Class is WIFI_MOD_CLASS_DSSS or WIFI_MOD_CLASS_HR_DSSS");
611 WifiModeItemList::const_iterator i;
615 if (i->uniqueUid == name)
626 << name <<
"\". Valid options are:");
647 for (WifiModeItemList::const_iterator i =
m_itemList.begin ();
650 if (i->uniqueUid == uniqueUid)
671 static bool isFirstTime =
true;
675 uint32_t uid = factory.
AllocateUid (
"Invalid-WifiMode");
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
WifiMode()
Create an invalid WifiMode.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiCodeRate
This enumeration defines the various convolutional coding rates used for the OFDM transmission modes ...
enum WifiModulationClass GetModulationClass() const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
bool IsShortGuardInterval(void) const
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
bool IsMandatory(void) const
static WifiMode CreateWifiMcs(std::string uniqueName, uint8_t mcsValue, enum WifiModulationClass modClass)
Modulation class unknown or unspecified.
WifiModeItem * Get(uint32_t uid)
Return a WifiModeItem at the given uid index.
uint64_t GetPhyRate(uint32_t channelWidth, bool isShortGuardInterval, uint8_t nss) const
uint16_t GetConstellationSize(void) const
bool IsHigherDataRate(WifiMode mode) const
enum WifiCodeRate GetCodeRate(void) const
enum WifiCodeRate codingRate
uint32_t GetChannelWidth(void) const
uint8_t GetMcsValue(void) const
std::string GetUniqueName(void) const
WifiModeItemList m_itemList
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionaly.
bool operator==(const BleAccessAddress &a, const BleAccessAddress &b)
uint64_t GetDataRate(uint32_t channelWidth, bool isShortGuardInterval, uint8_t nss) const
uint16_t constellationSize
uint64_t GetNonHtReferenceRate(void) const
static WifiMode CreateWifiMode(std::string uniqueName, enum WifiModulationClass modClass, bool isMandatory, enum WifiCodeRate codingRate, uint16_t constellationSize)
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
No explicit coding (e.g., DSSS rates)
create WifiMode class instances and keep track of them.
uint8_t GetNss(void) const
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
bool IsHigherCodeRate(WifiMode mode) const
static WifiModeFactory * GetFactory()
Return a WifiModeFactory.
uint32_t AllocateUid(std::string uniqueUid)
Allocate a WifiModeItem from a given uniqueUid.
enum WifiModulationClass modClass
uint32_t GetUid(void) const
WifiMode Search(std::string name)
Search and return WifiMode from a given name.
ATTRIBUTE_HELPER_CPP(BleAccessAddress)
This is the data associated to a unique WifiMode.