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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Stefano Avallone <stavallo@unina.it>
18 */
19
20#ifndef QOS_FRAME_EXCHANGE_MANAGER_H
21#define QOS_FRAME_EXCHANGE_MANAGER_H
22
24
25#include <optional>
26
27namespace ns3
28{
29
30/**
31 * \ingroup wifi
32 *
33 * QosFrameExchangeManager handles the frame exchange sequences
34 * for QoS stations.
35 * Note that Basic Block Ack is not supported.
36 */
38{
39 public:
40 /**
41 * \brief Get the type ID.
42 * \return the object TypeId
43 */
44 static TypeId GetTypeId();
46 ~QosFrameExchangeManager() override;
47
48 bool StartTransmission(Ptr<Txop> edca, uint16_t allowedWidth) override;
49
50 /**
51 * Recompute the protection and acknowledgment methods to use if the given MPDU
52 * is added to the frame being built (as described by the given TX parameters)
53 * and check whether the duration of the frame exchange sequence (including
54 * protection and acknowledgment) does not exceed the given available time.
55 * The protection and acknowledgment methods held by the given TX parameters are
56 * only updated if the given MPDU can be added.
57 *
58 * \param mpdu the MPDU to add to the frame being built
59 * \param txParams the TX parameters describing the frame being built
60 * \param availableTime the time limit on the frame exchange sequence
61 * \return true if the given MPDU can be added to the frame being built
62 */
63 bool TryAddMpdu(Ptr<const WifiMpdu> mpdu, WifiTxParameters& txParams, Time availableTime) const;
64
65 /**
66 * Check whether the given MPDU can be added to the frame being built (as described
67 * by the given TX parameters) without violating the given constraint on the
68 * PPDU transmission duration.
69 *
70 * \param mpdu the MPDU to add to the frame being built
71 * \param txParams the TX parameters describing the frame being built
72 * \param ppduDurationLimit the time limit on the PPDU transmission duration
73 * \return true if the given MPDU can be added to the frame being built
74 */
76 const WifiTxParameters& txParams,
77 Time ppduDurationLimit) const;
78
79 /**
80 * Check whether the transmission time of the frame being built (as described
81 * by the given TX parameters) does not exceed the given PPDU duration limit
82 * if the size of the PSDU addressed to the given receiver becomes
83 * <i>ppduPayloadSize</i>. Also check that the PSDU size does not exceed the
84 * max PSDU size for the modulation class being used.
85 *
86 * \param ppduPayloadSize the new PSDU size
87 * \param receiver the MAC address of the receiver of the PSDU
88 * \param txParams the TX parameters describing the frame being built
89 * \param ppduDurationLimit the limit on the PPDU duration
90 * \return true if the constraints on the PPDU duration limit and the maximum PSDU size are met
91 */
92 virtual bool IsWithinSizeAndTimeLimits(uint32_t ppduPayloadSize,
93 Mac48Address receiver,
94 const WifiTxParameters& txParams,
95 Time ppduDurationLimit) const;
96
97 /**
98 * Create an alias of the given MPDU for transmission by this Frame Exchange Manager.
99 * This is required by 11be MLDs to support translation of MAC addresses. For single
100 * link devices, the given MPDU is simply returned.
101 *
102 * \param mpdu the given MPDU
103 * \return the alias of the given MPDU for transmission on this link
104 */
106
107 protected:
108 void DoDispose() override;
109
111 RxSignalInfo rxSignalInfo,
112 const WifiTxVector& txVector,
113 bool inAmpdu) override;
114 void PreProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
115 void PostProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
116 void NavResetTimeout() override;
117 void UpdateNav(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
119 uint32_t size,
120 const WifiTxParameters& txParams,
121 Ptr<Packet> fragmentedPacket) const override;
122 Time GetRtsDurationId(const WifiTxVector& rtsTxVector,
123 Time txDuration,
124 Time response) const override;
125 Time GetCtsToSelfDurationId(const WifiTxVector& ctsTxVector,
126 Time txDuration,
127 Time response) const override;
128 void TransmissionSucceeded() override;
129 void TransmissionFailed() override;
130 void ForwardMpduDown(Ptr<WifiMpdu> mpdu, WifiTxVector& txVector) override;
131
132 /**
133 * Request the FrameExchangeManager to start a frame exchange sequence.
134 *
135 * \param edca the EDCA that gained channel access
136 * \param txopDuration the duration of a TXOP. This value is only used when a
137 * new TXOP is started (and hence the TXOP limit for the
138 * given EDCAF is non-zero)
139 * \return true if a frame exchange sequence was started, false otherwise
140 */
141 virtual bool StartTransmission(Ptr<QosTxop> edca, Time txopDuration);
142
143 /**
144 * Start a frame exchange (including protection frames and acknowledgment frames
145 * as needed) that fits within the given <i>availableTime</i> (if different than
146 * Time::Min()).
147 *
148 * \param edca the EDCAF which has been granted the opportunity to transmit
149 * \param availableTime the amount of time allowed for the frame exchange. Pass
150 * Time::Min() in case the TXOP limit is null
151 * \param initialFrame true if the frame being transmitted is the initial frame
152 * of the TXOP. This is used to determine whether the TXOP
153 * limit can be exceeded
154 * \return true if a frame exchange is started, false otherwise
155 */
156 virtual bool StartFrameExchange(Ptr<QosTxop> edca, Time availableTime, bool initialFrame);
157
158 /**
159 * Perform a PIFS recovery as a response to transmission failure within a TXOP.
160 * If the carrier sense indicates that the medium is idle, continue the TXOP.
161 * Otherwise, release the channel.
162 */
163 void PifsRecovery();
164
165 /**
166 * Send a CF-End frame to indicate the completion of the TXOP, provided that
167 * the remaining duration is long enough to transmit this frame.
168 *
169 * \return true if a CF-End frame was sent, false otherwise
170 */
171 virtual bool SendCfEndIfNeeded();
172
173 /**
174 * Set the TXOP holder, if needed, based on the received frame
175 *
176 * \param psdu the received PSDU
177 * \param txVector TX vector of the received PSDU
178 */
179 virtual void SetTxopHolder(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector);
180
181 /**
182 * Clear the TXOP holder if the NAV counted down to zero (includes the case of NAV reset).
183 */
184 virtual void ClearTxopHolderIfNeeded();
185
186 Ptr<QosTxop> m_edca; //!< the EDCAF that gained channel access
187 std::optional<Mac48Address> m_txopHolder; //!< MAC address of the TXOP holder
188 bool m_setQosQueueSize; /**< whether to set the Queue Size subfield of the
189 QoS Control field of QoS data frames */
190
191 private:
192 /**
193 * Cancel the PIFS recovery event and have the EDCAF attempting PIFS recovery
194 * release the channel.
195 */
196 void CancelPifsRecovery();
197
198 bool m_initialFrame; //!< true if transmitting the initial frame of a TXOP
199 bool m_pifsRecovery; //!< true if performing a PIFS recovery after failure
200 EventId m_pifsRecoveryEvent; //!< event associated with an attempt of PIFS recovery
201 Ptr<Txop> m_edcaBackingOff; //!< channel access function that invoked backoff during TXOP
202};
203
204} // namespace ns3
205
206#endif /* QOS_FRAME_EXCHANGE_MANAGER_H */
An identifier for simulation events.
Definition: event-id.h:55
FrameExchangeManager is a base class handling the basic frame exchange sequences for non-QoS stations...
an EUI-48 address
Definition: mac48-address.h:46
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
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 TransmissionFailed() override
Take necessary actions upon a transmission failure.
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...
virtual void SetTxopHolder(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
Set the TXOP holder, if needed, based on the received frame.
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...
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...
bool StartTransmission(Ptr< Txop > edca, uint16_t allowedWidth) override
Request the FrameExchangeManager to start a frame exchange sequence.
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 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.
void TransmissionSucceeded() override
Take necessary actions upon a transmission success.
static TypeId GetTypeId()
Get the type ID.
void UpdateNav(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector) override
Update the NAV, if needed, based on the Duration/ID of the given psdu.
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
void PifsRecovery()
Perform a PIFS recovery as a response to transmission failure within a TXOP.
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...
void NavResetTimeout() override
Reset the NAV upon expiration of the NAV reset timer.
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...
void DoDispose() override
Destructor implementation.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
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: phy-entity.h:69