A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
advanced-emlsr-manager.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Universita' di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
9#ifndef ADVANCED_EMLSR_MANAGER_H
10#define ADVANCED_EMLSR_MANAGER_H
11
13
14#include "ns3/channel-access-manager.h"
15
16#include <memory>
17
19
20namespace ns3
21{
22
23class WifiPhyListener;
24
25/**
26 * @ingroup wifi
27 *
28 * AdvancedEmlsrManager is an advanced EMLSR manager.
29 */
31{
32 /// Allow test cases to access private members
33 friend class ::EmlsrSwitchMainPhyBackTest;
34
35 public:
36 /**
37 * @brief Get the type ID.
38 * @return the object TypeId
39 */
40 static TypeId GetTypeId();
41
43 ~AdvancedEmlsrManager() override;
44
45 std::optional<WifiIcfDrop> CheckMainPhyTakesOverDlTxop(uint8_t linkId) const override;
46
47 /**
48 * This method is called by the PHY listener attached to the main PHY when a switch main PHY
49 * back timer is started to notify of events that may delay the channel access for the main
50 * PHY on the current link. If the expected channel access is beyond the end of the switch
51 * main PHY timer expiration plus a channel switch delay, the timer is stopped immediately.
52 */
54
55 protected:
56 void DoDispose() override;
57 void DoSetWifiMac(Ptr<StaWifiMac> mac) override;
58 std::pair<bool, Time> DoGetDelayUntilAccessRequest(uint8_t linkId) override;
59 std::pair<bool, Time> GetDelayUnlessMainPhyTakesOverUlTxop(uint8_t linkId) override;
60 void SwitchMainPhyIfTxopGainedByAuxPhy(uint8_t linkId, AcIndex aci) override;
61 void NotifyEmlsrModeChanged() override;
62 void SwitchMainPhyBackToPreferredLink(uint8_t linkId,
63 EmlsrMainPhySwitchTrace&& traceInfo) override;
64
65 /**
66 * Possibly take actions when notified of the MAC header of the MPDU being received by the
67 * given PHY.
68 *
69 * @param phy the given PHY
70 * @param macHdr the MAC header of the MPDU being received
71 * @param txVector the TXVECTOR used to transmit the PSDU
72 * @param psduDuration the remaining duration of the PSDU
73 */
75 const WifiMacHeader& macHdr,
76 const WifiTxVector& txVector,
77 Time psduDuration);
78
79 /**
80 * Use information from NAV and CCA performed by the given PHY on the given link in the last
81 * PIFS interval to determine whether the given EDCAF can start a TXOP. This function is
82 * intended to be used when the main PHY switches channel to start an UL TXOP on a link where
83 * channel access was obtained by a non-TX capable aux PHY.
84 *
85 * @param phy the PHY that performed CCA in the last PIFS interval
86 * @param linkId the ID of the given link
87 * @param edca the given EDCAF
88 */
89 void CheckNavAndCcaLastPifs(Ptr<WifiPhy> phy, uint8_t linkId, Ptr<QosTxop> edca);
90
91 /**
92 * Determine whether the main PHY shall be requested to switch to the link of an aux PHY that
93 * is expected to gain channel access through the given AC in the given delay but it is not
94 * TX capable.
95 *
96 * @param linkId the ID of the link on which the aux PHY is operating
97 * @param aci the index of the given AC
98 * @param delay the delay after which the given AC is expected to gain channel access. Zero
99 * indicates that channel access has been actually gained
100 * @return whether the main PHY shall be requested to switch to the link of the aux PHY
101 */
102 bool RequestMainPhyToSwitch(uint8_t linkId, AcIndex aci, const Time& delay);
103
104 /**
105 * This method is called when the given AC of the EMLSR client is expected to get channel
106 * access in the given delay on the given link, on which an aux PHY that is not TX capable
107 * is operating. This method has to decide whether to request the main PHY to switch to the
108 * given link to try to start a TXOP.
109 *
110 * @param linkId the ID of the given link
111 * @param aci the index of the given AC
112 * @param delay the delay after which the given AC is expected to gain channel access
113 */
114 void SwitchMainPhyIfTxopToBeGainedByAuxPhy(uint8_t linkId, AcIndex aci, const Time& delay);
115
116 /**
117 * This method is called when the switch main PHY back timer (which is started when the main PHY
118 * switches to the link of an aux PHY that does not switch and is not TX capable) expires and
119 * decides whether to delay the request to switch the main PHY back to the preferred link or to
120 * execute it immediately. This method can also be called to terminate a running switch main PHY
121 * back timer, in case it is determined that channel access is not expected to be gained before
122 * the expiration of the timer plus the channel switch delay.
123 *
124 * @param linkId the ID of the link that the main PHY is leaving
125 * @param stopReason the reason for terminating the switch main PHY back timer before expiration
126 */
127 void SwitchMainPhyBackDelayExpired(uint8_t linkId,
128 std::optional<WifiExpectedAccessReason> stopReason);
129
130 /**
131 * Register a PHY listener so that this EMLSR Manager is notified of PHY events generated by
132 * the given PHY.
133 *
134 * @param phy the PHY which a listener is connected to
135 */
137
138 /// Disconnect the PHY listener from the PHY it is connected to (if any)
139 void UnregisterListener();
140
141 private:
142 void DoNotifyTxopEnd(uint8_t linkId, Ptr<QosTxop> edca) override;
143 void DoNotifyDlTxopStart(uint8_t linkId) override;
144 void DoNotifyUlTxopStart(uint8_t linkId) override;
145
146 bool m_allowUlTxopInRx; //!< whether a (main or aux) PHY is allowed to start an UL
147 //!< TXOP if another PHY is receiving a PPDU
148 bool m_interruptSwitching; //!< whether a main PHY switching can be interrupted to start
149 //!< switching to another link
150 bool m_useAuxPhyCca; //!< whether the CCA performed in the last PIFS interval by a
151 //!< non-TX capable aux PHY should be used when the main PHY
152 //!< ends switching to the aux PHY's link to determine whether
153 //!< TX can start or not
154 Time m_switchMainPhyBackDelay; //!< duration of the timer started in case of non-TX capable aux
155 //!< PHY when medium is sensed busy during the PIFS interval
156 //!< preceding/following the main PHY switch end
157 bool m_keepMainPhyAfterDlTxop; //!< whether the main PHY must stay, for a switch main PHY back
158 //!< delay, on an aux PHY link after a DL TXOP, in case aux PHYs
159 //!< are not TX capable and do not switch
160 bool m_checkAccessOnMainPhyLink; //!< in case aux PHYs are not TX capable and an Access
161 //!< Category, say it AC X, is about to gain channel access on
162 //!< an aux PHY link, determine whether the time the ACs with
163 //!< priority higher than or equal to AC X and with frames to
164 //!< send on the main PHY link are expected to gain access on
165 //!< the main PHY link should be taken into account when taking
166 //!< the decision to switch the main PHY to the aux PHY link
167 AcIndex m_minAcToSkipCheckAccess; //!< if m_checkAccessOnMainPhyLink is set to false, indicate
168 //!< the minimum priority AC for which it is allowed to skip
169 //!< the check related to the expected channel access time on
170 //!< the main PHY link
171 EventId m_ccaLastPifs; //!< event scheduled in case of non-TX capable aux PHY to
172 //!< determine whether TX can be started based on whether
173 //!< the medium has been idle during the last PIFS interval
174 EventId m_switchMainPhyBackEvent; //!< event scheduled in case of non-TX capable aux PHY when
175 //!< medium is sensed busy during the PIFS interval
176 //!< preceding/following the main PHY switch end
177 std::shared_ptr<WifiPhyListener>
178 m_phyListener; //!< PHY listener connected to an aux PHY (that is not TX capable and does
179 //!< not switch link) while the main PHY attempts to gain access on the aux
180 //!< PHY link
181 Ptr<WifiPhy> m_auxPhyWithListener; //!< aux PHY which a PHY listener is connected to
182};
183
184/**
185 * Struct to trace that main PHY switched to leave a link on which an aux PHY was expected to gain
186 * a TXOP but the main PHY did not manage to gain a TXOP in the pre-configured amount of time.
187 */
188struct EmlsrSwitchMainPhyBackTrace : public EmlsrMainPhySwitchTraceImpl<EmlsrSwitchMainPhyBackTrace>
189{
190 static constexpr std::string_view m_name = "TxopNotGainedOnAuxPhyLink"; //!< trace name
191
192 Time elapsed; //!< the time elapsed since the switch main PHY back timer started
193 std::optional<WifiExpectedAccessReason>
194 earlySwitchReason; //!< the reason why the main PHY switches back before the expiration of
195 //!< the switch main PHY back timer
196 bool isSwitching; //!< whether the main PHY is switching while it is requested to switch back
197
198 /**
199 * Constructor provided because this struct is not an aggregate (it has a base struct), hence
200 * we cannot use designated initializers.
201 *
202 * @param time the value for the elapsed field
203 * @param reason the value for the earlySwitchReason field
204 * @param switching the value for the isSwitching field
205 */
207 std::optional<WifiExpectedAccessReason> reason,
208 bool switching)
209 : elapsed(time),
210 earlySwitchReason(reason),
211 isSwitching(switching)
212 {
213 }
214};
215
216} // namespace ns3
217
218#endif /* ADVANCED_EMLSR_MANAGER_H */
Switch main PHY back timer test.
AdvancedEmlsrManager is an advanced EMLSR manager.
void SwitchMainPhyBackDelayExpired(uint8_t linkId, std::optional< WifiExpectedAccessReason > stopReason)
This method is called when the switch main PHY back timer (which is started when the main PHY switche...
std::pair< bool, Time > DoGetDelayUntilAccessRequest(uint8_t linkId) override
Subclasses have to provide an implementation for this method, that is called by the base class when t...
void InterruptSwitchMainPhyBackTimerIfNeeded()
This method is called by the PHY listener attached to the main PHY when a switch main PHY back timer ...
void DoNotifyDlTxopStart(uint8_t linkId) override
Notify the subclass of the reception of an initial Control frame on the given link.
std::pair< bool, Time > GetDelayUnlessMainPhyTakesOverUlTxop(uint8_t linkId) override
Subclasses have to provide an implementation for this method, that is called by the base class when t...
bool m_useAuxPhyCca
whether the CCA performed in the last PIFS interval by a non-TX capable aux PHY should be used when t...
bool RequestMainPhyToSwitch(uint8_t linkId, AcIndex aci, const Time &delay)
Determine whether the main PHY shall be requested to switch to the link of an aux PHY that is expecte...
void UnregisterListener()
Disconnect the PHY listener from the PHY it is connected to (if any)
void RegisterListener(Ptr< WifiPhy > phy)
Register a PHY listener so that this EMLSR Manager is notified of PHY events generated by the given P...
void SwitchMainPhyIfTxopToBeGainedByAuxPhy(uint8_t linkId, AcIndex aci, const Time &delay)
This method is called when the given AC of the EMLSR client is expected to get channel access in the ...
bool m_allowUlTxopInRx
whether a (main or aux) PHY is allowed to start an UL TXOP if another PHY is receiving a PPDU
void CheckNavAndCcaLastPifs(Ptr< WifiPhy > phy, uint8_t linkId, Ptr< QosTxop > edca)
Use information from NAV and CCA performed by the given PHY on the given link in the last PIFS interv...
Ptr< WifiPhy > m_auxPhyWithListener
aux PHY which a PHY listener is connected to
std::optional< WifiIcfDrop > CheckMainPhyTakesOverDlTxop(uint8_t linkId) const override
This method is called when an aux PHY has completed reception of an ICF to determine whether there is...
void NotifyEmlsrModeChanged() override
Notify subclass that EMLSR mode changed.
static TypeId GetTypeId()
Get the type ID.
void SwitchMainPhyBackToPreferredLink(uint8_t linkId, EmlsrMainPhySwitchTrace &&traceInfo) override
This method can only be called when aux PHYs do not switch link.
void DoNotifyUlTxopStart(uint8_t linkId) override
Notify the subclass of the start of an UL TXOP on the given link.
std::shared_ptr< WifiPhyListener > m_phyListener
PHY listener connected to an aux PHY (that is not TX capable and does not switch link) while the main...
Time m_switchMainPhyBackDelay
duration of the timer started in case of non-TX capable aux PHY when medium is sensed busy during the...
void DoDispose() override
Destructor implementation.
EventId m_switchMainPhyBackEvent
event scheduled in case of non-TX capable aux PHY when medium is sensed busy during the PIFS interval...
void DoNotifyTxopEnd(uint8_t linkId, Ptr< QosTxop > edca) override
Notify the subclass of the end of a TXOP on the given link.
AcIndex m_minAcToSkipCheckAccess
if m_checkAccessOnMainPhyLink is set to false, indicate the minimum priority AC for which it is allow...
void SwitchMainPhyIfTxopGainedByAuxPhy(uint8_t linkId, AcIndex aci) override
Subclasses have to provide an implementation for this method, that is called by the base class when t...
void DoSetWifiMac(Ptr< StaWifiMac > mac) override
Allow subclasses to take actions when the MAC is set.
bool m_keepMainPhyAfterDlTxop
whether the main PHY must stay, for a switch main PHY back delay, on an aux PHY link after a DL TXOP,...
void ReceivedMacHdr(Ptr< WifiPhy > phy, const WifiMacHeader &macHdr, const WifiTxVector &txVector, Time psduDuration)
Possibly take actions when notified of the MAC header of the MPDU being received by the given PHY.
EventId m_ccaLastPifs
event scheduled in case of non-TX capable aux PHY to determine whether TX can be started based on whe...
bool m_interruptSwitching
whether a main PHY switching can be interrupted to start switching to another link
bool m_checkAccessOnMainPhyLink
in case aux PHYs are not TX capable and an Access Category, say it AC X, is about to gain channel acc...
DefaultEmlsrManager is the default EMLSR manager.
An identifier for simulation events.
Definition event-id.h:45
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
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...
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition qos-utils.h:62
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Base struct for EMLSR Main PHY switch traces.
Implementation for the EMLSR Main PHY switch trace base struct.
Struct to trace that main PHY switched to leave a link on which an aux PHY was expected to gain a TXO...
std::optional< WifiExpectedAccessReason > earlySwitchReason
the reason why the main PHY switches back before the expiration of the switch main PHY back timer
Time elapsed
the time elapsed since the switch main PHY back timer started
EmlsrSwitchMainPhyBackTrace(Time time, std::optional< WifiExpectedAccessReason > reason, bool switching)
Constructor provided because this struct is not an aggregate (it has a base struct),...
static constexpr std::string_view m_name
trace name
bool isSwitching
whether the main PHY is switching while it is requested to switch back