A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
qos-frame-exchange-manager.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 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 QOS_FRAME_EXCHANGE_MANAGER_H
10#define QOS_FRAME_EXCHANGE_MANAGER_H
11
13
14#include <optional>
15
16namespace ns3
17{
18
19/**
20 * @ingroup wifi
21 *
22 * QosFrameExchangeManager handles the frame exchange sequences
23 * for QoS stations.
24 * Note that Basic Block Ack is not supported.
25 */
27{
28 public:
29 /**
30 * @brief Get the type ID.
31 * @return the object TypeId
32 */
33 static TypeId GetTypeId();
35 ~QosFrameExchangeManager() override;
36
37 bool StartTransmission(Ptr<Txop> edca, MHz_u allowedWidth) override;
38
39 /**
40 * Recompute the protection and acknowledgment methods to use if the given MPDU
41 * is added to the frame being built (as described by the given TX parameters)
42 * and check whether the duration of the frame exchange sequence (including
43 * protection and acknowledgment) does not exceed the given available time.
44 * The protection and acknowledgment methods held by the given TX parameters are
45 * only updated if the given MPDU can be added.
46 *
47 * @param mpdu the MPDU to add to the frame being built
48 * @param txParams the TX parameters describing the frame being built
49 * @param availableTime the time limit on the frame exchange sequence
50 * @return true if the given MPDU can be added to the frame being built
51 */
52 bool TryAddMpdu(Ptr<const WifiMpdu> mpdu, WifiTxParameters& txParams, Time availableTime) const;
53
54 /**
55 * Check whether the given MPDU can be added to the frame being built (as described
56 * by the given TX parameters) without violating the given constraint on the
57 * PPDU transmission duration.
58 *
59 * @param mpdu the MPDU to add to the frame being built
60 * @param txParams the TX parameters describing the frame being built
61 * @param ppduDurationLimit the time limit on the PPDU transmission duration
62 * @return true if the given MPDU can be added to the frame being built
63 */
65 const WifiTxParameters& txParams,
66 Time ppduDurationLimit) const;
67
68 /**
69 * Check whether the transmission time of the frame being built (as described
70 * by the given TX parameters) does not exceed the given PPDU duration limit
71 * if the size of the PSDU addressed to the given receiver becomes
72 * <i>ppduPayloadSize</i>. Also check that the PSDU size does not exceed the
73 * max PSDU size for the modulation class being used.
74 *
75 * @param ppduPayloadSize the new PSDU size
76 * @param receiver the MAC address of the receiver of the PSDU
77 * @param txParams the TX parameters describing the frame being built
78 * @param ppduDurationLimit the limit on the PPDU duration
79 * @return true if the constraints on the PPDU duration limit and the maximum PSDU size are met
80 */
81 virtual bool IsWithinSizeAndTimeLimits(uint32_t ppduPayloadSize,
82 Mac48Address receiver,
83 const WifiTxParameters& txParams,
84 Time ppduDurationLimit) const;
85
86 /**
87 * Create an alias of the given MPDU for transmission by this Frame Exchange Manager.
88 * This is required by 11be MLDs to support translation of MAC addresses. For single
89 * link devices, the given MPDU is simply returned.
90 *
91 * @param mpdu the given MPDU
92 * @return the alias of the given MPDU for transmission on this link
93 */
95
96 /**
97 * @return the TXOP holder (if any)
98 */
99 std::optional<Mac48Address> GetTxopHolder() const;
100
101 protected:
102 void DoDispose() override;
103
105 RxSignalInfo rxSignalInfo,
106 const WifiTxVector& txVector,
107 bool inAmpdu) override;
108 void PreProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
109 void PostProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
110 void NavResetTimeout() override;
111 void UpdateNav(const WifiMacHeader& hdr,
112 const WifiTxVector& txVector,
113 const Time& surplus = Time{0}) override;
115 uint32_t size,
116 const WifiTxParameters& txParams,
117 Ptr<Packet> fragmentedPacket) const override;
118 Time GetRtsDurationId(const WifiTxVector& rtsTxVector,
119 Time txDuration,
120 Time response) const override;
121 Time GetCtsToSelfDurationId(const WifiTxVector& ctsTxVector,
122 Time txDuration,
123 Time response) const override;
124 void TransmissionSucceeded() override;
125 void TransmissionFailed(bool forceCurrentCw = false) override;
126 void ForwardMpduDown(Ptr<WifiMpdu> mpdu, WifiTxVector& txVector) override;
127 void ReceivedMacHdr(const WifiMacHeader& macHdr,
128 const WifiTxVector& txVector,
129 Time psduDuration) override;
130
131 /**
132 * Request the FrameExchangeManager to start a frame exchange sequence.
133 *
134 * @param edca the EDCA that gained channel access
135 * @param txopDuration the duration of a TXOP. This value is only used when a
136 * new TXOP is started (and hence the TXOP limit for the
137 * given EDCAF is non-zero)
138 * @return true if a frame exchange sequence was started, false otherwise
139 */
140 virtual bool StartTransmission(Ptr<QosTxop> edca, Time txopDuration);
141
142 /**
143 * Start a frame exchange (including protection frames and acknowledgment frames
144 * as needed) that fits within the given <i>availableTime</i> (if different than
145 * Time::Min()).
146 *
147 * @param edca the EDCAF which has been granted the opportunity to transmit
148 * @param availableTime the amount of time allowed for the frame exchange. Pass
149 * Time::Min() in case the TXOP limit is null
150 * @param initialFrame true if the frame being transmitted is the initial frame
151 * of the TXOP. This is used to determine whether the TXOP
152 * limit can be exceeded
153 * @return true if a frame exchange is started, false otherwise
154 */
155 virtual bool StartFrameExchange(Ptr<QosTxop> edca, Time availableTime, bool initialFrame);
156
157 /**
158 * Perform a PIFS recovery as a response to transmission failure within a TXOP.
159 * If the carrier sense indicates that the medium is idle, continue the TXOP.
160 * Otherwise, release the channel.
161 *
162 * @param forceCurrentCw whether to force the contention window to stay equal to the current
163 * value if PIFs recovery fails (normally, contention window is updated)
164 */
165 void PifsRecovery(bool forceCurrentCw);
166
167 /**
168 * Send a CF-End frame to indicate the completion of the TXOP, provided that
169 * the remaining duration is long enough to transmit this frame.
170 *
171 * @return true if a CF-End frame was sent, false otherwise
172 */
173 virtual bool SendCfEndIfNeeded();
174
175 /**
176 * Determine the holder of the TXOP, if possible, based on the received frame
177 *
178 * @param hdr the MAC header of an MPDU included in the received PSDU
179 * @param txVector TX vector of the received PSDU
180 * @return the holder of the TXOP, if one was found
181 */
182 virtual std::optional<Mac48Address> FindTxopHolder(const WifiMacHeader& hdr,
183 const WifiTxVector& txVector);
184
185 /**
186 * Clear the TXOP holder if the NAV counted down to zero (includes the case of NAV reset).
187 */
188 virtual void ClearTxopHolderIfNeeded();
189
190 Ptr<QosTxop> m_edca; //!< the EDCAF that gained channel access
191 std::optional<Mac48Address> m_txopHolder; //!< MAC address of the TXOP holder
192 bool m_setQosQueueSize; /**< whether to set the Queue Size subfield of the
193 QoS Control field of QoS data frames */
194 bool m_protectSingleExchange; /**< true if the Duration/ID field in frames establishing
195 protection only covers the immediate frame exchange instead of
196 rest of the TXOP limit when the latter is non-zero */
197 Time m_singleExchangeProtectionSurplus; /**< additional time to protect beyond end of the
198 immediate frame exchange in case of non-zero TXOP
199 limit when a single frame exchange is protected */
200
201 private:
202 /**
203 * Set the TXOP holder, if needed, based on the received frame
204 *
205 * @param hdr the MAC header of the received PSDU
206 * @param txVector TX vector of the received PSDU
207 */
208 void SetTxopHolder(const WifiMacHeader& hdr, const WifiTxVector& txVector);
209
210 /**
211 * Cancel the PIFS recovery event and have the EDCAF attempting PIFS recovery
212 * release the channel.
213 */
214 void CancelPifsRecovery();
215
216 bool m_initialFrame; //!< true if transmitting the initial frame of a TXOP
217 bool m_pifsRecovery; //!< true if performing a PIFS recovery after failure
218 EventId m_pifsRecoveryEvent; //!< event associated with an attempt of PIFS recovery
219 Ptr<Txop> m_edcaBackingOff; //!< channel access function that invoked backoff during TXOP
220};
221
222} // namespace ns3
223
224#endif /* QOS_FRAME_EXCHANGE_MANAGER_H */
An identifier for simulation events.
Definition event-id.h:45
FrameExchangeManager is a base class handling the basic frame exchange sequences for non-QoS stations...
an EUI-48 address
Smart pointer class similar to boost::intrusive_ptr.
QosFrameExchangeManager handles the frame exchange sequences for QoS stations.
EventId m_pifsRecoveryEvent
event associated with an attempt of PIFS recovery
void ForwardMpduDown(Ptr< WifiMpdu > mpdu, WifiTxVector &txVector) override
Forward an MPDU down to the PHY layer.
virtual void ClearTxopHolderIfNeeded()
Clear the TXOP holder if the NAV counted down to zero (includes the case of NAV reset).
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 ReceivedMacHdr(const WifiMacHeader &macHdr, const WifiTxVector &txVector, Time psduDuration) override
Store information about the MAC header of the MPDU being received.
virtual bool StartFrameExchange(Ptr< QosTxop > edca, Time availableTime, bool initialFrame)
Start a frame exchange (including protection frames and acknowledgment frames as needed) that fits wi...
Time GetFrameDurationId(const WifiMacHeader &header, uint32_t size, const WifiTxParameters &txParams, Ptr< Packet > fragmentedPacket) const override
Compute how to set the Duration/ID field of a frame being transmitted with the given TX parameters.
Time GetCtsToSelfDurationId(const WifiTxVector &ctsTxVector, Time txDuration, Time response) const override
Compute how to set the Duration/ID field of a CTS-to-self frame to send to protect a frame transmitte...
Ptr< QosTxop > m_edca
the EDCAF that gained channel access
virtual bool IsWithinLimitsIfAddMpdu(Ptr< const WifiMpdu > mpdu, const WifiTxParameters &txParams, Time ppduDurationLimit) const
Check whether the given MPDU can be added to the frame being built (as described by the given TX para...
void PifsRecovery(bool forceCurrentCw)
Perform a PIFS recovery as a response to transmission failure within a TXOP.
std::optional< Mac48Address > m_txopHolder
MAC address of the TXOP holder.
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.
Time GetRtsDurationId(const WifiTxVector &rtsTxVector, Time txDuration, Time response) const override
Compute how to set the Duration/ID field of an RTS frame to send to protect a frame transmitted with ...
virtual std::optional< Mac48Address > FindTxopHolder(const WifiMacHeader &hdr, const WifiTxVector &txVector)
Determine the holder of the TXOP, if possible, based on the received frame.
virtual bool SendCfEndIfNeeded()
Send a CF-End frame to indicate the completion of the TXOP, provided that the remaining duration is l...
bool m_initialFrame
true if transmitting the initial frame of a TXOP
virtual Ptr< WifiMpdu > CreateAliasIfNeeded(Ptr< WifiMpdu > mpdu) const
Create an alias of the given MPDU for transmission by this Frame Exchange Manager.
std::optional< Mac48Address > GetTxopHolder() const
void TransmissionSucceeded() override
Take necessary actions upon a transmission success.
static TypeId GetTypeId()
Get the type ID.
bool m_pifsRecovery
true if performing a PIFS recovery after failure
Ptr< Txop > m_edcaBackingOff
channel access function that invoked backoff during TXOP
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...
bool m_setQosQueueSize
whether to set the Queue Size subfield of the QoS Control field of QoS data frames
virtual bool IsWithinSizeAndTimeLimits(uint32_t ppduPayloadSize, Mac48Address receiver, const WifiTxParameters &txParams, Time ppduDurationLimit) const
Check whether the transmission time of the frame being built (as described by the given TX parameters...
Time m_singleExchangeProtectionSurplus
additional time to protect beyond end of the immediate frame exchange in case of non-zero TXOP limit ...
void NavResetTimeout() override
Reset the NAV upon expiration of the NAV reset timer.
void UpdateNav(const WifiMacHeader &hdr, const WifiTxVector &txVector, const Time &surplus=Time{0}) override
Update the NAV, if needed, based on the Duration/ID of the given MAC header and the given surplus.
void CancelPifsRecovery()
Cancel the PIFS recovery event and have the EDCAF attempting PIFS recovery release the channel.
bool TryAddMpdu(Ptr< const WifiMpdu > mpdu, WifiTxParameters &txParams, Time availableTime) const
Recompute the protection and acknowledgment methods to use if the given MPDU is added to the frame be...
bool StartTransmission(Ptr< Txop > edca, MHz_u allowedWidth) override
Request the FrameExchangeManager to start a frame exchange sequence.
bool m_protectSingleExchange
true if the Duration/ID field in frames establishing protection only covers the immediate frame excha...
void DoDispose() override
Destructor implementation.
void SetTxopHolder(const WifiMacHeader &hdr, const WifiTxVector &txVector)
Set the TXOP holder, if needed, based on the received frame.
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 stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
RxSignalInfo structure containing info on the received signal.
Definition wifi-types.h:78