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

#include <BasicFragmentationPolicy.h>

Inheritance diagram for inet::ieee80211::BasicFragmentationPolicy:
inet::ieee80211::IFragmentationPolicy

Public Member Functions

virtual std::vector< int > computeFragmentSizes (Ieee80211DataOrMgmtFrame *frame) override
 
- Public Member Functions inherited from inet::ieee80211::IFragmentationPolicy
virtual ~IFragmentationPolicy ()
 

Protected Member Functions

virtual void initialize () override
 

Protected Attributes

int fragmentationThreshold = -1
 

Member Function Documentation

std::vector< int > inet::ieee80211::BasicFragmentationPolicy::computeFragmentSizes ( Ieee80211DataOrMgmtFrame frame)
overridevirtual

Implements inet::ieee80211::IFragmentationPolicy.

32 {
33  if (fragmentationThreshold < frame->getByteLength()) {
34  std::vector<int> sizes;
35  int payloadLength = 0;
36  int headerLength = 0;
37  // Mgmt frames don't have payload
38  if (dynamic_cast<Ieee80211DataFrame*>(frame)) {
39  cPacket *payload = frame->decapsulate();
40  payloadLength = payload->getByteLength();
41  headerLength = frame->getByteLength();
42  frame->encapsulate(payload); // restore original state
43  }
44  else
45  headerLength = frame->getByteLength();
46  int maxFragmentPayload = fragmentationThreshold - headerLength;
47  if (payloadLength >= maxFragmentPayload * MAX_NUM_FRAGMENTS)
48  throw cRuntimeError("Fragmentation: frame \"%s\" too large, won't fit into %d fragments", frame->getName(), MAX_NUM_FRAGMENTS);
49  for(int i = 0; headerLength + payloadLength > fragmentationThreshold; i++) {
50  sizes.push_back(fragmentationThreshold);
51  payloadLength -= maxFragmentPayload;
52  }
53  sizes.push_back(headerLength + payloadLength);
54  return sizes;
55  }
56  return std::vector<int>();
57 }
const short int MAX_NUM_FRAGMENTS
Definition: Ieee80211Frame_m.h:50
int fragmentationThreshold
Definition: BasicFragmentationPolicy.h:29
void inet::ieee80211::BasicFragmentationPolicy::initialize ( )
overrideprotectedvirtual
27 {
28  fragmentationThreshold = par("fragmentationThreshold");
29 }
int fragmentationThreshold
Definition: BasicFragmentationPolicy.h:29

Member Data Documentation

int inet::ieee80211::BasicFragmentationPolicy::fragmentationThreshold = -1
protected

Referenced by computeFragmentSizes(), and initialize().


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