23 #include "ns3/simulator.h"
24 #include "ns3/assert.h"
75 uint32_t dataRate, phyRate;
76 dataRate =
GetDataRate (channelWidth, isShortGuardInterval, nss);
80 phyRate = dataRate * 6 / 5;
83 phyRate = dataRate * 4 / 3;
86 phyRate = dataRate * 3 / 2;
89 phyRate = dataRate * 2 / 1;
103 uint64_t dataRate = 0;
119 double symbolRate = (1 / 4.0) * 1e6;
121 uint32_t usableSubCarriers;
122 switch (channelWidth)
126 usableSubCarriers = 48;
129 usableSubCarriers = 24;
132 usableSubCarriers = 12;
140 codingRate = (3.0 / 4.0);
143 codingRate = (2.0 / 3.0);
146 codingRate = (1.0 / 2.0);
150 NS_FATAL_ERROR (
"trying to get datarate for a mcs without any coding rate defined");
156 dataRate = lrint (ceil (symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate));
167 if (!isShortGuardInterval)
169 symbolRate = (1 / 4.0) * 1e6;
173 symbolRate = (1 / 3.6) * 1e6;
176 uint32_t usableSubCarriers;
177 switch (channelWidth)
181 usableSubCarriers = 52;
184 usableSubCarriers = 108;
187 usableSubCarriers = 234;
190 usableSubCarriers = 468;
198 codingRate = (5.0 / 6.0);
201 codingRate = (3.0 / 4.0);
204 codingRate = (2.0 / 3.0);
207 codingRate = (1.0 / 2.0);
211 NS_FATAL_ERROR (
"trying to get datarate for a mcs without any coding rate defined");
217 dataRate = lrint (ceil (symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate));
221 NS_ASSERT (
"undefined datarate for the modulation class!");
234 switch (item->
mcsValue - (8 * (nss - 1)))
289 switch (item->
mcsValue - (8 * (nss - 1)))
407 uint16_t constellationSize)
426 NS_FATAL_ERROR (
"Error in creation of WifiMode named " << uniqueName << std::endl
427 <<
"Code rate must be WIFI_CODE_RATE_UNDEFINED iff Modulation Class is WIFI_MOD_CLASS_DSSS or WIFI_MOD_CLASS_HR_DSSS");
466 WifiModeItemList::const_iterator i;
470 if (i->uniqueUid == name)
481 << name <<
"\". Valid options are:");
502 for (WifiModeItemList::const_iterator i =
m_itemList.begin ();
505 if (i->uniqueUid == uniqueUid)
526 static bool isFirstTime =
true;
530 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.
enum WifiCodeRate GetCodeRate(uint8_t nss) const
WifiCodeRate
This enumeration defines the various convolutional coding rates used for the OFDM transmission modes ...
uint16_t GetConstellationSize(uint8_t nss) const
#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...
#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
enum WifiCodeRate codingRate
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
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.
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
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.