11#include "ns3/assert.h"
12#include "ns3/simulator.h"
25 "Presence bitmap not expected if default mapping is set");
37 auto val =
static_cast<uint8_t
>(direction) | ((defaultMapping ? 1 : 0) << 2) |
38 ((mappingSwitchTimePresent ? 1 : 0) << 3) |
39 ((expectedDurationPresent ? 1 : 0) << 4) | ((linkMappingSize == 1 ? 1 : 0) << 5);
43 "Presence bitmap not expected if default mapping is set");
44 if (presenceBitmap.has_value())
46 start.WriteU8(presenceBitmap.value());
55 auto val = i.ReadU8();
59 defaultMapping = (((val >> 2) & 0x01) == 1);
60 mappingSwitchTimePresent = (((val >> 3) & 0x01) == 1);
61 expectedDurationPresent = (((val >> 4) & 0x01) == 1);
62 linkMappingSize = (((val >> 5) & 0x01) == 1 ? 1 : 2);
65 presenceBitmap.reset();
68 presenceBitmap = i.ReadU8();
92 auto switchTimeUsec =
static_cast<uint64_t
>(mappingSwitchTime.
GetMicroSeconds());
108 if (switchTimeUsec < nowUsec)
113 switchTimeUsec += (1 << 26);
121 auto durationTu =
static_cast<uint64_t
>(expectedDuration.
GetMicroSeconds()) >> 10;
142 "Per-TID link mapping not expected if default mapping is set");
145 uint16_t linkMapping = 0;
147 for (
const auto& linkId : linkIds)
149 linkMapping |= (1 << linkId);
170 std::set<uint8_t> linkIds;
171 for (uint8_t linkId = 0; linkId < 15; linkId++)
173 if (((it->second >> linkId) & 0x0001) == 1)
175 linkIds.insert(linkId);
178 NS_ABORT_MSG_IF(linkIds.empty(),
"TID " << +tid <<
" cannot be mapped to an empty link set");
199 "Per-TID link mapping not expected if default mapping is set");
221 "Per-TID link mapping not expected if default mapping is set");
227 start.WriteU8(linkMapping);
231 start.WriteHtolsbU16(linkMapping);
242 NS_ASSERT_MSG(nCtrlOctets <= length,
"Tid-to-Link Mapping deserialize error");
244 count += nCtrlOctets;
252 uint8_t byte0 = i.ReadU8();
253 uint8_t byte1 = i.ReadU8();
254 uint8_t byte2 = i.ReadU8();
266 "Default mapping should not be set when presence bitmap is present");
268 for (uint8_t tid = 0; tid < 8; tid++)
270 if (((presenceBitmap >> tid) & 0x01) == 1)
287 "TID-to-Link Mapping Length (" << +length
289 "from actual number of bytes read ("
iterator in a Buffer instance
static Time Now()
Return the current simulation virtual time.
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)
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
void SerializeInformationField(Buffer::Iterator start) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
std::optional< Time > GetMappingSwitchTime() const
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
std::optional< uint32_t > m_expectedDuration
Expected Duration.
void SetLinkMappingOfTid(uint8_t tid, std::set< uint8_t > linkIds)
Set the Link Mapping field of the given TID such that the given TID is mapped to the links associated...
std::optional< Time > GetExpectedDuration() const
WifiInformationElementId ElementIdExt() const override
Get the wifi information element ID extension.
std::optional< uint16_t > m_mappingSwitchTime
Mapping Switch Time.
std::map< uint8_t, uint16_t > m_linkMapping
TID-indexed Link Mapping.
void SetExpectedDuration(Time expectedDuration)
Set the Expected Duration field.
void SetMappingSwitchTime(Time mappingSwitchTime)
Set the Mapping Switch Time field.
std::set< uint8_t > GetLinkMappingOfTid(uint8_t tid) const
Get the Link Mapping field of the given TID.
TidToLinkMapping::Control m_control
TID-to-link Mapping Control.
Simulation virtual time values and global simulation resolution.
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
constexpr uint16_t WIFI_TID_TO_LINK_MAPPING_CONTROL_BASIC_SIZE_B
size in bytes of the TID-To-Link Control field with default link mapping
static constexpr uint64_t BIT_63_TO_26_MASK
Bitmask with all bits from 63 to 26 set to 1, all the others set to 0.
constexpr uint8_t WIFI_IE_ELEMENT_ID_EXT_SIZE
Size in bytes of the Element ID Extension field (IEEE 802.11-2020 9.4.2.1 General)
WifiDirection
Wifi direction.
constexpr uint16_t WIFI_LINK_MAPPING_PRESENCE_IND_SIZE_B
size in bytes of the Link Mapping Presence Indicator field (IEEE 802.11be D2.0 9.4....
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
bool defaultMapping
Default link mapping.
void Serialize(Buffer::Iterator &start) const
Serialize the TID-to-Link Mapping Control subfield.
bool expectedDurationPresent
Expected Duration Present.
uint16_t GetSubfieldSize() const
bool mappingSwitchTimePresent
These members are private to prevent users to manipulate them directly (their values depend on the va...
uint8_t linkMappingSize
length of the Link Mapping Of TID n field in octets
uint16_t Deserialize(Buffer::Iterator start)
Deserialize the TID-to-Link Mapping Control subfield.
std::optional< uint8_t > presenceBitmap
Link Mapping Presence Indicator.