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 <memory>
15
16namespace ns3
17{
18
19class WifiPhyListener;
20
21/**
22 * @ingroup wifi
23 *
24 * AdvancedEmlsrManager is an advanced EMLSR manager.
25 */
27{
28 public:
29 /**
30 * @brief Get the type ID.
31 * @return the object TypeId
32 */
33 static TypeId GetTypeId();
34
36 ~AdvancedEmlsrManager() override;
37
38 /**
39 * This method is called by the PHY listener attached to the main PHY when a switch main PHY
40 * back timer is started to notify of events that may delay the channel access for the main
41 * PHY on the current link. If the expected channel access is beyond the end of the switch
42 * main PHY timer expiration plus a channel switch delay, the timer is stopped immediately.
43 */
45
46 protected:
47 void DoDispose() override;
48 void DoSetWifiMac(Ptr<StaWifiMac> mac) override;
49 std::pair<bool, Time> DoGetDelayUntilAccessRequest(uint8_t linkId) override;
50 std::pair<bool, Time> GetDelayUnlessMainPhyTakesOverUlTxop(uint8_t linkId) override;
51 void SwitchMainPhyIfTxopGainedByAuxPhy(uint8_t linkId, AcIndex aci) override;
52 void NotifyEmlsrModeChanged() override;
53
54 /**
55 * Possibly take actions when notified of the MAC header of the MPDU being received by the
56 * given PHY.
57 *
58 * @param phy the given PHY
59 * @param macHdr the MAC header of the MPDU being received
60 * @param txVector the TXVECTOR used to transmit the PSDU
61 * @param psduDuration the remaining duration of the PSDU
62 */
64 const WifiMacHeader& macHdr,
65 const WifiTxVector& txVector,
66 Time psduDuration);
67
68 /**
69 * Use information from NAV and CCA performed by the given PHY on the given link in the last
70 * PIFS interval to determine whether the given EDCAF can start a TXOP. This function is
71 * intended to be used when the main PHY switches channel to start an UL TXOP on a link where
72 * channel access was obtained by a non-TX capable aux PHY.
73 *
74 * @param phy the PHY that performed CCA in the last PIFS interval
75 * @param linkId the ID of the given link
76 * @param edca the given EDCAF
77 */
78 void CheckNavAndCcaLastPifs(Ptr<WifiPhy> phy, uint8_t linkId, Ptr<QosTxop> edca);
79
80 /**
81 * Determine whether the main PHY shall be requested to switch to the link of an aux PHY that
82 * is expected to gain channel access through the given AC in the given delay but it is not
83 * TX capable.
84 *
85 * @param linkId the ID of the link on which the aux PHY is operating
86 * @param aci the index of the given AC
87 * @param delay the delay after which the given AC is expected to gain channel access. Zero
88 * indicates that channel access has been actually gained
89 * @return whether the main PHY shall be requested to switch to the link of the aux PHY
90 */
91 bool RequestMainPhyToSwitch(uint8_t linkId, AcIndex aci, const Time& delay);
92
93 /**
94 * This method is called when the given AC of the EMLSR client is expected to get channel
95 * access in the given delay on the given link, on which an aux PHY that is not TX capable
96 * is operating. This method has to decide whether to request the main PHY to switch to the
97 * given link to try to start a TXOP.
98 *
99 * @param linkId the ID of the given link
100 * @param aci the index of the given AC
101 * @param delay the delay after which the given AC is expected to gain channel access
102 */
103 void SwitchMainPhyIfTxopToBeGainedByAuxPhy(uint8_t linkId, AcIndex aci, const Time& delay);
104
105 /**
106 * This method is called when the switch main PHY back delay timer (which is started when the
107 * main PHY switches to the link of an aux PHY that does not switch and is not TX capable)
108 * expires and decides whether to delay the request to switch the main PHY back to the preferred
109 * link or to execute it immediately.
110 *
111 * @param linkId the ID of the link that the main PHY is leaving
112 */
113 void SwitchMainPhyBackDelayExpired(uint8_t linkId);
114
115 private:
116 void DoNotifyTxopEnd(uint8_t linkId) override;
117 void DoNotifyIcfReceived(uint8_t linkId) override;
118 void DoNotifyUlTxopStart(uint8_t linkId) override;
119
120 bool m_allowUlTxopInRx; //!< whether a (main or aux) PHY is allowed to start an UL
121 //!< TXOP if another PHY is receiving a PPDU
122 bool m_interruptSwitching; //!< whether a main PHY switching can be interrupted to start
123 //!< switching to another link
124 bool m_useAuxPhyCca; //!< whether the CCA performed in the last PIFS interval by a
125 //!< non-TX capable aux PHY should be used when the main PHY
126 //!< ends switching to the aux PHY's link to determine whether
127 //!< TX can start or not
128 Time m_switchMainPhyBackDelay; //!< duration of the timer started in case of non-TX capable aux
129 //!< PHY when medium is sensed busy during the PIFS interval
130 //!< preceding/following the main PHY switch end
131 EventId m_ccaLastPifs; //!< event scheduled in case of non-TX capable aux PHY to
132 //!< determine whether TX can be started based on whether
133 //!< the medium has been idle during the last PIFS interval
134 EventId m_switchMainPhyBackEvent; //!< event scheduled in case of non-TX capable aux PHY when
135 //!< medium is sensed busy during the PIFS interval
136 //!< preceding/following the main PHY switch end
137 std::shared_ptr<WifiPhyListener>
138 m_phyListener; //!< PHY listener connected to the main PHY while operating on the link of
139 //!< an aux PHY that is not TX capable
140};
141
142/**
143 * Struct to trace that main PHY switched to leave a link on which an aux PHY was expected to gain
144 * a TXOP but the main PHY did not manage to gain a TXOP in the pre-configured amount of time.
145 */
146struct EmlsrSwitchMainPhyBackTrace : public EmlsrMainPhySwitchTraceImpl<EmlsrSwitchMainPhyBackTrace>
147{
148 static constexpr std::string_view m_name = "TxopNotGainedOnAuxPhyLink"; //!< trace name
149
150 bool nothingToTx; //!< if true, the main PHY managed to gain a TXOP but had nothing to transmit
151
152 /**
153 * Constructor provided because this struct is not an aggregate (it has a base struct), hence
154 * we cannot use designated initializers.
155 *
156 * @param nothing the value for the nothingToTx field
157 */
159 : nothingToTx(nothing)
160 {
161 }
162};
163
164} // namespace ns3
165
166#endif /* ADVANCED_EMLSR_MANAGER_H */
AdvancedEmlsrManager is an advanced EMLSR manager.
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 ...
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 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 ...
void DoNotifyIcfReceived(uint8_t linkId) override
Notify the subclass of the reception of an initial Control frame on the given link.
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...
void DoNotifyTxopEnd(uint8_t linkId) override
Notify the subclass of the end of a TXOP on the given link.
void NotifyEmlsrModeChanged() override
Notify subclass that EMLSR mode changed.
static TypeId GetTypeId()
Get the type ID.
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 the main PHY while operating on the link of an aux PHY that is not TX capab...
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 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.
void SwitchMainPhyBackDelayExpired(uint8_t linkId)
This method is called when the switch main PHY back delay timer (which is started when the main PHY s...
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
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.
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...
bool nothingToTx
if true, the main PHY managed to gain a TXOP but had nothing to transmit
EmlsrSwitchMainPhyBackTrace(bool nothing)
Constructor provided because this struct is not an aggregate (it has a base struct),...
static constexpr std::string_view m_name
trace name