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

#include <MsduAggregation.h>

Inheritance diagram for inet::ieee80211::MsduAggregation:
inet::ieee80211::IMsduAggregation

Public Member Functions

virtual Ieee80211DataFrameaggregateFrames (std::vector< Ieee80211DataFrame * > *frames) override
 
- Public Member Functions inherited from inet::ieee80211::IMsduAggregation
virtual ~IMsduAggregation ()
 

Protected Member Functions

virtual void setSubframeAddress (Ieee80211MsduSubframe *subframe, Ieee80211DataFrame *frame)
 

Member Function Documentation

Ieee80211DataFrame * inet::ieee80211::MsduAggregation::aggregateFrames ( std::vector< Ieee80211DataFrame * > *  frames)
overridevirtual

Implements inet::ieee80211::IMsduAggregation.

57 {
58  auto firstFrame = frames->at(0);
59  auto tid = firstFrame->getTid();
60  auto toDS = firstFrame->getToDS();
61  auto fromDS = firstFrame->getFromDS();
62  auto ra = firstFrame->getReceiverAddress();
63  auto ta = firstFrame->getTransmitterAddress();
64  auto aMsdu = new Ieee80211AMsdu();
65  auto aMsduLength = 0;
66  aMsdu->setSubframesArraySize(frames->size());
67  for (int i = 0; i < (int)frames->size(); i++)
68  {
69  Ieee80211MsduSubframe msduSubframe;
70  auto dataFrame = frames->at(i);
71  ASSERT(dataFrame->getType() == ST_DATA_WITH_QOS);
72  auto msdu = dataFrame->decapsulate();
73  if (auto dataFrameWithSnap = dynamic_cast<Ieee80211DataFrameWithSNAP*>(dataFrame)) {
74  aMsduLength += msdu->getByteLength() + LENGTH_A_MSDU_SUBFRAME_HEADER / 8 + SNAP_HEADER_BYTES; // sum of MSDU lengths + subframe header + snap header
75  msduSubframe.addByteLength(SNAP_HEADER_BYTES); // TODO: review, see Ieee80211MsduSubframe
76  msduSubframe.setEtherType(dataFrameWithSnap->getEtherType()); // TODO: review, see Ieee80211MsduSubframe
77  }
78  else {
79  aMsduLength += msdu->getByteLength() + LENGTH_A_MSDU_SUBFRAME_HEADER / 8; // sum of MSDU lengths + subframe header
80  msduSubframe.setEtherType(-1); // TODO: review, see Ieee80211MsduSubframe
81  }
82  setSubframeAddress(&msduSubframe, dataFrame);
83  msduSubframe.encapsulate(msdu);
84  aMsdu->setSubframes(i, msduSubframe);
85  aMsdu->getSubframes(i).setName(dataFrame->getName());
86  delete dataFrame;
87  }
88  aMsdu->setByteLength(aMsduLength);
89 // The MPDU containing the A-MSDU is carried in any of the following data frame subtypes: QoS Data,
90 // QoS Data + CF-Ack, QoS Data + CF-Poll, QoS Data + CF-Ack + CF-Poll. The A-MSDU structure is
91 // contained in the frame body of a single MPDU.
92  auto aggregatedDataFrame = new Ieee80211DataFrame("A-MSDU");
93  aggregatedDataFrame->setType(ST_DATA_WITH_QOS);
94  aggregatedDataFrame->setToDS(toDS);
95  aggregatedDataFrame->setFromDS(fromDS);
96  aggregatedDataFrame->setAMsduPresent(true);
97  aggregatedDataFrame->setTransmitterAddress(ta);
98  aggregatedDataFrame->setReceiverAddress(ra);
99  aggregatedDataFrame->setTid(tid);
100  aggregatedDataFrame->encapsulate(aMsdu);
101  // TODO: set addr3 and addr4 according to fromDS and toDS.
102  return aggregatedDataFrame;
103 }
Definition: Ieee80211Frame_m.h:117
virtual void setSubframeAddress(Ieee80211MsduSubframe *subframe, Ieee80211DataFrame *frame)
Definition: MsduAggregation.cc:25
const unsigned int LENGTH_A_MSDU_SUBFRAME_HEADER
Definition: Ieee80211Frame_m.h:51
const unsigned int SNAP_HEADER_BYTES
Definition: Ieee80211Frame_m.h:49
void inet::ieee80211::MsduAggregation::setSubframeAddress ( Ieee80211MsduSubframe subframe,
Ieee80211DataFrame frame 
)
protectedvirtual

Referenced by aggregateFrames().

26 {
27  // Note: Addr1 (RA), Addr2 (TA)
28  // Table 8-19—Address field contents
29  MACAddress da, sa;
30  bool toDS = frame->getToDS();
31  bool fromDS = frame->getFromDS();
32  if (toDS == 0 && fromDS == 0) // STA to STA
33  {
34  da = frame->getReceiverAddress();
35  sa = frame->getTransmitterAddress();
36  }
37  else if (toDS == 0 && fromDS == 1) // AP to STA
38  {
39  da = frame->getReceiverAddress();
40  sa = frame->getAddress3();
41  }
42  else if (toDS == 1 && fromDS == 0) // STA to AP
43  {
44  da = frame->getAddress3();
45  sa = frame->getTransmitterAddress();
46  }
47  else if (toDS == 1 && fromDS == 1) // AP to AP
48  {
49  da = frame->getAddress3();
50  sa = frame->getAddress4();
51  }
52  subframe->setDa(da);
53  subframe->setSa(sa);
54 }

The documentation for this class was generated from the following files: