INET Framework for OMNeT++/OMNEST
inet::ieee80211::BasicMsduAggregationPolicy Class Reference

#include <BasicMsduAggregationPolicy.h>

Inheritance diagram for inet::ieee80211::BasicMsduAggregationPolicy:
inet::ieee80211::IMsduAggregationPolicy

Public Member Functions

virtual std::vector< Packet * > * computeAggregateFrames (queueing::IPacketQueue *queue) override
 
- Public Member Functions inherited from inet::ieee80211::IMsduAggregationPolicy
virtual ~IMsduAggregationPolicy ()
 

Protected Member Functions

virtual void initialize () override
 
virtual bool isAggregationPossible (int numOfFramesToAggragate, int aMsduLength)
 
virtual bool isEligible (Packet *packet, const Ptr< const Ieee80211DataHeader > &header, const Ptr< const Ieee80211MacTrailer > &trailer, const Ptr< const Ieee80211DataHeader > &testHeader, b aMsduLength)
 

Protected Attributes

bool qOsCheck = false
 
int subframeNumThreshold = -1
 
int aggregationLengthThreshold = -1
 
b maxAMsduSize = b(-1)
 

Member Function Documentation

◆ computeAggregateFrames()

std::vector< Packet * > * inet::ieee80211::BasicMsduAggregationPolicy::computeAggregateFrames ( queueing::IPacketQueue queue)
overridevirtual

Implements inet::ieee80211::IMsduAggregationPolicy.

60 {
61  Enter_Method("computeAggregateFrames");
62  ASSERT(!queue->isEmpty());
63  b aMsduLength = b(0);
64  Ptr<const Ieee80211DataHeader> firstHeader = nullptr;
65  auto frames = new std::vector<Packet *>();
66  for (int i = 0; i < queue->getNumPackets(); i++) {
67  auto dataPacket = queue->getPacket(i);
68  const auto& dataHeader = dynamicPtrCast<const Ieee80211DataHeader>(dataPacket->peekAtFront<Ieee80211DataOrMgmtHeader>());
69  if (dataHeader == nullptr)
70  break;
71  if (firstHeader == nullptr)
72  firstHeader = dataHeader;
73  const auto& dataTrailer = dataPacket->peekAtBack<Ieee80211MacTrailer>(B(4));
74  if (!isEligible(dataPacket, staticPtrCast<const Ieee80211DataHeader>(dataHeader), dataTrailer, firstHeader, aMsduLength)) {
75  EV_TRACE << "Queued " << *dataPacket << " is not eligible for A-MSDU aggregation.\n";
76  break;
77  }
78  EV_TRACE << "Queued " << *dataPacket << " is eligible for A-MSDU aggregation.\n";
79  frames->push_back(dataPacket);
80  aMsduLength += dataPacket->getTotalLength() - dataHeader->getChunkLength() - dataTrailer->getChunkLength() + b(LENGTH_A_MSDU_SUBFRAME_HEADER); // sum of MSDU lengths + subframe header
81  }
82  if (frames->size() <= 1 || !isAggregationPossible(frames->size(), B(aMsduLength).get())) {
83  EV_DEBUG << "A-MSDU aggregation is not possible, collected " << frames->size() << " packets.\n";
84  delete frames;
85  return nullptr;
86  }
87  else {
88  EV_DEBUG << "A-MSDU aggregation is possible, collected " << frames->size() << " packets.\n";
89  return frames;
90  }
91 }

◆ initialize()

void inet::ieee80211::BasicMsduAggregationPolicy::initialize ( )
overrideprotectedvirtual
16 {
17  subframeNumThreshold = par("subframeNumThreshold");
18  aggregationLengthThreshold = par("aggregationLengthThreshold");
19  maxAMsduSize = B(par("maxAMsduSize"));
20  qOsCheck = par("qOsCheck");
21 }

◆ isAggregationPossible()

bool inet::ieee80211::BasicMsduAggregationPolicy::isAggregationPossible ( int  numOfFramesToAggragate,
int  aMsduLength 
)
protectedvirtual
24 {
25  return (subframeNumThreshold == -1 || subframeNumThreshold <= numOfFramesToAggragate) &&
27 }

Referenced by computeAggregateFrames().

◆ isEligible()

bool inet::ieee80211::BasicMsduAggregationPolicy::isEligible ( Packet packet,
const Ptr< const Ieee80211DataHeader > &  header,
const Ptr< const Ieee80211MacTrailer > &  trailer,
const Ptr< const Ieee80211DataHeader > &  testHeader,
b  aMsduLength 
)
protectedvirtual
30 {
31  // Only QoS data frames have a TID.
32  if (qOsCheck && header->getType() != ST_DATA_WITH_QOS)
33  return false;
34 
35  // The maximum MPDU length that can be transported using A-MPDU aggregation is 4095 octets. An
36  // A-MSDU cannot be fragmented. Therefore, an A-MSDU of a length that exceeds 4065 octets (
37  // 4095 minus the QoS data MPDU overhead) cannot be transported in an A-MPDU.
38  if (aMsduLength + packet->getTotalLength() - header->getChunkLength() - trailer->getChunkLength() + b(LENGTH_A_MSDU_SUBFRAME_HEADER) > maxAMsduSize) // default value of maxAMsduSize is 4065
39  return false;
40 
41  // The value of TID present in the QoS Control field of the MPDU carrying the A-MSDU indicates the TID for
42  // all MSDUs in the A-MSDU. Because this value of TID is common to all MSDUs in the A-MSDU, only MSDUs
43  // delivered to the MAC by an MA-UNITDATA.request primitive with an integer priority parameter that maps
44  // to the same TID can be aggregated together using A-MSDU.
45  if (testHeader->getTid() != header->getTid())
46  return false;
47 
48  // An A-MSDU contains only MSDUs whose DA and SA parameter values map to the same receiver address
49  // (RA) and transmitter address (TA) values, i.e., all the MSDUs are intended to be received by a single
50  // receiver, and necessarily they are all transmitted by the same transmitter. The rules for determining RA and
51  // TA are independent of whether the frame body carries an A-MSDU.
52  if (testHeader->getReceiverAddress() != header->getReceiverAddress() ||
53  testHeader->getTransmitterAddress() != header->getTransmitterAddress())
54  return false;
55 
56  return true;
57 }

Referenced by computeAggregateFrames().

Member Data Documentation

◆ aggregationLengthThreshold

int inet::ieee80211::BasicMsduAggregationPolicy::aggregationLengthThreshold = -1
protected

◆ maxAMsduSize

b inet::ieee80211::BasicMsduAggregationPolicy::maxAMsduSize = b(-1)
protected

Referenced by initialize(), and isEligible().

◆ qOsCheck

bool inet::ieee80211::BasicMsduAggregationPolicy::qOsCheck = false
protected

Referenced by initialize(), and isEligible().

◆ subframeNumThreshold

int inet::ieee80211::BasicMsduAggregationPolicy::subframeNumThreshold = -1
protected

The documentation for this class was generated from the following files:
inet::ieee80211::BasicMsduAggregationPolicy::maxAMsduSize
b maxAMsduSize
Definition: BasicMsduAggregationPolicy.h:22
inet::ieee80211::BasicMsduAggregationPolicy::isEligible
virtual bool isEligible(Packet *packet, const Ptr< const Ieee80211DataHeader > &header, const Ptr< const Ieee80211MacTrailer > &trailer, const Ptr< const Ieee80211DataHeader > &testHeader, b aMsduLength)
Definition: BasicMsduAggregationPolicy.cc:29
inet::ieee80211::BasicMsduAggregationPolicy::subframeNumThreshold
int subframeNumThreshold
Definition: BasicMsduAggregationPolicy.h:20
inet::ieee80211::LENGTH_A_MSDU_SUBFRAME_HEADER
const b LENGTH_A_MSDU_SUBFRAME_HEADER
Definition: Ieee80211Frame_m.h:103
inet::ieee80211::BasicMsduAggregationPolicy::qOsCheck
bool qOsCheck
Definition: BasicMsduAggregationPolicy.h:19
inet::units::units::B
intscale< b, 1, 8 > B
Definition: Units.h:1168
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::ieee80211::ST_DATA_WITH_QOS
@ ST_DATA_WITH_QOS
Definition: Ieee80211Frame_m.h:169
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::ieee80211::BasicMsduAggregationPolicy::isAggregationPossible
virtual bool isAggregationPossible(int numOfFramesToAggragate, int aMsduLength)
Definition: BasicMsduAggregationPolicy.cc:23
inet::ieee80211::BasicMsduAggregationPolicy::aggregationLengthThreshold
int aggregationLengthThreshold
Definition: BasicMsduAggregationPolicy.h:21