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