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

The default implementation of IDs. More...

#include <Ds.h>

Inheritance diagram for inet::ieee80211::Ds:
inet::ieee80211::IDs

Public Member Functions

virtual void processDataFrame (Packet *frame, const Ptr< const Ieee80211DataHeader > &header) override
 
- Public Member Functions inherited from inet::ieee80211::IDs
virtual ~IDs ()
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void distributeDataFrame (Packet *frame, const Ptr< const Ieee80211DataOrMgmtHeader > &header)
 Utility function for APs: sends back a data frame we received from a STA to the wireless LAN, after tweaking fromDS/toDS bits and shuffling addresses as needed. More...
 

Protected Attributes

Ieee80211Mibmib = nullptr
 
Ieee80211Macmac = nullptr
 

Detailed Description

The default implementation of IDs.

Member Function Documentation

◆ distributeDataFrame()

void inet::ieee80211::Ds::distributeDataFrame ( Packet frame,
const Ptr< const Ieee80211DataOrMgmtHeader > &  header 
)
protectedvirtual

Utility function for APs: sends back a data frame we received from a STA to the wireless LAN, after tweaking fromDS/toDS bits and shuffling addresses as needed.

99 {
100  EV_INFO << "Distributing data frame.\n";
101  incomingFrame->trim();
102  const auto& outgoingHeader = staticPtrCast<Ieee80211DataOrMgmtHeader>(incomingHeader->dupShared());
103 
104  // adjust toDS/fromDS bits, and shuffle addresses
105  outgoingHeader->setToDS(false);
106  outgoingHeader->setFromDS(true);
107 
108  // move destination address to address1 (receiver address),
109  // and fill address3 with original source address;
110  ASSERT(!outgoingHeader->getAddress3().isUnspecified());
111  outgoingHeader->setReceiverAddress(incomingHeader->getAddress3());
112  outgoingHeader->setAddress3(incomingHeader->getTransmitterAddress());
113 
114  auto outgoingFrame = new Packet(incomingFrame->getName(), incomingFrame->peekData());
115  outgoingFrame->insertAtFront(outgoingHeader);
116  const auto& trailer = makeShared<Ieee80211MacTrailer>();
117  // TODO add module parameter, implement fcs computing
118  // TODO trailer->setFcsMode(FCS_COMPUTED);
119  outgoingFrame->insertAtBack(trailer);
120  mac->processUpperFrame(outgoingFrame, outgoingHeader);
121 }

Referenced by processDataFrame().

◆ initialize()

void inet::ieee80211::Ds::initialize ( int  stage)
overrideprotectedvirtual
20 {
21  if (stage == INITSTAGE_LOCAL) {
22  mac = check_and_cast<Ieee80211Mac *>(getContainingNicModule(this)->getSubmodule("mac"));
23  mib = check_and_cast<Ieee80211Mib *>(getModuleByPath(par("mibModule")));
24  }
25 }

◆ processDataFrame()

void inet::ieee80211::Ds::processDataFrame ( Packet frame,
const Ptr< const Ieee80211DataHeader > &  header 
)
overridevirtual

Implements inet::ieee80211::IDs.

28 {
29  Enter_Method("processDataFrame");
30  take(frame);
32  mac->sendUp(frame);
33  else if (mib->mode == Ieee80211Mib::INFRASTRUCTURE) {
35  // check toDS bit
36  if (!header->getToDS()) {
37  // looks like this is not for us - discard
38  EV_WARN << "Frame is not for us (toDS=false) -- discarding\n";
39  PacketDropDetails details;
40  details.setReason(NOT_ADDRESSED_TO_US);
41  emit(packetDroppedSignal, frame, &details);
42  delete frame;
43  return;
44  }
45  // handle broadcast/multicast frames
46  if (header->getAddress3().isMulticast()) {
47  EV_INFO << "Handling multicast frame\n";
48  distributeDataFrame(frame, header);
49  mac->sendUp(frame);
50  return;
51  }
52  // look up destination address in our STA list
53  auto it = mib->bssAccessPointData.stations.find(header->getAddress3());
54  if (it == mib->bssAccessPointData.stations.end()) {
55  EV_WARN << "Frame's destination address is not in our STA list -- passing up\n";
56  mac->sendUp(frame);
57  }
58  else {
59  // dest address is our STA, but is it already associated?
60  if (it->second == Ieee80211Mib::ASSOCIATED) {
61  distributeDataFrame(frame, header); // send it out to the destination STA
62  delete frame;
63  }
64  else {
65  EV_WARN << "Frame's destination STA is not in associated state -- dropping frame\n";
66  PacketDropDetails details;
67  details.setReason(OTHER_PACKET_DROP);
68  emit(packetDroppedSignal, frame, &details);
69  delete frame;
70  }
71  }
72  }
75  EV_WARN << "Rejecting data frame as STA is not associated with an AP" << endl;
76  PacketDropDetails details;
77  details.setReason(OTHER_PACKET_DROP);
78  emit(packetDroppedSignal, frame, &details);
79  delete frame;
80  }
81  else if (mib->bssData.bssid != header->getTransmitterAddress()) {
82  EV_WARN << "Rejecting data frame received from another AP" << endl;
83  PacketDropDetails details;
84  details.setReason(OTHER_PACKET_DROP);
85  emit(packetDroppedSignal, frame, &details);
86  delete frame;
87  }
88  else
89  mac->sendUp(frame);
90  }
91  else
92  throw cRuntimeError("Unknown station type");
93  }
94  else
95  throw cRuntimeError("Unknown mode");
96 }

Member Data Documentation

◆ mac

Ieee80211Mac* inet::ieee80211::Ds::mac = nullptr
protected

◆ mib

Ieee80211Mib* inet::ieee80211::Ds::mib = nullptr
protected

Referenced by initialize(), and processDataFrame().


The documentation for this class was generated from the following files:
inet::ieee80211::Ieee80211Mib::INDEPENDENT
@ INDEPENDENT
Definition: Ieee80211Mib.h:22
inet::ieee80211::Ieee80211Mib::INFRASTRUCTURE
@ INFRASTRUCTURE
Definition: Ieee80211Mib.h:21
inet::ieee80211::Ieee80211Mib::STATION
@ STATION
Definition: Ieee80211Mib.h:28
inet::getContainingNicModule
NetworkInterface * getContainingNicModule(const cModule *from)
Find the nic module (inside the networkNode) containing the given module.
Definition: NetworkInterface.cc:691
inet::ieee80211::Ieee80211Mib::bssAccessPointData
BssAccessPointData bssAccessPointData
Definition: Ieee80211Mib.h:61
inet::ieee80211::Ds::mac
Ieee80211Mac * mac
Definition: Ds.h:26
inet::packetDroppedSignal
simsignal_t packetDroppedSignal
Definition: Simsignals.cc:85
inet::ieee80211::Ieee80211Mib::bssStationData
BssStationData bssStationData
Definition: Ieee80211Mib.h:60
inet::ieee80211::Ieee80211Mac::processUpperFrame
virtual void processUpperFrame(Packet *packet, const Ptr< const Ieee80211DataOrMgmtHeader > &header)
Definition: Ieee80211Mac.cc:374
inet::ieee80211::Ieee80211Mib::bssData
BssData bssData
Definition: Ieee80211Mib.h:59
inet::ieee80211::Ds::mib
Ieee80211Mib * mib
Definition: Ds.h:25
inet::ieee80211::Ieee80211Mib::BssStationData::isAssociated
bool isAssociated
Definition: Ieee80211Mib.h:46
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::ieee80211::Ieee80211Mib::BssStationData::stationType
BssStationType stationType
Definition: Ieee80211Mib.h:45
inet::ieee80211::Ieee80211Mib::BssData::bssid
MacAddress bssid
Definition: Ieee80211Mib.h:40
inet::OTHER_PACKET_DROP
@ OTHER_PACKET_DROP
Definition: Simsignals_m.h:84
inet::ieee80211::Ds::distributeDataFrame
virtual void distributeDataFrame(Packet *frame, const Ptr< const Ieee80211DataOrMgmtHeader > &header)
Utility function for APs: sends back a data frame we received from a STA to the wireless LAN,...
Definition: Ds.cc:98
inet::ieee80211::Ieee80211Mib::mode
Mode mode
Definition: Ieee80211Mib.h:56
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::ieee80211::Ieee80211Mib::ACCESS_POINT
@ ACCESS_POINT
Definition: Ieee80211Mib.h:27
inet::ieee80211::Ieee80211Mac::sendUp
virtual void sendUp(cMessage *message) override
Definition: Ieee80211Mac.cc:338
inet::ieee80211::Ieee80211Mib::ASSOCIATED
@ ASSOCIATED
Definition: Ieee80211Mib.h:34
inet::NOT_ADDRESSED_TO_US
@ NOT_ADDRESSED_TO_US
Definition: Simsignals_m.h:76
inet::ieee80211::Ieee80211Mib::BssAccessPointData::stations
std::map< MacAddress, BssMemberStatus > stations
Definition: Ieee80211Mib.h:51