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

Used in 802.11 infrastructure mode: handles management frames for an access point (AP). More...

#include <Ieee80211MgmtAP.h>

Inheritance diagram for inet::ieee80211::Ieee80211MgmtAP:
inet::ieee80211::Ieee80211MgmtAPBase inet::ieee80211::Ieee80211MgmtBase inet::ILifecycle

Classes

struct  MAC_compare
 
class  NotificationInfoSta
 
struct  STAInfo
 Describes a STA. More...
 

Public Types

enum  STAStatus { NOT_AUTHENTICATED, AUTHENTICATED, ASSOCIATED }
 State of a STA. More...
 
typedef std::map< MACAddress, STAInfo, MAC_compareSTAList
 
- Public Types inherited from inet::ieee80211::Ieee80211MgmtAPBase
enum  EncapDecap { ENCAP_DECAP_TRUE = 1, ENCAP_DECAP_FALSE, ENCAP_DECAP_ETH }
 

Public Member Functions

 Ieee80211MgmtAP ()
 
virtual ~Ieee80211MgmtAP ()
 
- Public Member Functions inherited from inet::ieee80211::Ieee80211MgmtBase
virtual bool handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int) override
 
virtual void handleTimer (cMessage *msg) override
 Implements abstract Ieee80211MgmtBase method. More...
 
virtual void handleUpperMessage (cPacket *msg) override
 Implements abstract Ieee80211MgmtBase method. More...
 
virtual void handleCommand (int msgkind, cObject *ctrl) override
 Implements abstract Ieee80211MgmtBase method – throws an error (no commands supported) More...
 
virtual void receiveSignal (cComponent *source, simsignal_t signalID, long value, cObject *details) override
 Called by the signal handler whenever a change occurs we're interested in. More...
 
virtual STAInfolookupSenderSTA (Ieee80211ManagementFrame *frame)
 Utility function: return sender STA's entry from our STA list, or nullptr if not in there. More...
 
virtual void sendManagementFrame (Ieee80211ManagementFrame *frame, const MACAddress &destAddr)
 Utility function: set fields in the given frame and send it out to the address. More...
 
virtual void sendBeacon ()
 Utility function: creates and sends a beacon frame. More...
 
void sendAssocNotification (const MACAddress &addr)
 
void sendDisAssocNotification (const MACAddress &addr)
 
Processing of different frame types
virtual void handleDataFrame (Ieee80211DataFrame *frame) override
 
virtual void handleAuthenticationFrame (Ieee80211AuthenticationFrame *frame) override
 
virtual void handleDeauthenticationFrame (Ieee80211DeauthenticationFrame *frame) override
 
virtual void handleAssociationRequestFrame (Ieee80211AssociationRequestFrame *frame) override
 
virtual void handleAssociationResponseFrame (Ieee80211AssociationResponseFrame *frame) override
 
virtual void handleReassociationRequestFrame (Ieee80211ReassociationRequestFrame *frame) override
 
virtual void handleReassociationResponseFrame (Ieee80211ReassociationResponseFrame *frame) override
 
virtual void handleDisassociationFrame (Ieee80211DisassociationFrame *frame) override
 
virtual void handleBeaconFrame (Ieee80211BeaconFrame *frame) override
 
virtual void handleProbeRequestFrame (Ieee80211ProbeRequestFrame *frame) override
 
virtual void handleProbeResponseFrame (Ieee80211ProbeResponseFrame *frame) override
 
virtual void start () override
 lifecycle support More...
 
virtual void stop () override
 
- Protected Member Functions inherited from inet::ieee80211::Ieee80211MgmtAPBase
virtual void distributeReceivedDataFrame (Ieee80211DataFrame *frame)
 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...
 
virtual Ieee80211DataFrameencapsulate (cPacket *msg)
 Utility function for handleUpperMessage() More...
 
virtual Ieee80211DataFrameconvertFromEtherFrame (EtherFrame *ethframe)
 Utility function: converts EtherFrame to Ieee80211Frame. More...
 
virtual EtherFrameconvertToEtherFrame (Ieee80211DataFrame *frame)
 Utility function: converts Ieee80211Frame to EtherFrame. More...
 
virtual void sendToUpperLayer (Ieee80211DataFrame *frame)
 Utility function: send a frame to upperLayerOut. More...
 
- Protected Member Functions inherited from inet::ieee80211::Ieee80211MgmtBase
virtual void handleMessage (cMessage *msg) override
 Dispatches incoming messages to handleTimer(), handleUpperMessage() or processFrame(). More...
 
virtual void sendDown (cPacket *frame)
 Utility method for implementing handleUpperMessage(): send message to MAC. More...
 
virtual void dropManagementFrame (Ieee80211ManagementFrame *frame)
 Utility method to dispose of an unhandled frame. More...
 
virtual void sendUp (cMessage *msg)
 Utility method: sends the packet to the upper layer. More...
 
virtual void processFrame (Ieee80211DataOrMgmtFrame *frame)
 Dispatch to frame processing methods according to frame type. More...
 

Protected Attributes

std::string ssid
 
int channelNumber = -1
 
simtime_t beaconInterval
 
int numAuthSteps = 0
 
Ieee80211SupportedRatesElement supportedRates
 
STAList staList
 list of STAs More...
 
cMessage * beaconTimer = nullptr
 
- Protected Attributes inherited from inet::ieee80211::Ieee80211MgmtAPBase
bool isConnectedToHL
 
EncapDecap encapDecap
 
- Protected Attributes inherited from inet::ieee80211::Ieee80211MgmtBase
MACAddress myAddress
 
bool isOperational
 
long numDataFramesReceived
 
long numMgmtFramesReceived
 
long numMgmtFramesDropped
 

Detailed Description

Used in 802.11 infrastructure mode: handles management frames for an access point (AP).

See corresponding NED file for a detailed description.

Author
Andras Varga

Member Typedef Documentation

Member Enumeration Documentation

State of a STA.

Enumerator
NOT_AUTHENTICATED 
AUTHENTICATED 
ASSOCIATED 

Constructor & Destructor Documentation

inet::ieee80211::Ieee80211MgmtAP::Ieee80211MgmtAP ( )
inline
84 {}
inet::ieee80211::Ieee80211MgmtAP::~Ieee80211MgmtAP ( )
virtual
47 {
48  cancelAndDelete(beaconTimer);
49 }
cMessage * beaconTimer
Definition: Ieee80211MgmtAP.h:81

Member Function Documentation

void inet::ieee80211::Ieee80211MgmtAP::handleAssociationRequestFrame ( Ieee80211AssociationRequestFrame frame)
overrideprotectedvirtual

Implements inet::ieee80211::Ieee80211MgmtBase.

287 {
288  EV << "Processing AssociationRequest frame\n";
289 
290  // "11.3.2 AP association procedures"
291  STAInfo *sta = lookupSenderSTA(frame);
292  if (!sta || sta->status == NOT_AUTHENTICATED) {
293  // STA not authenticated: send error and return
294  Ieee80211DeauthenticationFrame *resp = new Ieee80211DeauthenticationFrame("Deauth");
295  resp->getBody().setReasonCode(RC_NONAUTH_ASS_REQUEST);
296  sendManagementFrame(resp, frame->getTransmitterAddress());
297  delete frame;
298  return;
299  }
300 
301  delete frame;
302 
303  // mark STA as associated
304  if (sta->status != ASSOCIATED)
305  sendAssocNotification(sta->address);
306  sta->status = ASSOCIATED; // XXX this should only take place when MAC receives the ACK for the response
307 
308  // send OK response
309  Ieee80211AssociationResponseFrame *resp = new Ieee80211AssociationResponseFrame("AssocResp-OK");
310  Ieee80211AssociationResponseFrameBody& body = resp->getBody();
311  body.setStatusCode(SC_SUCCESSFUL);
312  body.setAid(0); //XXX
313  body.setSupportedRates(supportedRates);
314  sendManagementFrame(resp, sta->address);
315 }
Ieee80211SupportedRatesElement supportedRates
Definition: Ieee80211MgmtAP.h:77
virtual STAInfo * lookupSenderSTA(Ieee80211ManagementFrame *frame)
Utility function: return sender STA&#39;s entry from our STA list, or nullptr if not in there...
Definition: Ieee80211MgmtAP.cc:125
Definition: Ieee80211MgmtFrames_m.h:175
void sendAssocNotification(const MACAddress &addr)
Definition: Ieee80211MgmtAP.cc:401
Definition: Ieee80211MgmtAP.h:41
Definition: Ieee80211MgmtFrames_m.h:130
virtual void sendManagementFrame(Ieee80211ManagementFrame *frame, const MACAddress &destAddr)
Utility function: set fields in the given frame and send it out to the address.
Definition: Ieee80211MgmtAP.cc:131
void inet::ieee80211::Ieee80211MgmtAP::handleAssociationResponseFrame ( Ieee80211AssociationResponseFrame frame)
overrideprotectedvirtual

Implements inet::ieee80211::Ieee80211MgmtBase.

318 {
319  dropManagementFrame(frame);
320 }
virtual void dropManagementFrame(Ieee80211ManagementFrame *frame)
Utility method to dispose of an unhandled frame.
Definition: Ieee80211MgmtBase.cc:90
void inet::ieee80211::Ieee80211MgmtAP::handleAuthenticationFrame ( Ieee80211AuthenticationFrame frame)
overrideprotectedvirtual

Implements inet::ieee80211::Ieee80211MgmtBase.

202 {
203  int frameAuthSeq = frame->getBody().getSequenceNumber();
204  EV << "Processing Authentication frame, seqNum=" << frameAuthSeq << "\n";
205 
206  // create STA entry if needed
207  STAInfo *sta = lookupSenderSTA(frame);
208  if (!sta) {
209  MACAddress staAddress = frame->getTransmitterAddress();
210  sta = &staList[staAddress]; // this implicitly creates a new entry
211  sta->address = staAddress;
212  sta->status = NOT_AUTHENTICATED;
213  sta->authSeqExpected = 1;
214  }
215 
216  // reset authentication status, when starting a new auth sequence
217  // The statements below are added because the L2 handover time was greater than before when
218  // a STA wants to re-connect to an AP with which it was associated before. When the STA wants to
219  // associate again with the previous AP, then since the AP is already having an entry of the STA
220  // because of old association, and thus it is expecting an authentication frame number 3 but it
221  // receives authentication frame number 1 from STA, which will cause the AP to return an Auth-Error
222  // making the MN STA to start the handover process all over again.
223  if (frameAuthSeq == 1) {
224  if (sta->status == ASSOCIATED)
225  sendDisAssocNotification(sta->address);
226  sta->status = NOT_AUTHENTICATED;
227  sta->authSeqExpected = 1;
228  }
229 
230  // check authentication sequence number is OK
231  if (frameAuthSeq != sta->authSeqExpected) {
232  // wrong sequence number: send error and return
233  EV << "Wrong sequence number, " << sta->authSeqExpected << " expected\n";
234  Ieee80211AuthenticationFrame *resp = new Ieee80211AuthenticationFrame("Auth-ERROR");
235  resp->getBody().setStatusCode(SC_AUTH_OUT_OF_SEQ);
236  sendManagementFrame(resp, frame->getTransmitterAddress());
237  delete frame;
238  sta->authSeqExpected = 1; // go back to start square
239  return;
240  }
241 
242  // station is authenticated if it made it through the required number of steps
243  bool isLast = (frameAuthSeq + 1 == numAuthSteps);
244 
245  // send OK response (we don't model the cryptography part, just assume
246  // successful authentication every time)
247  EV << "Sending Authentication frame, seqNum=" << (frameAuthSeq + 1) << "\n";
248  Ieee80211AuthenticationFrame *resp = new Ieee80211AuthenticationFrame(isLast ? "Auth-OK" : "Auth");
249  resp->getBody().setSequenceNumber(frameAuthSeq + 1);
250  resp->getBody().setStatusCode(SC_SUCCESSFUL);
251  resp->getBody().setIsLast(isLast);
252  // XXX frame length could be increased to account for challenge text length etc.
253  sendManagementFrame(resp, frame->getTransmitterAddress());
254 
255  delete frame;
256 
257  // update status
258  if (isLast) {
259  if (sta->status == ASSOCIATED)
260  sendDisAssocNotification(sta->address);
261  sta->status = AUTHENTICATED; // XXX only when ACK of this frame arrives
262  EV << "STA authenticated\n";
263  }
264  else {
265  sta->authSeqExpected += 2;
266  EV << "Expecting Authentication frame " << sta->authSeqExpected << "\n";
267  }
268 }
STAList staList
list of STAs
Definition: Ieee80211MgmtAP.h:80
void sendDisAssocNotification(const MACAddress &addr)
Definition: Ieee80211MgmtAP.cc:409
Definition: Ieee80211MgmtAP.h:41
int numAuthSteps
Definition: Ieee80211MgmtAP.h:76
virtual STAInfo * lookupSenderSTA(Ieee80211ManagementFrame *frame)
Utility function: return sender STA&#39;s entry from our STA list, or nullptr if not in there...
Definition: Ieee80211MgmtAP.cc:125
Definition: Ieee80211MgmtFrames_m.h:175
Definition: Ieee80211MgmtAP.h:41
Definition: Ieee80211MgmtFrames_m.h:181
virtual void sendManagementFrame(Ieee80211ManagementFrame *frame, const MACAddress &destAddr)
Utility function: set fields in the given frame and send it out to the address.
Definition: Ieee80211MgmtAP.cc:131
void inet::ieee80211::Ieee80211MgmtAP::handleBeaconFrame ( Ieee80211BeaconFrame frame)
overrideprotectedvirtual

Implements inet::ieee80211::Ieee80211MgmtBase.

369 {
370  dropManagementFrame(frame);
371 }
virtual void dropManagementFrame(Ieee80211ManagementFrame *frame)
Utility method to dispose of an unhandled frame.
Definition: Ieee80211MgmtBase.cc:90
void inet::ieee80211::Ieee80211MgmtAP::handleCommand ( int  msgkind,
cObject *  ctrl 
)
overrideprotectedvirtual

Implements abstract Ieee80211MgmtBase method – throws an error (no commands supported)

Implements inet::ieee80211::Ieee80211MgmtBase.

112 {
113  throw cRuntimeError("handleCommand(): no commands supported");
114 }
void inet::ieee80211::Ieee80211MgmtAP::handleDataFrame ( Ieee80211DataFrame frame)
overrideprotectedvirtual

Implements inet::ieee80211::Ieee80211MgmtBase.

158 {
159  // check toDS bit
160  if (!frame->getToDS()) {
161  // looks like this is not for us - discard
162  EV << "Frame is not for us (toDS=false) -- discarding\n";
163  delete frame;
164  return;
165  }
166 
167  // handle broadcast/multicast frames
168  if (frame->getAddress3().isMulticast()) {
169  EV << "Handling multicast frame\n";
170 
171  if (isConnectedToHL)
172  sendToUpperLayer(frame->dup());
173 
175  return;
176  }
177 
178  // look up destination address in our STA list
179  auto it = staList.find(frame->getAddress3());
180  if (it == staList.end()) {
181  // not our STA -- pass up frame to relayUnit for LAN bridging if we have one
182  if (isConnectedToHL) {
183  sendToUpperLayer(frame);
184  }
185  else {
186  EV << "Frame's destination address is not in our STA list -- dropping frame\n";
187  delete frame;
188  }
189  }
190  else {
191  // dest address is our STA, but is it already associated?
192  if (it->second.status == ASSOCIATED)
193  distributeReceivedDataFrame(frame); // send it out to the destination STA
194  else {
195  EV << "Frame's destination STA is not in associated state -- dropping frame\n";
196  delete frame;
197  }
198  }
199 }
STAList staList
list of STAs
Definition: Ieee80211MgmtAP.h:80
bool isConnectedToHL
Definition: Ieee80211MgmtAPBase.h:44
virtual void distributeReceivedDataFrame(Ieee80211DataFrame *frame)
Utility function for APs: sends back a data frame we received from a STA to the wireless LAN...
Definition: Ieee80211MgmtAPBase.cc:50
Definition: Ieee80211MgmtAP.h:41
virtual void sendToUpperLayer(Ieee80211DataFrame *frame)
Utility function: send a frame to upperLayerOut.
Definition: Ieee80211MgmtAPBase.cc:66
void inet::ieee80211::Ieee80211MgmtAP::handleDeauthenticationFrame ( Ieee80211DeauthenticationFrame frame)
overrideprotectedvirtual

Implements inet::ieee80211::Ieee80211MgmtBase.

271 {
272  EV << "Processing Deauthentication frame\n";
273 
274  STAInfo *sta = lookupSenderSTA(frame);
275  delete frame;
276 
277  if (sta) {
278  // mark STA as not authenticated; alternatively, it could also be removed from staList
279  if (sta->status == ASSOCIATED)
280  sendDisAssocNotification(sta->address);
281  sta->status = NOT_AUTHENTICATED;
282  sta->authSeqExpected = 1;
283  }
284 }
void sendDisAssocNotification(const MACAddress &addr)
Definition: Ieee80211MgmtAP.cc:409
virtual STAInfo * lookupSenderSTA(Ieee80211ManagementFrame *frame)
Utility function: return sender STA&#39;s entry from our STA list, or nullptr if not in there...
Definition: Ieee80211MgmtAP.cc:125
Definition: Ieee80211MgmtAP.h:41
void inet::ieee80211::Ieee80211MgmtAP::handleDisassociationFrame ( Ieee80211DisassociationFrame frame)
overrideprotectedvirtual

Implements inet::ieee80211::Ieee80211MgmtBase.

357 {
358  STAInfo *sta = lookupSenderSTA(frame);
359  delete frame;
360 
361  if (sta) {
362  if (sta->status == ASSOCIATED)
363  sendDisAssocNotification(sta->address);
364  sta->status = AUTHENTICATED;
365  }
366 }
void sendDisAssocNotification(const MACAddress &addr)
Definition: Ieee80211MgmtAP.cc:409
Definition: Ieee80211MgmtAP.h:41
virtual STAInfo * lookupSenderSTA(Ieee80211ManagementFrame *frame)
Utility function: return sender STA&#39;s entry from our STA list, or nullptr if not in there...
Definition: Ieee80211MgmtAP.cc:125
Definition: Ieee80211MgmtAP.h:41
void inet::ieee80211::Ieee80211MgmtAP::handleProbeRequestFrame ( Ieee80211ProbeRequestFrame frame)
overrideprotectedvirtual

Implements inet::ieee80211::Ieee80211MgmtBase.

374 {
375  EV << "Processing ProbeRequest frame\n";
376 
377  if (strcmp(frame->getBody().getSSID(), "") != 0 && strcmp(frame->getBody().getSSID(), ssid.c_str()) != 0) {
378  EV << "SSID `" << frame->getBody().getSSID() << "' does not match, ignoring frame\n";
379  dropManagementFrame(frame);
380  return;
381  }
382 
383  MACAddress staAddress = frame->getTransmitterAddress();
384  delete frame;
385 
386  EV << "Sending ProbeResponse frame\n";
387  Ieee80211ProbeResponseFrame *resp = new Ieee80211ProbeResponseFrame("ProbeResp");
388  Ieee80211ProbeResponseFrameBody& body = resp->getBody();
389  body.setSSID(ssid.c_str());
390  body.setSupportedRates(supportedRates);
391  body.setBeaconInterval(beaconInterval);
392  body.setChannelNumber(channelNumber);
393  sendManagementFrame(resp, staAddress);
394 }
int channelNumber
Definition: Ieee80211MgmtAP.h:74
std::string ssid
Definition: Ieee80211MgmtAP.h:73
virtual void dropManagementFrame(Ieee80211ManagementFrame *frame)
Utility method to dispose of an unhandled frame.
Definition: Ieee80211MgmtBase.cc:90
Ieee80211SupportedRatesElement supportedRates
Definition: Ieee80211MgmtAP.h:77
virtual void sendManagementFrame(Ieee80211ManagementFrame *frame, const MACAddress &destAddr)
Utility function: set fields in the given frame and send it out to the address.
Definition: Ieee80211MgmtAP.cc:131
simtime_t beaconInterval
Definition: Ieee80211MgmtAP.h:75
void inet::ieee80211::Ieee80211MgmtAP::handleProbeResponseFrame ( Ieee80211ProbeResponseFrame frame)
overrideprotectedvirtual

Implements inet::ieee80211::Ieee80211MgmtBase.

397 {
398  dropManagementFrame(frame);
399 }
virtual void dropManagementFrame(Ieee80211ManagementFrame *frame)
Utility method to dispose of an unhandled frame.
Definition: Ieee80211MgmtBase.cc:90
void inet::ieee80211::Ieee80211MgmtAP::handleReassociationRequestFrame ( Ieee80211ReassociationRequestFrame frame)
overrideprotectedvirtual

Implements inet::ieee80211::Ieee80211MgmtBase.

323 {
324  EV << "Processing ReassociationRequest frame\n";
325 
326  // "11.3.4 AP reassociation procedures" -- almost the same as AssociationRequest processing
327  STAInfo *sta = lookupSenderSTA(frame);
328  if (!sta || sta->status == NOT_AUTHENTICATED) {
329  // STA not authenticated: send error and return
330  Ieee80211DeauthenticationFrame *resp = new Ieee80211DeauthenticationFrame("Deauth");
331  resp->getBody().setReasonCode(RC_NONAUTH_ASS_REQUEST);
332  sendManagementFrame(resp, frame->getTransmitterAddress());
333  delete frame;
334  return;
335  }
336 
337  delete frame;
338 
339  // mark STA as associated
340  sta->status = ASSOCIATED; // XXX this should only take place when MAC receives the ACK for the response
341 
342  // send OK response
343  Ieee80211ReassociationResponseFrame *resp = new Ieee80211ReassociationResponseFrame("ReassocResp-OK");
344  Ieee80211ReassociationResponseFrameBody& body = resp->getBody();
345  body.setStatusCode(SC_SUCCESSFUL);
346  body.setAid(0); //XXX
347  body.setSupportedRates(supportedRates);
348  sendManagementFrame(resp, sta->address);
349 }
Ieee80211SupportedRatesElement supportedRates
Definition: Ieee80211MgmtAP.h:77
virtual STAInfo * lookupSenderSTA(Ieee80211ManagementFrame *frame)
Utility function: return sender STA&#39;s entry from our STA list, or nullptr if not in there...
Definition: Ieee80211MgmtAP.cc:125
Definition: Ieee80211MgmtFrames_m.h:175
Definition: Ieee80211MgmtAP.h:41
Definition: Ieee80211MgmtFrames_m.h:130
virtual void sendManagementFrame(Ieee80211ManagementFrame *frame, const MACAddress &destAddr)
Utility function: set fields in the given frame and send it out to the address.
Definition: Ieee80211MgmtAP.cc:131
void inet::ieee80211::Ieee80211MgmtAP::handleReassociationResponseFrame ( Ieee80211ReassociationResponseFrame frame)
overrideprotectedvirtual

Implements inet::ieee80211::Ieee80211MgmtBase.

352 {
353  dropManagementFrame(frame);
354 }
virtual void dropManagementFrame(Ieee80211ManagementFrame *frame)
Utility method to dispose of an unhandled frame.
Definition: Ieee80211MgmtBase.cc:90
void inet::ieee80211::Ieee80211MgmtAP::handleTimer ( cMessage *  msg)
overrideprotectedvirtual

Implements abstract Ieee80211MgmtBase method.

Implements inet::ieee80211::Ieee80211MgmtBase.

85 {
86  if (msg == beaconTimer) {
87  sendBeacon();
88  scheduleAt(simTime() + beaconInterval, beaconTimer);
89  }
90  else {
91  throw cRuntimeError("internal error: unrecognized timer '%s'", msg->getName());
92  }
93 }
cMessage * beaconTimer
Definition: Ieee80211MgmtAP.h:81
virtual void sendBeacon()
Utility function: creates and sends a beacon frame.
Definition: Ieee80211MgmtAP.cc:139
simtime_t beaconInterval
Definition: Ieee80211MgmtAP.h:75
void inet::ieee80211::Ieee80211MgmtAP::handleUpperMessage ( cPacket *  msg)
overrideprotectedvirtual

Implements abstract Ieee80211MgmtBase method.

Implements inet::ieee80211::Ieee80211MgmtBase.

96 {
97  Ieee80211DataFrame *frame = encapsulate(msg);
98  MACAddress macAddr = frame->getReceiverAddress();
99  if (!macAddr.isMulticast()) {
100  auto it = staList.find(macAddr);
101  if (it == staList.end() || it->second.status != ASSOCIATED) {
102  EV << "STA with MAC address " << macAddr << " not associated with this AP, dropping frame\n";
103  delete frame; // XXX count drops?
104  return;
105  }
106  }
107 
108  sendDown(frame);
109 }
STAList staList
list of STAs
Definition: Ieee80211MgmtAP.h:80
virtual Ieee80211DataFrame * encapsulate(cPacket *msg)
Utility function for handleUpperMessage()
Definition: Ieee80211MgmtAPBase.cc:170
virtual void sendDown(cPacket *frame)
Utility method for implementing handleUpperMessage(): send message to MAC.
Definition: Ieee80211MgmtBase.cc:84
Definition: Ieee80211MgmtAP.h:41
void inet::ieee80211::Ieee80211MgmtAP::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::ieee80211::Ieee80211MgmtAPBase.

52 {
54 
55  if (stage == INITSTAGE_LOCAL) {
56  // read params and init vars
57  ssid = par("ssid").stringValue();
58  beaconInterval = par("beaconInterval");
59  numAuthSteps = par("numAuthSteps");
60  if (numAuthSteps != 2 && numAuthSteps != 4)
61  throw cRuntimeError("parameter 'numAuthSteps' (number of frames exchanged during authentication) must be 2 or 4, not %d", numAuthSteps);
62  channelNumber = -1; // value will arrive from physical layer in receiveChangeNotification()
63  WATCH(ssid);
64  WATCH(channelNumber);
65  WATCH(beaconInterval);
66  WATCH(numAuthSteps);
67  WATCH_MAP(staList);
68 
69  //TBD fill in supportedRates
70 
71  // subscribe for notifications
72  cModule *radioModule = getModuleFromPar<cModule>(par("radioModule"), this);
73  radioModule->subscribe(Ieee80211Radio::radioChannelChangedSignal, this);
74 
75  // start beacon timer (randomize startup time)
76  beaconTimer = new cMessage("beaconTimer");
77  }
78  else if (stage == INITSTAGE_LINK_LAYER) {
79  if (isOperational)
80  scheduleAt(simTime() + uniform(0, beaconInterval), beaconTimer);
81  }
82 }
STAList staList
list of STAs
Definition: Ieee80211MgmtAP.h:80
int channelNumber
Definition: Ieee80211MgmtAP.h:74
std::string ssid
Definition: Ieee80211MgmtAP.h:73
int numAuthSteps
Definition: Ieee80211MgmtAP.h:76
cMessage * beaconTimer
Definition: Ieee80211MgmtAP.h:81
virtual void initialize(int) override
Definition: Ieee80211MgmtAPBase.cc:30
Local initializations.
Definition: InitStages.h:35
Initialization of link-layer protocols.
Definition: InitStages.h:59
bool isOperational
Definition: Ieee80211MgmtBase.h:42
static simsignal_t radioChannelChangedSignal
This signal is emitted every time the radio channel changes.
Definition: Ieee80211Radio.h:40
simtime_t beaconInterval
Definition: Ieee80211MgmtAP.h:75
Ieee80211MgmtAP::STAInfo * inet::ieee80211::Ieee80211MgmtAP::lookupSenderSTA ( Ieee80211ManagementFrame frame)
protectedvirtual

Utility function: return sender STA's entry from our STA list, or nullptr if not in there.

126 {
127  auto it = staList.find(frame->getTransmitterAddress());
128  return it == staList.end() ? nullptr : &(it->second);
129 }
STAList staList
list of STAs
Definition: Ieee80211MgmtAP.h:80
virtual int inet::ieee80211::Ieee80211MgmtAP::numInitStages ( ) const
inlineoverrideprotectedvirtual

Reimplemented from inet::ieee80211::Ieee80211MgmtAPBase.

88 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::ieee80211::Ieee80211MgmtAP::receiveSignal ( cComponent *  source,
simsignal_t  signalID,
long  value,
cObject *  details 
)
overrideprotectedvirtual

Called by the signal handler whenever a change occurs we're interested in.

117 {
118  Enter_Method_Silent();
120  EV << "updating channel number\n";
121  channelNumber = value;
122  }
123 }
int channelNumber
Definition: Ieee80211MgmtAP.h:74
static simsignal_t radioChannelChangedSignal
This signal is emitted every time the radio channel changes.
Definition: Ieee80211Radio.h:40
void inet::ieee80211::Ieee80211MgmtAP::sendAssocNotification ( const MACAddress addr)
protected
402 {
403  NotificationInfoSta notif;
404  notif.setApAddress(myAddress);
405  notif.setStaAddress(addr);
406  emit(NF_L2_AP_ASSOCIATED, &notif);
407 }
MACAddress myAddress
Definition: Ieee80211MgmtBase.h:41
simsignal_t NF_L2_AP_ASSOCIATED
Definition: NotifierConsts.cc:40
void inet::ieee80211::Ieee80211MgmtAP::sendBeacon ( )
protectedvirtual

Utility function: creates and sends a beacon frame.

140 {
141  EV << "Sending beacon\n";
142  Ieee80211BeaconFrame *frame = new Ieee80211BeaconFrame("Beacon");
143  Ieee80211BeaconFrameBody& body = frame->getBody();
144  body.setSSID(ssid.c_str());
145  body.setSupportedRates(supportedRates);
146  body.setBeaconInterval(beaconInterval);
147  body.setChannelNumber(channelNumber);
148  body.setBodyLength(8 + 2 + 2 + (2 + ssid.length()) + (2 + supportedRates.numRates));
149 
150  frame->setByteLength(28 + body.getBodyLength());
151  frame->setReceiverAddress(MACAddress::BROADCAST_ADDRESS);
152  frame->setFromDS(true);
153 
154  sendDown(frame);
155 }
int channelNumber
Definition: Ieee80211MgmtAP.h:74
std::string ssid
Definition: Ieee80211MgmtAP.h:73
virtual void sendDown(cPacket *frame)
Utility method for implementing handleUpperMessage(): send message to MAC.
Definition: Ieee80211MgmtBase.cc:84
Ieee80211SupportedRatesElement supportedRates
Definition: Ieee80211MgmtAP.h:77
short numRates
Definition: Ieee80211MgmtFrames_m.h:219
simtime_t beaconInterval
Definition: Ieee80211MgmtAP.h:75
static const MACAddress BROADCAST_ADDRESS
The broadcast MAC address, ff:ff:ff:ff:ff:ff.
Definition: MACAddress.h:60
void inet::ieee80211::Ieee80211MgmtAP::sendDisAssocNotification ( const MACAddress addr)
protected
410 {
411  NotificationInfoSta notif;
412  notif.setApAddress(myAddress);
413  notif.setStaAddress(addr);
414  emit(NF_L2_AP_DISASSOCIATED, &notif);
415 }
simsignal_t NF_L2_AP_DISASSOCIATED
Definition: NotifierConsts.cc:41
MACAddress myAddress
Definition: Ieee80211MgmtBase.h:41
void inet::ieee80211::Ieee80211MgmtAP::sendManagementFrame ( Ieee80211ManagementFrame frame,
const MACAddress destAddr 
)
protectedvirtual

Utility function: set fields in the given frame and send it out to the address.

132 {
133  frame->setFromDS(true);
134  frame->setReceiverAddress(destAddr);
135  frame->setAddress3(myAddress);
136  sendDown(frame);
137 }
virtual void sendDown(cPacket *frame)
Utility method for implementing handleUpperMessage(): send message to MAC.
Definition: Ieee80211MgmtBase.cc:84
MACAddress myAddress
Definition: Ieee80211MgmtBase.h:41
void inet::ieee80211::Ieee80211MgmtAP::start ( )
overrideprotectedvirtual

lifecycle support

Reimplemented from inet::ieee80211::Ieee80211MgmtBase.

418 {
420  scheduleAt(simTime() + uniform(0, beaconInterval), beaconTimer);
421 }
virtual void start()
lifecycle support
Definition: Ieee80211MgmtBase.cc:187
cMessage * beaconTimer
Definition: Ieee80211MgmtAP.h:81
simtime_t beaconInterval
Definition: Ieee80211MgmtAP.h:75
void inet::ieee80211::Ieee80211MgmtAP::stop ( )
overrideprotectedvirtual

Reimplemented from inet::ieee80211::Ieee80211MgmtBase.

424 {
425  cancelEvent(beaconTimer);
426  staList.clear();
428 }
STAList staList
list of STAs
Definition: Ieee80211MgmtAP.h:80
cMessage * beaconTimer
Definition: Ieee80211MgmtAP.h:81
virtual void stop()
Definition: Ieee80211MgmtBase.cc:192

Member Data Documentation

simtime_t inet::ieee80211::Ieee80211MgmtAP::beaconInterval
protected
cMessage* inet::ieee80211::Ieee80211MgmtAP::beaconTimer = nullptr
protected
int inet::ieee80211::Ieee80211MgmtAP::channelNumber = -1
protected
int inet::ieee80211::Ieee80211MgmtAP::numAuthSteps = 0
protected
std::string inet::ieee80211::Ieee80211MgmtAP::ssid
protected
STAList inet::ieee80211::Ieee80211MgmtAP::staList
protected

list of STAs

Ieee80211SupportedRatesElement inet::ieee80211::Ieee80211MgmtAP::supportedRates
protected

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