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 protected:
97 void DoDispose() override;
98
100 RxSignalInfo rxSignalInfo,
101 const WifiTxVector& txVector,
102 bool inAmpdu) override;
103 void PreProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
104 void PostProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
105 void NavResetTimeout() override;
106 void UpdateNav(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
108 uint32_t size,
109 const WifiTxParameters& txParams,
110 Ptr<Packet> fragmentedPacket) const override;
111 Time GetRtsDurationId(const WifiTxVector& rtsTxVector,
112 Time txDuration,
113 Time response) const override;
114 Time GetCtsToSelfDurationId(const WifiTxVector& ctsTxVector,
115 Time txDuration,
116 Time response) const override;
117 void TransmissionSucceeded() override;
118 void TransmissionFailed() override;
119 void ForwardMpduDown(Ptr<WifiMpdu> mpdu, WifiTxVector& txVector) override;
120
121 /**
122 * Request the FrameExchangeManager to start a frame exchange sequence.
123 *
124 * \param edca the EDCA that gained channel access
125 * \param txopDuration the duration of a TXOP. This value is only used when a
126 * new TXOP is started (and hence the TXOP limit for the
127 * given EDCAF is non-zero)
128 * \return true if a frame exchange sequence was started, false otherwise
129 */
130 virtual bool StartTransmission(Ptr<QosTxop> edca, Time txopDuration);
131
132 /**
133 * Start a frame exchange (including protection frames and acknowledgment frames
134 * as needed) that fits within the given <i>availableTime</i> (if different than
135 * Time::Min()).
136 *
137 * \param edca the EDCAF which has been granted the opportunity to transmit
138 * \param availableTime the amount of time allowed for the frame exchange. Pass
139 * Time::Min() in case the TXOP limit is null
140 * \param initialFrame true if the frame being transmitted is the initial frame
141 * of the TXOP. This is used to determine whether the TXOP
142 * limit can be exceeded
143 * \return true if a frame exchange is started, false otherwise
144 */
145 virtual bool StartFrameExchange(Ptr<QosTxop> edca, Time availableTime, bool initialFrame);
146
147 /**
148 * Perform a PIFS recovery as a response to transmission failure within a TXOP.
149 * If the carrier sense indicates that the medium is idle, continue the TXOP.
150 * Otherwise, release the channel.
151 */
152 void PifsRecovery();
153
154 /**
155 * Send a CF-End frame to indicate the completion of the TXOP, provided that
156 * the remaining duration is long enough to transmit this frame.
157 *
158 * \return true if a CF-End frame was sent, false otherwise
159 */
160 virtual bool SendCfEndIfNeeded();
161
162 /**
163 * Determine the holder of the TXOP, if possible, based on the received frame
164 *
165 * \param hdr the MAC header of an MPDU included in the received PSDU
166 * \param txVector TX vector of the received PSDU
167 * \return the holder of the TXOP, if one was found
168 */
169 virtual std::optional<Mac48Address> FindTxopHolder(const WifiMacHeader& hdr,
170 const WifiTxVector& txVector);
171
172 /**
173 * Clear the TXOP holder if the NAV counted down to zero (includes the case of NAV reset).
174 */
175 virtual void ClearTxopHolderIfNeeded();
176
177 Ptr<QosTxop> m_edca; //!< the EDCAF that gained channel access
178 std::optional<Mac48Address> m_txopHolder; //!< MAC address of the TXOP holder
179 bool m_setQosQueueSize; /**< whether to set the Queue Size subfield of the
180 QoS Control field of QoS data frames */
181
182 private:
183 /**
184 * Set the TXOP holder, if needed, based on the received frame
185 *
186 * \param psdu the received PSDU
187 * \param txVector TX vector of the received PSDU
188 */
189 void SetTxopHolder(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector);
190
191 /**
192 * Cancel the PIFS recovery event and have the EDCAF attempting PIFS recovery
193 * release the channel.
194 */
195 void CancelPifsRecovery();
196
197 bool m_initialFrame; //!< true if transmitting the initial frame of a TXOP
198 bool m_pifsRecovery; //!< true if performing a PIFS recovery after failure
199 EventId m_pifsRecoveryEvent; //!< event associated with an attempt of PIFS recovery
200 Ptr<Txop> m_edcaBackingOff; //!< channel access function that invoked backoff during TXOP
201};
202
203} // namespace ns3
204
205#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 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...
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...
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.
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...
bool StartTransmission(Ptr< Txop > edca, MHz_u allowedWidth) override
Request the FrameExchangeManager to start a frame exchange sequence.
void DoDispose() override
Destructor implementation.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
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:72