30 #include "ns3/he-phy.h" 31 #include "ns3/he-frame-exchange-manager.h" 43 static TypeId tid =
TypeId (
"ns3::WifiDefaultAckManager")
45 .SetGroupName (
"Wifi")
47 .AddAttribute (
"UseExplicitBar",
48 "Specify whether to send Block Ack Requests (if true) or use" 49 " Implicit Block Ack Request ack policy (if false).",
53 .AddAttribute (
"BaThreshold",
54 "Immediate acknowledgment is requested upon transmission of a frame " 55 "whose sequence number is distant at least BaThreshold multiplied " 56 "by the transmit window size from the starting sequence number of " 57 "the transmit window. Set to zero to request a response for every " 61 MakeDoubleChecker<double> (0.0, 1.0))
62 .AddAttribute (
"DlMuAckSequenceType",
63 "Type of the acknowledgment sequence for DL MU PPDUs.",
69 .AddAttribute (
"MaxBlockAckMcs",
70 "The MCS used to send a BlockAck in a TB PPDU is the minimum between " 71 "the MCS used for the PSDU sent in the preceding DL MU PPDU and the " 72 "value of this attribute.",
75 MakeUintegerChecker<uint8_t> (0, 11))
102 "An established Block Ack agreement is required");
107 "The given QoS data frame is too old");
114 return maxDistFromStartingSeq;
117 for (
const auto& seqNumber : psduInfo->
seqNumbers.at (tid))
123 if (currDistToStartingSeq > maxDistFromStartingSeq)
125 maxDistFromStartingSeq = currDistToStartingSeq;
131 return maxDistFromStartingSeq;
140 uint8_t tid = mpdu->GetHeader ().GetQosTid ();
155 + edca->
GetBaManager ()->GetRetransmitQueue ()->GetNPackets (tid, receiver) > 1)
166 std::unique_ptr<WifiAcknowledgment>
204 acknowledgment =
new WifiNoAck (*acknowledgment);
211 return std::unique_ptr<WifiAcknowledgment> (acknowledgment);
225 return std::unique_ptr<WifiAcknowledgment> (acknowledgment);
246 "Unicast frames only can be aggregated");
253 return std::unique_ptr<WifiAcknowledgment> (acknowledgment);
260 NS_LOG_DEBUG (
"Non-QoS data frame or Block Ack agreement not established, request Normal Ack");
267 return std::unique_ptr<WifiAcknowledgment> (acknowledgment);
274 NS_LOG_DEBUG (
"A response is not needed: no ack for now, use Block Ack policy");
288 return std::unique_ptr<WifiAcknowledgment> (acknowledgment);
292 uint8_t tid =
GetTid (mpdu->GetPacket (), hdr);
294 && txParams.
GetSize (receiver) == 0
296 ==
m_mac->GetQosTxop (tid)->GetBaStartingSequence (receiver, tid))
298 NS_LOG_DEBUG (
"Sending a single MPDU, no previous frame to ack: request Normal Ack");
302 return std::unique_ptr<WifiAcknowledgment> (acknowledgment);
312 NS_LOG_DEBUG (
"Request to schedule a Block Ack Request");
317 acknowledgment->
barType =
m_mac->GetQosTxop (tid)->GetBlockAckReqType (receiver, tid);
318 acknowledgment->
baType =
m_mac->GetQosTxop (tid)->GetBlockAckType (receiver, tid);
320 return std::unique_ptr<WifiAcknowledgment> (acknowledgment);
323 NS_LOG_DEBUG (
"A-MPDU using Implicit Block Ack Request policy or BlockAckReq, request Block Ack");
326 acknowledgment->
baType =
m_mac->GetQosTxop (tid)->GetBlockAckType (receiver, tid);
328 return std::unique_ptr<WifiAcknowledgment> (acknowledgment);
331 std::unique_ptr<WifiAcknowledgment>
341 std::unique_ptr<WifiAcknowledgment>
355 "QoS data frames only can be aggregated when transmitting a " 356 "DL MU PPDU acknowledged via a sequence of BAR and BA frames");
369 if (psduInfo !=
nullptr)
397 acknowledgment->stationsReplyingWithNormalAck.clear ();
399 acknowledgment->stationsReplyingWithBlockAck.emplace
403 m_mac->GetWifiRemoteStationManager ()->GetBlockAckTxVector (receiver, txParams.
m_txVector),
406 return std::unique_ptr<WifiDlMuBarBaSequence> (acknowledgment);
410 if (edca->
GetBaManager ()->GetBar (
true, tid, receiver) != 0
411 || (acknowledgment !=
nullptr 418 if (acknowledgment !=
nullptr)
430 NS_LOG_DEBUG (
"Adding STA " << receiver <<
" to the list of stations receiving a BlockAckReq");
435 m_mac->GetWifiRemoteStationManager ()->GetBlockAckTxVector (receiver, txParams.
m_txVector),
437 m_mac->GetWifiRemoteStationManager ()->GetBlockAckTxVector (receiver, txParams.
m_txVector),
442 return std::unique_ptr<WifiDlMuBarBaSequence> (acknowledgment);
446 if (acknowledgment !=
nullptr)
458 NS_LOG_DEBUG (
"Adding STA " << receiver <<
" as the station that will immediately reply with a Normal Ack");
463 m_mac->GetWifiRemoteStationManager ()->GetAckTxVector (receiver, txParams.
m_txVector)
467 return std::unique_ptr<WifiDlMuBarBaSequence> (acknowledgment);
470 std::unique_ptr<WifiAcknowledgment>
492 if (psduInfo ==
nullptr)
497 uint16_t staId = apMac->GetAssociationId (receiver);
500 "QoS data frames only can be aggregated when transmitting a " 501 "DL MU PPDU acknowledged via a MU-BAR sent as SU frame");
505 if (acknowledgment !=
nullptr)
528 NS_LOG_DEBUG (
"Adding STA " << receiver <<
" to the list of stations that will be solicited by the MU-BAR");
534 edca->
GetBaManager ()->GetBlockAckReqHeader (receiver, tid),
540 acknowledgment->
muBarTxVector =
m_mac->GetWifiRemoteStationManager ()->GetRtsTxVector (receiver);
542 return std::unique_ptr<WifiDlMuTfMuBar> (acknowledgment);
548 "QoS data frames only can be aggregated when transmitting a DL MU PPDU");
554 std::unique_ptr<WifiAcknowledgment>
576 if (psduInfo ==
nullptr)
581 uint16_t staId = apMac->GetAssociationId (receiver);
584 "QoS data frames only can be aggregated when transmitting a " 585 "DL MU PPDU acknowledged via a sequence of BAR and BA frames");
589 if (acknowledgment !=
nullptr)
612 NS_LOG_DEBUG (
"Adding STA " << receiver <<
" to the list of stations that will reply with a Block Ack");
619 edca->
GetBaManager ()->GetBlockAckReqHeader (receiver, tid),
625 return std::unique_ptr<WifiDlMuAggregateTf> (acknowledgment);
631 "QoS data and MU-BAR Trigger frames only can be aggregated when transmitting a DL MU PPDU");
637 std::unique_ptr<WifiAcknowledgment>
642 NS_ASSERT (mpdu->GetHeader ().IsTrigger ());
645 NS_ABORT_MSG_IF (apMac ==
nullptr,
"HE APs only can send Trigger Frames");
648 NS_ABORT_MSG_IF (heFem ==
nullptr,
"HE APs only can send Trigger Frames");
651 mpdu->GetPacket ()->PeekHeader (trigger);
659 for (
const auto& userInfo : trigger)
661 uint16_t aid12 = userInfo.GetAid12 ();
668 NS_ABORT_MSG_IF (aid12 == 0 || aid12 > 2007,
"Allocation of RA-RUs is not supported");
670 NS_ASSERT (apMac->GetStaList ().find (aid12) != apMac->GetStaList ().end ());
671 Mac48Address staAddress = apMac->GetStaList ().find (aid12)->second;
675 while (tid < 8 && !heFem->GetBaAgreementEstablished (staAddress, tid))
679 NS_ASSERT_MSG (tid < 8,
"No Block Ack agreement established with originator " << staAddress);
686 acknowledgment->
baType.
m_bitmapLen.push_back (heFem->GetBlockAckType (staAddress, tid).m_bitmapLen.at (0));
689 uint16_t staId = trigger.begin ()->GetAid12 ();
691 acknowledgment->
multiStaBaTxVector =
m_mac->GetWifiRemoteStationManager ()->GetBlockAckTxVector (apMac->GetStaList ().find (staId)->second,
693 return std::unique_ptr<WifiUlMuMultiStaBa> (acknowledgment);
695 else if (trigger.
IsBsrp ())
697 return std::unique_ptr<WifiAcknowledgment> (
new WifiNoAck);
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
Set of stations replying with a BlockAck frame.
virtual std::unique_ptr< WifiAcknowledgment > GetAckInfoIfBarBaSequence(Ptr< const WifiMacQueueItem > mpdu, const WifiTxParameters &txParams)
Compute the information about the acknowledgment of the current multi-user frame (as described by the...
bool m_useExplicitBar
true for sending BARs, false for using Implicit BAR policy
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
AttributeValue implementation for Boolean.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiAcknowledgment::Method m_dlMuAckType
Type of the ack sequence for DL MU PPDUs.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
information related to a BlockAckReq frame sent to a station
virtual std::unique_ptr< WifiAcknowledgment > TryAddMpdu(Ptr< const WifiMacQueueItem > mpdu, const WifiTxParameters &txParams) override
Determine the acknowledgment method to use if the given MPDU is added to the current frame...
virtual std::unique_ptr< WifiAcknowledgment > GetAckInfoIfTfMuBar(Ptr< const WifiMacQueueItem > mpdu, const WifiTxParameters &txParams)
Compute the information about the acknowledgment of the current multi-user frame (as described by the...
std::unique_ptr< WifiProtection > m_protection
protection method
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
WifiDlMuBarBaSequence specifies that a DL MU PPDU is acknowledged through a sequence of BlockAckReq a...
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
const uint16_t SEQNO_SPACE_HALF_SIZE
Size of the half the space of sequence numbers (used to determine old packets)
WifiTxVector tbPpduTxVector
TXVECTOR for a TB PPDU.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
WifiTxVector ackTxVector
Ack TXVECTOR.
Ptr< BlockAckManager > GetBaManager(void)
Get the Block Ack Manager associated with this QosTxop.
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
Set of stations replying with a BlockAck frame.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
bool QosUtilsIsOldPacket(uint16_t startingSeq, uint16_t seqNumber)
This function checks if packet with sequence number seqNumber is an "old" packet. ...
bool IsStrictlyPositive(void) const
Exactly equivalent to t > 0.
uint16_t GetBaStartingSequence(Mac48Address address, uint8_t tid) const
uint16_t GetGuardInterval(void) const
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
virtual Time GetRemainingTxop(void) const
Return the remaining duration in the current TXOP.
HeMuUserInfo GetHeMuUserInfo(uint16_t staId) const
Get the HE MU user-specific transmission information for the given STA-ID.
WifiTxVector blockAckReqTxVector
BlockAckReq TXVECTOR.
BlockAckType baType
BlockAck type.
std::map< std::pair< Mac48Address, uint8_t >, std::size_t > stationsReceivingMultiStaBa
Map (originator, tid) pairs to the their index in baType.
static WifiMode GetHeMcs(uint8_t index)
Return the HE MCS corresponding to the provided index.
enum Variant m_variant
Block Ack variant.
WifiTxVector muBarTxVector
TXVECTOR used to transmit the MU-BAR Trigger Frame.
BlockAckType baType
BlockAck type.
WifiTxVector multiStaBaTxVector
TXVECTOR for the Multi-STA BlockAck.
information related to a BlockAck frame sent by a station
virtual std::unique_ptr< WifiAcknowledgment > GetAckInfoIfAggregatedMuBar(Ptr< const WifiMacQueueItem > mpdu, const WifiTxParameters &txParams)
Compute the information about the acknowledgment of the current multi-user frame (as described by the...
information related to a BlockAck frame sent by a station
Hold variables of type enum.
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
Hold an unsigned integer type.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
std::map< Mac48Address, BlockAckInfo > stationsReplyingWithBlockAck
Set of stations replying with a BlockAck frame (no more than one)
const PsduInfo * GetPsduInfo(Mac48Address receiver) const
Get a pointer to the information about the PSDU addressed to the given receiver, if present...
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
static TypeId GetTypeId(void)
Get the type ID.
std::list< BlockAckReqType > barTypes
BAR types.
WifiTxVector blockAckTxVector
BlockAck TXVECTOR.
WifiNoAck specifies that no acknowledgment is required.
WifiUlMuMultiStaBa specifies that a Basic Trigger Frame is being sent to solicit TB PPDUs that will b...
WifiAckManager is an abstract base class.
uint32_t GetMuBarSize(std::list< BlockAckReqType > types)
Return the total MU-BAR size (including FCS trailer).
void SetHeMuUserInfo(uint16_t staId, HeMuUserInfo userInfo)
Set the HE MU user-specific transmission information for the given STA-ID.
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
BlockAckType GetBlockAckType(Mac48Address recipient, uint8_t tid) const
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
WifiTxVector blockAckTxVector
BlockAck TXVECTOR.
double m_baThreshold
Threshold to determine when a BlockAck must be requested.
WifiDefaultAckManager is the default ack manager.
virtual ~WifiDefaultAckManager()
WifiBarBlockAck specifies that a BlockAckReq is sent to solicit a Block Ack response.
std::map< uint8_t, std::set< uint16_t > > seqNumbers
set of the sequence numbers of the MPDUs added for each TID
uint8_t GetTid(Ptr< const Packet > packet, const WifiMacHeader hdr)
This function is useful to get traffic id of different packet types.
virtual std::unique_ptr< WifiAcknowledgment > TryAggregateMsdu(Ptr< const WifiMacQueueItem > msdu, const WifiTxParameters &txParams) override
Determine the acknowledgment method to use if the given MSDU is aggregated to the current frame...
WifiBlockAck specifies that acknowledgment via Block Ack is required.
information about the frame being prepared for a specific receiver
uint32_t GetSize(Mac48Address receiver) const
Get the size in bytes of the (A-)MPDU addressed to the given receiver.
bool IsDlMu(void) const
Return true if this TX vector is used for a downlink multi-user transmission.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual std::unique_ptr< WifiAcknowledgment > TryUlMuTransmission(Ptr< const WifiMacQueueItem > mpdu, const WifiTxParameters &txParams)
Calculate the acknowledgment method for the TB PPDUs solicited by the given Trigger Frame...
uint16_t GetMaxDistFromStartingSeq(Ptr< const WifiMacQueueItem > mpdu, const WifiTxParameters &txParams) const
Get the maximum distance between the starting sequence number of the Block Ack agreement which the gi...
std::vector< uint8_t > m_bitmapLen
Length (bytes) of included bitmaps.
BlockAckReqType GetBlockAckReqType(Mac48Address recipient, uint8_t tid) const
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Ptr< RegularWifiMac > m_mac
MAC which is using this Acknowledgment Manager.
information related to a BlockAck frame sent by a station
BlockAckType baType
BlockAck type.
void SetQosAckPolicy(Mac48Address receiver, uint8_t tid, WifiMacHeader::QosAckPolicy ackPolicy)
Set the QoS Ack policy to use for the MPDUs addressed to the given receiver and belonging to the give...
bool IsUlMu(void) const
Return true if this TX vector is used for an uplink multi-user transmission.
bool GetBaAgreementEstablished(Mac48Address address, uint8_t tid) const
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism...
uint8_t m_maxMcsForBlockAckInTbPpdu
Max MCS used to send a BlockAck in a TB PPDU.
WifiDlMuAggregateTf specifies that a DL MU PPDU made of PSDUs including each a MU-BAR Trigger Frame i...
uint16_t GetBaBufferSize(Mac48Address address, uint8_t tid) const
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
const uint16_t SEQNO_SPACE_SIZE
Size of the space of sequence numbers.
WifiAckAfterTbPpdu is used when a station prepares a TB PPDU to send in response to a Basic Trigger F...
uint16_t GetChannelWidth(void) const
information related to an Ack frame sent by a station
std::unique_ptr< WifiAcknowledgment > m_acknowledgment
acknowledgment method
BlockAckReqType barType
BlockAckReq type.
WifiNormalAck specifies that acknowledgment via Normal Ack is required.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
bool IsResponseNeeded(Ptr< const WifiMacQueueItem > mpdu, const WifiTxParameters &txParams) const
Determine whether the (A-)MPDU containing the given MPDU and the MPDUs (if any) included in the given...
WifiDlMuTfMuBar specifies that a DL MU PPDU is followed after a SIFS duration by a MU-BAR Trigger Fra...
std::map< Mac48Address, BlockAckReqInfo > stationsSendBlockAckReqTo
Set of stations receiving a BlockAckReq frame and replying with a BlockAck frame. ...
std::map< Mac48Address, AckInfo > stationsReplyingWithNormalAck
Set of stations replying with an Ack frame (no more than one)
Time GetTxopLimit(void) const
Return the TXOP limit.