23 #include "ns3/packet.h"    52     .SetGroupName (
"Wifi")
   126   if (padding && !last)
   160         device->
GetMac ()->GetAttribute (
"BE_MaxAmpduSize", size);
   163         device->
GetMac ()->GetAttribute (
"BK_MaxAmpduSize", size);
   166         device->
GetMac ()->GetAttribute (
"VI_MaxAmpduSize", size);
   169         device->
GetMac ()->GetAttribute (
"VO_MaxAmpduSize", size);
   176   uint32_t maxAmpduSize = size.
Get ();
   178   if (maxAmpduSize == 0)
   180       NS_LOG_DEBUG (
"A-MPDU Aggregation is disabled on this station for AC " << ac);
   193       NS_ABORT_MSG_IF (!heCapabilities, 
"HE Capabilities element not received");
   195       maxAmpduSize = 
std::min (maxAmpduSize, heCapabilities->GetMaxAmpduLength ());
   199       NS_ABORT_MSG_IF (!vhtCapabilities, 
"VHT Capabilities element not received");
   201       maxAmpduSize = 
std::min (maxAmpduSize, vhtCapabilities->GetMaxAmpduLength ());
   205       NS_ABORT_MSG_IF (!htCapabilities, 
"HT Capabilities element not received");
   207       maxAmpduSize = 
std::min (maxAmpduSize, htCapabilities->GetMaxAmpduLength ());
   211       NS_LOG_DEBUG (
"A-MPDU aggregation is not available for non-HT PHYs");
   222   return (4 - (ampduSize % 4 )) % 4;
   233   uint32_t maxSize = aggregatedPacket->
GetSize ();
   234   uint16_t extractedLength;
   236   uint32_t deserialized = 0;
   238   while (deserialized < maxSize)
   242       extractedMpdu = aggregatedPacket->
CreateFragment (0, static_cast<uint32_t> (extractedLength));
   244       deserialized += extractedLength;
   246       padding = (4 - (extractedLength % 4 )) % 4;
   248       if (padding > 0 && deserialized < maxSize)
   251           deserialized += padding;
   255       set.push_back (packetHdr);
   257   NS_LOG_INFO (
"Deaggreated A-MPDU: extracted " << 
set.size () << 
" MPDUs");
   261 std::list<Ptr<const Packet>>
   265   std::list<Ptr<const Packet> > ampduSubframes;
   268   uint32_t maxSize = aggregatedPacket->
GetSize ();
   269   uint16_t bytesToExtract;
   271   uint32_t deserialized = 0;
   274   while (deserialized < maxSize)
   277       bytesToExtract = tempPacket->
PeekHeader (hdr);
   280       padding = (4 - (hdr.
GetLength () % 4 )) % 4;
   281       if (padding > 0 && (deserialized + bytesToExtract) < maxSize)
   283           bytesToExtract += padding;
   286       ampduSubframes.push_back (aggregatedPacket->
CreateFragment (deserialized , bytesToExtract));
   287       deserialized += bytesToExtract;
   289   NS_LOG_INFO (
"Peek A-MPDU subframes of A-MPDU: peeked " << ampduSubframes.size () << 
" A-MPDU subrames");
   290   return ampduSubframes;
   293 std::list<Ptr<const Packet>>
   298   std::list<Ptr<const Packet> > mpdus;
   300   for (
const auto& subframe : ampduSubframes)
   304   NS_LOG_INFO (
"Peek MPDUs of A-MPDU: peeked " << mpdus.size () << 
" MPDUs");
   313   uint32_t headerSize = ampduSubframe->
PeekHeader (hdr);
   317 std::vector<Ptr<WifiMacQueueItem>>
   319                               Time ppduDurationLimit)
 const   322   std::vector<Ptr<WifiMacQueueItem>> mpduList;
   323   Mac48Address recipient = mpdu->GetHeader ().GetAddr1 ();
   327   uint8_t tid = 
GetTid (mpdu->GetPacket (), mpdu->GetHeader ());
   334   if (maxAmpduSize == 0)
   341   if (edcaIt->second->GetBaAgreementEstablished (recipient, tid))
   344       uint16_t startingSequenceNumber = edcaIt->second->GetBaStartingSequence (recipient, tid);
   346       uint16_t maxMpdus = edcaIt->second->GetBaBufferSize (recipient, tid);
   347       uint32_t currentAmpduSize = 0;
   350       if (edcaIt->second->GetLow ()->IsWithinSizeAndTimeLimits (mpdu, txVector, 0, ppduDurationLimit))
   353           nextMpdu = 
Copy (mpdu);
   356       while (nextMpdu != 0)
   370           NS_LOG_DEBUG (
"Adding packet with sequence number " << nextMpdu->GetHeader ().GetSequenceNumber ()
   371                         << 
" to A-MPDU, packet size = " << nextMpdu->GetSize ()
   372                         << 
", A-MPDU size = " << currentAmpduSize);
   377           mpduList.push_back (nextMpdu);
   383           peekedMpdu = edcaIt->second->PeekNextFrame (tid, recipient);
   386               uint16_t currentSequenceNumber = peekedMpdu->GetHeader ().GetSequenceNumber ();
   388               if (
IsInWindow (currentSequenceNumber, startingSequenceNumber, maxMpdus))
   394                   nextMpdu = edcaIt->second->DequeuePeekedFrame (peekedMpdu, txVector, 
true,
   395                                                                  currentAmpduSize, ppduDurationLimit);
   399       if (mpduList.size () == 1)
 Aggregator used to construct A-MPDUs. 
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer. 
bool IsBroadcast(void) const
Simulation virtual time values and global simulation resolution. 
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 "...
#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...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload). 
void AddWifiMacTrailer(Ptr< Packet > packet)
Add FCS trailer to a packet. 
static Ptr< const Packet > PeekMpduInAmpduSubframe(Ptr< const Packet > ampduSubframe)
Peeks the MPDU contained in the A-MPDU subframe. 
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet. 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
static DeaggregatedMpdus Deaggregate(Ptr< Packet > aggregatedPacket)
Deaggregates an A-MPDU by removing the A-MPDU subframe header and padding. 
std::vector< Ptr< WifiMacQueueItem > > GetNextAmpdu(Ptr< const WifiMacQueueItem > mpdu, WifiTxVector txVector, Time ppduDurationLimit=Seconds(0)) const
Attempt to aggregate other MPDUs to the given MPDU, while meeting the following constraints: ...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO. 
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function. 
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 void AddHeaderAndPad(Ptr< Packet > mpdu, bool last, bool isSingleMpdu)
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet. 
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet. 
Ptr< WifiRemoteStationManager > GetRemoteStationManager(void) const
static std::list< Ptr< const Packet > > PeekMpdus(Ptr< const Packet > aggregatedPacket)
Peeks the MPDUs of the provided A-MPDU. 
Hold an unsigned integer type. 
virtual ~MpduAggregator()
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes. 
WifiMode GetMode(void) const
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer. 
Ptr< const HeCapabilities > GetStationHeCapabilities(Mac48Address from)
Return the HE capabilities sent by the remote station. 
WifiModulationClass GetModulationClass() const
Ptr< const HtCapabilities > GetStationHtCapabilities(Mac48Address from)
Return the HT capabilities sent by the remote station. 
static void Aggregate(Ptr< const WifiMacQueueItem > mpdu, Ptr< Packet > ampdu, bool isSingle)
Aggregate an MPDU to an A-MPDU. 
Ptr< MacLow > GetLow(void) const
Return the MacLow associated with this Txop. 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
static uint8_t CalculatePadding(uint32_t ampduSize)
bool IsInWindow(uint16_t seq, uint16_t winstart, uint16_t winsize)
uint8_t GetTid(Ptr< const Packet > packet, const WifiMacHeader hdr)
Extraction operator for TypeId. 
Ptr< WifiMac > GetMac(void) const
WifiModulationClass
This enumeration defines the modulation classes per (Table 9-4 "Modulation classes"; IEEE 802...
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message. 
uint32_t GetMaxAmpduSize(Mac48Address recipient, uint8_t tid, WifiModulationClass modulation) const
Determine the maximum size for an A-MPDU of the given TID that can be sent to the given receiver when...
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG. 
static TypeId GetTypeId(void)
Get the type ID. 
Ptr< const VhtCapabilities > GetStationVhtCapabilities(Mac48Address from)
Return the VHT capabilities sent by the remote station. 
std::list< std::pair< Ptr< Packet >, AmpduSubframeHeader > > DeaggregatedMpdus
A list of deaggregated packets and their A-MPDU subframe headers. 
std::map< AcIndex, Ptr< QosTxop > > EdcaQueues
EDCA queues typedef. 
static std::list< Ptr< const Packet > > PeekAmpduSubframes(Ptr< const Packet > aggregatedPacket)
Peeks the A-MPDU subframes of the provided A-MPDU. 
A base class which provides memory management and object aggregation. 
EdcaQueues m_edca
the map of EDCA queues 
a unique identifier for an interface. 
TypeId SetParent(TypeId tid)
Set the parent TypeId. 
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Ptr< T > Copy(Ptr< T > object)
Return a deep copy of a Ptr. 
void AddHeader(const Header &header)
Add header to this packet. 
void SetEdcaQueues(EdcaQueues edcaQueues)
Set the map of EDCA queues.