diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index f13da1531..4c9dc062a 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -290,6 +290,45 @@ ApWifiMac::GetGcrManager() const return m_gcrManager; } +bool +ApWifiMac::UseGcr(const WifiMacHeader& hdr) const +{ + if (!hdr.IsQosData()) + { + return false; + } + + if (!IsGroupcast(hdr.GetAddr1())) + { + return false; + } + + if (!m_gcrManager) + { + return false; + } + + if (m_gcrManager->GetRetransmissionPolicy() == + GroupAddressRetransmissionPolicy::NO_ACK_NO_RETRY) + { + return false; + } + + /* + * 802.11-2020 11.21.16.3.4 (GCR operation): + * An AP or mesh STA shall transmit a frame belonging to a group address + * via the GCR service if any associated STA or peer mesh STA has a GCR + * agreement for the group address and, otherwise, does not transmit the + * frame via the GCR service. + */ + if (m_gcrManager->GetMemberStasForGroupAddress(hdr.GetAddr1()).empty()) + { + return false; + } + + return true; +} + void ApWifiMac::DoCompleteConfig() { diff --git a/src/wifi/model/ap-wifi-mac.h b/src/wifi/model/ap-wifi-mac.h index 88ed6a14a..74d8d341d 100644 --- a/src/wifi/model/ap-wifi-mac.h +++ b/src/wifi/model/ap-wifi-mac.h @@ -177,6 +177,14 @@ class ApWifiMac : public WifiMac */ uint8_t GetMaxBufferStatus(Mac48Address address) const; + /** + * Return whether GCR is used to transmit a packet. + * + * @param hdr the header of the packet to transmit + * @return true if a GCR manager is set and the packet is a groupcast QoS data, false otherwise + */ + bool UseGcr(const WifiMacHeader& hdr) const; + /// ACI-indexed map of access parameters of type unsigned integer (CWmin, CWmax and AIFSN) using UintAccessParamsMap = std::map>;