28 #include "ns3/packet.h"
38 m_mpduList.push_back(Create<WifiMpdu>(p, header));
43 : m_isSingle(isSingle)
60 : m_isSingle(mpduList.size() == 1),
63 NS_ABORT_MSG_IF(mpduList.empty(),
"Cannot initialize a WifiPsdu with an empty MPDU list");
94 packet =
m_mpduList.at(0)->GetPacket()->Copy();
117 for (std::size_t i = 1; i <
m_mpduList.size(); i++)
119 if (
m_mpduList.at(i)->GetHeader().GetAddr1() != ra)
121 NS_ABORT_MSG(
"MPDUs in an A-AMPDU must have the same receiver address");
132 for (std::size_t i = 1; i <
m_mpduList.size(); i++)
134 if (
m_mpduList.at(i)->GetHeader().GetAddr2() != ta)
136 NS_ABORT_MSG(
"MPDUs in an A-AMPDU must have the same transmitter address");
149 return (
m_mpduList.at(0)->GetHeader().GetRawDuration() & 0x8000) == 0;
157 for (std::size_t i = 1; i <
m_mpduList.size(); i++)
159 if (
m_mpduList.at(i)->GetHeader().GetDuration() != duration)
161 NS_ABORT_MSG(
"MPDUs in an A-AMPDU must have the same Duration/ID");
173 mpdu->GetHeader().SetDuration(duration);
183 if (mpdu->GetHeader().IsQosData())
185 s.insert(mpdu->GetHeader().GetQosTid());
202 if ((*it)->GetHeader().IsQosData() && (*it)->GetHeader().GetQosTid() == tid)
204 policy = (*it)->GetHeader().GetQosAckPolicy();
215 if ((*it)->GetHeader().IsQosData() && (*it)->GetHeader().GetQosTid() == tid &&
216 (*it)->GetHeader().GetQosAckPolicy() != policy)
218 NS_ABORT_MSG(
"QoS Data frames with the same TID must have the same QoS Ack Policy");
231 if (mpdu->GetHeader().IsQosData() && mpdu->GetHeader().GetQosTid() == tid)
233 mpdu->GetHeader().SetQosAckPolicy(policy);
243 uint16_t maxDistFromStartingSeq = 0;
244 bool foundFirst =
false;
248 uint16_t currSeqNum = mpdu->GetHeader().GetSequenceNumber();
252 uint16_t currDistToStartingSeq =
255 if (!foundFirst || currDistToStartingSeq > maxDistFromStartingSeq)
258 maxDistFromStartingSeq = currDistToStartingSeq;
265 NS_LOG_DEBUG(
"All QoS Data frames in this PSDU are old frames");
269 return maxDistFromStartingSeq;
317 size_t subframeSize = 4;
332 std::vector<Ptr<WifiMpdu>>::const_iterator
338 std::vector<Ptr<WifiMpdu>>::iterator
344 std::vector<Ptr<WifiMpdu>>::const_iterator
350 std::vector<Ptr<WifiMpdu>>::iterator
362 os <<
", A-MPDU of " <<
GetNMpdus() <<
" MPDUs";
365 os <<
" (" << *mpdu <<
")";
static uint8_t CalculatePadding(uint32_t ampduSize)
static void Aggregate(Ptr< const WifiMpdu > mpdu, Ptr< Packet > ampdu, bool isSingle)
Aggregate an MPDU to an A-MPDU.
static AmpduSubframeHeader GetAmpduSubframeHeader(uint16_t mpduSize, bool isSingle)
Get the A-MPDU subframe header corresponding to the MPDU size and whether the MPDU is a single MPDU.
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...
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Simulation virtual time values and global simulation resolution.
WifiMpdu stores a (const) packet along with a MAC header.
WifiPsdu stores an MPDU, S-MPDU or A-MPDU, by keeping header(s) and payload(s) separate for each cons...
std::set< uint8_t > GetTids() const
Get the set of TIDs of the QoS Data frames included in the PSDU.
void SetAckPolicyForTid(uint8_t tid, WifiMacHeader::QosAckPolicy policy)
Set the QoS Ack Policy of the QoS Data frames included in the PSDU that have the given TID to the giv...
const WifiMacHeader & GetHeader(std::size_t i) const
Get the header of the i-th MPDU.
void Print(std::ostream &os) const
Print the PSDU contents.
Time GetDuration() const
Get the duration from the Duration/ID field, which is common to all the MPDUs.
Ptr< const Packet > GetPacket() const
Get the PSDU as a single packet.
Ptr< Packet > GetAmpduSubframe(std::size_t i) const
Get a copy of the i-th A-MPDU subframe (includes subframe header, MPDU, and possibly padding)
std::vector< Ptr< WifiMpdu > >::const_iterator end() const
Return a const iterator to past-the-last MPDU.
std::vector< Ptr< WifiMpdu > >::const_iterator begin() const
Return a const iterator to the first MPDU.
WifiPsdu(Ptr< const Packet > p, const WifiMacHeader &header)
Create a PSDU storing an MPDU.
Mac48Address GetAddr2() const
Get the Transmitter Address (TA), which is common to all the MPDUs.
uint32_t m_size
the size of the PSDU in bytes
uint32_t GetSize() const
Return the size of the PSDU in bytes.
Ptr< const Packet > GetPayload(std::size_t i) const
Get the payload of the i-th MPDU.
std::size_t GetAmpduSubframeSize(std::size_t i) const
Return the size of the i-th A-MPDU subframe.
bool m_isSingle
true for an S-MPDU
Mac48Address GetAddr1() const
Get the Receiver Address (RA), which is common to all the MPDUs.
bool IsAggregate() const
Return true if the PSDU is an S-MPDU or A-MPDU.
bool IsSingle() const
Return true if the PSDU is an S-MPDU.
void SetDuration(Time duration)
Set the Duration/ID field on all the MPDUs.
std::vector< Ptr< WifiMpdu > > m_mpduList
list of constituent MPDUs
uint16_t GetMaxDistFromStartingSeq(uint16_t startingSeq) const
Get the maximum distance between the sequence number of any QoS Data frame included in this PSDU that...
std::size_t GetNMpdus() const
Return the number of MPDUs constituting the PSDU.
WifiMacHeader::QosAckPolicy GetAckPolicyForTid(uint8_t tid) const
Get the QoS Ack Policy of the QoS Data frames included in the PSDU that have the given TID.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
bool QosUtilsIsOldPacket(uint16_t startingSeq, uint16_t seqNumber)
This function checks if packet with sequence number seqNumber is an "old" packet.
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.
static constexpr uint16_t SEQNO_SPACE_SIZE
Size of the space of sequence numbers.
void AddWifiMacTrailer(Ptr< Packet > packet)
Add FCS trailer to a packet.
std::ostream & operator<<(std::ostream &os, const Angles &a)