A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
advanced-ap-emlsr-manager.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Universita' di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
10
12
13#include "ns3/ap-wifi-mac.h"
14#include "ns3/boolean.h"
15#include "ns3/log.h"
16#include "ns3/wifi-phy.h"
17#include "ns3/wifi-psdu.h"
18
19namespace ns3
20{
21
22NS_LOG_COMPONENT_DEFINE("AdvancedApEmlsrManager");
23
24NS_OBJECT_ENSURE_REGISTERED(AdvancedApEmlsrManager);
25
26TypeId
28{
29 static TypeId tid =
30 TypeId("ns3::AdvancedApEmlsrManager")
32 .SetGroupName("Wifi")
33 .AddConstructor<AdvancedApEmlsrManager>()
34 .AddAttribute("UseNotifiedMacHdr",
35 "Whether to use the information about the MAC header of the MPDU "
36 "being received, if notified by the PHY.",
37 BooleanValue(true),
40 .AddAttribute("EarlySwitchToListening",
41 "Whether the AP MLD assumes that an EMLSR client is able to detect at "
42 "the end of the MAC header that a PSDU is not addressed to it and "
43 "immediately starts switching to listening mode.",
44 BooleanValue(false),
47 .AddAttribute(
48 "WaitTransDelayOnPsduRxError",
49 "If true, the AP MLD waits for a response timeout after a PSDU reception "
50 "error before starting the transition delay for the EMLSR client that "
51 "sent the failed PSDU. Otherwise, the AP MLD does not start the "
52 "transition delay timer for the EMLSR client that sent the failed PSDU.",
53 BooleanValue(true),
56 .AddAttribute("UpdateCwAfterFailedIcf",
57 "Whether the AP MLD shall double the CW upon CTS timeout after an "
58 "MU-RTS in case all the clients solicited by the MU-RTS are EMLSR "
59 "clients that have sent (or are sending) a frame to the AP",
60 BooleanValue(true),
63 return tid;
64}
65
70
75
76void
78{
79 NS_LOG_FUNCTION(this);
80 for (uint8_t linkId = 0; linkId < GetApMac()->GetNLinks(); linkId++)
81 {
82 auto phy = GetApMac()->GetWifiPhy(linkId);
83 phy->TraceDisconnectWithoutContext(
84 "PhyRxMacHeaderEnd",
86 }
88}
89
90void
92{
93 NS_LOG_FUNCTION(this << mac);
94
95 for (uint8_t linkId = 0; linkId < GetApMac()->GetNLinks(); linkId++)
96 {
97 auto phy = GetApMac()->GetWifiPhy(linkId);
98 phy->TraceConnectWithoutContext(
99 "PhyRxMacHeaderEnd",
101 }
102}
103
104void
106 const WifiMacHeader& macHdr,
107 const WifiTxVector& txVector,
108 Time psduDuration)
109{
110 NS_LOG_FUNCTION(this << linkId << macHdr << txVector << psduDuration.As(Time::MS));
111
112 if (m_useNotifiedMacHdr && GetEhtFem(linkId)->CheckEmlsrClientStartingTxop(macHdr, txVector))
113 {
114 // the AP MLD is receiving an MPDU from an EMLSR client that is starting an UL TXOP.
115 // CheckEmlsrClientStartingTxop has blocked transmissions to the EMLSR client on other
116 // links. If the reception of the PSDU fails, however, the AP MLD does not respond and
117 // the EMLSR client will switch to listening mode after the ack timeout.
118 m_blockedLinksOnMacHdrRx.insert(linkId);
119 }
120}
121
122void
124{
125 NS_LOG_FUNCTION(this << linkId << *psdu);
126 m_blockedLinksOnMacHdrRx.erase(linkId);
127}
128
129void
131{
132 NS_LOG_FUNCTION(this << linkId << *psdu);
133
134 if (auto it = m_blockedLinksOnMacHdrRx.find(linkId); it == m_blockedLinksOnMacHdrRx.cend())
135 {
136 return;
137 }
138 else
139 {
140 m_blockedLinksOnMacHdrRx.erase(it);
141 }
142
144 {
145 auto phy = GetApMac()->GetWifiPhy(linkId);
146 auto delay = phy->GetSifs() + phy->GetSlot() + EMLSR_RX_PHY_START_DELAY;
147 GetEhtFem(linkId)->EmlsrSwitchToListening(psdu->GetAddr2(), delay);
148 return;
149 }
150
151 // all other EMLSR links were blocked when receiving MAC header; unblock them now
152 auto mldAddress =
153 GetApMac()->GetWifiRemoteStationManager(linkId)->GetMldAddress(psdu->GetAddr2());
154 if (!mldAddress.has_value())
155 {
156 NS_LOG_DEBUG(psdu->GetAddr2() << " is not an EMLSR client");
157 return;
158 }
159
160 std::set<uint8_t> linkIds;
161 for (uint8_t id = 0; id < GetApMac()->GetNLinks(); id++)
162 {
163 if (GetApMac()->GetWifiRemoteStationManager(id)->GetEmlsrEnabled(*mldAddress))
164 {
165 linkIds.insert(id);
166 }
167 }
169 *mldAddress,
170 linkIds);
171}
172
173Time
175 const WifiTxVector& txVector,
176 WifiPhyBand band)
177{
178 NS_LOG_FUNCTION(this << psdu << txVector << band);
179
181 {
182 return DefaultApEmlsrManager::GetDelayOnTxPsduNotForEmlsr(psdu, txVector, band);
183 }
184
185 // EMLSR clients switch back to listening operation at the end of MAC header RX
186 auto macHdrSize = (*psdu->begin())->GetHeader().GetSerializedSize() +
187 ((psdu->GetNMpdus() > 1 || psdu->IsSingle()) ? 4 : 0);
188 // return the duration of the MAC header TX
189 return DataRate(txVector.GetMode().GetDataRate(txVector)).CalculateBytesTxTime(macHdrSize);
190}
191
192bool
197
198} // namespace ns3
AdvancedApEmlsrManager is an advanced AP EMLSR manager.
bool m_updateCwAfterFailedIcf
Whether the AP MLD shall double the CW upon CTS timeout.
void DoSetWifiMac(Ptr< ApWifiMac > mac) override
Allow subclasses to take actions when the MAC is set.
void ReceivedMacHdr(uint8_t linkId, const WifiMacHeader &macHdr, const WifiTxVector &txVector, Time psduDuration)
Store information about the MAC header of the MPDU being received on the given link.
bool m_useNotifiedMacHdr
whether to use the information about the MAC header of the MPDU being received (if notified by the PH...
bool m_waitTransDelayOnPsduRxError
Whether the AP MLD waits for a response timeout after a PSDU reception error before starting the tran...
Time GetDelayOnTxPsduNotForEmlsr(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector, WifiPhyBand band) override
This method is intended to be called when the AP MLD starts transmitting an SU frame that is not addr...
std::set< uint8_t > m_blockedLinksOnMacHdrRx
links that have been blocked upon receiving a MAC header
void NotifyPsduRxError(uint8_t linkId, Ptr< const WifiPsdu > psdu) override
This method is called when the reception of a PSDU fails on the given link.
void NotifyPsduRxOk(uint8_t linkId, Ptr< const WifiPsdu > psdu) override
This method is called when the reception of a PSDU succeeds on the given link.
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Get the type ID.
bool m_earlySwitchToListening
Whether the AP MLD assumes that an EMLSR client is able to detect at the end of the MAC header that a...
Ptr< ApWifiMac > GetApMac() const
Ptr< EhtFrameExchangeManager > GetEhtFem(uint8_t linkId) const
Class for representing data rates.
Definition data-rate.h:78
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
Definition data-rate.cc:220
DefaultApEmlsrManager is the default AP EMLSR manager.
Time GetDelayOnTxPsduNotForEmlsr(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector, WifiPhyBand band) override
This method is intended to be called when the AP MLD starts transmitting an SU frame that is not addr...
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition time.cc:404
@ MS
millisecond
Definition nstime.h:106
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Implements the IEEE 802.11 MAC header.
uint64_t GetDataRate(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
Definition wifi-mode.cc:111
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.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#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.
Definition object-base.h:35
WifiPhyBand
Identifies the PHY band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition boolean.cc:113
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition boolean.h:70
const Time EMLSR_RX_PHY_START_DELAY
aRxPHYStartDelay value to use when waiting for a new frame in the context of EMLSR operations (Sec.