A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
he-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 HE_FRAME_EXCHANGE_MANAGER_H
21#define HE_FRAME_EXCHANGE_MANAGER_H
22
23#include "mu-snr-tag.h"
24
25#include "ns3/vht-frame-exchange-manager.h"
26
27#include <map>
28#include <unordered_map>
29
30namespace ns3
31{
32
33class MultiUserScheduler;
34class ApWifiMac;
35class StaWifiMac;
36class CtrlTriggerHeader;
37
41typedef std::unordered_map<uint16_t /* staId */, Ptr<WifiPsdu> /* PSDU */> WifiPsduMap;
45typedef std::unordered_map<uint16_t /* staId */, Ptr<const WifiPsdu> /* PSDU */> WifiConstPsduMap;
46
52bool IsTrigger(const WifiPsduMap& psduMap);
53
61{
62 public:
67 static TypeId GetTypeId();
69 ~HeFrameExchangeManager() override;
70
71 uint16_t GetSupportedBaBufferSize() const override;
72 bool StartFrameExchange(Ptr<QosTxop> edca, Time availableTime, bool initialFrame) override;
73 void SetWifiMac(const Ptr<WifiMac> mac) override;
74 void SetWifiPhy(const Ptr<WifiPhy> phy) override;
75 void CalculateAcknowledgmentTime(WifiAcknowledgment* acknowledgment) const override;
76 void CalculateProtectionTime(WifiProtection* protection) const override;
77 void SetTxopHolder(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
78 bool VirtualCsMediumIdle() const override;
79
85 void SetMultiUserScheduler(const Ptr<MultiUserScheduler> muScheduler);
86
95 static Ptr<WifiPsdu> GetPsduTo(Mac48Address to, const WifiPsduMap& psduMap);
96
104 virtual void SetTargetRssi(CtrlTriggerHeader& trigger) const;
105
113 virtual std::optional<double> GetMostRecentRssi(const Mac48Address& address) const;
114
125 bool IsIntraBssPpdu(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) const;
126
135 bool UlMuCsMediumIdle(const CtrlTriggerHeader& trigger) const;
136
137 protected:
138 void DoDispose() override;
139 void Reset() override;
140
142 RxSignalInfo rxSignalInfo,
143 const WifiTxVector& txVector,
144 bool inAmpdu) override;
146 const RxSignalInfo& rxSignalInfo,
147 const WifiTxVector& txVector,
148 const std::vector<bool>& perMpduStatus) override;
149 void PostProcessFrame(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
150 Time GetTxDuration(uint32_t ppduPayloadSize,
151 Mac48Address receiver,
152 const WifiTxParameters& txParams) const override;
153 bool SendMpduFromBaManager(Ptr<WifiMpdu> mpdu, Time availableTime, bool initialFrame) override;
154 void NormalAckTimeout(Ptr<WifiMpdu> mpdu, const WifiTxVector& txVector) override;
155 void BlockAckTimeout(Ptr<WifiPsdu> psdu, const WifiTxVector& txVector) override;
156 void CtsTimeout(Ptr<WifiMpdu> rts, const WifiTxVector& txVector) override;
157 void UpdateNav(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) override;
158 void NavResetTimeout() override;
159
164 void ClearTxopHolderIfNeeded() override;
165
169 virtual void IntraBssNavResetTimeout();
170
181 virtual Time GetMuRtsDurationId(uint32_t muRtsSize,
182 const WifiTxVector& muRtsTxVector,
183 Time txDuration,
184 Time response) const;
185
191 void SendMuRts(const WifiTxParameters& txParams);
192
199 virtual void CtsAfterMuRtsTimeout(Ptr<WifiMpdu> muRts, const WifiTxVector& txVector);
200
208 void SendCtsAfterMuRts(const WifiMacHeader& muRtsHdr,
209 const CtrlTriggerHeader& trigger,
210 double muRtsSnr);
211
216
225 WifiTxVector GetCtsTxVectorAfterMuRts(const CtrlTriggerHeader& trigger, uint16_t staId) const;
226
236
243 void ForwardPsduMapDown(WifiConstPsduMap psduMap, WifiTxVector& txVector);
244
254 virtual void BlockAcksInTbPpduTimeout(WifiPsduMap* psduMap,
255 const std::set<Mac48Address>* staMissedBlockAckFrom,
256 std::size_t nSolicitedStations);
257
267 virtual void TbPpduTimeout(WifiPsduMap* psduMap,
268 const std::set<Mac48Address>* staMissedTbPpduFrom,
269 std::size_t nSolicitedStations);
270
278 virtual void BlockAckAfterTbPpduTimeout(Ptr<WifiPsdu> psdu, const WifiTxVector& txVector);
279
287 WifiTxVector GetTrigVector(const CtrlTriggerHeader& trigger) const;
288
299 WifiTxVector GetHeTbTxVector(CtrlTriggerHeader trigger, Mac48Address triggerSender) const;
300
313 Ptr<WifiMpdu> PrepareMuBar(const WifiTxVector& responseTxVector,
314 std::map<uint16_t, CtrlBAckRequestHeader> recipients) const;
315
323 void SendMultiStaBlockAck(const WifiTxParameters& txParams, Time durationId);
324
333 void SendQosNullFramesInTbPpdu(const CtrlTriggerHeader& trigger, const WifiMacHeader& hdr);
334
340
341 private:
345 void SendPsduMap();
346
353 void ReceiveBasicTrigger(const CtrlTriggerHeader& trigger, const WifiMacHeader& hdr);
354
363 void ReceiveMuBarTrigger(const CtrlTriggerHeader& trigger,
364 uint8_t tid,
365 Time durationId,
366 double snr);
367
372 std::set<Mac48Address> m_staExpectTbPpduFrom;
376};
377
378} // namespace ns3
379
380#endif /* HE_FRAME_EXCHANGE_MANAGER_H */
Headers for Trigger frames.
Definition: ctrl-headers.h:945
An identifier for simulation events.
Definition: event-id.h:55
HeFrameExchangeManager handles the frame exchange sequences for HE stations.
WifiTxVector GetTrigVector(const CtrlTriggerHeader &trigger) const
Get the TRIGVECTOR that the MAC has to pass to the PHY when transmitting the given Trigger Frame.
virtual Time GetMuRtsDurationId(uint32_t muRtsSize, const WifiTxVector &muRtsTxVector, Time txDuration, Time response) const
Compute how to set the Duration/ID field of an MU-RTS Trigger Frame to send to protect a frame transm...
Ptr< ApWifiMac > m_apMac
MAC pointer (null if not an AP)
void ReceiveMuBarTrigger(const CtrlTriggerHeader &trigger, uint8_t tid, Time durationId, double snr)
Respond to a MU-BAR Trigger Frame (if permitted by UL MU CS mechanism).
void SendQosNullFramesInTbPpdu(const CtrlTriggerHeader &trigger, const WifiMacHeader &hdr)
Send QoS Null frames in response to a Basic or BSRP Trigger Frame.
void SetWifiPhy(const Ptr< WifiPhy > phy) override
Set the PHY layer to use.
void DoDispose() override
Destructor implementation.
void Reset() override
Reset this frame exchange manager.
Ptr< WifiMpdu > PrepareMuBar(const WifiTxVector &responseTxVector, std::map< uint16_t, CtrlBAckRequestHeader > recipients) const
Build a MU-BAR Trigger Frame starting from the TXVECTOR used to respond to the MU-BAR (in case of mul...
virtual void IntraBssNavResetTimeout()
Reset the intra-BSS NAV upon expiration of the intra-BSS NAV reset timer.
void SendMuRts(const WifiTxParameters &txParams)
Send an MU-RTS to begin an MU-RTS/CTS frame exchange protecting an MU PPDU.
WifiTxParameters m_txParams
the TX parameters for the current PPDU
Time GetTxDuration(uint32_t ppduPayloadSize, Mac48Address receiver, const WifiTxParameters &txParams) const override
Get the updated TX duration of the frame associated with the given TX parameters if the size of the P...
void BlockAckTimeout(Ptr< WifiPsdu > psdu, const WifiTxVector &txVector) override
Called when the BlockAck timeout expires.
uint16_t GetSupportedBaBufferSize() const override
Get the maximum supported buffer size for a Block Ack agreement.
void CalculateAcknowledgmentTime(WifiAcknowledgment *acknowledgment) const override
Calculate the time required to acknowledge a frame according to the given acknowledgment method.
Ptr< WifiMpdu > m_triggerFrame
Trigger Frame being sent.
void SetMultiUserScheduler(const Ptr< MultiUserScheduler > muScheduler)
Set the Multi-user Scheduler associated with this Frame Exchange Manager.
virtual void TbPpduTimeout(WifiPsduMap *psduMap, const std::set< Mac48Address > *staMissedTbPpduFrom, std::size_t nSolicitedStations)
Take the necessary actions after that some TB PPDUs are missing in response to Trigger Frame.
WifiTxVector GetCtsTxVectorAfterMuRts(const CtrlTriggerHeader &trigger, uint16_t staId) const
Get the TXVECTOR that the station having the given station ID has to use to send a CTS frame after re...
void SetWifiMac(const Ptr< WifiMac > mac) override
Set the MAC layer to use.
bool m_triggerFrameInAmpdu
True if the received A-MPDU contains an MU-BAR.
virtual std::optional< double > GetMostRecentRssi(const Mac48Address &address) const
Get the RSSI (in dBm) of the most recent packet received from the station having the given address.
Ptr< MultiUserScheduler > m_muScheduler
Multi-user Scheduler (HE APs only)
virtual void CtsAfterMuRtsTimeout(Ptr< WifiMpdu > muRts, const WifiTxVector &txVector)
Called when no CTS frame is received after an MU-RTS.
void NavResetTimeout() override
Reset the NAV upon expiration of the NAV reset timer.
WifiTxVector m_trigVector
the TRIGVECTOR
virtual void SetTargetRssi(CtrlTriggerHeader &trigger) const
Set the UL Target RSSI subfield of every User Info fields of the given Trigger Frame to the most rece...
void SendCtsAfterMuRts(const WifiMacHeader &muRtsHdr, const CtrlTriggerHeader &trigger, double muRtsSnr)
Send CTS after receiving an MU-RTS.
static Ptr< WifiPsdu > GetPsduTo(Mac48Address to, const WifiPsduMap &psduMap)
Get the PSDU in the given PSDU map that is addressed to the given MAC address, if any,...
void EndReceiveAmpdu(Ptr< const WifiPsdu > psdu, const RxSignalInfo &rxSignalInfo, const WifiTxVector &txVector, const std::vector< bool > &perMpduStatus) override
This method is called when the reception of an A-MPDU including multiple MPDUs is completed.
void CalculateProtectionTime(WifiProtection *protection) const override
Calculate the time required to protect a frame according to the given protection method.
Ptr< StaWifiMac > m_staMac
MAC pointer (null if not a STA)
void CtsTimeout(Ptr< WifiMpdu > rts, const WifiTxVector &txVector) override
Called when the CTS timeout expires.
MuSnrTag m_muSnrTag
Tag to attach to Multi-STA BlockAck frames.
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)
EventId m_intraBssNavResetEvent
the event to reset the intra-BSS NAV after an RTS
void ForwardPsduMapDown(WifiConstPsduMap psduMap, WifiTxVector &txVector)
Forward a map of PSDUs down to the PHY layer.
bool StartFrameExchange(Ptr< QosTxop > edca, Time availableTime, bool initialFrame) override
Start a frame exchange (including protection frames and acknowledgment frames as needed) that fits wi...
void ClearTxopHolderIfNeeded() override
Clear the TXOP holder if the intra-BSS NAV counted down to zero (includes the case of intra-BSS NAV r...
std::set< Mac48Address > m_staExpectTbPpduFrom
set of stations expected to send a TB PPDU
void NormalAckTimeout(Ptr< WifiMpdu > mpdu, const WifiTxVector &txVector) override
Called when the Ack timeout expires.
virtual void BlockAckAfterTbPpduTimeout(Ptr< WifiPsdu > psdu, const WifiTxVector &txVector)
Take the necessary actions after that a Block Ack is missing after a TB PPDU solicited through a Trig...
void SendPsduMap()
Send the current PSDU map as a DL MU PPDU.
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...
WifiPsduMap m_psduMap
the A-MPDU being transmitted
void SendMultiStaBlockAck(const WifiTxParameters &txParams, Time durationId)
Send a Multi-STA Block Ack frame after the reception of some TB PPDUs.
static TypeId GetTypeId()
Get the type ID.
Time m_intraBssNavEnd
intra-BSS NAV expiration time
bool UlMuCsMediumIdle(const CtrlTriggerHeader &trigger) const
This method is intended to be called a SIFS after the reception of a Trigger Frame to determine wheth...
bool SendMpduFromBaManager(Ptr< WifiMpdu > mpdu, Time availableTime, bool initialFrame) override
If the given MPDU contains a BlockAckReq frame (the duration of which plus the response fits within t...
void UpdateNav(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector) override
Update the NAV, if needed, based on the Duration/ID of the given psdu.
virtual void BlockAcksInTbPpduTimeout(WifiPsduMap *psduMap, const std::set< Mac48Address > *staMissedBlockAckFrom, std::size_t nSolicitedStations)
Take the necessary actions after that some BlockAck frames are missing in response to a DL MU PPDU.
EventId m_multiStaBaEvent
Sending a Multi-STA BlockAck event.
void SetTxopHolder(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector) override
Set the TXOP holder, if needed, based on the received frame.
bool IsIntraBssPpdu(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector) const
Return whether the received frame is classified as intra-BSS.
void SendPsduMapWithProtection(WifiPsduMap psduMap, WifiTxParameters &txParams)
Send a map of PSDUs as a DL MU PPDU.
void ReceiveBasicTrigger(const CtrlTriggerHeader &trigger, const WifiMacHeader &hdr)
Take the necessary actions when receiving a Basic Trigger Frame.
WifiTxVector GetHeTbTxVector(CtrlTriggerHeader trigger, Mac48Address triggerSender) const
Return a TXVECTOR for the UL frame that the station will send in response to the given Trigger frame,...
an EUI-48 address
Definition: mac48-address.h:46
A tag to be attached to a response to a multi-user UL frame, that carries the SNR values with which t...
Definition: mu-snr-tag.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:60
VhtFrameExchangeManager handles the frame exchange sequences for VHT stations.
Implements the IEEE 802.11 MAC header.
represent a single transmission mode
Definition: wifi-mode.h:50
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.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
bool IsTrigger(const WifiPsduMap &psduMap)
std::unordered_map< uint16_t, Ptr< WifiPsdu > > WifiPsduMap
Map of PSDUs indexed by STA-ID.
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:70
WifiAcknowledgment is an abstract base struct.
WifiProtection is an abstract base struct.