A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
eht-frame-exchange-manager.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
9#ifndef EHT_FRAME_EXCHANGE_MANAGER_H
10#define EHT_FRAME_EXCHANGE_MANAGER_H
11
12#include "ns3/he-frame-exchange-manager.h"
13#include "ns3/mgt-headers.h"
14
15#include <unordered_map>
16
17namespace ns3
18{
19
20/// aRxPHYStartDelay value to use when waiting for a new frame in the context of EMLSR operations
21/// (Sec. 35.3.17 of 802.11be D3.1)
23
24class MgtEmlOmn;
25
26/**
27 * @ingroup wifi
28 * Reasons for an EMLSR client to drop an ICF
29 */
30enum class WifiIcfDrop : uint8_t
31{
32 USING_OTHER_LINK = 0, // another EMLSR link is being used
33 NOT_ENOUGH_TIME_TX, // not enough time for the main PHY to switch (because in TX state)
34 NOT_ENOUGH_TIME_RX, // not enough time for the main PHY to switch (because in RX state)
35 NOT_ENOUGH_TIME_SWITCH, // not enough time for the main PHY to switch (already switching)
36 NOT_ENOUGH_TIME_SLEEP, // not enough time for the main PHY to switch (because in SLEEP state)
37};
38
39/**
40 * @brief Stream insertion operator.
41 *
42 * @param os the stream
43 * @param reason the reason for dropping the ICF
44 * @returns a reference to the stream
45 */
46inline std::ostream&
47operator<<(std::ostream& os, WifiIcfDrop reason)
48{
49 switch (reason)
50 {
52 return (os << "USING_OTHER_LINK");
54 return (os << "NOT_ENOUGH_TIME_TX");
56 return (os << "NOT_ENOUGH_TIME_RX");
58 return (os << "NOT_ENOUGH_TIME_SWITCH");
60 return (os << "NOT_ENOUGH_TIME_SLEEP");
61 default:
62 NS_FATAL_ERROR("Unknown wifi ICF drop reason");
63 return (os << "UNKNOWN");
64 }
65}
66
67/**
68 * @ingroup wifi
69 *
70 * EhtFrameExchangeManager handles the frame exchange sequences
71 * for EHT stations.
72 */
74{
75 public:
76 /**
77 * @brief Get the type ID.
78 * @return the object TypeId
79 */
80 static TypeId GetTypeId();
82 ~EhtFrameExchangeManager() override;
83
84 void SetLinkId(uint8_t linkId) override;
86 bool StartTransmission(Ptr<Txop> edca, MHz_u allowedWidth) override;
87
88 /**
89 * Send an EML Operating Mode Notification frame to the given station.
90 *
91 * @param dest the MAC address of the receiver
92 * @param frame the EML Operating Mode Notification frame to send
93 */
94 void SendEmlOmn(const Mac48Address& dest, const MgtEmlOmn& frame);
95
96 /**
97 * Get the RSSI of the most recent packet received from the station having the given address. If
98 * there is no such information for the given station and the station is affiliated with an MLD,
99 * return the RSSI of the most recent packet received from another station of the same MLD.
100 *
101 * @param address of the remote station
102 * @return the RSSI of the most recent packet received from the remote station
103 */
104 std::optional<dBm_u> GetMostRecentRssi(const Mac48Address& address) const override;
105
106 /**
107 * @param psdu the given PSDU
108 * @param aid the AID of an EMLSR client
109 * @param address the link MAC address of an EMLSR client
110 * @return whether the EMLSR client having the given AID and MAC address shall switch back to
111 * the listening operation when receiving the given PSDU
112 */
114 uint16_t aid,
115 const Mac48Address& address) const;
116
117 /**
118 * Notify that the given PHY will switch channel to operate on another EMLSR link
119 * after the given delay.
120 *
121 * @param phy the given PHY
122 * @param linkId the ID of the EMLSR link on which the given PHY is operating
123 * @param delay the delay after which the channel switch will be completed
124 */
125 void NotifySwitchingEmlsrLink(Ptr<WifiPhy> phy, uint8_t linkId, Time delay);
126
127 /**
128 * @return whether this is an EMLSR link that has been blocked because another EMLSR link
129 * is being used
130 */
131 bool UsingOtherEmlsrLink() const;
132
133 /**
134 * Check if the frame received (or being received) is sent by an EMLSR client to start an
135 * UL TXOP. If so, take the appropriate actions (e.g., block transmission to the EMLSR client
136 * on the other links). This method is intended to be called when an MPDU (possibly within
137 * an A-MPDU) is received or when the reception of the MAC header in an MPDU is notified.
138 *
139 * @param hdr the MAC header of the received (or being received) MPDU
140 * @param txVector the TXVECTOR used to transmit the frame received (or being received)
141 * @return whether the frame received (or being received) is sent by an EMLSR client to start
142 * an UL TXOP
143 */
144 bool CheckEmlsrClientStartingTxop(const WifiMacHeader& hdr, const WifiTxVector& txVector);
145
146 /**
147 * This method is intended to be called when an AP MLD detects that an EMLSR client previously
148 * involved in the current TXOP will start waiting for the transition delay interval (to switch
149 * back to listening operation) after the given delay.
150 * This method blocks the transmissions on all the EMLSR links of the given EMLSR client until
151 * the transition delay advertised by the EMLSR client expires.
152 *
153 * @param address the link MAC address of the given EMLSR client
154 * @param delay the given delay
155 */
156 void EmlsrSwitchToListening(Mac48Address address, const Time& delay);
157
158 /**
159 * @return a reference to the event indicating the possible end of the current TXOP (of
160 * which this device is not the holder)
161 */
163
164 /**
165 * Set the padding and the TXVECTOR of the given Trigger Frame, in case it is an Initial
166 * Control Frame for some EMLSR client(s).
167 *
168 * @param trigger the given Trigger Frame
169 * @param txVector the TXVECTOR used to transmit the Trigger Frame
170 */
171 void SetIcfPaddingAndTxVector(CtrlTriggerHeader& trigger, WifiTxVector& txVector) const;
172
173 /// ICF drop reason traced callback (WifiMac exposes this trace source)
175
176 protected:
177 void DoDispose() override;
178 void RxStartIndication(WifiTxVector txVector, Time psduDuration) override;
179 void ForwardPsduDown(Ptr<const WifiPsdu> psdu, WifiTxVector& txVector) override;
180 void ForwardPsduMapDown(WifiConstPsduMap psduMap, WifiTxVector& txVector) override;
181 void CtsAfterMuRtsTimeout(Ptr<WifiMpdu> muRts, const WifiTxVector& txVector) override;
182 bool GetUpdateCwOnCtsTimeout() const override;
183 bool GetReportRtsFailed() const override;
184 void SendCtsAfterMuRts(const WifiMacHeader& muRtsHdr,
185 const CtrlTriggerHeader& trigger,
186 double muRtsSnr) override;
187 void TransmissionSucceeded() override;
188 void TransmissionFailed(bool forceCurrentCw = false) override;
189 void NotifyChannelReleased(Ptr<Txop> txop) override;
190 void PreProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
191 void PostProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
193 RxSignalInfo rxSignalInfo,
194 const WifiTxVector& txVector,
195 bool inAmpdu) override;
197 const RxSignalInfo& rxSignalInfo,
198 const WifiTxVector& txVector,
199 const std::vector<bool>& perMpduStatus) override;
200 void NavResetTimeout() override;
201 void IntraBssNavResetTimeout() override;
202 void SendCtsAfterRts(const WifiMacHeader& rtsHdr,
203 const WifiTxVector& rtsTxVector,
204 double rtsSnr) override;
205 void PsduRxError(Ptr<const WifiPsdu> psdu) override;
206 void ReceivedQosNullAfterBsrpTf(Mac48Address sender) override;
208 const WifiMacHeader& hdr) override;
209 void TbPpduTimeout(WifiPsduMap* psduMap, std::size_t nSolicitedStations) override;
210 void BlockAcksInTbPpduTimeout(WifiPsduMap* psduMap, std::size_t nSolicitedStations) override;
211 void ProtectionCompleted() override;
212
213 /**
214 * @return whether this is an EMLSR client that cannot respond to an ICF received a SIFS before
215 */
217
218 /**
219 * Check if the MPDU that has been received on this link shall be dropped. In our model,
220 * an aux PHY, or the main PHY that is not involved in any TXOP, can receive:
221 * - management frames
222 * - CTS
223 * - CF-End
224 * - broadcast data frames
225 * Note that this method does not attempt to detect if the given MPDU is an ICF (this is done
226 * by ReceiveMpdu).
227 *
228 * @param mpdu the MPDU that has been received
229 * @return whether the given MPDU shall be dropped
230 */
232
233 /**
234 * Check whether all the stations that did not respond (to a certain frame) are EMLSR clients
235 * trying to start an UL TXOP on another link.
236 *
237 * @param staMissedResponseFrom stations that did not respond
238 * @return whether all the stations that did not respond are EMLSR clients trying to start an
239 * UL TXOP on another link
240 */
241 bool IsCrossLinkCollision(const std::set<Mac48Address>& staMissedResponseFrom) const;
242
243 /**
244 * Unblock transmissions on all the links of the given EMLSR client, provided that the latter
245 * is not involved in any DL or UL TXOP on another link.
246 *
247 * @param address the link MAC address of the given EMLSR client
248 * @return whether transmissions could be unblocked
249 */
251
252 private:
253 /**
254 * @return whether the received ICF must be dropped because we are unable to process it
255 * (e.g., another EMLSR link is being used or there is no time for main PHY switch)
256 */
257 bool DropReceivedIcf();
258
259 /**
260 * For each EMLSR client in the given set of clients that did not respond to a frame requesting
261 * a response from multiple clients, have the client switch to listening or simply unblock
262 * links depending on whether the EMLSR client was protected or not.
263 *
264 * @param clients the given set of clients
265 */
266 void SwitchToListeningOrUnblockLinks(const std::set<Mac48Address>& clients);
267
268 /**
269 * Generate an in-device interference of the given power on the given link for the given
270 * duration.
271 *
272 * @param linkId the ID of the link on which in-device interference is generated
273 * @param duration the duration of the in-device interference
274 * @param txPower the TX power
275 */
276 void GenerateInDeviceInterference(uint8_t linkId, Time duration, Watt_u txPower);
277
278 /**
279 * Update the TXOP end timer when starting a frame transmission.
280 *
281 * @param txDuration the TX duration of the frame being transmitted
282 * @param durationId the Duration/ID value carried by the frame being transmitted
283 */
284 void UpdateTxopEndOnTxStart(Time txDuration, Time durationId);
285
286 /**
287 * Update the TXOP end timer when receiving a PHY-RXSTART.indication.
288 *
289 * @param psduDuration the TX duration of the PSDU being received
290 */
291 void UpdateTxopEndOnRxStartIndication(Time psduDuration);
292
293 /**
294 * Update the TXOP end timer when a frame reception ends.
295 *
296 * @param durationId the Duration/ID value carried by the received frame
297 */
298 void UpdateTxopEndOnRxEnd(Time durationId);
299
300 /**
301 * Take actions when a TXOP (of which we are not the holder) ends.
302 *
303 * @param txopHolder the holder of the TXOP (if any)
304 */
305 void TxopEnd(const std::optional<Mac48Address>& txopHolder);
306
307 bool m_icfReceived{false}; //!< whether an ICF has been received and needs to be notified to
308 //!< the EMLSR manager after post-processing the frame
309 EventId m_ongoingTxopEnd; //!< event indicating the possible end of the current TXOP (of which
310 //!< we are not the holder)
311 std::unordered_map<Mac48Address, EventId, WifiAddressHash>
312 m_transDelayTimer; //!< MLD address-indexed map of transition delay timers
313};
314
315} // namespace ns3
316
317#endif /* EHT_FRAME_EXCHANGE_MANAGER_H */
Headers for Trigger frames.
EhtFrameExchangeManager handles the frame exchange sequences for EHT stations.
void PostProcessFrame(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector) override
Perform actions that are possibly needed after receiving any frame, independently of whether the fram...
void TransmissionFailed(bool forceCurrentCw=false) override
Take necessary actions upon a transmission failure.
void ForwardPsduMapDown(WifiConstPsduMap psduMap, WifiTxVector &txVector) override
Forward a map of PSDUs down to the PHY layer.
void SendCtsAfterRts(const WifiMacHeader &rtsHdr, const WifiTxVector &rtsTxVector, double rtsSnr) override
Send CTS after receiving RTS.
void ReceivedQosNullAfterBsrpTf(Mac48Address sender) override
Perform the actions required when receiving QoS Null frame(s) from the given sender after a BSRP Trig...
TracedCallback< WifiIcfDrop, uint8_t > m_icfDropCallback
ICF drop reason traced callback (WifiMac exposes this trace source)
void SetIcfPaddingAndTxVector(CtrlTriggerHeader &trigger, WifiTxVector &txVector) const
Set the padding and the TXVECTOR of the given Trigger Frame, in case it is an Initial Control Frame f...
void PreProcessFrame(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector) override
Perform actions that are possibly needed when receiving any frame, independently of whether the frame...
void NavResetTimeout() override
Reset the NAV upon expiration of the NAV reset timer.
void ForwardPsduDown(Ptr< const WifiPsdu > psdu, WifiTxVector &txVector) override
Forward a PSDU down to the PHY layer.
void PsduRxError(Ptr< const WifiPsdu > psdu) override
This method is called when the reception of a PSDU fails.
void EmlsrSwitchToListening(Mac48Address address, const Time &delay)
This method is intended to be called when an AP MLD detects that an EMLSR client previously involved ...
void BlockAcksInTbPpduTimeout(WifiPsduMap *psduMap, std::size_t nSolicitedStations) override
Take the necessary actions after that some BlockAck frames are missing in response to a DL MU PPDU.
bool UnblockEmlsrLinksIfAllowed(Mac48Address address)
Unblock transmissions on all the links of the given EMLSR client, provided that the latter is not inv...
void SendEmlOmn(const Mac48Address &dest, const MgtEmlOmn &frame)
Send an EML Operating Mode Notification frame to the given station.
Ptr< WifiMpdu > CreateAliasIfNeeded(Ptr< WifiMpdu > mpdu) const override
Create an alias of the given MPDU for transmission by this Frame Exchange Manager.
void ProtectionCompleted() override
Transmit prepared frame immediately, if no protection was used, or in a SIFS, if protection was compl...
void TbPpduTimeout(WifiPsduMap *psduMap, std::size_t nSolicitedStations) override
Take the necessary actions after that some TB PPDUs are missing in response to Trigger Frame.
void IntraBssNavResetTimeout() override
Reset the intra-BSS NAV upon expiration of the intra-BSS NAV reset timer.
bool ShallDropReceivedMpdu(Ptr< const WifiMpdu > mpdu) const
Check if the MPDU that has been received on this link shall be dropped.
void SendCtsAfterMuRts(const WifiMacHeader &muRtsHdr, const CtrlTriggerHeader &trigger, double muRtsSnr) override
Send CTS after receiving an MU-RTS.
void SwitchToListeningOrUnblockLinks(const std::set< Mac48Address > &clients)
For each EMLSR client in the given set of clients that did not respond to a frame requesting a respon...
bool IsCrossLinkCollision(const std::set< Mac48Address > &staMissedResponseFrom) const
Check whether all the stations that did not respond (to a certain frame) are EMLSR clients trying to ...
std::optional< dBm_u > GetMostRecentRssi(const Mac48Address &address) const override
Get the RSSI of the most recent packet received from the station having the given address.
void UpdateTxopEndOnRxEnd(Time durationId)
Update the TXOP end timer when a frame reception ends.
void EndReceiveAmpdu(Ptr< const WifiPsdu > psdu, const RxSignalInfo &rxSignalInfo, const WifiTxVector &txVector, const std::vector< bool > &perMpduStatus) override
This method is called when the reception of an A-MPDU including multiple MPDUs is completed.
bool CheckEmlsrClientStartingTxop(const WifiMacHeader &hdr, const WifiTxVector &txVector)
Check if the frame received (or being received) is sent by an EMLSR client to start an UL TXOP.
void TransmissionSucceeded() override
Take necessary actions upon a transmission success.
bool GetEmlsrSwitchToListening(Ptr< const WifiPsdu > psdu, uint16_t aid, const Mac48Address &address) const
static TypeId GetTypeId()
Get the type ID.
void DoDispose() override
Destructor implementation.
std::unordered_map< Mac48Address, EventId, WifiAddressHash > m_transDelayTimer
MLD address-indexed map of transition delay timers.
bool m_icfReceived
whether an ICF has been received and needs to be notified to the EMLSR manager after post-processing ...
void NotifyChannelReleased(Ptr< Txop > txop) override
Notify the given Txop that channel has been released.
EventId m_ongoingTxopEnd
event indicating the possible end of the current TXOP (of which we are not the holder)
void RxStartIndication(WifiTxVector txVector, Time psduDuration) override
void ReceiveMpdu(Ptr< const WifiMpdu > mpdu, RxSignalInfo rxSignalInfo, const WifiTxVector &txVector, bool inAmpdu) override
This method handles the reception of an MPDU (possibly included in an A-MPDU)
void UpdateTxopEndOnTxStart(Time txDuration, Time durationId)
Update the TXOP end timer when starting a frame transmission.
void GenerateInDeviceInterference(uint8_t linkId, Time duration, Watt_u txPower)
Generate an in-device interference of the given power on the given link for the given duration.
void SendQosNullFramesInTbPpdu(const CtrlTriggerHeader &trigger, const WifiMacHeader &hdr) override
Send QoS Null frames in response to a Basic or BSRP Trigger Frame.
void UpdateTxopEndOnRxStartIndication(Time psduDuration)
Update the TXOP end timer when receiving a PHY-RXSTART.indication.
void TxopEnd(const std::optional< Mac48Address > &txopHolder)
Take actions when a TXOP (of which we are not the holder) ends.
void CtsAfterMuRtsTimeout(Ptr< WifiMpdu > muRts, const WifiTxVector &txVector) override
Called when no CTS frame is received after an MU-RTS.
void NotifySwitchingEmlsrLink(Ptr< WifiPhy > phy, uint8_t linkId, Time delay)
Notify that the given PHY will switch channel to operate on another EMLSR link after the given delay.
bool StartTransmission(Ptr< Txop > edca, MHz_u allowedWidth) override
Request the FrameExchangeManager to start a frame exchange sequence.
void SetLinkId(uint8_t linkId) override
Set the ID of the link this Frame Exchange Manager is associated with.
An identifier for simulation events.
Definition event-id.h:45
HeFrameExchangeManager handles the frame exchange sequences for HE stations.
an EUI-48 address
Implement the header for Action frames of type EML Operating Mode Notification.
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:49
Implements the IEEE 802.11 MAC header.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
WifiIcfDrop
Reasons for an EMLSR client to drop an ICF.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition nstime.h:865
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148
std::unordered_map< uint16_t, Ptr< WifiPsdu > > WifiPsduMap
Map of PSDUs indexed by STA-ID.
Definition wifi-mac.h:78
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition wifi-ppdu.h:38
const Time EMLSR_RX_PHY_START_DELAY
aRxPHYStartDelay value to use when waiting for a new frame in the context of EMLSR operations (Sec.
RxSignalInfo structure containing info on the received signal.
Definition wifi-types.h:78