wifi: Add a method to check whether packet is an A-MPDU
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "ht-configuration.h"
|
||||
#include "he-configuration.h"
|
||||
#include "wifi-mode.h"
|
||||
#include "ampdu-subframe-header.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -264,4 +265,41 @@ GetPpduMaxTime (WifiPreamble preamble)
|
||||
return duration;
|
||||
}
|
||||
|
||||
bool
|
||||
IsAmpdu (Ptr<const Packet> packet)
|
||||
{
|
||||
AmpduSubframeHeader hdr;
|
||||
//Rely on metadata if present
|
||||
bool metadataEnabled = false;
|
||||
PacketMetadata::ItemIterator metadataIterator = packet->BeginItem ();
|
||||
while (metadataIterator.HasNext ())
|
||||
{
|
||||
metadataEnabled = true;
|
||||
PacketMetadata::Item item = metadataIterator.Next ();
|
||||
if (item.tid == hdr.GetTypeId ())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (metadataEnabled)
|
||||
{
|
||||
//Didn't find header in metadata
|
||||
return false;
|
||||
}
|
||||
|
||||
//No metadata so peek manually into buffer and check consistency of extracted data
|
||||
uint32_t totalSize = packet->GetSize ();
|
||||
uint32_t deserialized = packet->PeekHeader (hdr);
|
||||
if (deserialized == hdr.GetSerializedSize ()
|
||||
&& hdr.IsSignatureValid ()
|
||||
&& hdr.GetLength () <= (totalSize - deserialized))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace ns3
|
||||
|
||||
@@ -175,6 +175,13 @@ void AddWifiMacTrailer (Ptr<Packet> packet);
|
||||
* \return the total packet size
|
||||
*/
|
||||
uint32_t GetSize (Ptr<const Packet> packet, const WifiMacHeader *hdr, bool isAmpdu);
|
||||
/**
|
||||
* \param packet the packet to check
|
||||
* \returns true if packet is an A-MPDU
|
||||
*
|
||||
* This method checks if the packet is an A-MPDU by looking for A-MPDU subframe headers.
|
||||
*/
|
||||
bool IsAmpdu (Ptr<const Packet> packet);
|
||||
|
||||
/**
|
||||
* Get the maximum PPDU duration (see Section 10.14 of 802.11-2016) for
|
||||
|
||||
Reference in New Issue
Block a user