diff --git a/src/wifi/CMakeLists.txt b/src/wifi/CMakeLists.txt index b7e1ed87f..edd3689b5 100644 --- a/src/wifi/CMakeLists.txt +++ b/src/wifi/CMakeLists.txt @@ -12,6 +12,7 @@ set(source_files helper/wifi-mac-helper.cc helper/wifi-radio-energy-model-helper.cc helper/yans-wifi-helper.cc + model/addba-extension.cc model/adhoc-wifi-mac.cc model/ampdu-subframe-header.cc model/ampdu-tag.cc @@ -164,6 +165,7 @@ set(header_files helper/wifi-mac-helper.h helper/wifi-radio-energy-model-helper.h helper/yans-wifi-helper.h + model/addba-extension.h model/adhoc-wifi-mac.h model/ampdu-subframe-header.h model/ampdu-tag.h diff --git a/src/wifi/model/addba-extension.cc b/src/wifi/model/addba-extension.cc new file mode 100644 index 000000000..5e505d8f2 --- /dev/null +++ b/src/wifi/model/addba-extension.cc @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023 Universita' degli Studi di Napoli Federico II + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Stefano Avallone + */ + +#include "addba-extension.h" + +namespace ns3 +{ + +void +AddbaExtension::Print(std::ostream& os) const +{ + os << "extBufferSize=" << +m_extParamSet.extBufferSize; +} + +WifiInformationElementId +AddbaExtension::ElementId() const +{ + return IE_ADDBA_EXTENSION; +} + +uint16_t +AddbaExtension::GetInformationFieldSize() const +{ + return 1U; // ADDBA Extended Parameter Set field +} + +void +AddbaExtension::SerializeInformationField(Buffer::Iterator start) const +{ + uint8_t extParamSet = m_extParamSet.noFragment | (m_extParamSet.heFragmentOp << 1) | + (m_extParamSet.extBufferSize << 5); + start.WriteU8(extParamSet); +} + +uint16_t +AddbaExtension::DeserializeInformationField(Buffer::Iterator start, uint16_t length) +{ + auto extParamSet = start.ReadU8(); + m_extParamSet.noFragment = extParamSet & 0x01; + m_extParamSet.heFragmentOp = (extParamSet >> 1) & 0x03; + m_extParamSet.extBufferSize = (extParamSet >> 5) & 0x07; + return 1; +} + +} // namespace ns3 diff --git a/src/wifi/model/addba-extension.h b/src/wifi/model/addba-extension.h new file mode 100644 index 000000000..6975def7c --- /dev/null +++ b/src/wifi/model/addba-extension.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 Universita' degli Studi di Napoli Federico II + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Stefano Avallone + */ + +#ifndef ADDBA_EXTENSION_H +#define ADDBA_EXTENSION_H + +#include "wifi-information-element.h" + +namespace ns3 +{ + +/** + * \ingroup wifi + * + * The IEEE 802.11 ADDBA Extension Element (Sec. 9.4.2.139 of 802.11-2020) + */ +class AddbaExtension : public WifiInformationElement +{ + public: + AddbaExtension() = default; + + /** + * ADDBA Extended Parameter Set + */ + struct ExtParamSet + { + uint8_t noFragment : 1; //!< reserved when transmitted by HE STA to HE STA + uint8_t heFragmentOp : 2; //!< indicates level of HE dynamic fragmentation (unsupported) + uint8_t : 2; //!< reserved + uint8_t extBufferSize : 3; //!< extended buffer size + }; + + // Implementations of pure virtual methods of WifiInformationElement + WifiInformationElementId ElementId() const override; + void Print(std::ostream& os) const override; + + ExtParamSet m_extParamSet{}; //!< ADDBA Extended Parameter Set field + + private: + uint16_t GetInformationFieldSize() const override; + void SerializeInformationField(Buffer::Iterator start) const override; + uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override; +}; + +} // namespace ns3 + +#endif /* ADDBA_EXTENSION_H */