25#include "ns3/ap-wifi-mac.h"
27#include "ns3/wifi-mac-queue.h"
29#undef NS_LOG_APPEND_CONTEXT
30#define NS_LOG_APPEND_CONTEXT std::clog << "[link=" << +m_linkId << "][mac=" << m_self << "] "
42 static TypeId tid =
TypeId(
"ns3::EhtFrameExchangeManager")
44 .AddConstructor<EhtFrameExchangeManager>()
45 .SetGroupName(
"Wifi");
74 mpdu->GetHeader().GetAddr1().IsGroup() ||
81 auto& hdr = mpdu->GetHeader();
85 hdr.SetAddr1(*address);
95 if (hdr.IsToDs() && !hdr.IsFromDs())
98 hdr.SetAddr3(hdr.GetAddr1());
100 else if (!hdr.IsToDs() && hdr.IsFromDs())
103 hdr.SetAddr3(hdr.GetAddr2());
119 auto sigBMode = phy->GetSigBMode(txVector);
170 if (
auto psduMapIt = psduMap.find(aid);
172 (psduMapIt == psduMap.cend() ||
221 emlCapabilities->emlsrTransitionDelay),
223 m_mac->UnblockUnicastTxOnLinks(
224 WifiQueueBlockedReason::WAITING_EMLSR_TRANSITION_DELAY,
233EhtFrameExchangeManager::SendEmlOperatingModeNotification(
248 const auto sequence = m_txMiddle->GetNextSequenceNumberFor(&hdr);
253 action.protectedEhtAction = WifiActionHeader::PROTECTED_EHT_EML_OPERATING_MODE_NOTIFICATION;
254 actionHdr.
SetAction(WifiActionHeader::PROTECTED_EHT, action);
256 auto packet = Create<Packet>();
257 packet->AddHeader(frame);
258 packet->AddHeader(actionHdr);
261 m_mac->GetQosTxop(
AC_VO)->Queue(Create<WifiMpdu>(packet, hdr));
265EhtFrameExchangeManager::GetMostRecentRssi(
const Mac48Address& address)
const
267 auto optRssi = HeFrameExchangeManager::GetMostRecentRssi(address);
274 auto mldAddress = GetWifiRemoteStationManager()->GetMldAddress(address);
282 for (uint8_t linkId = 0; linkId < m_mac->GetNLinks(); linkId++)
284 std::optional<Mac48Address> linkAddress;
285 if (linkId != m_linkId &&
286 (linkAddress = m_mac->GetWifiRemoteStationManager(linkId)->GetAffiliatedStaAddress(
288 (optRssi = m_mac->GetWifiRemoteStationManager(linkId)->GetMostRecentRssi(*linkAddress)))
302 uint8_t maxPaddingDelay = 0;
305 for (
const auto& address : m_sentRtsTo)
307 if (!GetWifiRemoteStationManager()->GetEmlsrEnabled(address))
312 auto emlCapabilities = GetWifiRemoteStationManager()->GetStationEmlCapabilities(address);
314 maxPaddingDelay = std::max(maxPaddingDelay, emlCapabilities->emlsrPaddingDelay);
316 auto mldAddress = GetWifiRemoteStationManager()->GetMldAddress(address);
319 for (uint8_t linkId = 0; linkId < m_apMac->GetNLinks(); linkId++)
321 if (linkId != m_linkId &&
322 m_mac->GetWifiRemoteStationManager(linkId)->GetEmlsrEnabled(*mldAddress))
324 m_mac->BlockUnicastTxOnLinks(WifiQueueBlockedReason::USING_OTHER_EMLSR_LINK,
332 if (maxPaddingDelay > 0)
335 txParams.
m_protection->method == WifiProtection::MU_RTS_CTS);
342 std::size_t nDbps = rate / 1e6 * 4;
346 HeFrameExchangeManager::SendMuRts(txParams);
362 if (psdu->GetAddr1() == address)
371 if (mpdu->GetHeader().IsTrigger())
374 mpdu->GetPacket()->PeekHeader(trigger);
384 if (psdu->GetHeader(0).IsCts())
386 if (m_apMac && psdu->GetAddr1() == m_self)
390 if (m_staMac && psdu->GetAddr1() == m_bssid)
398 if (psdu->GetHeader(0).IsBlockAck())
401 psdu->GetPayload(0)->PeekHeader(blockAck);
416EhtFrameExchangeManager::NotifyChannelReleased(
Ptr<Txop> txop)
422 auto delay = m_phy->GetSifs() + m_phy->GetSlot() +
MicroSeconds(20);
423 for (
const auto& address : m_protectedStas)
425 if (GetWifiRemoteStationManager()->GetEmlsrEnabled(address))
427 EmlsrSwitchToListening(address, delay);
431 HeFrameExchangeManager::NotifyChannelReleased(txop);
void ForwardPsduMapDown(WifiConstPsduMap psduMap, WifiTxVector &txVector) override
Forward a map of PSDUs down to the PHY layer.
void ForwardPsduDown(Ptr< const WifiPsdu > psdu, WifiTxVector &txVector) override
Forward a PSDU down to the PHY layer.
Ptr< WifiMpdu > CreateAliasIfNeeded(Ptr< WifiMpdu > mpdu) const override
Create an alias of the given MPDU for transmission by this Frame Exchange Manager.
EhtFrameExchangeManager()
bool GetEmlsrSwitchToListening(Ptr< const WifiPsdu > psdu, uint16_t aid, const Mac48Address &address) const
static TypeId GetTypeId()
Get the type ID.
~EhtFrameExchangeManager() override
void EmlsrSwitchToListening(const Mac48Address &address, const Time &delay)
This method is intended to be called when an AP MLD detects that an EMLSR client previously involved ...
void SetLinkId(uint8_t linkId) override
Set the ID of the link this Frame Exchange Manager is associated with.
uint8_t m_linkId
the ID of the link this object is associated with
Ptr< WifiMac > m_mac
the MAC layer on this station
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager() const
std::set< Mac48Address > m_protectedStas
STAs that have replied to an RTS in this TXOP.
Mac48Address GetAddress() const
Get the MAC address.
virtual void SetLinkId(uint8_t linkId)
Set the ID of the link this Frame Exchange Manager is associated with.
Ptr< WifiPhy > m_phy
the PHY layer on this station
HeFrameExchangeManager handles the frame exchange sequences for HE stations.
Ptr< ApWifiMac > m_apMac
MAC pointer (null if not an AP)
virtual void ForwardPsduMapDown(WifiConstPsduMap psduMap, WifiTxVector &txVector)
Forward a map of PSDUs down to the PHY layer.
Ptr< MpduAggregator > m_mpduAggregator
A-MPDU aggregator.
virtual void ForwardPsduDown(Ptr< const WifiPsdu > psdu, WifiTxVector &txVector)
Forward a PSDU down to the PHY layer.
Ptr< MsduAggregator > m_msduAggregator
A-MSDU aggregator.
Implement the header for Action frames of type EML Operating Mode Notification.
Smart pointer class similar to boost::intrusive_ptr.
virtual Ptr< WifiMpdu > CreateAliasIfNeeded(Ptr< WifiMpdu > mpdu) const
Create an alias of the given MPDU for transmission by this Frame Exchange Manager.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
uint8_t GetNLinks() const
Get the number of links (can be greater than 1 for 11be devices only).
void UnblockUnicastTxOnLinks(WifiQueueBlockedReason reason, const Mac48Address &address, const std::set< uint8_t > &linkIds)
Unblock the transmission on the given links of all unicast frames addressed to the station with the g...
void BlockUnicastTxOnLinks(WifiQueueBlockedReason reason, const Mac48Address &address, const std::set< uint8_t > &linkIds)
Block the transmission on the given links of all unicast frames addressed to the station with the giv...
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId=0) const
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class.
bool GetEmlsrEnabled(const Mac48Address &address) const
uint16_t GetAssociationId(Mac48Address remoteAddress) const
Get the AID of a remote station.
std::optional< Mac48Address > GetAffiliatedStaAddress(const Mac48Address &mldAddress) const
Get the address of the remote station operating on this link and affiliated with the MLD having the g...
std::shared_ptr< CommonInfoBasicMle::EmlCapabilities > GetStationEmlCapabilities(const Mac48Address &from)
std::optional< Mac48Address > GetMldAddress(const Mac48Address &address) const
Get the address of the MLD the given station is affiliated with, if any.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
std::unique_ptr< WifiProtection > m_protection
protection method
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
WifiPreamble GetPreambleType() const
void SetSigBMode(const WifiMode &mode)
Set the MCS used for SIG-B.
Declaration of ns3::EhtPhy class.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
@ WIFI_MOD_CLASS_EHT
EHT (Clause 36)
@ WAITING_EMLSR_TRANSITION_DELAY
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
static Time DecodeEmlsrTransitionDelay(uint8_t value)
WifiMuRtsCtsProtection specifies that MU-RTS/CTS protection method is used.
CtrlTriggerHeader muRts
MU-RTS.
WifiTxVector muRtsTxVector
MU-RTS TXVECTOR.