diff --git a/src/wifi/model/eht/eht-frame-exchange-manager.cc b/src/wifi/model/eht/eht-frame-exchange-manager.cc index 38da580f4..1fb715fd4 100644 --- a/src/wifi/model/eht/eht-frame-exchange-manager.cc +++ b/src/wifi/model/eht/eht-frame-exchange-manager.cc @@ -23,6 +23,7 @@ #include "ns3/abort.h" #include "ns3/log.h" +#include "ns3/wifi-mac-queue.h" #undef NS_LOG_APPEND_CONTEXT #define NS_LOG_APPEND_CONTEXT std::clog << "[link=" << +m_linkId << "][mac=" << m_self << "] " @@ -121,6 +122,38 @@ EhtFrameExchangeManager::ForwardPsduDown(Ptr psdu, WifiTxVector& HeFrameExchangeManager::ForwardPsduDown(psdu, txVector); } +void +EhtFrameExchangeManager::SendEmlOperatingModeNotification( + const Mac48Address& dest, + const MgtEmlOperatingModeNotification& frame) +{ + NS_LOG_FUNCTION(this << dest << frame); + + WifiMacHeader hdr; + hdr.SetType(WIFI_MAC_MGT_ACTION); + hdr.SetAddr1(dest); + hdr.SetAddr2(m_self); + hdr.SetAddr3(m_bssid); + hdr.SetDsNotTo(); + hdr.SetDsNotFrom(); + + // get the sequence number for the TWT Setup management frame + const auto sequence = m_txMiddle->GetNextSequenceNumberFor(&hdr); + hdr.SetSequenceNumber(sequence); + + WifiActionHeader actionHdr; + WifiActionHeader::ActionValue action; + action.protectedEhtAction = WifiActionHeader::PROTECTED_EHT_EML_OPERATING_MODE_NOTIFICATION; + actionHdr.SetAction(WifiActionHeader::PROTECTED_EHT, action); + + auto packet = Create(); + packet->AddHeader(frame); + packet->AddHeader(actionHdr); + + // Use AC_VO to send management frame addressed to a QoS STA (Sec. 10.2.3.2 of 802.11-2020) + m_mac->GetQosTxop(AC_VO)->Queue(Create(packet, hdr)); +} + std::optional EhtFrameExchangeManager::GetMostRecentRssi(const Mac48Address& address) const { diff --git a/src/wifi/model/eht/eht-frame-exchange-manager.h b/src/wifi/model/eht/eht-frame-exchange-manager.h index 84069b2f7..be5bbc69e 100644 --- a/src/wifi/model/eht/eht-frame-exchange-manager.h +++ b/src/wifi/model/eht/eht-frame-exchange-manager.h @@ -21,6 +21,7 @@ #define EHT_FRAME_EXCHANGE_MANAGER_H #include "ns3/he-frame-exchange-manager.h" +#include "ns3/mgt-headers.h" namespace ns3 { @@ -45,6 +46,15 @@ class EhtFrameExchangeManager : public HeFrameExchangeManager void SetLinkId(uint8_t linkId) override; Ptr CreateAliasIfNeeded(Ptr mpdu) const override; + /** + * Send an EML Operating Mode Notification frame to the given station. + * + * \param dest the MAC address of the receiver + * \param frame the EML Operating Mode Notification frame to send + */ + void SendEmlOperatingModeNotification(const Mac48Address& dest, + const MgtEmlOperatingModeNotification& frame); + /** * Get the RSSI (in dBm) of the most recent packet received from the station having * the given address. If there is no such information for the given station and the