23 #include "ns3/packet.h" 52 .SetGroupName (
"Wifi")
131 device->
GetMac ()->GetAttribute (
"BE_MaxAmpduSize", size);
134 device->
GetMac ()->GetAttribute (
"BK_MaxAmpduSize", size);
137 device->
GetMac ()->GetAttribute (
"VI_MaxAmpduSize", size);
140 device->
GetMac ()->GetAttribute (
"VO_MaxAmpduSize", size);
147 uint32_t maxAmpduSize = size.
Get ();
149 if (maxAmpduSize == 0)
151 NS_LOG_DEBUG (
"A-MPDU Aggregation is disabled on this station for AC " << ac);
164 NS_ABORT_MSG_IF (!heCapabilities,
"HE Capabilities element not received");
166 maxAmpduSize =
std::min (maxAmpduSize, heCapabilities->GetMaxAmpduLength ());
170 NS_ABORT_MSG_IF (!vhtCapabilities,
"VHT Capabilities element not received");
172 maxAmpduSize =
std::min (maxAmpduSize, vhtCapabilities->GetMaxAmpduLength ());
176 NS_ABORT_MSG_IF (!htCapabilities,
"HT Capabilities element not received");
178 maxAmpduSize =
std::min (maxAmpduSize, htCapabilities->GetMaxAmpduLength ());
182 NS_LOG_DEBUG (
"A-MPDU aggregation is not available for non-HT PHYs");
193 return (4 - (ampduSize % 4 )) % 4;
208 std::vector<Ptr<WifiMacQueueItem>>
210 Time ppduDurationLimit)
const 213 std::vector<Ptr<WifiMacQueueItem>> mpduList;
214 Mac48Address recipient = mpdu->GetHeader ().GetAddr1 ();
218 uint8_t tid =
GetTid (mpdu->GetPacket (), mpdu->GetHeader ());
225 if (maxAmpduSize == 0)
232 if (edcaIt->second->GetBaAgreementEstablished (recipient, tid))
235 uint16_t startingSequenceNumber = edcaIt->second->GetBaStartingSequence (recipient, tid);
237 uint16_t maxMpdus = edcaIt->second->GetBaBufferSize (recipient, tid);
238 uint32_t currentAmpduSize = 0;
241 if (edcaIt->second->GetLow ()->IsWithinSizeAndTimeLimits (mpdu, txVector, 0, ppduDurationLimit))
244 nextMpdu =
Copy (mpdu);
247 while (nextMpdu != 0)
261 NS_LOG_DEBUG (
"Adding packet with sequence number " << nextMpdu->GetHeader ().GetSequenceNumber ()
262 <<
" to A-MPDU, packet size = " << nextMpdu->GetSize ()
263 <<
", A-MPDU size = " << currentAmpduSize);
268 mpduList.push_back (nextMpdu);
274 peekedMpdu = edcaIt->second->PeekNextFrame (tid, recipient);
277 uint16_t currentSequenceNumber = peekedMpdu->GetHeader ().GetSequenceNumber ();
279 if (
IsInWindow (currentSequenceNumber, startingSequenceNumber, maxMpdus))
285 nextMpdu = edcaIt->second->DequeuePeekedFrame (peekedMpdu, txVector,
true,
286 currentAmpduSize, ppduDurationLimit);
290 if (mpduList.size () == 1)
Aggregator used to construct A-MPDUs.
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.
#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 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...
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode...
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
Ptr< WifiRemoteStationManager > GetRemoteStationManager(void) const
Hold an unsigned integer type.
virtual ~MpduAggregator()
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
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.
std::vector< Ptr< WifiMacQueueItem > > GetNextAmpdu(Ptr< const WifiMacQueueItem > mpdu, WifiTxVector txVector, Time ppduDurationLimit=Time::Min()) const
Attempt to aggregate other MPDUs to the given MPDU, while meeting the following constraints: ...
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::map< AcIndex, Ptr< QosTxop > > EdcaQueues
EDCA queues typedef.
A base class which provides memory management and object aggregation.
EdcaQueues m_edca
the map of EDCA queues
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...
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.