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

#include <RecipientBlockAckAgreementHandler.h>

Inheritance diagram for inet::ieee80211::RecipientBlockAckAgreementHandler:
inet::ieee80211::IRecipientBlockAckAgreementHandler

Public Member Functions

virtual ~RecipientBlockAckAgreementHandler ()
 
virtual void processTransmittedAddbaResp (Ieee80211AddbaResponse *addbaResp, IBlockAckAgreementHandlerCallback *callback) override
 
virtual void processReceivedAddbaRequest (Ieee80211AddbaRequest *addbaRequest, IRecipientBlockAckAgreementPolicy *blockAckAgreementPolicy, IProcedureCallback *callback) override
 
virtual void processReceivedDelba (Ieee80211Delba *delba, IRecipientBlockAckAgreementPolicy *blockAckAgreementPolicy) override
 
virtual void qosFrameReceived (Ieee80211DataFrame *qosFrame, IBlockAckAgreementHandlerCallback *callback) override
 
virtual void processTransmittedDelba (Ieee80211Delba *delba) override
 
virtual void blockAckAgreementExpired (IProcedureCallback *procedureCallback, IBlockAckAgreementHandlerCallback *agreementHandlerCallback) override
 
virtual RecipientBlockAckAgreementgetAgreement (Tid tid, MACAddress originatorAddr) override
 
- Public Member Functions inherited from inet::ieee80211::IRecipientBlockAckAgreementHandler
virtual ~IRecipientBlockAckAgreementHandler ()
 

Protected Member Functions

virtual void terminateAgreement (MACAddress originatorAddr, Tid tid)
 
virtual RecipientBlockAckAgreementaddAgreement (Ieee80211AddbaRequest *addbaReq)
 
virtual void updateAgreement (Ieee80211AddbaResponse *frame)
 
virtual Ieee80211AddbaResponsebuildAddbaResponse (Ieee80211AddbaRequest *frame, IRecipientBlockAckAgreementPolicy *blockAckAgreementPolicy)
 
virtual Ieee80211DelbabuildDelba (MACAddress receiverAddr, Tid tid, int reasonCode)
 
virtual simtime_t computeEarliestExpirationTime ()
 
virtual void scheduleInactivityTimer (IBlockAckAgreementHandlerCallback *callback)
 

Protected Attributes

std::map< std::pair< MACAddress, Tid >, RecipientBlockAckAgreement * > blockAckAgreements
 

Constructor & Destructor Documentation

inet::ieee80211::RecipientBlockAckAgreementHandler::~RecipientBlockAckAgreementHandler ( )
virtual
186 {
187  for (auto it : blockAckAgreements)
188  delete it.second;
189 }
std::map< std::pair< MACAddress, Tid >, RecipientBlockAckAgreement * > blockAckAgreements
Definition: RecipientBlockAckAgreementHandler.h:38

Member Function Documentation

RecipientBlockAckAgreement * inet::ieee80211::RecipientBlockAckAgreementHandler::addAgreement ( Ieee80211AddbaRequest addbaReq)
protectedvirtual

Referenced by processReceivedAddbaRequest().

82 {
83  MACAddress originatorAddr = addbaReq->getTransmitterAddress();
84  auto id = std::make_pair(originatorAddr, addbaReq->getTid());
85  auto it = blockAckAgreements.find(id);
86  if (it == blockAckAgreements.end()) {
87  RecipientBlockAckAgreement *agreement = new RecipientBlockAckAgreement(originatorAddr, addbaReq->getTid(), addbaReq->getStartingSequenceNumber(), addbaReq->getBufferSize(), addbaReq->getBlockAckTimeoutValue());
88  blockAckAgreements[id] = agreement;
89  EV_DETAIL << "Block Ack Agreement is added with the following parameters: " << *agreement << endl;
90  return agreement;
91  }
92  else
93  throw cRuntimeError("TODO"); // TODO: update?
94 }
uint16_t id
Definition: TCP_NSC.cc:85
std::map< std::pair< MACAddress, Tid >, RecipientBlockAckAgreement * > blockAckAgreements
Definition: RecipientBlockAckAgreementHandler.h:38
void inet::ieee80211::RecipientBlockAckAgreementHandler::blockAckAgreementExpired ( IProcedureCallback procedureCallback,
IBlockAckAgreementHandlerCallback agreementHandlerCallback 
)
overridevirtual

Implements inet::ieee80211::IRecipientBlockAckAgreementHandler.

57 {
58  // When a timeout of BlockAckTimeout is detected, the STA shall send a DELBA frame to the
59  // peer STA with the Reason Code field set to TIMEOUT and shall issue a MLME-DELBA.indication
60  // primitive with the ReasonCode parameter having a value of TIMEOUT.
61  // The procedure is illustrated in Figure 10-14.
62  simtime_t now = simTime();
63  for (auto id : blockAckAgreements) {
64  auto agreement = id.second;
65  if (agreement->getExpirationTime() == now) {
66  MACAddress receiverAddr = id.first.first;
67  Tid tid = id.first.second;
68  procedureCallback->processMgmtFrame(buildDelba(receiverAddr, tid, 39)); // 39 - TIMEOUT see: Table 8-36—Reason codes
69  }
70  }
71  scheduleInactivityTimer(agreementHandlerCallback);
72 }
int8_t Tid
Definition: Ieee80211Defs.h:28
std::map< std::pair< MACAddress, Tid >, RecipientBlockAckAgreement * > blockAckAgreements
Definition: RecipientBlockAckAgreementHandler.h:38
virtual void scheduleInactivityTimer(IBlockAckAgreementHandlerCallback *callback)
Definition: RecipientBlockAckAgreementHandler.cc:34
virtual Ieee80211Delba * buildDelba(MACAddress receiverAddr, Tid tid, int reasonCode)
Definition: RecipientBlockAckAgreementHandler.cc:101
Ieee80211AddbaResponse * inet::ieee80211::RecipientBlockAckAgreementHandler::buildAddbaResponse ( Ieee80211AddbaRequest frame,
IRecipientBlockAckAgreementPolicy blockAckAgreementPolicy 
)
protectedvirtual

Referenced by processReceivedAddbaRequest().

112 {
113  Ieee80211AddbaResponse *addbaResponse = new Ieee80211AddbaResponse("AddbaResponse");
114  addbaResponse->setReceiverAddress(frame->getTransmitterAddress());
115  // The Block Ack Policy subfield is set to 1 for immediate Block Ack and 0 for delayed Block Ack.
116  Tid tid = frame->getTid();
117  addbaResponse->setTid(tid);
118  addbaResponse->setBlockAckPolicy(!frame->getBlockAckPolicy() && blockAckAgreementPolicy->delayedBlockAckPolicySupported() ? false : true);
119  addbaResponse->setBufferSize(frame->getBufferSize() <= blockAckAgreementPolicy->getMaximumAllowedBufferSize() ? frame->getBufferSize() : blockAckAgreementPolicy->getMaximumAllowedBufferSize());
120  addbaResponse->setBlockAckTimeoutValue(blockAckAgreementPolicy->getBlockAckTimeoutValue() == 0 ? blockAckAgreementPolicy->getBlockAckTimeoutValue() : frame->getBlockAckTimeoutValue());
121  addbaResponse->setAMsduSupported(blockAckAgreementPolicy->aMsduSupported());
122  return addbaResponse;
123 }
int8_t Tid
Definition: Ieee80211Defs.h:28
Ieee80211Delba * inet::ieee80211::RecipientBlockAckAgreementHandler::buildDelba ( MACAddress  receiverAddr,
Tid  tid,
int  reasonCode 
)
protectedvirtual

Referenced by blockAckAgreementExpired().

102 {
103  Ieee80211Delba *delba = new Ieee80211Delba("Delba");
104  delba->setReceiverAddress(receiverAddr);
105  delba->setInitiator(false);
106  delba->setTid(tid);
107  delba->setReasonCode(reasonCode);
108  return delba;
109 }
simtime_t inet::ieee80211::RecipientBlockAckAgreementHandler::computeEarliestExpirationTime ( )
protectedvirtual

Referenced by scheduleInactivityTimer().

25 {
26  simtime_t earliestTime = SIMTIME_MAX;
27  for (auto id : blockAckAgreements) {
28  auto agreement = id.second;
29  earliestTime = std::min(earliestTime, agreement->getExpirationTime());
30  }
31  return earliestTime;
32 }
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
std::map< std::pair< MACAddress, Tid >, RecipientBlockAckAgreement * > blockAckAgreements
Definition: RecipientBlockAckAgreementHandler.h:38
RecipientBlockAckAgreement * inet::ieee80211::RecipientBlockAckAgreementHandler::getAgreement ( Tid  tid,
MACAddress  originatorAddr 
)
overridevirtual

Implements inet::ieee80211::IRecipientBlockAckAgreementHandler.

Referenced by qosFrameReceived().

149 {
150  auto agreementId = std::make_pair(originatorAddr, tid);
151  auto it = blockAckAgreements.find(agreementId);
152  return it != blockAckAgreements.end() ? it->second : nullptr;
153 }
std::map< std::pair< MACAddress, Tid >, RecipientBlockAckAgreement * > blockAckAgreements
Definition: RecipientBlockAckAgreementHandler.h:38
void inet::ieee80211::RecipientBlockAckAgreementHandler::processReceivedAddbaRequest ( Ieee80211AddbaRequest addbaRequest,
IRecipientBlockAckAgreementPolicy blockAckAgreementPolicy,
IProcedureCallback callback 
)
overridevirtual

Implements inet::ieee80211::IRecipientBlockAckAgreementHandler.

162 {
163  EV_INFO << "Processing Addba Request from " << addbaRequest->getTransmitterAddress() << endl;
164  if (blockAckAgreementPolicy->isAddbaReqAccepted(addbaRequest)) {
165  EV_DETAIL << "Addba Request has been accepted. Creating a new Block Ack Agreement." << endl;
166  auto agreement = addAgreement(addbaRequest);
167  EV_DETAIL << "Agreement is added with the following parameters: " << *agreement << endl;
168  EV_DETAIL << "Building Addba Response" << endl;
169  auto addbaResponse = buildAddbaResponse(addbaRequest, blockAckAgreementPolicy);
170  callback->processMgmtFrame(addbaResponse);
171  }
172 }
virtual RecipientBlockAckAgreement * addAgreement(Ieee80211AddbaRequest *addbaReq)
Definition: RecipientBlockAckAgreementHandler.cc:81
virtual Ieee80211AddbaResponse * buildAddbaResponse(Ieee80211AddbaRequest *frame, IRecipientBlockAckAgreementPolicy *blockAckAgreementPolicy)
Definition: RecipientBlockAckAgreementHandler.cc:111
void inet::ieee80211::RecipientBlockAckAgreementHandler::processReceivedDelba ( Ieee80211Delba delba,
IRecipientBlockAckAgreementPolicy blockAckAgreementPolicy 
)
overridevirtual

Implements inet::ieee80211::IRecipientBlockAckAgreementHandler.

180 {
181  if (blockAckAgreementPolicy->isDelbaAccepted(delba))
182  terminateAgreement(delba->getReceiverAddress(), delba->getTid());
183 }
virtual void terminateAgreement(MACAddress originatorAddr, Tid tid)
Definition: RecipientBlockAckAgreementHandler.cc:137
void inet::ieee80211::RecipientBlockAckAgreementHandler::processTransmittedAddbaResp ( Ieee80211AddbaResponse addbaResp,
IBlockAckAgreementHandlerCallback callback 
)
overridevirtual

Implements inet::ieee80211::IRecipientBlockAckAgreementHandler.

156 {
157  updateAgreement(addbaResp);
158  scheduleInactivityTimer(callback);
159 }
virtual void scheduleInactivityTimer(IBlockAckAgreementHandlerCallback *callback)
Definition: RecipientBlockAckAgreementHandler.cc:34
virtual void updateAgreement(Ieee80211AddbaResponse *frame)
Definition: RecipientBlockAckAgreementHandler.cc:125
void inet::ieee80211::RecipientBlockAckAgreementHandler::processTransmittedDelba ( Ieee80211Delba delba)
overridevirtual

Implements inet::ieee80211::IRecipientBlockAckAgreementHandler.

175 {
176  terminateAgreement(delba->getReceiverAddress(), delba->getTid());
177 }
virtual void terminateAgreement(MACAddress originatorAddr, Tid tid)
Definition: RecipientBlockAckAgreementHandler.cc:137
void inet::ieee80211::RecipientBlockAckAgreementHandler::qosFrameReceived ( Ieee80211DataFrame qosFrame,
IBlockAckAgreementHandlerCallback callback 
)
overridevirtual

Implements inet::ieee80211::IRecipientBlockAckAgreementHandler.

46 {
47  if (qosFrame->getAckPolicy() == AckPolicy::BLOCK_ACK) { // TODO: + Implicit Block Ack
48  Tid tid = qosFrame->getTid();
49  MACAddress originatorAddr = qosFrame->getTransmitterAddress();
50  auto agreement = getAgreement(tid, originatorAddr);
51  if (agreement)
52  scheduleInactivityTimer(callback);
53  }
54 }
int8_t Tid
Definition: Ieee80211Defs.h:28
Definition: Ieee80211Frame_m.h:142
virtual RecipientBlockAckAgreement * getAgreement(Tid tid, MACAddress originatorAddr) override
Definition: RecipientBlockAckAgreementHandler.cc:148
virtual void scheduleInactivityTimer(IBlockAckAgreementHandlerCallback *callback)
Definition: RecipientBlockAckAgreementHandler.cc:34
void inet::ieee80211::RecipientBlockAckAgreementHandler::scheduleInactivityTimer ( IBlockAckAgreementHandlerCallback callback)
protectedvirtual

Referenced by blockAckAgreementExpired(), processTransmittedAddbaResp(), and qosFrameReceived().

35 {
36  simtime_t earliestExpirationTime = computeEarliestExpirationTime();
37  if (earliestExpirationTime != SIMTIME_MAX)
38  callback->scheduleInactivityTimer(earliestExpirationTime);
39 }
virtual simtime_t computeEarliestExpirationTime()
Definition: RecipientBlockAckAgreementHandler.cc:24
void inet::ieee80211::RecipientBlockAckAgreementHandler::terminateAgreement ( MACAddress  originatorAddr,
Tid  tid 
)
protectedvirtual

Referenced by processReceivedDelba(), and processTransmittedDelba().

138 {
139  auto agreementId = std::make_pair(originatorAddr, tid);
140  auto it = blockAckAgreements.find(agreementId);
141  if (it != blockAckAgreements.end()) {
142  RecipientBlockAckAgreement *agreement = it->second;
143  blockAckAgreements.erase(it);
144  delete agreement;
145  }
146 }
std::map< std::pair< MACAddress, Tid >, RecipientBlockAckAgreement * > blockAckAgreements
Definition: RecipientBlockAckAgreementHandler.h:38
void inet::ieee80211::RecipientBlockAckAgreementHandler::updateAgreement ( Ieee80211AddbaResponse frame)
protectedvirtual

Referenced by processTransmittedAddbaResp().

126 {
127  auto id = std::make_pair(frame->getReceiverAddress(), frame->getTid());
128  auto it = blockAckAgreements.find(id);
129  if (it != blockAckAgreements.end()) {
130  RecipientBlockAckAgreement *agreement = it->second;
131  agreement->addbaResposneSent();
132  }
133  else
134  throw cRuntimeError("Agreement is not found");
135 }
std::map< std::pair< MACAddress, Tid >, RecipientBlockAckAgreement * > blockAckAgreements
Definition: RecipientBlockAckAgreementHandler.h:38

Member Data Documentation

std::map<std::pair<MACAddress, Tid>, RecipientBlockAckAgreement *> inet::ieee80211::RecipientBlockAckAgreementHandler::blockAckAgreements
protected

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