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 void SendCtsAfterMuRts(const WifiMacHeader& muRtsHdr,
183 const CtrlTriggerHeader& trigger,
184 double muRtsSnr) override;
185 void TransmissionSucceeded() override;
186 void TransmissionFailed(bool forceCurrentCw = false) override;
187 void NotifyChannelReleased(Ptr<Txop> txop) override;
188 void PreProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
189 void PostProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
191 RxSignalInfo rxSignalInfo,
192 const WifiTxVector& txVector,
193 bool inAmpdu) override;
195 const RxSignalInfo& rxSignalInfo,
196 const WifiTxVector& txVector,
197 const std::vector<bool>& perMpduStatus) override;
198 void NavResetTimeout() override;
199 void IntraBssNavResetTimeout() override;
200 void SendCtsAfterRts(const WifiMacHeader& rtsHdr, WifiMode rtsTxMode, double rtsSnr) override;
201 void PsduRxError(Ptr<const WifiPsdu> psdu) override;
202 void ReceivedQosNullAfterBsrpTf(Mac48Address sender) override;
204 const WifiMacHeader& hdr) override;
205 void TbPpduTimeout(WifiPsduMap* psduMap, std::size_t nSolicitedStations) override;
206 void BlockAcksInTbPpduTimeout(WifiPsduMap* psduMap, std::size_t nSolicitedStations) override;
207 void ProtectionCompleted() override;
208
209 /**
210 * @return whether this is an EMLSR client that cannot respond to an ICF received a SIFS before
211 */
213
214 /**
215 * Check if the MPDU that has been received on this link shall be dropped. In our model,
216 * an aux PHY, or the main PHY that is not involved in any TXOP, can receive:
217 * - management frames
218 * - CTS
219 * - CF-End
220 * - broadcast data frames
221 * Note that this method does not attempt to detect if the given MPDU is an ICF (this is done
222 * by ReceiveMpdu).
223 *
224 * @param mpdu the MPDU that has been received
225 * @return whether the given MPDU shall be dropped
226 */
228
229 /**
230 * Check whether all the stations that did not respond (to a certain frame) are EMLSR clients
231 * trying to start an UL TXOP on another link.
232 *
233 * @param staMissedResponseFrom stations that did not respond
234 * @return whether all the stations that did not respond are EMLSR clients trying to start an
235 * UL TXOP on another link
236 */
237 bool IsCrossLinkCollision(const std::set<Mac48Address>& staMissedResponseFrom);
238
239 /**
240 * Unblock transmissions on all the links of the given EMLSR client, provided that the latter
241 * is not involved in any DL or UL TXOP on another link.
242 *
243 * @param address the link MAC address of the given EMLSR client
244 * @return whether transmissions could be unblocked
245 */
247
248 private:
249 /**
250 * @return whether the received ICF must be dropped because we are unable to process it
251 * (e.g., another EMLSR link is being used or there is no time for main PHY switch)
252 */
253 bool DropReceivedIcf();
254
255 /**
256 * For each EMLSR client in the given set of clients that did not respond to a frame requesting
257 * a response from multiple clients, have the client switch to listening or simply unblock
258 * links depending on whether the EMLSR client was protected or not.
259 *
260 * @param clients the given set of clients
261 */
262 void SwitchToListeningOrUnblockLinks(const std::set<Mac48Address>& clients);
263
264 /**
265 * Generate an in-device interference of the given power on the given link for the given
266 * duration.
267 *
268 * @param linkId the ID of the link on which in-device interference is generated
269 * @param duration the duration of the in-device interference
270 * @param txPower the TX power
271 */
272 void GenerateInDeviceInterference(uint8_t linkId, Time duration, Watt_u txPower);
273
274 /**
275 * Update the TXOP end timer when starting a frame transmission.
276 *
277 * @param txDuration the TX duration of the frame being transmitted
278 * @param durationId the Duration/ID value carried by the frame being transmitted
279 */
280 void UpdateTxopEndOnTxStart(Time txDuration, Time durationId);
281
282 /**
283 * Update the TXOP end timer when receiving a PHY-RXSTART.indication.
284 *
285 * @param psduDuration the TX duration of the PSDU being received
286 */
287 void UpdateTxopEndOnRxStartIndication(Time psduDuration);
288
289 /**
290 * Update the TXOP end timer when a frame reception ends.
291 *
292 * @param durationId the Duration/ID value carried by the received frame
293 */
294 void UpdateTxopEndOnRxEnd(Time durationId);
295
296 /**
297 * Take actions when a TXOP (of which we are not the holder) ends.
298 *
299 * @param txopHolder the holder of the TXOP (if any)
300 */
301 void TxopEnd(const std::optional<Mac48Address>& txopHolder);
302
303 bool m_icfReceived{false}; //!< whether an ICF has been received and needs to be notified to
304 //!< the EMLSR manager after post-processing the frame
305 EventId m_ongoingTxopEnd; //!< event indicating the possible end of the current TXOP (of which
306 //!< we are not the holder)
307 std::unordered_map<Mac48Address, EventId, WifiAddressHash>
308 m_transDelayTimer; //!< MLD address-indexed map of transition delay timers
309};
310
311} // namespace ns3
312
313#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 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)
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 SendCtsAfterRts(const WifiMacHeader &rtsHdr, WifiMode rtsTxMode, double rtsSnr) override
Send CTS after receiving RTS.
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:48
Implements the IEEE 802.11 MAC header.
represent a single transmission mode
Definition wifi-mode.h:40
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:864
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition angles.cc:148
const Time EMLSR_RX_PHY_START_DELAY
aRxPHYStartDelay value to use when waiting for a new frame in the context of EMLSR operations (Sec.
std::unordered_map< uint16_t, Ptr< WifiPsdu > > WifiPsduMap
Map of PSDUs indexed by STA-ID.
RxSignalInfo structure containing info on the received signal.
Definition wifi-types.h:72