From 338d625f558f6124eb850d8891c036a39d0cb132 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Fri, 12 May 2023 09:37:45 +0200 Subject: [PATCH] wifi: Update TID-to-Link Mapping IE to 802.11be D3.1 --- .../model/eht/tid-to-link-mapping-element.cc | 170 +++++++++++++++--- .../model/eht/tid-to-link-mapping-element.h | 54 ++++-- src/wifi/test/wifi-eht-info-elems-test.cc | 27 +-- 3 files changed, 201 insertions(+), 50 deletions(-) diff --git a/src/wifi/model/eht/tid-to-link-mapping-element.cc b/src/wifi/model/eht/tid-to-link-mapping-element.cc index 9a8feb6ab..63b291ad7 100644 --- a/src/wifi/model/eht/tid-to-link-mapping-element.cc +++ b/src/wifi/model/eht/tid-to-link-mapping-element.cc @@ -17,20 +17,25 @@ * Author: Sharan Naribole */ -#include -#include +#include "tid-to-link-mapping-element.h" + +#include "ns3/assert.h" +#include "ns3/simulator.h" namespace ns3 { +/// Bitmask with all bits from 63 to 26 set to 1, all the others set to 0 +static constexpr uint64_t BIT_63_TO_26_MASK = 0xfffffffffc000000; + uint16_t TidToLinkMapping::Control::GetSubfieldSize() const { - // IEEE 802.11be D2.0 Figure 9-1002an - NS_ASSERT_MSG(defaultMapping != presenceBitmap.has_value(), + // IEEE 802.11be D3.1 Figure 9-1002ap + NS_ASSERT_MSG(!defaultMapping || !presenceBitmap.has_value(), "Presence bitmap not expected if default mapping is set"); auto size = WIFI_TID_TO_LINK_MAPPING_CONTROL_BASIC_SIZE_B; - if (defaultMapping) + if (!presenceBitmap.has_value()) { return size; } @@ -40,10 +45,12 @@ TidToLinkMapping::Control::GetSubfieldSize() const void TidToLinkMapping::Control::Serialize(Buffer::Iterator& start) const { - uint8_t val = static_cast(direction); - val |= ((defaultMapping ? 1 : 0) << 2); + uint8_t val = static_cast(direction) | ((defaultMapping ? 1 : 0) << 2) | + ((mappingSwitchTimePresent ? 1 : 0) << 3) | + ((expectedDurationPresent ? 1 : 0) << 4) | ((linkMappingSize == 1 ? 1 : 0) << 5); + start.WriteU8(val); - NS_ASSERT_MSG(defaultMapping != presenceBitmap.has_value(), + NS_ASSERT_MSG(!defaultMapping || !presenceBitmap.has_value(), "Presence bitmap not expected if default mapping is set"); if (presenceBitmap.has_value()) { @@ -61,8 +68,12 @@ TidToLinkMapping::Control::Deserialize(Buffer::Iterator start) direction = static_cast(val & 0x03); defaultMapping = (((val >> 2) & 0x01) == 1); + mappingSwitchTimePresent = (((val >> 3) & 0x01) == 1); + expectedDurationPresent = (((val >> 4) & 0x01) == 1); + linkMappingSize = (((val >> 5) & 0x01) == 1 ? 1 : 2); if (defaultMapping) { + presenceBitmap.reset(); return count; } presenceBitmap = i.ReadU8(); @@ -82,7 +93,60 @@ TidToLinkMapping::ElementIdExt() const } void -TidToLinkMapping::SetLinkMappingOfTid(uint8_t tid, std::list linkIds) +TidToLinkMapping::SetMappingSwitchTime(Time mappingSwitchTime) +{ + // The 2 octet Mapping Switch Time field has units of TUs and is set to the time at which + // the new mapping is established using as a time-base the value of the TSF corresponding + // to the BSS identified by the BSSID of the frame containing the TID-To-Link Mapping + // element: i.e., bits 10 to 25 of the TSF. (Sec. 9.4.2.314 of 802.11be D3.1) + NS_ABORT_IF(mappingSwitchTime < Simulator::Now()); + auto switchTimeUsec = static_cast(mappingSwitchTime.GetMicroSeconds()); + // set the Mapping Switch Time field to bits 10 to 25 of the given time + m_mappingSwitchTime = (switchTimeUsec & ~BIT_63_TO_26_MASK) >> 10; + m_control.mappingSwitchTimePresent = true; +} + +std::optional