21 #include "ns3/packet.h"
36 m_mpduList.push_back (Create<WifiMacQueueItem> (p, header));
41 : m_isSingle (isSingle)
58 : m_isSingle (mpduList.size () == 1),
61 NS_ABORT_MSG_IF (mpduList.empty (),
"Cannot initialize a WifiPsdu with an empty MPDU list");
92 packet =
m_mpduList.at (0)->GetPacket ()->Copy ();
115 for (std::size_t i = 1; i <
m_mpduList.size (); i++)
117 if (
m_mpduList.at (i)->GetHeader ().GetAddr1 () != ra)
119 NS_ABORT_MSG (
"MPDUs in an A-AMPDU must have the same receiver address");
130 for (std::size_t i = 1; i <
m_mpduList.size (); i++)
132 if (
m_mpduList.at (i)->GetHeader ().GetAddr2 () != ta)
134 NS_ABORT_MSG (
"MPDUs in an A-AMPDU must have the same transmitter address");
145 for (std::size_t i = 1; i <
m_mpduList.size (); i++)
147 if (
m_mpduList.at (i)->GetHeader ().GetDuration () != duration)
149 NS_ABORT_MSG (
"MPDUs in an A-AMPDU must have the same Duration/ID");
161 mpdu->GetHeader ().SetDuration (duration);
171 if (mpdu->GetHeader ().IsQosData ())
173 s.insert (mpdu->GetHeader ().GetQosTid ());
190 if ((*it)->GetHeader ().IsQosData () && (*it)->GetHeader ().GetQosTid () == tid)
192 policy = (*it)->GetHeader ().GetQosAckPolicy ();
203 if ((*it)->GetHeader ().IsQosData () && (*it)->GetHeader ().GetQosTid () == tid
204 && (*it)->GetHeader ().GetQosAckPolicy () != policy)
206 NS_ABORT_MSG (
"QoS Data frames with the same TID must have the same QoS Ack Policy");
219 if (mpdu->GetHeader ().IsQosData () && mpdu->GetHeader ().GetQosTid () == tid)
221 mpdu->GetHeader ().SetQosAckPolicy (policy);
231 uint16_t maxDistFromStartingSeq = 0;
232 bool foundFirst =
false;
236 uint16_t currSeqNum = mpdu->GetHeader ().GetSequenceNumber ();
242 if (!foundFirst || currDistToStartingSeq > maxDistFromStartingSeq)
245 maxDistFromStartingSeq = currDistToStartingSeq;
252 NS_LOG_DEBUG (
"All QoS Data frames in this PSDU are old frames");
256 return maxDistFromStartingSeq;
309 size_t subframeSize = 4;
310 subframeSize +=
m_mpduList.at (i)->GetSize ();
324 std::vector<Ptr<WifiMacQueueItem>>::const_iterator
330 std::vector<Ptr<WifiMacQueueItem>>::iterator
336 std::vector<Ptr<WifiMacQueueItem>>::const_iterator
342 std::vector<Ptr<WifiMacQueueItem>>::iterator
354 os <<
", A-MPDU of " <<
GetNMpdus () <<
" MPDUs";
357 os <<
" (" << *mpdu <<
")";
362 os <<
", " << ((
m_isSingle) ?
"S-MPDU" :
"normal MPDU")
static uint8_t CalculatePadding(uint32_t ampduSize)
static void Aggregate(Ptr< const WifiMacQueueItem > 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(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Simulation virtual time values and global simulation resolution.
WifiMacQueueItem stores (const) packets along with their Wifi MAC headers and the time when they were...
WifiPsdu stores an MPDU, S-MPDU or A-MPDU, by keeping header(s) and payload(s) separate for each cons...
Time GetDuration(void) const
Get the duration from the Duration/ID field, which is common to all the MPDUs.
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
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...
std::vector< Ptr< WifiMacQueueItem > >::const_iterator begin(void) const
Return a const iterator to the first MPDU.
const WifiMacHeader & GetHeader(std::size_t i) const
Get the header of the i-th MPDU.
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
std::vector< Ptr< WifiMacQueueItem > > m_mpduList
list of constituent MPDUs
void Print(std::ostream &os) const
Print the PSDU contents.
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)
WifiPsdu(Ptr< const Packet > p, const WifiMacHeader &header)
Create a PSDU storing an MPDU.
std::vector< Ptr< WifiMacQueueItem > >::const_iterator end(void) const
Return a const iterator to past-the-last MPDU.
uint32_t m_size
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 IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.
bool m_isSingle
true for an S-MPDU
Mac48Address GetAddr2(void) const
Get the Transmitter Address (TA), which is common to all the MPDUs.
void SetDuration(Time duration)
Set the Duration/ID field on all the MPDUs.
bool IsSingle(void) const
Return true if the PSDU is an S-MPDU.
Mac48Address GetAddr1(void) const
Get the Receiver Address (RA), which is common to all the 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...
Time GetTimeStamp(std::size_t i) const
Get the timestamp of the i-th MPDU.
std::set< uint8_t > GetTids(void) const
Get the set of TIDs of the QoS Data frames included in 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.
Ptr< const Packet > GetPacket(void) const
Get the PSDU as a single packet.
#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 octects of the IEEE 802.11 MAC FCS field.
void AddWifiMacTrailer(Ptr< Packet > packet)
Add FCS trailer to a packet.
const uint16_t SEQNO_SPACE_SIZE
Size of the space of sequence numbers.
std::ostream & operator<<(std::ostream &os, const Angles &a)