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;
115 uint32_t usableSubCarriers = 0;
116 double symbolRate = 0;
117 double codingRate = 0;
121 dataRate = ((11000000 / 11) * numberOfBitsPerSubcarrier);
125 dataRate = ((11000000 / 8) * numberOfBitsPerSubcarrier);
129 usableSubCarriers = 48;
130 switch (channelWidth)
134 symbolRate = (1 / 4.0) * 1e6;
137 symbolRate = (1 / 8.0) * 1e6;
140 symbolRate = (1 / 16.0) * 1e6;
147 codingRate = (3.0 / 4.0);
150 codingRate = (2.0 / 3.0);
153 codingRate = (1.0 / 2.0);
157 NS_FATAL_ERROR (
"trying to get datarate for a mcs without any coding rate defined");
161 dataRate = lrint (ceil (symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate));
167 NS_ASSERT_MSG (channelWidth != 20,
"VHT MCS 9 forbidden at 20 MHz (only allowed when NSS = 3)");
171 NS_ASSERT_MSG (channelWidth != 80,
"VHT MCS 6 forbidden at 80 MHz when NSS = 3");
174 if (!isShortGuardInterval)
176 symbolRate = (1 / 4.0) * 1e6;
180 symbolRate = (1 / 3.6) * 1e6;
183 switch (channelWidth)
187 usableSubCarriers = 52;
190 usableSubCarriers = 108;
193 usableSubCarriers = 234;
196 usableSubCarriers = 468;
203 codingRate = (5.0 / 6.0);
206 codingRate = (3.0 / 4.0);
209 codingRate = (2.0 / 3.0);
212 codingRate = (1.0 / 2.0);
216 NS_FATAL_ERROR (
"trying to get datarate for a mcs without any coding rate defined with nss: " << (uint16_t) nss);
220 dataRate = lrint (ceil (symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate));
224 NS_ASSERT (
"undefined datarate for the modulation class!");
401 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
409 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
417 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
425 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
431 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
439 NS_FATAL_ERROR (
"Trying to get reference rate for a non-HT rate");
547 uint16_t constellationSize)
566 NS_FATAL_ERROR (
"Error in creation of WifiMode named " << uniqueName << std::endl
567 <<
"Code rate must be WIFI_CODE_RATE_UNDEFINED iff Modulation Class is WIFI_MOD_CLASS_DSSS or WIFI_MOD_CLASS_HR_DSSS");
606 WifiModeItemList::const_iterator i;
610 if (i->uniqueUid == name)
621 << name <<
"\". Valid options are:");
642 for (WifiModeItemList::const_iterator i =
m_itemList.begin ();
645 if (i->uniqueUid == uniqueUid)
666 static bool isFirstTime =
true;
670 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)
#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
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.