30#include "ns3/packet.h"
54 if (&txParams ==
this)
84 auto infoIt =
m_info.find(receiver);
86 if (infoIt ==
m_info.end())
90 return &infoIt->second;
108 if (infoIt ==
m_info.end())
111 std::map<uint8_t, std::set<uint16_t>> seqNumbers;
118 const auto [it, inserted] =
130 "An MPDU can only be aggregated to an existing (A-)MPDU");
135 PsduInfo{infoIt->second.
header, infoIt->second.amsduSize, infoIt->second.ampduSize, {}};
145 infoIt->second.ampduSize);
146 infoIt->second.header = hdr;
147 infoIt->second.amsduSize = mpdu->GetPacketSize();
151 const auto [it, inserted] =
152 infoIt->second.seqNumbers.emplace(hdr.
GetQosTid(),
153 std::set<uint16_t>{hdr.GetSequenceNumber()});
177 auto& lastInfo = (*m_lastInfoIt)->second;
189 NS_ASSERT(lastInfo.seqNumbers.contains(tid));
190 lastInfo.seqNumbers.at(tid).erase(*seqNoSet.cbegin());
198 auto infoIt =
m_info.find(receiver);
209 auto infoIt =
m_info.find(mpdu->GetHeader().GetAddr1());
211 if (infoIt ==
m_info.end())
219 return mpdu->GetSize();
225 infoIt->second.ampduSize);
235 auto infoIt =
m_info.find(msdu->GetHeader().GetAddr1());
237 "There must be already an MPDU addressed to the same receiver");
242 PsduInfo{infoIt->second.
header, infoIt->second.amsduSize, infoIt->second.ampduSize, {}};
245 infoIt->second.header.SetQosAmsdu();
254 "Can only aggregate a QoS data frame to an A-MSDU");
256 auto infoIt =
m_info.find(msdu->GetHeader().GetAddr1());
258 "There must be already an MPDU addressed to the same receiver");
261 "The amsduSize should be set to the size of the previous MSDU(s)");
263 "The MPDU being built for this receiver must be a QoS data frame");
264 NS_ASSERT_MSG(infoIt->second.header.GetQosTid() == msdu->GetHeader().GetQosTid(),
265 "The MPDU being built must belong to the same TID as the MSDU to aggregate");
266 NS_ASSERT_MSG(infoIt->second.seqNumbers.contains(msdu->GetHeader().GetQosTid()),
267 "At least one MPDU with the same TID must have been added previously");
270 uint32_t currAmsduSize = infoIt->second.amsduSize;
272 if (!infoIt->second.header.IsQosAmsdu())
286 auto infoIt =
m_info.find(receiver);
288 if (infoIt ==
m_info.end())
317 for (
const auto& info :
m_info)
319 os <<
" [To=" << info.second.header.GetAddr1() <<
", A-MSDU size=" << info.second.amsduSize
320 <<
", A-MPDU size=" << info.second.ampduSize <<
"]";
static uint32_t GetSizeIfAggregated(uint32_t mpduSize, uint32_t ampduSize)
Compute the size of the A-MPDU resulting from the aggregation of an MPDU of size mpduSize and an A-MP...
static uint16_t GetSizeIfAggregated(uint16_t msduSize, uint16_t amsduSize)
Compute the size of the A-MSDU resulting from the aggregation of an MSDU of size msduSize and an A-MS...
Smart pointer class similar to boost::intrusive_ptr.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
uint32_t GetSizeIfAddMpdu(Ptr< const WifiMpdu > mpdu) const
Get the size in bytes of the frame in case the given MPDU is added.
std::optional< Time > m_txDuration
TX duration of the frame.
const PsduInfoMap & GetPsduInfoMap() const
Get a const reference to the map containing information about PSDUs.
PsduInfo m_undoInfo
information needed to undo the addition of an MPDU
std::unique_ptr< WifiProtection > m_protection
protection method
WifiTxParameters & operator=(const WifiTxParameters &txParams)
Copy assignment operator.
uint32_t GetSizeIfAggregateMsdu(Ptr< const WifiMpdu > msdu) const
Get the size in bytes of the frame in case the given MSDU is aggregated.
uint32_t GetSize(Mac48Address receiver) const
Get the size in bytes of the (A-)MPDU addressed to the given receiver.
std::unique_ptr< WifiAcknowledgment > m_acknowledgment
acknowledgment method
const PsduInfo * GetPsduInfo(Mac48Address receiver) const
Get a pointer to the information about the PSDU addressed to the given receiver, if present,...
void UndoAddMpdu()
Undo the addition of the last MPDU added by calling AddMpdu().
bool LastAddedIsFirstMpdu(Mac48Address receiver) const
Check if the last added MPDU is the first MPDU for the given receiver.
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
PsduInfoMap m_info
information about the frame being prepared.
void AggregateMsdu(Ptr< const WifiMpdu > msdu)
Record that an MSDU is being aggregated to the last MPDU added to the frame that hase the same receiv...
void Print(std::ostream &os) const
Print the object contents.
void AddMpdu(Ptr< const WifiMpdu > mpdu)
Record that an MPDU is being added to the current frame.
void Clear()
Reset the TX parameters.
std::map< Mac48Address, PsduInfo > PsduInfoMap
Map containing information about the PSDUs addressed to every receiver.
std::optional< PsduInfoMap::iterator > m_lastInfoIt
iterator pointing to the entry in the m_info map that was created/modified by the last added MPDU
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiModulationClass GetModulationClass() const
Get the modulation class specified by this TXVECTOR.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octets of the IEEE 802.11 MAC FCS field.
std::ostream & operator<<(std::ostream &os, const Angles &a)
information about the frame being prepared for a specific receiver
std::map< uint8_t, std::set< uint16_t > > seqNumbers
set of the sequence numbers of the MPDUs added for each TID
uint32_t ampduSize
the size in bytes of the A-MPDU if multiple MPDUs have been added, and zero otherwise
WifiMacHeader header
MAC header of the last MPDU added.
uint32_t amsduSize
the size in bytes of the MSDU or A-MSDU included in the last MPDU added