24 #include "ns3/abort.h"
25 #include "ns3/address-utils.h"
60 uint8_t operatingClass = 0;
61 uint8_t channelNumber =
channel.GetNumber();
71 else if (
channel.GetWidth() == 40)
79 if (channelNumber == 36 || channelNumber == 40 || channelNumber == 44 ||
84 else if (channelNumber == 52 || channelNumber == 56 || channelNumber == 60 ||
89 else if (channelNumber == 100 || channelNumber == 104 || channelNumber == 108 ||
90 channelNumber == 112 || channelNumber == 116 || channelNumber == 120 ||
91 channelNumber == 124 || channelNumber == 128 || channelNumber == 132 ||
92 channelNumber == 136 || channelNumber == 140 || channelNumber == 144)
96 else if (channelNumber == 149 || channelNumber == 153 || channelNumber == 157 ||
97 channelNumber == 161 || channelNumber == 165 || channelNumber == 169 ||
98 channelNumber == 173 || channelNumber == 177 || channelNumber == 181)
100 operatingClass = 125;
103 else if (
channel.GetWidth() == 40)
105 if (channelNumber == 38 || channelNumber == 46)
107 operatingClass = 116;
109 else if (channelNumber == 54 || channelNumber == 62)
111 operatingClass = 119;
113 else if (channelNumber == 102 || channelNumber == 110 || channelNumber == 118 ||
114 channelNumber == 126 || channelNumber == 134 || channelNumber == 142)
116 operatingClass = 122;
118 else if (channelNumber == 151 || channelNumber == 159 || channelNumber == 167 ||
119 channelNumber == 175)
121 operatingClass = 126;
124 else if (
channel.GetWidth() == 80)
126 if (channelNumber == 42 || channelNumber == 58 || channelNumber == 106 ||
127 channelNumber == 122 || channelNumber == 138 || channelNumber == 155 ||
128 channelNumber == 171)
130 operatingClass = 128;
133 else if (
channel.GetWidth() == 160)
135 if (channelNumber == 50 || channelNumber == 114 || channelNumber == 163)
137 operatingClass = 129;
144 operatingClass = 131;
146 else if (
channel.GetWidth() == 40)
148 operatingClass = 132;
150 else if (
channel.GetWidth() == 80)
152 operatingClass = 133;
154 else if (
channel.GetWidth() == 160)
156 operatingClass = 134;
161 NS_ABORT_MSG(
"The provided channel has an unspecified PHY band");
166 "Operating class not found for channel number "
167 << channelNumber <<
" width " <<
channel.GetWidth() <<
" MHz "
168 <<
"band " <<
channel.GetPhyBand());
171 uint16_t startingFreq = 0;
186 NS_ABORT_MSG(
"The provided channel has an unspecified PHY band");
190 uint8_t primaryChannelNumber =
191 (
channel.GetPrimaryChannelCenterFrequency(20) - startingFreq) / 5;
259 uint16_t startingFreq = 0;
279 uint16_t primaryChannelCenterFrequency = startingFreq + primaryChannelNumber * 5;
281 uint8_t channelNumber = 0;
282 uint16_t frequency = 0;
287 std::get<4>(
channel) == band &&
288 primaryChannelCenterFrequency > std::get<1>(
channel) - width / 2 &&
289 primaryChannelCenterFrequency < std::get<1>(
channel) + width / 2)
307 if (std::get<1>(
channel) == primaryChannelCenterFrequency)
313 if (std::get<1>(
channel) == primaryChannelCenterFrequency + 10 ||
314 std::get<1>(
channel) == primaryChannelCenterFrequency - 10)
320 NS_ABORT_MSG(
"No channel of width " << width <<
" MHz in the 2.4 GHz band");
326 channelNumber = std::get<0>(
channel);
327 frequency = std::get<1>(
channel);
338 uint16_t channelLowestFreq = frequency - width / 2;
339 uint16_t primaryChannelLowestFreq = primaryChannelCenterFrequency - 10;
340 channel.SetPrimary20Index((primaryChannelLowestFreq - channelLowestFreq) / 20);
368 if (it->hasBssid && !it->hasShortSsid && !it->hasBssParams && !it->has20MHzPsd &&
373 else if (it->hasBssid && it->hasShortSsid && it->hasBssParams && it->has20MHzPsd &&
380 NS_ABORT_MSG(
"Unsupported TBTT Information field contents");
384 it->tbttInfoHdr.tbttInfoLength = length;
394 switch (it->tbttInfoHdr.tbttInfoLength)
398 it->hasShortSsid =
false;
399 it->hasBssParams =
false;
400 it->has20MHzPsd =
false;
401 it->hasMldParams =
false;
405 it->hasShortSsid =
true;
406 it->hasBssParams =
true;
407 it->has20MHzPsd =
true;
408 it->hasMldParams =
true;
412 "Unsupported TBTT Information Length value: " << it->tbttInfoHdr.tbttInfoLength);
450 m_nbrApInfoFields.at(nbrApInfoId).tbttInformationSet.at(index).shortSsid = shortSsid;
475 uint8_t bssParameters)
480 m_nbrApInfoFields.at(nbrApInfoId).tbttInformationSet.at(index).bssParameters = bssParameters;
499 return m_nbrApInfoFields.at(nbrApInfoId).tbttInformationSet.at(index).bssParameters;
508 m_nbrApInfoFields.at(nbrApInfoId).tbttInformationSet.at(index).psd20MHz = psd20MHz;
540 auto it = std::next(
m_nbrApInfoFields.at(nbrApInfoId).tbttInformationSet.begin(), index);
541 it->mldParameters.mldId = mldId;
542 it->mldParameters.linkId = (linkId & 0x0f);
543 it->mldParameters.bssParamsChangeCount = changeCount;
562 return m_nbrApInfoFields.at(nbrApInfoId).tbttInformationSet.at(index).mldParameters.mldId;
571 return m_nbrApInfoFields.at(nbrApInfoId).tbttInformationSet.at(index).mldParameters.linkId &
603 size += 1 * neighborApInfo.tbttInformationSet.size();
605 if (neighborApInfo.hasBssid)
607 size += 6 * neighborApInfo.tbttInformationSet.size();
609 if (neighborApInfo.hasShortSsid)
611 size += 4 * neighborApInfo.tbttInformationSet.size();
613 if (neighborApInfo.hasBssParams)
615 size += 1 * neighborApInfo.tbttInformationSet.size();
617 if (neighborApInfo.has20MHzPsd)
619 size += 1 * neighborApInfo.tbttInformationSet.size();
621 if (neighborApInfo.hasMldParams)
623 size += 3 * neighborApInfo.tbttInformationSet.size();
642 uint16_t tbttInfoHdr = 0;
643 tbttInfoHdr |= neighborApInfo.tbttInfoHdr.type;
644 tbttInfoHdr |= (neighborApInfo.tbttInfoHdr.filtered << 2);
645 tbttInfoHdr |= (neighborApInfo.tbttInfoHdr.tbttInfoCount << 4);
646 tbttInfoHdr |= (neighborApInfo.tbttInfoHdr.tbttInfoLength << 8);
647 start.WriteHtolsbU16(tbttInfoHdr);
649 start.WriteU8(neighborApInfo.operatingClass);
650 start.WriteU8(neighborApInfo.channelNumber);
652 for (
const auto& tbttInformation : neighborApInfo.tbttInformationSet)
654 start.WriteU8(tbttInformation.neighborApTbttOffset);
656 if (neighborApInfo.hasBssid)
660 if (neighborApInfo.hasShortSsid)
662 start.WriteHtolsbU32(tbttInformation.shortSsid);
664 if (neighborApInfo.hasBssParams)
666 start.WriteU8(tbttInformation.bssParameters);
668 if (neighborApInfo.has20MHzPsd)
670 start.WriteU8(tbttInformation.psd20MHz);
672 if (neighborApInfo.hasMldParams)
674 start.WriteU8(tbttInformation.mldParameters.mldId);
676 other |= (tbttInformation.mldParameters.linkId & 0x0f);
677 other |= (tbttInformation.mldParameters.bssParamsChangeCount << 4);
678 start.WriteHtolsbU16(other);
690 while (count < length)
697 m_nbrApInfoFields.back().tbttInfoHdr.tbttInfoCount = (tbttInfoHdr >> 4) & 0x000f;
698 m_nbrApInfoFields.back().tbttInfoHdr.tbttInfoLength = (tbttInfoHdr >> 8) & 0x00ff;
742 .tbttInformationSet.back()
743 .mldParameters.bssParamsChangeCount = (other >> 4) & 0x00ff;
iterator in a Buffer instance
void WriteTbttInformationLength(std::size_t nbrApInfoId) const
Set the TBTT Information Length field of the given Neighbor AP Information field based on the xxxPres...
Mac48Address GetBssid(std::size_t nbrApInfoId, std::size_t index) const
Get the BSSID field (must be present) in the i-th TBTT Information field of the given Neighbor AP Inf...
std::vector< NeighborApInformation > m_nbrApInfoFields
one or more Neighbor AP Information fields
void SerializeInformationField(Buffer::Iterator start) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
bool HasShortSsid(std::size_t nbrApInfoId) const
Return true if the Short SSID field is present in all the TBTT Information fields of the given Neighb...
std::size_t GetNNbrApInfoFields() const
Get the number of Neighbor AP Information fields.
void WriteTbttInformationCount(std::size_t nbrApInfoId) const
Set the TBTT Information Count field of the given Neighbor AP Information field based on the size of ...
bool HasBssid(std::size_t nbrApInfoId) const
Return true if the BSSID field is present in all the TBTT Information fields of the given Neighbor AP...
uint8_t ReadTbttInformationCount(std::size_t nbrApInfoId) const
Get the TBTT Information Count field of the given Neighbor AP Information field.
void SetMldParameters(std::size_t nbrApInfoId, std::size_t index, uint8_t mldId, uint8_t linkId, uint8_t changeSequence)
Set the MLD Parameters subfield of the i-th TBTT Information field of the given Neighbor AP Informati...
void SetShortSsid(std::size_t nbrApInfoId, std::size_t index, uint32_t shortSsid)
Set the Short SSID field of the i-th TBTT Information field of the given Neighbor AP Information fiel...
uint32_t GetShortSsid(std::size_t nbrApInfoId, std::size_t index) const
Get the Short SSID field (must be present) in the i-th TBTT Information field of the given Neighbor A...
void SetBssid(std::size_t nbrApInfoId, std::size_t index, Mac48Address bssid)
Set the BSSID field of the i-th TBTT Information field of the given Neighbor AP Information field.
std::size_t GetNTbttInformationFields(std::size_t nbrApInfoId) const
Get the number of TBTT Information fields included in the TBTT Information Set field of the given Nei...
uint8_t GetLinkId(std::size_t nbrApInfoId, std::size_t index) const
Get the Link ID value in the MLD Parameters subfield (must be present) in the i-th TBTT Information f...
uint8_t GetMldId(std::size_t nbrApInfoId, std::size_t index) const
Get the MLD ID value in the MLD Parameters subfield (must be present) in the i-th TBTT Information fi...
void SetPsd20MHz(std::size_t nbrApInfoId, std::size_t index, uint8_t psd20MHz)
Set the 20 MHz PSD field of the i-th TBTT Information field of the given Neighbor AP Information fiel...
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
void AddNbrApInfoField()
Add a Neighbor AP Information field.
WifiPhyOperatingChannel GetOperatingChannel(std::size_t nbrApInfoId) const
Get the operating channel coded into the Operating Class and the Channel Number fields of the given N...
void SetBssParameters(std::size_t nbrApInfoId, std::size_t index, uint8_t bssParameters)
Set the BSS Parameters field of the i-th TBTT Information field of the given Neighbor AP Information ...
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
uint8_t GetPsd20MHz(std::size_t nbrApInfoId, std::size_t index) const
Get the 20 MHz PSD field (must be present) in the i-th TBTT Information field of the given Neighbor A...
bool HasMldParameters(std::size_t nbrApInfoId) const
Return true if the MLD Parameters subfield is present in all the TBTT Information fields of the given...
void AddTbttInformationField(std::size_t nbrApInfoId)
Add a TBTT Information fields to the TBTT Information Set field of the given Neighbor AP Information ...
void ReadTbttInformationLength(std::size_t nbrApInfoId)
Use the TBTT Information Length field of the given Neighbor AP Information field to set the xxxPresen...
bool HasBssParameters(std::size_t nbrApInfoId) const
Return true if the BSS Parameters field is present in all the TBTT Information fields of the given Ne...
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
void SetOperatingChannel(std::size_t nbrApInfoId, const WifiPhyOperatingChannel &channel)
Set the Operating Class and the Channel Number fields of the given Neighbor AP Information field base...
bool HasPsd20MHz(std::size_t nbrApInfoId) const
Return true if the 20 MHz PSD field is present in all the TBTT Information fields of the given Neighb...
uint8_t GetBssParameters(std::size_t nbrApInfoId, std::size_t index) const
Get the BSS Parameters field (must be present) in the i-th TBTT Information field of the given Neighb...
Class that keeps track of all information about the current PHY operating channel.
static const std::set< FrequencyChannelInfo > m_frequencyChannels
Available frequency channels.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
WifiPhyBand
Identifies the PHY band.
@ WIFI_STANDARD_UNSPECIFIED
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
@ WIFI_PHY_BAND_UNSPECIFIED
Unspecified.
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.