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

#include <QoSAckHandler.h>

Inheritance diagram for inet::ieee80211::QoSAckHandler:
inet::ieee80211::IAckHandler

Public Types

enum  Status {
  Status::FRAME_NOT_YET_TRANSMITTED, Status::NO_ACK_REQUIRED, Status::BLOCK_ACK_NOT_YET_REQUESTED, Status::WAITING_FOR_NORMAL_ACK,
  Status::WAITING_FOR_BLOCK_ACK, Status::NORMAL_ACK_NOT_ARRIVED, Status::NORMAL_ACK_ARRIVED, Status::BLOCK_ACK_ARRIVED_UNACKED,
  Status::BLOCK_ACK_ARRIVED_ACKED
}
 

Public Member Functions

virtual ~QoSAckHandler ()
 
virtual void processReceivedAck (Ieee80211ACKFrame *ack, Ieee80211DataOrMgmtFrame *ackedFrame)
 
virtual std::set< std::pair< MACAddress, std::pair< Tid, SequenceControlField > > > processReceivedBlockAck (Ieee80211BlockAck *blockAck)
 
virtual void frameGotInProgress (Ieee80211DataOrMgmtFrame *dataOrMgmtFrame) override
 
virtual void processTransmittedDataOrMgmtFrame (Ieee80211DataOrMgmtFrame *frame)
 
virtual void processTransmittedBlockAckReq (Ieee80211BlockAckReq *blockAckReq)
 
virtual void processFailedFrame (Ieee80211DataOrMgmtFrame *dataOrMgmtFrame)
 
virtual Status getQoSDataAckStatus (Ieee80211DataFrame *frame)
 
virtual Status getMgmtOrNonQoSAckStatus (Ieee80211DataOrMgmtFrame *frame)
 
virtual int getNumberOfFramesWithStatus (Status status)
 
virtual bool isEligibleToTransmit (Ieee80211DataOrMgmtFrame *frame) override
 
virtual bool isOutstandingFrame (Ieee80211DataOrMgmtFrame *frame) override
 
- Public Member Functions inherited from inet::ieee80211::IAckHandler
virtual ~IAckHandler ()
 

Protected Types

typedef std::pair< MACAddress, std::pair< Tid, SequenceControlField > > QoSKey
 
typedef std::pair< MACAddress, SequenceControlFieldKey
 

Protected Member Functions

virtual StatusgetQoSDataAckStatus (const QoSKey &id)
 
virtual StatusgetMgmtOrNonQoSAckStatus (const Key &id)
 
std::string getStatusString (Status status)
 
void printAckStatuses ()
 

Protected Attributes

std::map< QoSKey, StatusackStatuses
 
std::map< Key, StatusmgmtAckStatuses
 

Member Typedef Documentation

typedef std::pair<MACAddress, std::pair<Tid, SequenceControlField> > inet::ieee80211::QoSAckHandler::QoSKey
protected

Member Enumeration Documentation

Enumerator
FRAME_NOT_YET_TRANSMITTED 
NO_ACK_REQUIRED 
BLOCK_ACK_NOT_YET_REQUESTED 
WAITING_FOR_NORMAL_ACK 
WAITING_FOR_BLOCK_ACK 
NORMAL_ACK_NOT_ARRIVED 
NORMAL_ACK_ARRIVED 
BLOCK_ACK_ARRIVED_UNACKED 
BLOCK_ACK_ARRIVED_ACKED 
34  {
35  FRAME_NOT_YET_TRANSMITTED,
36  NO_ACK_REQUIRED,
37  BLOCK_ACK_NOT_YET_REQUESTED,
38  WAITING_FOR_NORMAL_ACK,
39  WAITING_FOR_BLOCK_ACK,
40  NORMAL_ACK_NOT_ARRIVED,
41  NORMAL_ACK_ARRIVED,
42  BLOCK_ACK_ARRIVED_UNACKED,
43  BLOCK_ACK_ARRIVED_ACKED
44  };

Constructor & Destructor Documentation

virtual inet::ieee80211::QoSAckHandler::~QoSAckHandler ( )
inlinevirtual
60 { }

Member Function Documentation

void inet::ieee80211::QoSAckHandler::frameGotInProgress ( Ieee80211DataOrMgmtFrame dataOrMgmtFrame)
overridevirtual

Implements inet::ieee80211::IAckHandler.

211 {
212  if (dataOrMgmtFrame->getType() == ST_DATA_WITH_QOS) {
213  auto dataFrame = check_and_cast<Ieee80211DataFrame*>(dataOrMgmtFrame);
214  auto id = std::make_pair(dataFrame->getReceiverAddress(), std::make_pair(dataFrame->getTid(), SequenceControlField(dataFrame->getSequenceNumber(), dataFrame->getFragmentNumber())));
215  Status& status = getQoSDataAckStatus(id);
218  }
219  else {
220  auto id = std::make_pair(dataOrMgmtFrame->getReceiverAddress(), SequenceControlField(dataOrMgmtFrame->getSequenceNumber(), dataOrMgmtFrame->getFragmentNumber()));
221  Status& status = getMgmtOrNonQoSAckStatus(id);
222  ASSERT(status != Status::WAITING_FOR_NORMAL_ACK);
224  }
225 }
Definition: Ieee80211Frame_m.h:117
std::map< Key, Status > mgmtAckStatuses
Definition: QoSAckHandler.h:49
Status
Definition: QoSAckHandler.h:34
std::map< QoSKey, Status > ackStatuses
Definition: QoSAckHandler.h:48
uint16_t id
Definition: TCP_NSC.cc:85
virtual Status & getMgmtOrNonQoSAckStatus(const Key &id)
Definition: QoSAckHandler.cc:33
virtual Status & getQoSDataAckStatus(const QoSKey &id)
Definition: QoSAckHandler.cc:23
QoSAckHandler::Status & inet::ieee80211::QoSAckHandler::getMgmtOrNonQoSAckStatus ( const Key id)
protectedvirtual

Referenced by frameGotInProgress(), isEligibleToTransmit(), processFailedFrame(), and processReceivedAck().

34 {
35  auto it = mgmtAckStatuses.find(id);
36  if (it == mgmtAckStatuses.end()) {
38  return mgmtAckStatuses[id];
39  }
40  return it->second;
41 }
std::map< Key, Status > mgmtAckStatuses
Definition: QoSAckHandler.h:49
uint16_t id
Definition: TCP_NSC.cc:85
QoSAckHandler::Status inet::ieee80211::QoSAckHandler::getMgmtOrNonQoSAckStatus ( Ieee80211DataOrMgmtFrame frame)
virtual
44 {
45  auto id = std::make_pair(frame->getReceiverAddress(), SequenceControlField(frame->getSequenceNumber(), frame->getFragmentNumber()));
46  auto it = mgmtAckStatuses.find(id);
47  if (it == mgmtAckStatuses.end()) {
50  }
51  return it->second;
52 }
std::map< Key, Status > mgmtAckStatuses
Definition: QoSAckHandler.h:49
uint16_t id
Definition: TCP_NSC.cc:85
int inet::ieee80211::QoSAckHandler::getNumberOfFramesWithStatus ( Status  status)
virtual
228 {
229  int count = 0;
230  for (auto ackStatus : ackStatuses)
231  if (ackStatus.second == status)
232  count++;
233  return count;
234 }
int count(const std::vector< T > &v, const T &a)
Definition: stlutils.h:58
std::map< QoSKey, Status > ackStatuses
Definition: QoSAckHandler.h:48
QoSAckHandler::Status & inet::ieee80211::QoSAckHandler::getQoSDataAckStatus ( const QoSKey id)
protectedvirtual

Referenced by frameGotInProgress(), isEligibleToTransmit(), isOutstandingFrame(), processFailedFrame(), processReceivedAck(), and processReceivedBlockAck().

24 {
25  auto it = ackStatuses.find(id);
26  if (it == ackStatuses.end()) {
28  return ackStatuses[id];
29  }
30  return it->second;
31 }
std::map< QoSKey, Status > ackStatuses
Definition: QoSAckHandler.h:48
uint16_t id
Definition: TCP_NSC.cc:85
QoSAckHandler::Status inet::ieee80211::QoSAckHandler::getQoSDataAckStatus ( Ieee80211DataFrame frame)
virtual
56 {
57  auto id = std::make_pair(frame->getReceiverAddress(), std::make_pair(frame->getTid(), SequenceControlField(frame->getSequenceNumber(), frame->getFragmentNumber())));
58  auto it = ackStatuses.find(id);
59  if (it == ackStatuses.end()) {
62  }
63  return it->second;
64 }
std::map< QoSKey, Status > ackStatuses
Definition: QoSAckHandler.h:48
uint16_t id
Definition: TCP_NSC.cc:85
std::string inet::ieee80211::QoSAckHandler::getStatusString ( Status  status)
protected
bool inet::ieee80211::QoSAckHandler::isEligibleToTransmit ( Ieee80211DataOrMgmtFrame frame)
overridevirtual

Implements inet::ieee80211::IAckHandler.

188 {
189  QoSAckHandler::Status status;
190  if (frame->getType() == ST_DATA_WITH_QOS) {
191  auto dataFrame = check_and_cast<Ieee80211DataFrame*>(frame);
192  status = getQoSDataAckStatus(dataFrame);
193  }
194  else
195  status = getMgmtOrNonQoSAckStatus(frame);
197 }
Definition: Ieee80211Frame_m.h:117
Status
Definition: QoSAckHandler.h:34
virtual Status & getMgmtOrNonQoSAckStatus(const Key &id)
Definition: QoSAckHandler.cc:33
virtual Status & getQoSDataAckStatus(const QoSKey &id)
Definition: QoSAckHandler.cc:23
bool inet::ieee80211::QoSAckHandler::isOutstandingFrame ( Ieee80211DataOrMgmtFrame frame)
overridevirtual

Implements inet::ieee80211::IAckHandler.

200 {
201  if (frame->getType() == ST_DATA_WITH_QOS) {
202  auto dataFrame = check_and_cast<Ieee80211DataFrame*>(frame);
203  auto status = getQoSDataAckStatus(dataFrame);
205  }
206  else
207  return false;
208 }
Definition: Ieee80211Frame_m.h:117
virtual Status & getQoSDataAckStatus(const QoSKey &id)
Definition: QoSAckHandler.cc:23
void inet::ieee80211::QoSAckHandler::printAckStatuses ( )
protected

Referenced by processReceivedBlockAck().

253 {
254 // for (auto ackStatus : ackStatuses) {
255 // std::cout << "Seq Num = " << ackStatus.first.getSequenceNumber() << " " << "Frag Num = " << (int)ackStatus.first.getFragmentNumber() << std::endl;
256 // std::cout << "Status = " << getStatusString(ackStatus.second) << std::endl;
257 // }
258 // std::cout << "=========================================" << std::endl;
259 }
void inet::ieee80211::QoSAckHandler::processFailedFrame ( Ieee80211DataOrMgmtFrame dataOrMgmtFrame)
virtual
85 {
86  if (dataOrMgmtFrame->getType() == ST_DATA_WITH_QOS) {
87  auto dataFrame = check_and_cast<Ieee80211DataFrame*>(dataOrMgmtFrame);
89  auto id = std::make_pair(dataFrame->getReceiverAddress(), std::make_pair(dataFrame->getTid(), SequenceControlField(dataFrame->getSequenceNumber(), dataFrame->getFragmentNumber())));
90  Status &status = getQoSDataAckStatus(id);
92  }
93  else {
94  ASSERT(getMgmtOrNonQoSAckStatus(dataOrMgmtFrame) == Status::WAITING_FOR_NORMAL_ACK);
95  Status &status = getMgmtOrNonQoSAckStatus(std::make_pair(dataOrMgmtFrame->getReceiverAddress(), SequenceControlField(dataOrMgmtFrame->getSequenceNumber(), dataOrMgmtFrame->getFragmentNumber())));
97  }
98 }
Definition: Ieee80211Frame_m.h:117
Status
Definition: QoSAckHandler.h:34
virtual Status & getMgmtOrNonQoSAckStatus(const Key &id)
Definition: QoSAckHandler.cc:33
virtual Status & getQoSDataAckStatus(const QoSKey &id)
Definition: QoSAckHandler.cc:23
void inet::ieee80211::QoSAckHandler::processReceivedAck ( Ieee80211ACKFrame ack,
Ieee80211DataOrMgmtFrame ackedFrame 
)
virtual
67 {
68  if (ackedFrame->getType() == ST_DATA_WITH_QOS) {
69  auto dataFrame = check_and_cast<Ieee80211DataFrame*>(ackedFrame);
70  auto id = std::make_pair(dataFrame->getReceiverAddress(), std::make_pair(dataFrame->getTid(), SequenceControlField(dataFrame->getSequenceNumber(), dataFrame->getFragmentNumber())));
71  Status &status = getQoSDataAckStatus(id);
73  throw cRuntimeError("ackedFrame = %s is not yet transmitted", dataFrame->getName());
75  }
76  else {
77  Status &status = getMgmtOrNonQoSAckStatus(std::make_pair(ackedFrame->getReceiverAddress(), SequenceControlField(ackedFrame->getSequenceNumber(), ackedFrame->getFragmentNumber())));
79  throw cRuntimeError("ackedFrame = %s is not yet transmitted", ackedFrame->getName());
81  }
82 }
Definition: Ieee80211Frame_m.h:117
Status
Definition: QoSAckHandler.h:34
virtual Status & getMgmtOrNonQoSAckStatus(const Key &id)
Definition: QoSAckHandler.cc:33
virtual Status & getQoSDataAckStatus(const QoSKey &id)
Definition: QoSAckHandler.cc:23
std::set< std::pair< MACAddress, std::pair< Tid, SequenceControlField > > > inet::ieee80211::QoSAckHandler::processReceivedBlockAck ( Ieee80211BlockAck blockAck)
virtual
101 {
103  MACAddress receiverAddr = blockAck->getTransmitterAddress();
104  std::set<QoSKey> ackedFrames;
105  // Table 8-16—BlockAckReq frame variant encoding
106  if (auto basicBlockAck = dynamic_cast<Ieee80211BasicBlockAck *>(blockAck)) {
107  int startingSeqNum = basicBlockAck->getStartingSequenceNumber();
108  for (int seqNum = 0; seqNum < 64; seqNum++) {
109  BitVector bitmap = basicBlockAck->getBlockAckBitmap(seqNum);
110  for (int fragNum = 0; fragNum < 16; fragNum++) { // TODO: declare these const values
111  auto id = std::make_pair(receiverAddr, std::make_pair(basicBlockAck->getTidInfo(), SequenceControlField((startingSeqNum + seqNum) % 4096, fragNum)));
112  Status& status = getQoSDataAckStatus(id);
113  if (status == Status::WAITING_FOR_BLOCK_ACK) {
114  bool acked = bitmap.getBit(fragNum) == 1;
115  if (acked) ackedFrames.insert(id);
117  }
118  else ; // TODO: erroneous BlockAck
119  }
120  }
121  }
122  else if (auto compressedBlockAck = dynamic_cast<Ieee80211CompressedBlockAck *>(blockAck)) {
123  int startingSeqNum = compressedBlockAck->getStartingSequenceNumber();
124  BitVector bitmap = compressedBlockAck->getBlockAckBitmap();
125  for (int seqNum = 0; seqNum < 64; seqNum++) {
126  auto id = std::make_pair(receiverAddr, std::make_pair(compressedBlockAck->getTidInfo(), SequenceControlField(startingSeqNum + seqNum, 0)));
127  Status& status = getQoSDataAckStatus(id);
128  if (status == Status::WAITING_FOR_BLOCK_ACK) {
129  bool acked = bitmap.getBit(seqNum) == 1;
131  if (acked) ackedFrames.insert(id);
132  }
133  else ; // TODO: erroneous BlockAck
134  }
135  }
136  else {
137  throw cRuntimeError("Multi-TID BlockReq is unimplemented");
138  }
140  return ackedFrames;
141 }
void printAckStatuses()
Definition: QoSAckHandler.cc:252
Status
Definition: QoSAckHandler.h:34
virtual Status & getQoSDataAckStatus(const QoSKey &id)
Definition: QoSAckHandler.cc:23
void inet::ieee80211::QoSAckHandler::processTransmittedBlockAckReq ( Ieee80211BlockAckReq blockAckReq)
virtual
161 {
162  //printAckStatuses();
163  for (auto &ackStatus : ackStatuses) {
164  auto tid = ackStatus.first.second.first;
165  auto seqCtrlField = ackStatus.first.second.second;
166  auto &status = ackStatus.second;
167  if (auto basicBlockAckReq = dynamic_cast<Ieee80211BasicBlockAckReq *>(blockAckReq)) {
168  if (basicBlockAckReq->getTidInfo() == tid) {
169  int startingSeqNum = basicBlockAckReq->getStartingSequenceNumber();
170  if (status == Status::BLOCK_ACK_NOT_YET_REQUESTED && seqCtrlField.getSequenceNumber() >= startingSeqNum)
172  }
173  }
174  else if (auto compressedBlockAckReq = dynamic_cast<Ieee80211CompressedBlockAckReq *>(blockAckReq)) {
175  if (compressedBlockAckReq->getTidInfo() == tid) {
176  int startingSeqNum = compressedBlockAckReq->getStartingSequenceNumber();
177  if (status == Status::BLOCK_ACK_NOT_YET_REQUESTED && seqCtrlField.getSequenceNumber() >= startingSeqNum && seqCtrlField.getFragmentNumber() == 0) // TODO: ASSERT(seqCtrlField.second == 0)?
179  }
180  }
181  else
182  throw cRuntimeError("Multi-TID BlockReq is unimplemented");
183  }
184  //printAckStatuses();
185 }
std::map< QoSKey, Status > ackStatuses
Definition: QoSAckHandler.h:48
void inet::ieee80211::QoSAckHandler::processTransmittedDataOrMgmtFrame ( Ieee80211DataOrMgmtFrame frame)
virtual
144 {
145  if (frame->getType() == ST_DATA_WITH_QOS) {
146  auto dataFrame = check_and_cast<Ieee80211DataFrame*>(frame);
147  auto id = std::make_pair(dataFrame->getReceiverAddress(), std::make_pair(dataFrame->getTid(), SequenceControlField(dataFrame->getSequenceNumber(), dataFrame->getFragmentNumber())));
148  switch (dataFrame->getAckPolicy()) {
151  case NO_ACK : ackStatuses[id] = Status::NO_ACK_REQUIRED; break;
152  case NO_EXPLICIT_ACK : throw cRuntimeError("Unimplemented"); /* TODO: ACKED by default? */ break;
153  default: throw cRuntimeError("Unknown Ack Policy = %d", dataFrame->getAckPolicy());
154  }
155  }
156  else
157  mgmtAckStatuses[std::make_pair(frame->getReceiverAddress(), SequenceControlField(frame->getSequenceNumber(), frame->getFragmentNumber()))] = Status::WAITING_FOR_NORMAL_ACK;
158 }
Definition: Ieee80211Frame_m.h:140
Definition: Ieee80211Frame_m.h:142
Definition: Ieee80211Frame_m.h:141
Definition: Ieee80211Frame_m.h:117
std::map< Key, Status > mgmtAckStatuses
Definition: QoSAckHandler.h:49
Definition: Ieee80211Frame_m.h:139
std::map< QoSKey, Status > ackStatuses
Definition: QoSAckHandler.h:48
uint16_t id
Definition: TCP_NSC.cc:85

Member Data Documentation

std::map<Key, Status> inet::ieee80211::QoSAckHandler::mgmtAckStatuses
protected

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