From 9861301ea52e132212e7a90f7e6310c2da5e42eb Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Tue, 22 Aug 2023 19:26:46 +0200 Subject: [PATCH] wifi: ADDBA Request/Response frames optionally support GCR Group Address --- src/wifi/model/mgt-action-headers.cc | 75 +++++++++++++++++++++++++++- src/wifi/model/mgt-action-headers.h | 51 +++++++++++++------ 2 files changed, 110 insertions(+), 16 deletions(-) diff --git a/src/wifi/model/mgt-action-headers.cc b/src/wifi/model/mgt-action-headers.cc index 0f4b76102..a2976c853 100644 --- a/src/wifi/model/mgt-action-headers.cc +++ b/src/wifi/model/mgt-action-headers.cc @@ -11,6 +11,7 @@ #include "mgt-action-headers.h" #include "addba-extension.h" +#include "gcr-group-address.h" #include "ns3/multi-link-element.h" #include "ns3/packet.h" @@ -742,6 +743,10 @@ MgtAddBaRequestHeader::Print(std::ostream& os) const os << "A-MSDU support=" << m_amsduSupport << " Policy=" << +m_policy << " TID=" << +m_tid << " Buffer size=" << m_bufferSize << " Timeout=" << m_timeoutValue << " Starting seq=" << m_startingSeq; + if (m_gcrGroupAddress.has_value()) + { + os << " GCR group address=" << m_gcrGroupAddress.value(); + } } uint32_t @@ -752,6 +757,11 @@ MgtAddBaRequestHeader::GetSerializedSize() const size += 2; // Block ack parameter set size += 2; // Block ack timeout value size += 2; // Starting sequence control + if (m_gcrGroupAddress) + { + // a GCR Group Address element has to be added + size += GcrGroupAddress().GetSerializedSize(); + } if (m_bufferSize >= 1024) { // an ADDBA Extension element has to be added @@ -768,6 +778,12 @@ MgtAddBaRequestHeader::Serialize(Buffer::Iterator start) const i.WriteHtolsbU16(GetParameterSet()); i.WriteHtolsbU16(m_timeoutValue); i.WriteHtolsbU16(GetStartingSequenceControl()); + if (m_gcrGroupAddress) + { + GcrGroupAddress gcrGroupAddr; + gcrGroupAddr.m_gcrGroupAddress = *m_gcrGroupAddress; + i = gcrGroupAddr.Serialize(i); + } if (m_bufferSize >= 1024) { AddbaExtension addbaExt; @@ -784,8 +800,16 @@ MgtAddBaRequestHeader::Deserialize(Buffer::Iterator start) SetParameterSet(i.ReadLsbtohU16()); m_timeoutValue = i.ReadLsbtohU16(); SetStartingSequenceControl(i.ReadLsbtohU16()); - AddbaExtension addbaExt; + m_gcrGroupAddress.reset(); + GcrGroupAddress gcrGroupAddr; auto tmp = i; + i = gcrGroupAddr.DeserializeIfPresent(i); + if (i.GetDistanceFrom(tmp) != 0) + { + m_gcrGroupAddress = gcrGroupAddr.m_gcrGroupAddress; + } + AddbaExtension addbaExt; + tmp = i; i = addbaExt.DeserializeIfPresent(i); if (i.GetDistanceFrom(tmp) != 0) { @@ -845,6 +869,12 @@ MgtAddBaRequestHeader::SetAmsduSupport(bool supported) m_amsduSupport = supported; } +void +MgtAddBaRequestHeader::SetGcrGroupAddress(const Mac48Address& address) +{ + m_gcrGroupAddress = address; +} + uint8_t MgtAddBaRequestHeader::GetTid() const { @@ -887,6 +917,12 @@ MgtAddBaRequestHeader::GetStartingSequenceControl() const return (m_startingSeq << 4) & 0xfff0; } +std::optional +MgtAddBaRequestHeader::GetGcrGroupAddress() const +{ + return m_gcrGroupAddress; +} + uint16_t MgtAddBaRequestHeader::GetParameterSet() const { @@ -933,6 +969,10 @@ MgtAddBaResponseHeader::Print(std::ostream& os) const { os << "Status code=" << m_code << "A-MSDU support=" << m_amsduSupport << " Policy=" << +m_policy << " TID=" << +m_tid << " Buffer size=" << m_bufferSize << " Timeout=" << m_timeoutValue; + if (m_gcrGroupAddress.has_value()) + { + os << " GCR group address=" << m_gcrGroupAddress.value(); + } } uint32_t @@ -943,6 +983,11 @@ MgtAddBaResponseHeader::GetSerializedSize() const size += m_code.GetSerializedSize(); // Status code size += 2; // Block ack parameter set size += 2; // Block ack timeout value + if (m_gcrGroupAddress) + { + // a GCR Group Address element has to be added + size += GcrGroupAddress().GetSerializedSize(); + } if (m_bufferSize >= 1024) { // an ADDBA Extension element has to be added @@ -959,6 +1004,12 @@ MgtAddBaResponseHeader::Serialize(Buffer::Iterator start) const i = m_code.Serialize(i); i.WriteHtolsbU16(GetParameterSet()); i.WriteHtolsbU16(m_timeoutValue); + if (m_gcrGroupAddress) + { + GcrGroupAddress gcrGroupAddr; + gcrGroupAddr.m_gcrGroupAddress = *m_gcrGroupAddress; + i = gcrGroupAddr.Serialize(i); + } if (m_bufferSize >= 1024) { AddbaExtension addbaExt; @@ -975,8 +1026,16 @@ MgtAddBaResponseHeader::Deserialize(Buffer::Iterator start) i = m_code.Deserialize(i); SetParameterSet(i.ReadLsbtohU16()); m_timeoutValue = i.ReadLsbtohU16(); - AddbaExtension addbaExt; + m_gcrGroupAddress.reset(); + GcrGroupAddress gcrGroupAddr; auto tmp = i; + i = gcrGroupAddr.DeserializeIfPresent(i); + if (i.GetDistanceFrom(tmp) != 0) + { + m_gcrGroupAddress = gcrGroupAddr.m_gcrGroupAddress; + } + AddbaExtension addbaExt; + tmp = i; i = addbaExt.DeserializeIfPresent(i); if (i.GetDistanceFrom(tmp) != 0) { @@ -1030,6 +1089,12 @@ MgtAddBaResponseHeader::SetAmsduSupport(bool supported) m_amsduSupport = supported; } +void +MgtAddBaResponseHeader::SetGcrGroupAddress(const Mac48Address& address) +{ + m_gcrGroupAddress = address; +} + StatusCode MgtAddBaResponseHeader::GetStatusCode() const { @@ -1066,6 +1131,12 @@ MgtAddBaResponseHeader::IsAmsduSupported() const return m_amsduSupport; } +std::optional +MgtAddBaResponseHeader::GetGcrGroupAddress() const +{ + return m_gcrGroupAddress; +} + uint16_t MgtAddBaResponseHeader::GetParameterSet() const { diff --git a/src/wifi/model/mgt-action-headers.h b/src/wifi/model/mgt-action-headers.h index 80537dd53..83527f1c1 100644 --- a/src/wifi/model/mgt-action-headers.h +++ b/src/wifi/model/mgt-action-headers.h @@ -18,6 +18,7 @@ #include "wifi-standards.h" #include "ns3/header.h" +#include "ns3/mac48-address.h" #include #include @@ -345,6 +346,12 @@ class MgtAddBaRequestHeader : public Header * @param supported enable or disable A-MSDU support */ void SetAmsduSupport(bool supported); + /** + * Set the GCR Group address. + * + * @param address the GCR Group Address + */ + void SetGcrGroupAddress(const Mac48Address& address); /** * Return the starting sequence number. @@ -382,6 +389,10 @@ class MgtAddBaRequestHeader : public Header * @return true is A-MSDU is supported, false otherwise */ bool IsAmsduSupported() const; + /** + * @return the GCR Group Address, if present + */ + std::optional GetGcrGroupAddress() const; private: /** @@ -409,13 +420,14 @@ class MgtAddBaRequestHeader : public Header */ void SetStartingSequenceControl(uint16_t seqControl); - uint8_t m_dialogToken{1}; //!< Not used for now - bool m_amsduSupport{true}; //!< Flag if A-MSDU is supported - uint8_t m_policy{1}; //!< Block Ack policy - uint8_t m_tid{0}; //!< Traffic ID - uint16_t m_bufferSize{0}; //!< Buffer size - uint16_t m_timeoutValue{0}; //!< Timeout - uint16_t m_startingSeq{0}; //!< Starting sequence number + uint8_t m_dialogToken{1}; //!< Not used for now + bool m_amsduSupport{true}; //!< Flag if A-MSDU is supported + uint8_t m_policy{1}; //!< Block Ack policy + uint8_t m_tid{0}; //!< Traffic ID + uint16_t m_bufferSize{0}; //!< Buffer size + uint16_t m_timeoutValue{0}; //!< Timeout + uint16_t m_startingSeq{0}; //!< Starting sequence number + std::optional m_gcrGroupAddress; //!< GCR Group Address (optional) }; /** @@ -474,6 +486,12 @@ class MgtAddBaResponseHeader : public Header * @param supported enable or disable A-MSDU support */ void SetAmsduSupport(bool supported); + /** + * Set the GCR Group address. + * + * @param address the GCR Group Address + */ + void SetGcrGroupAddress(const Mac48Address& address); /** * Return the status code. @@ -511,6 +529,10 @@ class MgtAddBaResponseHeader : public Header * @return true is A-MSDU is supported, false otherwise */ bool IsAmsduSupported() const; + /** + * @return the GCR Group Address, if present + */ + std::optional GetGcrGroupAddress() const; private: /** @@ -526,13 +548,14 @@ class MgtAddBaResponseHeader : public Header */ void SetParameterSet(uint16_t params); - uint8_t m_dialogToken{1}; //!< Not used for now - StatusCode m_code{}; //!< Status code - bool m_amsduSupport{true}; //!< Flag if A-MSDU is supported - uint8_t m_policy{1}; //!< Block ACK policy - uint8_t m_tid{0}; //!< Traffic ID - uint16_t m_bufferSize{0}; //!< Buffer size - uint16_t m_timeoutValue{0}; //!< Timeout + uint8_t m_dialogToken{1}; //!< Not used for now + StatusCode m_code{}; //!< Status code + bool m_amsduSupport{true}; //!< Flag if A-MSDU is supported + uint8_t m_policy{1}; //!< Block ACK policy + uint8_t m_tid{0}; //!< Traffic ID + uint16_t m_bufferSize{0}; //!< Buffer size + uint16_t m_timeoutValue{0}; //!< Timeout + std::optional m_gcrGroupAddress; //!< GCR Group Address (optional) }; /**