A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
emlsr-manager.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 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 EMLSR_MANAGER_H
10#define EMLSR_MANAGER_H
11
12#include "ns3/ctrl-headers.h"
13#include "ns3/mac48-address.h"
14#include "ns3/object.h"
15#include "ns3/sta-wifi-mac.h"
16#include "ns3/wifi-export.h"
17#include "ns3/wifi-phy-operating-channel.h"
18
19#include <map>
20#include <memory>
21#include <optional>
22#include <set>
23#include <string_view>
24#include <utility>
25
27
28namespace ns3
29{
30
32class MgtEmlOmn;
33class WifiMpdu;
34
35/**
36 * @ingroup wifi
37 * Base struct for EMLSR Main PHY switch traces.
38 */
39struct WIFI_EXPORT EmlsrMainPhySwitchTrace
40{
41 virtual ~EmlsrMainPhySwitchTrace() = default;
42
43 /// @return the name of this instance
44 virtual std::string_view GetName() const = 0;
45
46 /// @return a pointer to the clone of this object
47 virtual std::shared_ptr<EmlsrMainPhySwitchTrace> Clone() const = 0;
48
49 std::optional<uint8_t> fromLinkId; //!< ID of the link the main PHY is moving from (if any)
50 uint8_t toLinkId{WIFI_LINKID_UNDEFINED}; //!< ID of the link the main PHY is moving to
51};
52
53/**
54 * Implementation for the EMLSR Main PHY switch trace base struct. Child structs are inherited
55 * from this implementation according to the CRTP idiom and must define a static string_view
56 * member containing the name of the child.
57 */
58template <class T>
60{
61 /// @copydoc ns3::EmlsrMainPhySwitchTrace::GetName
62 std::string_view GetName() const override
63 {
64 return T::m_name;
65 }
66
67 /// @copydoc ns3::EmlsrMainPhySwitchTrace::Clone
68 std::shared_ptr<EmlsrMainPhySwitchTrace> Clone() const override
69 {
70 return std::shared_ptr<EmlsrMainPhySwitchTrace>(new T(static_cast<const T&>(*this)));
71 }
72};
73
74/**
75 * @ingroup wifi
76 *
77 * EmlsrManager is an abstract base class defining the API that EHT non-AP MLDs
78 * with EMLSR activated can use to handle the operations on the EMLSR links
79 */
80class WIFI_EXPORT EmlsrManager : public Object
81{
82 /// Allow test cases to access private members
83 friend class ::EmlsrCcaBusyTest;
85
86 public:
87 /**
88 * @brief Get the type ID.
89 * @return the object TypeId
90 */
91 static TypeId GetTypeId();
93 ~EmlsrManager() override;
94
95 /**
96 * Set the wifi MAC. Note that it must be the MAC of an EHT non-AP MLD.
97 *
98 * @param mac the wifi MAC
99 */
100 void SetWifiMac(Ptr<StaWifiMac> mac);
101
102 /**
103 * Set the Transition Timeout advertised by the associated AP with EMLSR activated.
104 *
105 * @param timeout the advertised Transition Timeout
106 */
108
109 /**
110 * @return the Transition Timeout, if advertised by the associated AP
111 */
112 std::optional<Time> GetTransitionTimeout() const;
113
114 /**
115 * Set the duration of the MediumSyncDelay timer.
116 *
117 * @param duration the duration of the MediumSyncDelay timer
118 */
119 void SetMediumSyncDuration(Time duration);
120
121 /**
122 * @return the duration of the MediumSyncDelay timer
123 */
125
126 /**
127 * Set the Medium Synchronization OFDM ED threshold (dBm) to use while the MediumSyncDelay
128 * timer is running.
129 *
130 * @param threshold the threshold in dBm (ranges from -72 to -62 dBm)
131 */
132 void SetMediumSyncOfdmEdThreshold(int8_t threshold);
133
134 /**
135 * @return the Medium Synchronization OFDM ED threshold (dBm) to use while the MediumSyncDelay
136 * timer is running.
137 */
139
140 /**
141 * Set the maximum number of TXOPs a non-AP STA is allowed to attempt to initiate while
142 * the MediumSyncDelay timer is running. No value indicates no limit.
143 *
144 * @param nTxops the maximum number of TXOPs a non-AP STA is allowed to attempt to
145 * initiate while the MediumSyncDelay timer is running
146 */
147 void SetMediumSyncMaxNTxops(std::optional<uint8_t> nTxops);
148
149 /**
150 * @return the maximum number of TXOPs a non-AP STA is allowed to attempt to initiate while
151 * the MediumSyncDelay timer is running. No value indicates no limit.
152 */
153 std::optional<uint8_t> GetMediumSyncMaxNTxops() const;
154
155 /**
156 * @return the ID of main PHY (position in the vector of PHYs held by WifiNetDevice)
157 */
158 uint8_t GetMainPhyId() const;
159
160 /**
161 * Take actions to enable EMLSR mode on the given set of links, if non-empty, or
162 * disable EMLSR mode, otherwise.
163 *
164 * @param linkIds the IDs of the links on which EMLSR mode should be enabled
165 * (empty to disable EMLSR mode)
166 */
167 void SetEmlsrLinks(const std::set<uint8_t>& linkIds);
168
169 /**
170 * @return the set of links on which EMLSR mode is enabled
171 */
172 const std::set<uint8_t>& GetEmlsrLinks() const;
173
174 /**
175 * Set the member variable indicating whether the state of the CAM should be reset when
176 * the main PHY switches channel and operates on the link associated with the CAM.
177 *
178 * @param enable whether the CAM state should be reset
179 */
180 void SetCamStateReset(bool enable);
181
182 /**
183 * @return the value of the member variable indicating whether the state of the CAM should be
184 * reset when the main PHY switches channel and operates on the link associated with the CAM.
185 */
186 bool GetCamStateReset() const;
187
188 /**
189 * Notify that an UL TXOP is gained on the given link by the given AC. This method has to
190 * determine whether to start the UL TXOP or release the channel.
191 *
192 * @param linkId the ID of the given link
193 * @param aci the index of the given AC
194 * @return a pair consisting of a boolean value indicating whether the UL TXOP can be started
195 * and a Time value indicating the delay after which the EMLSR client must restart
196 * channel access (if needed) in case the UL TXOP is not started
197 */
198 std::pair<bool, Time> GetDelayUntilAccessRequest(uint8_t linkId, AcIndex aci);
199
200 /**
201 * Set the member variable indicating whether Aux PHYs are capable of transmitting PPDUs.
202 *
203 * @param capable whether Aux PHYs are capable of transmitting PPDUs
204 */
205 void SetAuxPhyTxCapable(bool capable);
206
207 /**
208 * @return whether Aux PHYs are capable of transmitting PPDUs
209 */
210 bool GetAuxPhyTxCapable() const;
211
212 /**
213 * Set the member variable indicating whether in-device interference is such that a PHY cannot
214 * decode anything and cannot decrease the backoff counter when another PHY is transmitting.
215 *
216 * @param enable whether in-device interference is such that a PHY cannot decode anything
217 * and cannot decrease the backoff counter when another PHY is transmitting
218 */
219 void SetInDeviceInterference(bool enable);
220
221 /**
222 * @return whether in-device interference is such that a PHY cannot decode anything and cannot
223 * decrease the backoff counter when another PHY is transmitting
224 */
225 bool GetInDeviceInterference() const;
226
227 /**
228 * Notify the reception of a management frame addressed to us.
229 *
230 * @param mpdu the received MPDU
231 * @param linkId the ID of the link over which the MPDU was received
232 */
233 void NotifyMgtFrameReceived(Ptr<const WifiMpdu> mpdu, uint8_t linkId);
234
235 /**
236 * Notify the start of a DL TXOP on the given link.
237 *
238 * @param linkId the ID of the given link
239 */
240 void NotifyDlTxopStart(uint8_t linkId);
241
242 /**
243 * Notify the start of an UL TXOP on the given link
244 *
245 * @param linkId the ID of the given link
246 */
247 void NotifyUlTxopStart(uint8_t linkId);
248
249 /**
250 * Notify that RTS transmission is starting on the given link.
251 *
252 * @param linkId the ID of the given link
253 * @param rts the RTS being transmitted
254 * @param txVector the TXVECTOR used to transmit the RTS
255 */
256 virtual void NotifyRtsSent(uint8_t linkId,
258 const WifiTxVector& txVector);
259
260 /**
261 * Notify that protection (if required) is completed and data frame exchange can start
262 * on the given link.
263 *
264 * @param linkId the ID of the given link
265 */
266 void NotifyProtectionCompleted(uint8_t linkId);
267
268 /**
269 * Notify the end of a TXOP on the given link.
270 *
271 * @param linkId the ID of the given link
272 * @param edca the EDCAF that carried out the TXOP, in case of UL TXOP, or a null pointer,
273 * in case of DL TXOP
274 */
275 void NotifyTxopEnd(uint8_t linkId, Ptr<QosTxop> edca = nullptr);
276
277 /**
278 * Notify that an STA affiliated with the EMLSR client is causing in-device interference
279 * for the given amount of time.
280 *
281 * @param linkId the ID of the link on which the STA is operating
282 * @param duration the duration of the in-device interference
283 */
284 virtual void NotifyInDeviceInterferenceStart(uint8_t linkId, Time duration);
285
286 /**
287 * Check whether the MediumSyncDelay timer is running for the STA operating on the given link.
288 * If so, returns the time elapsed since the timer started.
289 *
290 * @param linkId the ID of the given link
291 * @return the time elapsed since the MediumSyncDelay timer started, if this timer is running
292 * for the STA operating on the given link
293 */
294 std::optional<Time> GetElapsedMediumSyncDelayTimer(uint8_t linkId) const;
295
296 /**
297 * Cancel the MediumSyncDelay timer associated with the given link and take the appropriate
298 * actions. This function must not be called when the MediumSyncDelay timer is not running
299 * on the given link.
300 *
301 * @param linkId the ID of the link associated with the MediumSyncDelay timer to cancel
302 */
303 void CancelMediumSyncDelayTimer(uint8_t linkId);
304
305 /**
306 * Decrement the counter indicating the number of TXOP attempts left while the MediumSyncDelay
307 * timer is running. This function must not be called when the MediumSyncDelay timer is not
308 * running on the given link.
309 *
310 * @param linkId the ID of the link on which a new TXOP attempt may be carried out
311 */
312 void DecrementMediumSyncDelayNTxops(uint8_t linkId);
313
314 /**
315 * Reset the counter indicating the number of TXOP attempts left while the MediumSyncDelay
316 * timer is running, so as to remove the limit on the number of attempts that can be made
317 * while the MediumSyncDelay timer is running. This function is normally called when a TXOP
318 * attempt is successful. This function must not be called when the MediumSyncDelay timer is
319 * not running on the given link.
320 *
321 * @param linkId the ID of the link for which the counter of the TXOP attempts is reset
322 */
323 void ResetMediumSyncDelayNTxops(uint8_t linkId);
324
325 /**
326 * Return whether no more TXOP attempt is allowed on the given link. This function must not
327 * be called when the MediumSyncDelay timer is not running on the given link.
328 *
329 * @param linkId the ID of the link on which a new TXOP attempt may be carried out
330 * @return whether no more TXOP attempt on the given link is allowed
331 */
332 bool MediumSyncDelayNTxopsExceeded(uint8_t linkId);
333
334 /**
335 * Check whether a PPDU that may be an ICF is being received on the given link. If so, return
336 * true along with the time to wait to know more information about the PPDU being received.
337 * Otherwise, return false.
338 *
339 * @param linkId the ID of the given link
340 * @return a pair indicating whether a PPDU that may be an ICF is being received on the link
341 */
342 std::pair<bool, Time> CheckPossiblyReceivingIcf(uint8_t linkId) const;
343
344 /**
345 * This method is called when an aux PHY has completed reception of an ICF to determine whether
346 * there is any reason preventing the main PHY from switching link and be on the aux PHY link
347 * by the time the ICF reception is completed to take over the DL TXOP.
348 *
349 * @param linkId the ID of the link on which ICF has been received
350 * @return the reason, if any, preventing the main PHY from switching link
351 */
352 virtual std::optional<WifiIcfDrop> CheckMainPhyTakesOverDlTxop(uint8_t linkId) const;
353
354 protected:
355 void DoDispose() override;
356
357 /**
358 * Allow subclasses to take actions when the MAC is set.
359 *
360 * @param mac the wifi MAC
361 */
362 virtual void DoSetWifiMac(Ptr<StaWifiMac> mac);
363
364 /**
365 * @return the MAC of the non-AP MLD managed by this EMLSR Manager.
366 */
368
369 /**
370 * @param linkId the ID of the given link
371 * @return the EHT FrameExchangeManager attached to the non-AP STA operating on the given link
372 */
373 Ptr<EhtFrameExchangeManager> GetEhtFem(uint8_t linkId) const;
374
375 /**
376 * @return the ID of the link on which the EML Operating Mode Notification frame has to be sent
377 */
378 virtual uint8_t GetLinkToSendEmlOmn() = 0;
379
380 /**
381 * A previous EML Operating Mode Notification frame was dropped. Ask the subclass whether
382 * the frame needs to be re-sent on the given link (if any).
383 *
384 * @param mpdu the dropped MPDU that includes the EML Operating Mode Notification frame
385 * @return the ID of the link over which to re-send the frame, if needed
386 */
387 virtual std::optional<uint8_t> ResendNotification(Ptr<const WifiMpdu> mpdu) = 0;
388
389 /**
390 * @param linkId the ID of the given link
391 * @return the operating channel the main PHY must switch to in order to operate
392 * on the given link
393 */
394 const WifiPhyOperatingChannel& GetChannelForMainPhy(uint8_t linkId) const;
395
396 /**
397 * @param linkId the ID of the given link
398 * @return the operating channel an aux PHY must switch to in order to operate
399 * on the given link
400 */
401 const WifiPhyOperatingChannel& GetChannelForAuxPhy(uint8_t linkId) const;
402
403 /**
404 * Switch channel on the Main PHY so that it operates on the given link.
405 *
406 * @param linkId the ID of the link on which the main PHY has to operate
407 * @param noSwitchDelay whether switching delay should be zero
408 * @param requestAccess whether channel access should be requested on the link on which the
409 * main PHY is moving onto
410 * @param traceInfo information to pass to the main PHY switch traced callback (the fromLinkId
411 * and toLinkId fields are set by this function)
412 */
413 void SwitchMainPhy(uint8_t linkId,
414 bool noSwitchDelay,
415 bool requestAccess,
416 EmlsrMainPhySwitchTrace&& traceInfo);
417
418 static constexpr bool REQUEST_ACCESS = true; //!< request channel access when PHY switch ends
419 static constexpr bool DONT_REQUEST_ACCESS =
420 false; //!< do not request channel access when PHY switch ends
421
422 /**
423 * Switch channel on the Aux PHY operating on the given current link so that it operates
424 * on the given next link.
425 *
426 * @param auxPhy the Aux PHY
427 * @param currLinkId the ID of the link on which the aux PHY is currently operating
428 * @param nextLinkId the ID of the link on which the aux PHY will be operating
429 */
430 void SwitchAuxPhy(Ptr<WifiPhy> auxPhy, uint8_t currLinkId, uint8_t nextLinkId);
431
432 /**
433 * Callback connected to the EmlsrLinkSwitch trace source of StaWifiMac.
434 *
435 * @param linkId the ID of the link which the PHY is connected to/disconnected from
436 * @param phy a pointer to the PHY that is connected to/disconnected from the given link
437 * @param connected true if the PHY is connected, false if the PHY is disconnected
438 */
439 virtual void EmlsrLinkSwitchCallback(uint8_t linkId, Ptr<WifiPhy> phy, bool connected);
440
441 /**
442 * Set the CCA ED threshold (if needed) on the given PHY that is switching channel to
443 * operate on the given link.
444 *
445 * @param phy the given PHY
446 * @param linkId the ID of the given link
447 */
448 void SetCcaEdThresholdOnLinkSwitch(Ptr<WifiPhy> phy, uint8_t linkId);
449
450 /**
451 * @return the EML Operating Mode Notification to send
452 */
454
455 /**
456 * Subclasses have to provide an implementation for this method, that is called by the base
457 * class when the EMLSR client gets channel access on the given link. This method has to
458 * check possible reasons to give up the TXOP that apply to both main PHY and aux PHYs.
459 *
460 * @param linkId the ID of the given link
461 * @return a pair consisting of a boolean value indicating whether the UL TXOP can be started
462 * and a Time value indicating the delay after which the EMLSR client must restart
463 * channel access (if needed) in case the UL TXOP is not started
464 */
465 virtual std::pair<bool, Time> DoGetDelayUntilAccessRequest(uint8_t linkId) = 0;
466
467 /**
468 * Subclasses have to provide an implementation for this method, that is called by the base
469 * class when the given AC of the EMLSR client gets channel access on the given link, on which
470 * an aux PHY that is not TX capable is operating. This method has to request the main PHY to
471 * switch to the given link to take over the TXOP, unless it is decided to give up the TXOP.
472 *
473 * @param linkId the ID of the given link
474 * @param aci the index of the given AC
475 */
476 virtual void SwitchMainPhyIfTxopGainedByAuxPhy(uint8_t linkId, AcIndex aci) = 0;
477
478 /**
479 * Subclasses have to provide an implementation for this method, that is called by the base
480 * class when the EMLSR client gets channel access on the given link, on which an aux PHY that
481 * is TX capable is operating. This method has to request the main PHY to switch to the
482 * given link to take over the TXOP, if possible, or determine the delay after which the
483 * EMLSR client restarts channel access on the given link, otherwise.
484 *
485 * @param linkId the ID of the given link
486 * @return a pair consisting of a boolean value indicating whether the UL TXOP can be started
487 * and a Time value indicating the delay after which the EMLSR client must restart
488 * channel access (if needed) in case the UL TXOP is not started
489 */
490 virtual std::pair<bool, Time> GetDelayUnlessMainPhyTakesOverUlTxop(uint8_t linkId) = 0;
491
492 /**
493 * Set sleep state or awake state for all aux PHYs.
494 *
495 * @param sleep set sleep state, if true, or awake state, otherwise
496 */
497 void SetSleepStateForAllAuxPhys(bool sleep);
498
499 /**
500 * Cancel all pending events to put aux PHYs into sleep/awake state.
501 */
503
504 /// Store information about a main PHY switch.
505 struct WIFI_EXPORT MainPhySwitchInfo
506 {
507 Time start; //!< start of channel switching
508 bool disconnected{false}; //!< true if the main PHY is not connected to any link, i.e., it
509 //!< is switching or waiting to be connected to a link
510 uint8_t from{}; //!< ID of the link which the main PHY is/has been leaving
511 uint8_t to{}; //!< ID of the link which the main PHY is moving to
512 std::string reason; //!< the reason for switching the main PHY
513 };
514
515 Time m_emlsrPaddingDelay; //!< EMLSR Padding delay
516 Time m_emlsrTransitionDelay; //!< EMLSR Transition delay
517 uint8_t m_mainPhyId; //!< ID of main PHY (position in the vector of PHYs held by WifiNetDevice)
518 MHz_u m_auxPhyMaxWidth; //!< max channel width supported by aux PHYs
519 WifiModulationClass m_auxPhyMaxModClass; //!< max modulation class supported by aux PHYs
520 bool m_auxPhyTxCapable; //!< whether Aux PHYs are capable of transmitting PPDUs
521 bool m_auxPhyToSleep; //!< whether Aux PHYs should be put into sleep mode while the Main PHY
522 //!< is carrying out a (DL or UL) TXOP
523 bool m_useNotifiedMacHdr; //!< whether to use the information about the MAC header of
524 //!< the MPDU being received (if notified by the PHY)
525 std::map<uint8_t, EventId> m_auxPhyToSleepEvents; //!< PHY ID-indexed map of events scheduled to
526 //!< put an Aux PHY to sleep
527 std::map<uint8_t, Time> m_startSleep; //!< PHY ID-indexed map of last time sleep mode started
528 std::map<uint8_t, EventId> m_ulMainPhySwitch; //!< link ID-indexed map of timers started when
529 //!< an aux PHY gains an UL TXOP and schedules
530 //!< a channel switch for the main PHY
531 MainPhySwitchInfo m_mainPhySwitchInfo; //!< main PHY switch info
532
533 private:
534 /**
535 * Set the ID of main PHY (position in the vector of PHYs held by WifiNetDevice). This
536 * method cannot be called during or after initialization.
537 *
538 * @param mainPhyId the ID of the main PHY
539 */
540 void SetMainPhyId(uint8_t mainPhyId);
541
542 /**
543 * Compute the operating channels that the main PHY and the aux PHY(s) must switch to in order
544 * to operate on each of the setup links. The operating channels may be different due to
545 * limited channel width capabilities of the aux PHY(s). This method shall be called upon
546 * completion of ML setup.
547 */
549
550 /**
551 * Send an EML Operating Mode Notification frame.
552 */
553 void SendEmlOmn();
554
555 /**
556 * Start the MediumSyncDelay timer and take the appropriate actions.
557 *
558 * @param linkId the ID of the link on which medium synchronization was lost
559 */
560 void StartMediumSyncDelayTimer(uint8_t linkId);
561
562 /**
563 * Take the appropriate actions when the MediumSyncDelay timer expires or is cancelled.
564 *
565 * @param linkId the ID of the link associated with the MediumSyncDelay timer to cancel
566 */
567 void MediumSyncDelayTimerExpired(uint8_t linkId);
568
569 /**
570 * Notify the subclass of the reception of a management frame addressed to us.
571 *
572 * @param mpdu the received MPDU
573 * @param linkId the ID of the link over which the MPDU was received
574 */
575 virtual void DoNotifyMgtFrameReceived(Ptr<const WifiMpdu> mpdu, uint8_t linkId) = 0;
576
577 /**
578 * Notify the subclass of the reception of an initial Control frame on the given link.
579 *
580 * @param linkId the ID of the link on which the initial Control frame was received
581 */
582 virtual void DoNotifyDlTxopStart(uint8_t linkId) = 0;
583
584 /**
585 * Notify the subclass of the start of an UL TXOP on the given link
586 *
587 * @param linkId the ID of the given link
588 */
589 virtual void DoNotifyUlTxopStart(uint8_t linkId) = 0;
590
591 /**
592 * Notify the subclass that protection (if required) is completed and data frame exchange can
593 * start on the given link.
594 *
595 * @param linkId the ID of the given link
596 */
597 virtual void DoNotifyProtectionCompleted(uint8_t linkId) = 0;
598
599 /**
600 * Notify the subclass of the end of a TXOP on the given link.
601 *
602 * @param linkId the ID of the given link
603 * @param edca the EDCAF that carried out the TXOP, in case of UL TXOP, or a null pointer,
604 * in case of DL TXOP
605 */
606 virtual void DoNotifyTxopEnd(uint8_t linkId, Ptr<QosTxop> edca) = 0;
607
608 /**
609 * Notify the acknowledgment of the given MPDU.
610 *
611 * @param mpdu the acknowledged MPDU
612 */
613 void TxOk(Ptr<const WifiMpdu> mpdu);
614
615 /**
616 * Notify that the given MPDU has been discarded for the given reason.
617 *
618 * @param reason the reason why the MPDU was dropped
619 * @param mpdu the dropped MPDU
620 */
622
623 /**
624 * This method is called to make an EMLSR mode change effective after the transition
625 * delay has elapsed or a notification response has been received from the AP.
626 *
627 * @param txLinkId the ID of the link on which the EML OMN frame was sent by the EMLSR client
628 */
629 void ChangeEmlsrMode(uint8_t txLinkId);
630
631 /**
632 * Adjust the operating channel of all the aux PHYs to meet the constraint on the maximum
633 * channel width supported by aux PHYs.
634 */
636
637 /**
638 * Notify subclass that EMLSR mode changed.
639 */
640 virtual void NotifyEmlsrModeChanged() = 0;
641
642 /**
643 * Notify subclass that the main PHY is switching channel to operate on another link.
644 *
645 * @param currLinkId the ID of the link on which the main PHY is operating (if any)
646 * @param nextLinkId the ID of the link on which the main PHY will be operating
647 * @param auxPhy the aux PHY operating on the link on which the main PHY will be operating
648 * @param duration the channel switch duration
649 */
650 virtual void NotifyMainPhySwitch(std::optional<uint8_t> currLinkId,
651 uint8_t nextLinkId,
652 Ptr<WifiPhy> auxPhy,
653 Time duration) = 0;
654
655 /**
656 * Information about the status of the MediumSyncDelay timer associated with a link.
657 */
658 struct WIFI_EXPORT MediumSyncDelayStatus
659 {
660 EventId timer; //!< the MediumSyncDelay timer
661 std::optional<uint8_t> msdNTxopsLeft; //!< number of TXOP attempts left while the
662 //!< MediumSyncDelay timer is running
663 };
664
665 /**
666 * TracedCallback signature for main PHY switch events.
667 *
668 * @param info the information associated with the main PHY switch event
669 */
670 typedef void (*MainPhySwitchCallback)(const EmlsrMainPhySwitchTrace& info);
671
672 /// TracedCallback for main PHY switch events typedef
674
675 MainPhySwitchTracedCallback m_mainPhySwitchTrace; //!< main PHY switch trace source
676
677 Ptr<StaWifiMac> m_staMac; //!< the MAC of the managed non-AP MLD
678 std::optional<Time> m_emlsrTransitionTimeout; /**< Transition timeout advertised by APs with
679 EMLSR activated */
680 Time m_mediumSyncDuration; //!< duration of the MediumSyncDelay timer
681 int8_t m_msdOfdmEdThreshold; //!< MediumSyncDelay OFDM ED threshold
682 std::optional<uint8_t> m_msdMaxNTxops; //!< MediumSyncDelay max number of TXOPs
683
684 std::map<uint8_t, MediumSyncDelayStatus>
685 m_mediumSyncDelayStatus; //!< the status of MediumSyncDelay timers (link ID-indexed)
686 std::map<Ptr<WifiPhy>, dBm_u> m_prevCcaEdThreshold; //!< the CCA sensitivity threshold
687 //!< to restore once the MediumSyncDelay
688 //!< timer expires or the PHY moves to a
689 //!< link on which the timer is not running
690
691 std::set<uint8_t> m_emlsrLinks; //!< ID of the EMLSR links (empty if EMLSR mode is disabled)
692 std::optional<std::set<uint8_t>> m_nextEmlsrLinks; /**< ID of the links that will become the
693 EMLSR links when the pending
694 notification frame is acknowledged */
695 Time m_lastAdvPaddingDelay; //!< last advertised padding delay
696 Time m_lastAdvTransitionDelay; //!< last advertised transition delay
697 EventId m_transitionTimeoutEvent; /**< Timer started after the successful transmission of an
698 EML Operating Mode Notification frame */
699 bool m_resetCamState; //!< whether to reset the state of CAM when main PHY switches channel
700 bool m_inDeviceInterference; //!< whether in-device interference is such that a PHY cannot
701 //!< decode anything and cannot decrease the backoff counter
702 //!< when another PHY is transmitting
703 std::map<uint8_t, WifiPhyOperatingChannel>
704 m_mainPhyChannels; //!< link ID-indexed map of operating channels for the main PHY
705 std::map<uint8_t, WifiPhyOperatingChannel>
706 m_auxPhyChannels; //!< link ID-indexed map of operating channels for the aux PHYs
707 std::map<uint8_t, Time>
708 m_noPhySince; //!< link ID-indexed map of the time since no PHY is operating on the link
709};
710
711/**
712 * Struct to trace that main PHY switched to start a DL TXOP after that an aux PHY received an ICF.
713 */
715 : public EmlsrMainPhySwitchTraceImpl<EmlsrDlTxopIcfReceivedByAuxPhyTrace>
716{
717 static constexpr std::string_view m_name = "DlTxopIcfReceivedByAuxPhy"; //!< trace name
718};
719
720/**
721 * Struct to trace that main PHY switched to start an UL TXOP after that an aux PHY transmitted an
722 * RTS.
723 */
725 : public EmlsrMainPhySwitchTraceImpl<EmlsrUlTxopRtsSentByAuxPhyTrace>
726{
727 static constexpr std::string_view m_name = "UlTxopRtsSentByAuxPhy"; //!< trace name
728};
729
730/**
731 * Struct to trace that main PHY switched when a (DL or UL) TXOP ended.
732 *
733 * This trace is called when aux PHYs do not switch link and the main PHY switches back to the
734 * preferred link when a TXOP carried out on another link ends.
735 */
736struct WIFI_EXPORT EmlsrTxopEndedTrace : public EmlsrMainPhySwitchTraceImpl<EmlsrTxopEndedTrace>
737{
738 static constexpr std::string_view m_name = "TxopEnded"; //!< trace name
739};
740
741/**
742 * Struct to trace that main PHY started switching after a CTS timeout occurred on the link on
743 * which an RTS was transmitted to start an UL TXOP. Provides the time elapsed since the
744 * CTS timeout occurred.
745 *
746 * |-- main PHY switch --|
747 * |----- to link 1 -----|
748 * ┌───────────┐
749 * │ CTS │
750 * ────────────────────────┬───────────┬───┴X──────────┴─────────────────────────────
751 * [link 1] │ RTS │ │-elapsed-│
752 * └───────────┘ │-- time--|-- main PHY switch --|
753 * │ |- to preferred link -|
754 * CTS timeout
755 *
756 * Normally, this trace is called when aux PHYs do not switch links, because the main PHY has to
757 * return to the preferred link upon CTS timeout, because a TXOP did not start. In some cases, the
758 * main PHY may be switching when CTS timeout occurs; this happens when an aux PHY that is TX
759 * capable transmits an RTS and the main PHY starts switching to the aux PHY link (the start time
760 * of the main PHY switch is computed such that the main PHY switch ends slightly after the
761 * reception of the CTS). In such a case, the main PHY completes the current link switch and then
762 * it starts switching to return back to the preferred link.
763 *
764 * Note that the Advanced EMLSR manager may allow a main PHY switch to be interrupted. If this
765 * option is enabled and the main PHY is switching when CTS timeout occurs, the previous switch is
766 * interrupted and the main PHY starts switching to the previous link (in this case, the time
767 * elapsed since the CTS timeout occurred is zero). This holds true for both the case aux PHYs do
768 * not switch link and the case aux PHYs switch link.
769 */
771 : public EmlsrMainPhySwitchTraceImpl<EmlsrCtsAfterRtsTimeoutTrace>
772{
773 static constexpr std::string_view m_name = "CtsAfterRtsTimeout"; //!< trace name
774
775 Time sinceCtsTimeout; //!< time elapsed since CTS timeout occurred
776
777 /**
778 * Constructor provided because this struct is not an aggregate (it has a base struct), hence
779 * we cannot use designated initializers.
780 *
781 * @param elapsed the value for the sinceCtsTimeout field
782 */
784 : sinceCtsTimeout(elapsed)
785 {
786 }
787};
788
789/**
790 * Struct to trace that main PHY switched to operate on a link on which an aux PHY that is not
791 * TX capable has gained or is expected to shortly gain a TXOP.
792 */
794 : public EmlsrMainPhySwitchTraceImpl<EmlsrUlTxopAuxPhyNotTxCapableTrace>
795{
796 static constexpr std::string_view m_name = "UlTxopAuxPhyNotTxCapable"; //!< trace name
797
798 AcIndex acIndex; //!< Access category of TXOP on aux PHY
799 Time remTime; //!< Remaining time to complete backoff countdown on the aux PHY link
800 Time remNav; //!< the remaining NAV on main PHY link when main PHY is requested to switch
801
802 /**
803 * Constructor provided because this struct is not an aggregate (it has a base struct), hence
804 * we cannot use designated initializers.
805 *
806 * @param aci the value for the acIndex field
807 * @param delay the value for the remTime field
808 * @param navLeft the value for the remNav field
809 */
810 EmlsrUlTxopAuxPhyNotTxCapableTrace(AcIndex aci, const Time& delay, const Time& navLeft)
811 : acIndex(aci),
812 remTime(delay),
813 remNav(navLeft)
814 {
815 }
816};
817
818} // namespace ns3
819
820#endif /* EMLSR_MANAGER_H */
Test CCA busy notifications on EMLSR clients.
EhtFrameExchangeManager handles the frame exchange sequences for EHT stations.
void SendEmlOmn()
Send an EML Operating Mode Notification frame.
void ChangeEmlsrMode(uint8_t txLinkId)
This method is called to make an EMLSR mode change effective after the transition delay has elapsed o...
Time GetMediumSyncDuration() const
void ComputeOperatingChannels()
Compute the operating channels that the main PHY and the aux PHY(s) must switch to in order to operat...
void(* MainPhySwitchCallback)(const EmlsrMainPhySwitchTrace &info)
TracedCallback signature for main PHY switch events.
void SwitchMainPhy(uint8_t linkId, bool noSwitchDelay, bool requestAccess, EmlsrMainPhySwitchTrace &&traceInfo)
Switch channel on the Main PHY so that it operates on the given link.
std::map< uint8_t, Time > m_startSleep
PHY ID-indexed map of last time sleep mode started.
void NotifyProtectionCompleted(uint8_t linkId)
Notify that protection (if required) is completed and data frame exchange can start on the given link...
void SetTransitionTimeout(Time timeout)
Set the Transition Timeout advertised by the associated AP with EMLSR activated.
void CancelMediumSyncDelayTimer(uint8_t linkId)
Cancel the MediumSyncDelay timer associated with the given link and take the appropriate actions.
bool m_useNotifiedMacHdr
whether to use the information about the MAC header of the MPDU being received (if notified by the PH...
bool m_auxPhyTxCapable
whether Aux PHYs are capable of transmitting PPDUs
virtual void DoNotifyTxopEnd(uint8_t linkId, Ptr< QosTxop > edca)=0
Notify the subclass of the end of a TXOP on the given link.
bool MediumSyncDelayNTxopsExceeded(uint8_t linkId)
Return whether no more TXOP attempt is allowed on the given link.
std::optional< Time > GetTransitionTimeout() const
std::pair< bool, Time > GetDelayUntilAccessRequest(uint8_t linkId, AcIndex aci)
Notify that an UL TXOP is gained on the given link by the given AC.
virtual std::pair< bool, Time > DoGetDelayUntilAccessRequest(uint8_t linkId)=0
Subclasses have to provide an implementation for this method, that is called by the base class when t...
Ptr< EhtFrameExchangeManager > GetEhtFem(uint8_t linkId) const
void TxDropped(WifiMacDropReason reason, Ptr< const WifiMpdu > mpdu)
Notify that the given MPDU has been discarded for the given reason.
void NotifyUlTxopStart(uint8_t linkId)
Notify the start of an UL TXOP on the given link.
void TxOk(Ptr< const WifiMpdu > mpdu)
Notify the acknowledgment of the given MPDU.
void MediumSyncDelayTimerExpired(uint8_t linkId)
Take the appropriate actions when the MediumSyncDelay timer expires or is cancelled.
std::map< uint8_t, EventId > m_ulMainPhySwitch
link ID-indexed map of timers started when an aux PHY gains an UL TXOP and schedules a channel switch...
bool m_inDeviceInterference
whether in-device interference is such that a PHY cannot decode anything and cannot decrease the back...
bool GetCamStateReset() const
void SetEmlsrLinks(const std::set< uint8_t > &linkIds)
Take actions to enable EMLSR mode on the given set of links, if non-empty, or disable EMLSR mode,...
void SetMediumSyncOfdmEdThreshold(int8_t threshold)
Set the Medium Synchronization OFDM ED threshold (dBm) to use while the MediumSyncDelay timer is runn...
uint8_t m_mainPhyId
ID of main PHY (position in the vector of PHYs held by WifiNetDevice).
int8_t GetMediumSyncOfdmEdThreshold() const
std::map< uint8_t, EventId > m_auxPhyToSleepEvents
PHY ID-indexed map of events scheduled to put an Aux PHY to sleep.
std::map< uint8_t, MediumSyncDelayStatus > m_mediumSyncDelayStatus
the status of MediumSyncDelay timers (link ID-indexed)
bool m_auxPhyToSleep
whether Aux PHYs should be put into sleep mode while the Main PHY is carrying out a (DL or UL) TXOP
virtual std::pair< bool, Time > GetDelayUnlessMainPhyTakesOverUlTxop(uint8_t linkId)=0
Subclasses have to provide an implementation for this method, that is called by the base class when t...
TracedCallback< const EmlsrMainPhySwitchTrace & > MainPhySwitchTracedCallback
TracedCallback for main PHY switch events typedef.
virtual void SwitchMainPhyIfTxopGainedByAuxPhy(uint8_t linkId, AcIndex aci)=0
Subclasses have to provide an implementation for this method, that is called by the base class when t...
void NotifyDlTxopStart(uint8_t linkId)
Notify the start of a DL TXOP on the given link.
void NotifyMgtFrameReceived(Ptr< const WifiMpdu > mpdu, uint8_t linkId)
Notify the reception of a management frame addressed to us.
virtual uint8_t GetLinkToSendEmlOmn()=0
std::map< uint8_t, WifiPhyOperatingChannel > m_auxPhyChannels
link ID-indexed map of operating channels for the aux PHYs
virtual void DoNotifyUlTxopStart(uint8_t linkId)=0
Notify the subclass of the start of an UL TXOP on the given link.
Ptr< StaWifiMac > m_staMac
the MAC of the managed non-AP MLD
virtual void DoNotifyMgtFrameReceived(Ptr< const WifiMpdu > mpdu, uint8_t linkId)=0
Notify the subclass of the reception of a management frame addressed to us.
Time m_emlsrPaddingDelay
EMLSR Padding delay.
bool GetInDeviceInterference() const
virtual void NotifyMainPhySwitch(std::optional< uint8_t > currLinkId, uint8_t nextLinkId, Ptr< WifiPhy > auxPhy, Time duration)=0
Notify subclass that the main PHY is switching channel to operate on another link.
MHz_u m_auxPhyMaxWidth
max channel width supported by aux PHYs
virtual void NotifyInDeviceInterferenceStart(uint8_t linkId, Time duration)
Notify that an STA affiliated with the EMLSR client is causing in-device interference for the given a...
void SetMediumSyncMaxNTxops(std::optional< uint8_t > nTxops)
Set the maximum number of TXOPs a non-AP STA is allowed to attempt to initiate while the MediumSyncDe...
Time m_emlsrTransitionDelay
EMLSR Transition delay.
void SetWifiMac(Ptr< StaWifiMac > mac)
Set the wifi MAC.
void DecrementMediumSyncDelayNTxops(uint8_t linkId)
Decrement the counter indicating the number of TXOP attempts left while the MediumSyncDelay timer is ...
bool GetAuxPhyTxCapable() const
const std::set< uint8_t > & GetEmlsrLinks() const
MainPhySwitchTracedCallback m_mainPhySwitchTrace
main PHY switch trace source
void CancelAllSleepEvents()
Cancel all pending events to put aux PHYs into sleep/awake state.
friend class WifiStaticSetupHelper
Time m_mediumSyncDuration
duration of the MediumSyncDelay timer
void NotifyTxopEnd(uint8_t linkId, Ptr< QosTxop > edca=nullptr)
Notify the end of a TXOP on the given link.
std::optional< Time > m_emlsrTransitionTimeout
Transition timeout advertised by APs with EMLSR activated.
void SwitchAuxPhy(Ptr< WifiPhy > auxPhy, uint8_t currLinkId, uint8_t nextLinkId)
Switch channel on the Aux PHY operating on the given current link so that it operates on the given ne...
std::map< Ptr< WifiPhy >, dBm_u > m_prevCcaEdThreshold
the CCA sensitivity threshold to restore once the MediumSyncDelay timer expires or the PHY moves to a...
void ResetMediumSyncDelayNTxops(uint8_t linkId)
Reset the counter indicating the number of TXOP attempts left while the MediumSyncDelay timer is runn...
std::optional< Time > GetElapsedMediumSyncDelayTimer(uint8_t linkId) const
Check whether the MediumSyncDelay timer is running for the STA operating on the given link.
virtual void DoSetWifiMac(Ptr< StaWifiMac > mac)
Allow subclasses to take actions when the MAC is set.
std::map< uint8_t, Time > m_noPhySince
link ID-indexed map of the time since no PHY is operating on the link
void SetAuxPhyTxCapable(bool capable)
Set the member variable indicating whether Aux PHYs are capable of transmitting PPDUs.
virtual std::optional< WifiIcfDrop > CheckMainPhyTakesOverDlTxop(uint8_t linkId) const
This method is called when an aux PHY has completed reception of an ICF to determine whether there is...
std::optional< std::set< uint8_t > > m_nextEmlsrLinks
ID of the links that will become the EMLSR links when the pending notification frame is acknowledged.
void SetCcaEdThresholdOnLinkSwitch(Ptr< WifiPhy > phy, uint8_t linkId)
Set the CCA ED threshold (if needed) on the given PHY that is switching channel to operate on the giv...
virtual void NotifyEmlsrModeChanged()=0
Notify subclass that EMLSR mode changed.
void SetMainPhyId(uint8_t mainPhyId)
Set the ID of main PHY (position in the vector of PHYs held by WifiNetDevice).
virtual void EmlsrLinkSwitchCallback(uint8_t linkId, Ptr< WifiPhy > phy, bool connected)
Callback connected to the EmlsrLinkSwitch trace source of StaWifiMac.
const WifiPhyOperatingChannel & GetChannelForMainPhy(uint8_t linkId) const
void ApplyMaxChannelWidthAndModClassOnAuxPhys()
Adjust the operating channel of all the aux PHYs to meet the constraint on the maximum channel width ...
void SetMediumSyncDuration(Time duration)
Set the duration of the MediumSyncDelay timer.
Time m_lastAdvTransitionDelay
last advertised transition delay
MainPhySwitchInfo m_mainPhySwitchInfo
main PHY switch info
virtual void DoNotifyDlTxopStart(uint8_t linkId)=0
Notify the subclass of the reception of an initial Control frame on the given link.
static constexpr bool REQUEST_ACCESS
request channel access when PHY switch ends
static constexpr bool DONT_REQUEST_ACCESS
do not request channel access when PHY switch ends
void DoDispose() override
Destructor implementation.
void StartMediumSyncDelayTimer(uint8_t linkId)
Start the MediumSyncDelay timer and take the appropriate actions.
int8_t m_msdOfdmEdThreshold
MediumSyncDelay OFDM ED threshold.
virtual void DoNotifyProtectionCompleted(uint8_t linkId)=0
Notify the subclass that protection (if required) is completed and data frame exchange can start on t...
std::map< uint8_t, WifiPhyOperatingChannel > m_mainPhyChannels
link ID-indexed map of operating channels for the main PHY
std::optional< uint8_t > m_msdMaxNTxops
MediumSyncDelay max number of TXOPs.
virtual std::optional< uint8_t > ResendNotification(Ptr< const WifiMpdu > mpdu)=0
A previous EML Operating Mode Notification frame was dropped.
Ptr< StaWifiMac > GetStaMac() const
Time m_lastAdvPaddingDelay
last advertised padding delay
WifiModulationClass m_auxPhyMaxModClass
max modulation class supported by aux PHYs
uint8_t GetMainPhyId() const
std::optional< uint8_t > GetMediumSyncMaxNTxops() const
void SetCamStateReset(bool enable)
Set the member variable indicating whether the state of the CAM should be reset when the main PHY swi...
virtual void NotifyRtsSent(uint8_t linkId, Ptr< const WifiPsdu > rts, const WifiTxVector &txVector)
Notify that RTS transmission is starting on the given link.
EventId m_transitionTimeoutEvent
Timer started after the successful transmission of an EML Operating Mode Notification frame.
void SetInDeviceInterference(bool enable)
Set the member variable indicating whether in-device interference is such that a PHY cannot decode an...
const WifiPhyOperatingChannel & GetChannelForAuxPhy(uint8_t linkId) const
bool m_resetCamState
whether to reset the state of CAM when main PHY switches channel
static TypeId GetTypeId()
Get the type ID.
std::pair< bool, Time > CheckPossiblyReceivingIcf(uint8_t linkId) const
Check whether a PPDU that may be an ICF is being received on the given link.
std::set< uint8_t > m_emlsrLinks
ID of the EMLSR links (empty if EMLSR mode is disabled).
void SetSleepStateForAllAuxPhys(bool sleep)
Set sleep state or awake state for all aux PHYs.
An identifier for simulation events.
Definition event-id.h:45
Implement the header for Action frames of type EML Operating Mode Notification.
Object()
Caller graph was not generated because of its size.
Definition object.cc:93
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:50
WifiMpdu stores a (const) packet along with a MAC header.
Definition wifi-mpdu.h:52
Class that keeps track of all information about the current PHY operating channel.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiMacDropReason
The reason why an MPDU was dropped.
Definition wifi-mac.h:72
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition qos-utils.h:64
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double MHz_u
MHz weak type.
Definition wifi-units.h:31
double dBm_u
dBm weak type
Definition wifi-units.h:27
static constexpr uint8_t WIFI_LINKID_UNDEFINED
Invalid link identifier.
Definition wifi-utils.h:310
ns3::Time timeout
EmlsrCtsAfterRtsTimeoutTrace(const Time &elapsed)
Constructor provided because this struct is not an aggregate (it has a base struct),...
static constexpr std::string_view m_name
trace name
Time sinceCtsTimeout
time elapsed since CTS timeout occurred
Struct to trace that main PHY switched to start a DL TXOP after that an aux PHY received an ICF.
static constexpr std::string_view m_name
trace name
Base struct for EMLSR Main PHY switch traces.
virtual ~EmlsrMainPhySwitchTrace()=default
uint8_t toLinkId
ID of the link the main PHY is moving to.
std::optional< uint8_t > fromLinkId
ID of the link the main PHY is moving from (if any).
virtual std::string_view GetName() const =0
virtual std::shared_ptr< EmlsrMainPhySwitchTrace > Clone() const =0
Implementation for the EMLSR Main PHY switch trace base struct.
std::string_view GetName() const override
std::shared_ptr< EmlsrMainPhySwitchTrace > Clone() const override
Store information about a main PHY switch.
std::string reason
the reason for switching the main PHY
uint8_t from
ID of the link which the main PHY is/has been leaving.
Time start
start of channel switching
uint8_t to
ID of the link which the main PHY is moving to.
bool disconnected
true if the main PHY is not connected to any link, i.e., it is switching or waiting to be connected t...
Information about the status of the MediumSyncDelay timer associated with a link.
std::optional< uint8_t > msdNTxopsLeft
number of TXOP attempts left while the MediumSyncDelay timer is running
EventId timer
the MediumSyncDelay timer
Struct to trace that main PHY switched when a (DL or UL) TXOP ended.
static constexpr std::string_view m_name
trace name
Time remTime
Remaining time to complete backoff countdown on the aux PHY link.
EmlsrUlTxopAuxPhyNotTxCapableTrace(AcIndex aci, const Time &delay, const Time &navLeft)
Constructor provided because this struct is not an aggregate (it has a base struct),...
static constexpr std::string_view m_name
trace name
AcIndex acIndex
Access category of TXOP on aux PHY.
Time remNav
the remaining NAV on main PHY link when main PHY is requested to switch
Struct to trace that main PHY switched to start an UL TXOP after that an aux PHY transmitted an RTS.
static constexpr std::string_view m_name
trace name