22 #include "ns3/assert.h"
23 #include "ns3/simulator.h"
36 "Presence bitmap not expected if default mapping is set");
48 auto val =
static_cast<uint8_t
>(direction) | ((defaultMapping ? 1 : 0) << 2) |
49 ((mappingSwitchTimePresent ? 1 : 0) << 3) |
50 ((expectedDurationPresent ? 1 : 0) << 4) | ((linkMappingSize == 1 ? 1 : 0) << 5);
54 "Presence bitmap not expected if default mapping is set");
55 if (presenceBitmap.has_value())
57 start.WriteU8(presenceBitmap.value());
66 auto val = i.ReadU8();
70 defaultMapping = (((val >> 2) & 0x01) == 1);
71 mappingSwitchTimePresent = (((val >> 3) & 0x01) == 1);
72 expectedDurationPresent = (((val >> 4) & 0x01) == 1);
73 linkMappingSize = (((val >> 5) & 0x01) == 1 ? 1 : 2);
76 presenceBitmap.reset();
79 presenceBitmap = i.ReadU8();
103 auto switchTimeUsec =
static_cast<uint64_t
>(mappingSwitchTime.
GetMicroSeconds());
119 if (switchTimeUsec < nowUsec)
124 switchTimeUsec += (1 << 26);
132 auto durationTu =
static_cast<uint64_t
>(expectedDuration.
GetMicroSeconds()) >> 10;
153 "Per-TID link mapping not expected if default mapping is set");
156 uint16_t linkMapping = 0;
158 for (
const auto& linkId : linkIds)
160 linkMapping |= (1 << linkId);
181 std::set<uint8_t> linkIds;
182 for (uint8_t linkId = 0; linkId < 15; linkId++)
184 if (((it->second >> linkId) & 0x0001) == 1)
186 linkIds.insert(linkId);
189 NS_ABORT_MSG_IF(linkIds.empty(),
"TID " << +tid <<
" cannot be mapped to an empty link set");
210 "Per-TID link mapping not expected if default mapping is set");
232 "Per-TID link mapping not expected if default mapping is set");
238 start.WriteU8(linkMapping);
242 start.WriteHtolsbU16(linkMapping);
253 NS_ASSERT_MSG(nCtrlOctets <= length,
"Tid-to-Link Mapping deserialize error");
255 count += nCtrlOctets;
263 uint8_t byte0 = i.ReadU8();
264 uint8_t byte1 = i.ReadU8();
265 uint8_t byte2 = i.ReadU8();
277 "Default mapping should not be set when presence bitmap is present");
279 for (uint8_t tid = 0; tid < 8; tid++)
281 if (((presenceBitmap >> tid) & 0x01) == 1)
298 "TID-to-Link Mapping Length (" << +length
300 "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.