#include <Ieee80211AgentSTA.h>
Inheritance diagram for Ieee80211AgentSTA:

See corresponding NED file for a detailed description.
|
|
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 }
|
|
|
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 }
|
|
|
Overridden cSimpleModule method 00055 {
00056 if (msg->isSelfMessage())
00057 handleTimer(msg);
00058 else
00059 handleResponse(msg);
00060 }
|
|
|
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 }
|
|
|
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 }
|
|
|
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 }
|
|
|
00049 {return 2;}
|
|
|
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 }
|
|
|
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 }
|
|
|
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 }
|
|
|
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 }
|
|
||||||||||||
|
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 }
|
|
|
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 }
|
|
|
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 }
|
|
||||||||||||
|
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 }
|
|
||||||||||||
|
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 }
|
|
|
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 }
|
|
|
00114 {
00115 cMessage *msg = new cMessage(req->className());
00116 msg->setControlInfo(req);
00117 send(msg, "mgmtOut");
00118 }
|
|
|
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 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.4.0