23 #include "ns3/packet.h" 49 .SetGroupName (
"Wifi")
111 Time ppduDurationLimit)
const 113 NS_LOG_FUNCTION (recipient << +tid << txVector << ampduSize << ppduDurationLimit);
123 WifiMacQueue::ConstIterator peekedIt = queue->PeekByTidAndAddress (tid, recipient);
125 if (peekedIt == queue->end ())
127 NS_LOG_DEBUG (
"No packet with the given TID and address in the queue");
143 if (maxAmsduSize == 0)
151 Time tstamp = (*peekedIt)->GetTimeStamp ();
154 WifiMacQueue::ConstIterator
first = peekedIt;
159 while (peekedIt != queue->end ())
165 if (newAmsduSize > maxAmsduSize)
167 NS_LOG_DEBUG (
"No other MSDU can be aggregated: maximum A-MSDU size reached");
174 recipient, tid, txVector, ampduSize, ppduDurationLimit))
181 Aggregate ((*peekedIt)->GetPacket (), amsdu,
182 qosTxop->MapSrcAddressForAggregation (header),
183 qosTxop->MapDestAddressForAggregation (header));
190 tstamp =
Max (tstamp, (*peekedIt)->GetTimeStamp ());
200 peekedIt = queue->Remove (peekedIt);
205 peekedIt = queue->PeekByTidAndAddress (tid, recipient, peekedIt);
210 NS_LOG_DEBUG (
"Aggregation failed (could not aggregate at least two MSDUs)");
215 queue->Remove (
first);
218 header.
SetAddr3 (qosTxop->GetLow ()->GetBssid ());
220 return Create<WifiMacQueueItem> (amsdu, header, tstamp);
226 return (4 - (amsduSize % 4 )) % 4;
248 device->
GetMac ()->GetAttribute (
"BE_MaxAmsduSize", size);
251 device->
GetMac ()->GetAttribute (
"BK_MaxAmsduSize", size);
254 device->
GetMac ()->GetAttribute (
"VI_MaxAmsduSize", size);
257 device->
GetMac ()->GetAttribute (
"VO_MaxAmsduSize", size);
264 uint16_t maxAmsduSize = size.
Get ();
266 if (maxAmsduSize == 0)
268 NS_LOG_DEBUG (
"A-MSDU Aggregation is disabled on this station for AC " << ac);
282 NS_LOG_DEBUG (
"A-MSDU Aggregation disabled because the recipient did not" 283 " send an HT Capabilities element");
294 NS_ABORT_MSG_IF (!vhtCapabilities,
"VHT Capabilities element not received");
296 maxAmsduSize =
std::min (maxAmsduSize, static_cast<uint16_t>(vhtCapabilities->GetMaxMpduLength () - 56));
304 maxAmsduSize =
std::min (maxAmsduSize, htCapabilities->GetMaxAmsduLength ());
311 maxAmsduSize =
std::min (maxAmsduSize, static_cast<uint16_t>(3839));
325 uint32_t maxSize = aggregatedPacket->
GetSize ();
326 uint16_t extractedLength;
328 uint32_t deserialized = 0;
330 while (deserialized < maxSize)
334 extractedMsdu = aggregatedPacket->
CreateFragment (0, static_cast<uint32_t> (extractedLength));
336 deserialized += extractedLength;
338 padding = (4 - ((extractedLength + 14) % 4 )) % 4;
340 if (padding > 0 && deserialized < maxSize)
343 deserialized += padding;
347 set.push_back (packetHdr);
349 NS_LOG_INFO (
"Deaggreated A-MSDU: extracted " <<
set.size () <<
" MSDUs");
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.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint16_t GetMaxAmsduSize(Mac48Address recipient, uint8_t tid, WifiModulationClass modulation) const
Determine the maximum size for an A-MSDU of the given TID that can be sent to the given receiver when...
#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).
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...
static const uint16_t WIFI_MAC_FCS_LENGTH
The length in octects of the IEEE 802.11 MAC FCS field.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
static DeaggregatedMsdus Deaggregate(Ptr< Packet > aggregatedPacket)
#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.
EdcaQueues m_edca
the map of EDCA queues
Ptr< WifiMacQueueItem > GetNextAmsdu(Mac48Address recipient, uint8_t tid, WifiTxVector txVector, uint32_t ampduSize=0, Time ppduDurationLimit=Seconds(0)) const
Dequeue MSDUs to be transmitted to a given station and belonging to a given TID from the correspondin...
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
void SetEdcaQueues(EdcaQueues map)
Set the map of EDCA queues.
Hold an unsigned integer type.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
WifiMode GetMode(void) const
static TypeId GetTypeId(void)
Get the type ID.
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...
void Aggregate(Ptr< const Packet > msdu, Ptr< Packet > amsdu, Mac48Address src, Mac48Address dest) const
Aggregate an MSDU to an A-MSDU.
WifiModulationClass GetModulationClass() const
Ptr< const HtCapabilities > GetStationHtCapabilities(Mac48Address from)
Return the HT capabilities sent by the remote station.
Ptr< MacLow > GetLow(void) const
Return the MacLow associated with this Txop.
std::list< std::pair< Ptr< Packet >, AmsduSubframeHeader > > DeaggregatedMsdus
DeaggregatedMsdus typedef.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
virtual ~MsduAggregator()
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.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< const VhtCapabilities > GetStationVhtCapabilities(Mac48Address from)
Return the VHT capabilities sent by the remote station.
static uint8_t CalculatePadding(uint16_t amsduSize)
Calculate how much padding must be added to the end of an A-MSDU of the given size if a new MSDU is a...
Aggregator used to construct A-MSDUs.
A base class which provides memory management and object aggregation.
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 ...
void AddHeader(const Header &header)
Add header to this packet.
std::map< AcIndex, Ptr< QosTxop > > EdcaQueues
EDCA queues typedef.