Ieee80211AgentSTA Class Reference

#include <Ieee80211AgentSTA.h>

Inheritance diagram for Ieee80211AgentSTA:

INotifiable List of all members.

Detailed Description

Used in 802.11 infrastructure mode: in a station (STA), this module controls channel scanning, association and handovers, by sending commands (e.g. Ieee80211Prim_ScanRequest) to the management module (Ieee80211MgmtSTA).

See corresponding NED file for a detailed description.

Author:
Andras Varga


Protected Member Functions

virtual int numInitStages () const
virtual void initialize (int)
virtual void handleMessage (cMessage *msg)
virtual void handleTimer (cMessage *msg)
virtual void handleResponse (cMessage *msg)
virtual void receiveChangeNotification (int category, cPolymorphic *details)
virtual void sendRequest (Ieee80211PrimRequest *req)
virtual int chooseBSS (Ieee80211Prim_ScanConfirm *resp)
virtual void dumpAPList (Ieee80211Prim_ScanConfirm *resp)
virtual void sendScanRequest ()
virtual void sendAuthenticateRequest (const MACAddress &address)
virtual void sendDeauthenticateRequest (const MACAddress &address, int reasonCode)
virtual void sendAssociateRequest (const MACAddress &address)
virtual void sendReassociateRequest (const MACAddress &address)
virtual void sendDisassociateRequest (const MACAddress &address, int reasonCode)
virtual void processScanConfirm (Ieee80211Prim_ScanConfirm *resp)
virtual void processAuthenticateConfirm (Ieee80211Prim_AuthenticateConfirm *resp)
virtual void processAssociateConfirm (Ieee80211Prim_AssociateConfirm *resp)
virtual void processReassociateConfirm (Ieee80211Prim_ReassociateConfirm *resp)

Protected Attributes

bool activeScan
std::vector< int > channelsToScan
double probeDelay
double minChannelTime
double maxChannelTime
double authenticationTimeout
double associationTimeout


Member Function Documentation

int Ieee80211AgentSTA::chooseBSS ( Ieee80211Prim_ScanConfirm resp  )  [protected, virtual]

Choose one AP from the list to associate with

00219 {
00220     if (resp->getBssListArraySize()==0)
00221         return -1;
00222 
00223     // here, just choose the one with the greatest receive power
00224     // TODO and which supports a good data rate we support
00225     int bestIndex = 0;
00226     for (int i=0; i<resp->getBssListArraySize(); i++)
00227         if (resp->getBssList(i).getRxPower() > resp->getBssList(bestIndex).getRxPower())
00228             bestIndex = i;
00229     return bestIndex;
00230 }

void Ieee80211AgentSTA::dumpAPList ( Ieee80211Prim_ScanConfirm resp  )  [protected, virtual]

00202 {
00203     EV << "Received AP list:\n";
00204     for (int i=0; i<resp->getBssListArraySize(); i++)
00205     {
00206         Ieee80211Prim_BSSDescription& bssDesc = resp->getBssList(i);
00207         EV << "    " << i << ". "
00208            << " address=" << bssDesc.getBSSID()
00209            << " channel=" << bssDesc.getChannelNumber()
00210            << " SSID=" << bssDesc.getSSID()
00211            << " beaconIntvl=" << bssDesc.getBeaconInterval()
00212            << " rxPower=" << bssDesc.getRxPower()
00213            << endl;
00214         // later: supportedRates
00215     }
00216 }

void Ieee80211AgentSTA::handleMessage ( cMessage *  msg  )  [protected, virtual]

Overridden cSimpleModule method

00055 {
00056     if (msg->isSelfMessage())
00057         handleTimer(msg);
00058     else
00059         handleResponse(msg);
00060 }

void Ieee80211AgentSTA::handleResponse ( cMessage *  msg  )  [protected, virtual]

Handle responses from mgmgt

00077 {
00078     cPolymorphic *ctrl = msg->removeControlInfo();
00079     delete msg;
00080 
00081     EV << "Processing confirmation from mgmt: " << ctrl->className() << "\n";
00082 
00083     if (dynamic_cast<Ieee80211Prim_ScanConfirm *>(ctrl))
00084         processScanConfirm((Ieee80211Prim_ScanConfirm *)ctrl);
00085     else if (dynamic_cast<Ieee80211Prim_AuthenticateConfirm *>(ctrl))
00086         processAuthenticateConfirm((Ieee80211Prim_AuthenticateConfirm *)ctrl);
00087     else if (dynamic_cast<Ieee80211Prim_AssociateConfirm *>(ctrl))
00088         processAssociateConfirm((Ieee80211Prim_AssociateConfirm *)ctrl);
00089     else if (dynamic_cast<Ieee80211Prim_ReassociateConfirm *>(ctrl))
00090         processReassociateConfirm((Ieee80211Prim_ReassociateConfirm *)ctrl);
00091     else if (ctrl)
00092         error("handleResponse(): unrecognized control info class `%s'", ctrl->className());
00093     else
00094         error("handleResponse(): control info is NULL");
00095     delete ctrl;
00096 }

void Ieee80211AgentSTA::handleTimer ( cMessage *  msg  )  [protected, virtual]

Handle timers

00063 {
00064     if (msg->kind()==MK_STARTUP)
00065     {
00066         EV << "Starting up\n";
00067         sendScanRequest();
00068         delete msg;
00069     }
00070     else
00071     {
00072         error("internal error: unrecognized timer '%s'", msg->name());
00073     }
00074 }

void Ieee80211AgentSTA::initialize ( int   )  [protected, virtual]

00031 {
00032     if (stage==0)
00033     {
00034         // read parameters
00035         activeScan = par("activeScan");
00036         probeDelay = par("probeDelay");
00037         minChannelTime = par("minChannelTime");
00038         maxChannelTime = par("maxChannelTime");
00039         authenticationTimeout = par("authenticationTimeout");
00040         associationTimeout = par("associationTimeout");
00041         cStringTokenizer tokenizer(par("channelsToScan"));
00042         const char *token;
00043         while ((token = tokenizer.nextToken())!=NULL)
00044             channelsToScan.push_back(atoi(token));
00045 
00046         NotificationBoard *nb = NotificationBoardAccess().get();
00047         nb->subscribe(this, NF_L2_BEACON_LOST);
00048 
00049         // start up: send scan request
00050         scheduleAt(simTime(), new cMessage("startUp", MK_STARTUP));
00051     }
00052 }

virtual int Ieee80211AgentSTA::numInitStages (  )  const [inline, protected, virtual]

00049 {return 2;}

void Ieee80211AgentSTA::processAssociateConfirm ( Ieee80211Prim_AssociateConfirm resp  )  [protected, virtual]

00250 {
00251     if (resp->getResultCode()!=PRC_SUCCESS)
00252     {
00253         EV << "Association error\n";
00254 
00255         // try scanning again, maybe we'll have better luck next time, possibly with a different AP
00256         EV << "Going back to scanning\n";
00257         sendScanRequest();
00258     }
00259     else
00260     {
00261         EV << "Association successful\n";
00262         // we are happy!
00263         parentModule()->parentModule()->bubble("Associated with AP");
00264     }
00265 }

void Ieee80211AgentSTA::processAuthenticateConfirm ( Ieee80211Prim_AuthenticateConfirm resp  )  [protected, virtual]

00233 {
00234     if (resp->getResultCode()!=PRC_SUCCESS)
00235     {
00236         EV << "Authentication error\n";
00237 
00238         // try scanning again, maybe we'll have better luck next time, possibly with a different AP
00239         EV << "Going back to scanning\n";
00240         sendScanRequest();
00241     }
00242     else
00243     {
00244         EV << "Authentication successful, let's try to associate\n";
00245         sendAssociateRequest(resp->getAddress());
00246     }
00247 }

void Ieee80211AgentSTA::processReassociateConfirm ( Ieee80211Prim_ReassociateConfirm resp  )  [protected, virtual]

00268 {
00269     // treat the same way as AssociateConfirm
00270     if (resp->getResultCode()!=PRC_SUCCESS)
00271     {
00272         EV << "Reassociation error\n";
00273         EV << "Going back to scanning\n";
00274         sendScanRequest();
00275     }
00276     else
00277     {
00278         EV << "Reassociation successful\n";
00279         // we are happy!
00280     }
00281 }

void Ieee80211AgentSTA::processScanConfirm ( Ieee80211Prim_ScanConfirm resp  )  [protected, virtual]

Processing Confirm primitives

00184 {
00185     // choose best AP
00186     int bssIndex = chooseBSS(resp);
00187     if (bssIndex==-1)
00188     {
00189         EV << "No (suitable) AP found, continue scanning\n";
00190         sendScanRequest();
00191         return;
00192     }
00193 
00194     dumpAPList(resp);
00195 
00196     Ieee80211Prim_BSSDescription& bssDesc = resp->getBssList(bssIndex);
00197     EV << "Chosen AP address=" << bssDesc.getBSSID() << " from list, starting authentication\n";
00198     sendAuthenticateRequest(bssDesc.getBSSID());
00199 }

void Ieee80211AgentSTA::receiveChangeNotification ( int  category,
cPolymorphic *  details 
) [protected, virtual]

Redefined from INotifiable; called by NotificationBoard

Implements INotifiable.

00099 {
00100     Enter_Method_Silent();
00101     printNotificationBanner(category, details);
00102 
00103     if (category == NF_L2_BEACON_LOST)
00104     {
00105         //XXX should check details if it's about this NIC
00106         EV << "beacon lost, starting scanning again\n";
00107         parentModule()->parentModule()->bubble("Beacon lost!");
00108         //sendDisassociateRequest();
00109         sendScanRequest();
00110     }
00111 }

void Ieee80211AgentSTA::sendAssociateRequest ( const MACAddress address  )  [protected, virtual]

00157 {
00158     EV << "Sending AssociateRequest primitive to mgmt\n";
00159     Ieee80211Prim_AssociateRequest *req = new Ieee80211Prim_AssociateRequest();
00160     req->setAddress(address);
00161     req->setTimeout(associationTimeout);
00162     sendRequest(req);
00163 }

void Ieee80211AgentSTA::sendAuthenticateRequest ( const MACAddress address  )  [protected, virtual]

00139 {
00140     EV << "Sending AuthenticateRequest primitive to mgmt\n";
00141     Ieee80211Prim_AuthenticateRequest *req = new Ieee80211Prim_AuthenticateRequest();
00142     req->setAddress(address);
00143     req->setTimeout(authenticationTimeout);
00144     sendRequest(req);
00145 }

void Ieee80211AgentSTA::sendDeauthenticateRequest ( const MACAddress address,
int  reasonCode 
) [protected, virtual]

00148 {
00149     EV << "Sending DeauthenticateRequest primitive to mgmt\n";
00150     Ieee80211Prim_DeauthenticateRequest *req = new Ieee80211Prim_DeauthenticateRequest();
00151     req->setAddress(address);
00152     req->setReasonCode(reasonCode);
00153     sendRequest(req);
00154 }

void Ieee80211AgentSTA::sendDisassociateRequest ( const MACAddress address,
int  reasonCode 
) [protected, virtual]

00175 {
00176     EV << "Sending DisassociateRequest primitive to mgmt\n";
00177     Ieee80211Prim_DisassociateRequest *req = new Ieee80211Prim_DisassociateRequest();
00178     req->setAddress(address);
00179     req->setReasonCode(reasonCode);
00180     sendRequest(req);
00181 }

void Ieee80211AgentSTA::sendReassociateRequest ( const MACAddress address  )  [protected, virtual]

00166 {
00167     EV << "Sending ReassociateRequest primitive to mgmt\n";
00168     Ieee80211Prim_ReassociateRequest *req = new Ieee80211Prim_ReassociateRequest();
00169     req->setAddress(address);
00170     req->setTimeout(associationTimeout);
00171     sendRequest(req);
00172 }

void Ieee80211AgentSTA::sendRequest ( Ieee80211PrimRequest req  )  [protected, virtual]

00114 {
00115     cMessage *msg = new cMessage(req->className());
00116     msg->setControlInfo(req);
00117     send(msg, "mgmtOut");
00118 }

void Ieee80211AgentSTA::sendScanRequest (  )  [protected, virtual]

Sending of Request primitives

00122 {
00123     EV << "Sending ScanRequest primitive to mgmt\n";
00124     Ieee80211Prim_ScanRequest *req = new Ieee80211Prim_ScanRequest();
00125     req->setBSSType(BSSTYPE_INFRASTRUCTURE);
00126     req->setActiveScan(activeScan);
00127     req->setProbeDelay(probeDelay);
00128     req->setMinChannelTime(minChannelTime);
00129     req->setMaxChannelTime(maxChannelTime);
00130     req->setChannelListArraySize(channelsToScan.size());
00131     for (int i=0; i<channelsToScan.size(); i++)
00132         req->setChannelList(i, channelsToScan[i]);
00133     //XXX BSSID, SSID are left at default ("any")
00134 
00135     sendRequest(req);
00136 }


Member Data Documentation

bool Ieee80211AgentSTA::activeScan [protected]

double Ieee80211AgentSTA::associationTimeout [protected]

double Ieee80211AgentSTA::authenticationTimeout [protected]

std::vector<int> Ieee80211AgentSTA::channelsToScan [protected]

double Ieee80211AgentSTA::maxChannelTime [protected]

double Ieee80211AgentSTA::minChannelTime [protected]

double Ieee80211AgentSTA::probeDelay [protected]


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:20:20 2007 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.7