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));
177 if (!isShortGuardInterval)
179 symbolRate = (1 / 4.0) * 1e6;
183 symbolRate = (1 / 3.6) * 1e6;
186 uint32_t usableSubCarriers;
187 switch (channelWidth)
191 usableSubCarriers = 52;
194 usableSubCarriers = 108;
197 usableSubCarriers = 234;
200 usableSubCarriers = 468;
208 codingRate = (5.0 / 6.0);
211 codingRate = (3.0 / 4.0);
214 codingRate = (2.0 / 3.0);
217 codingRate = (1.0 / 2.0);
221 NS_FATAL_ERROR (
"trying to get datarate for a mcs without any coding rate defined with nss: " << (uint16_t) nss);
227 dataRate = lrint (ceil (symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate));
231 NS_ASSERT (
"undefined datarate for the modulation class!");
408 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
416 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
424 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
432 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
438 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
446 NS_FATAL_ERROR (
"Trying to get reference rate for a non-HT rate");
554 uint16_t constellationSize)
573 NS_FATAL_ERROR (
"Error in creation of WifiMode named " << uniqueName << std::endl
574 <<
"Code rate must be WIFI_CODE_RATE_UNDEFINED iff Modulation Class is WIFI_MOD_CLASS_DSSS or WIFI_MOD_CLASS_HR_DSSS");
613 WifiModeItemList::const_iterator i;
617 if (i->uniqueUid == name)
628 << name <<
"\". Valid options are:");
649 for (WifiModeItemList::const_iterator i =
m_itemList.begin ();
652 if (i->uniqueUid == uniqueUid)
673 static bool isFirstTime =
true;
677 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 ...
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type.
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionaly.
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)
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
bool operator==(const EventId &a, const EventId &b)
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.
This is the data associated to a unique WifiMode.