📄 ssscheduler.cc
字号:
case WimaxLostDLMAPTimerID: mac_->debug ("At %f in Mac %d, lost synchronization (DL_MAP)\n", NOW, mac_->addr()); lost_synch (); break; case WimaxT1TimerID: mac_->debug ("At %f in Mac %d, lost synchronization (DCD)\n", NOW, mac_->addr()); lost_synch (); break; case WimaxLostULMAPTimerID: mac_->debug ("At %f in Mac %d, lost synchronization (UL_MAP)\n", NOW, mac_->addr()); lost_synch (); break; case WimaxT12TimerID: mac_->debug ("At %f in Mac %d, lost uplink param (UCD)\n", NOW, mac_->addr()); lost_synch (); break; case WimaxT2TimerID: mac_->debug ("At %f in Mac %d, lost synchronization (RNG)\n", NOW, mac_->addr()); map_->getUlSubframe()->getRanging()->removeRequest (); lost_synch (); break; case WimaxT3TimerID: mac_->debug ("At %f in Mac %d, no response from BS\n", NOW, mac_->addr()); //we reach the maximum number of retries //mark DL channel usuable (i.e we go to next) map_->getUlSubframe()->getRanging()->removeRequest (); mac_->nextChannel(); lost_synch (); break; case WimaxT6TimerID: mac_->debug ("At %f in Mac %d, registration timeout (nbretry=%d)\n", NOW, mac_->addr(), nb_reg_retry_); if (nb_reg_retry_ == mac_->macmib_.reg_req_retry) { mac_->debug ("\tmax retry excedeed\n"); lost_synch (); } else { send_registration(); } break; case WimaxT44TimerID: mac_->debug ("At %f in Mac %d, did not receive MOB_SCN-RSP (nb_retry=%d)\n", NOW, mac_->addr(), nb_scan_req_); if (nb_scan_req_ <= mac_->macmib_.scan_req_retry) { send_scan_request (); } else { //reset for next time nb_scan_req_ = 0; } break; case WimaxScanIntervalTimerID: pause_scanning (); break; case WimaxRdvTimerID: //we need to meet at another station. We cancel the current scanning //lost_synch (); mac_->debug ("At %f in Mac %d Rdv timer expired\n", NOW, mac_->addr()); break; default: mac_->debug ("Trigger unkown\n"); }}/**** Packet processing methods ****//** * Process a DL_MAP message * @param frame The dl_map information */void SSscheduler::process_dl_map (mac802_16_dl_map_frame *frame){ assert (frame); //create an entry for the BS if (mac_->getPeerNode (frame->bsid)==NULL) mac_->addPeerNode (new PeerNode (frame->bsid)); map_->parseDLMAPframe (frame); if (mac_->getMacState()==MAC802_16_WAIT_DL_SYNCH) { mac_->debug ("At %f in %d, received DL_MAP for synch from %d (substate=%d)\n", NOW, mac_->addr(), frame->bsid,scan_info_->substate); assert (t21timer_->busy()!=0); //synchronization is done t21timer_->stop(); //start lost_dl_map lostDLMAPtimer_->start (mac_->macmib_.lost_dlmap_interval); //start T1: DCD t1timer_->start (mac_->macmib_.t1_timeout); //start T12: UCD t12timer_->start (mac_->macmib_.t12_timeout);#ifdef USE_802_21 mac_->debug ("At %f in Mac %d, send link detected\n", NOW, mac_->addr()); mac_->send_link_detected (mac_->addr(), frame->bsid, 1);#endif mac_->setMacState(MAC802_16_WAIT_DL_SYNCH_DCD); //if I am doing handoff and we have dcd/ucd information //from scanning, use it if (scan_info_->substate == HANDOVER || scan_info_->substate == SCANNING) { if (scan_info_->substate == SCANNING) { if (scan_info_->nbr == NULL || scan_info_->nbr->getID()!=frame->bsid) { //check if an entry already exist in the database scan_info_->nbr = nbr_db_->getNeighbor (frame->bsid); if (scan_info_->nbr == NULL) { //create entry debug2 ("Creating nbr info for node %d\n", frame->bsid); scan_info_->nbr = new NeighborEntry (frame->bsid); nbr_db_->addNeighbor (scan_info_->nbr); } else { debug2 ("loaded nbr info\n"); if (scan_info_->nbr->isDetected ()) { //we already synchronized with this AP...skip channel mac_->nextChannel(); lost_synch (); return; } } } }//if HANDOVER, scan_info_->nbr is already set bool error = false; //we check if we can read the DL_MAP mac802_16_dcd_frame *dcd = scan_info_->nbr->getDCD(); if (dcd!=NULL) { debug2 ("Check if we can decode stored dcd\n"); //check if we can decode dl_map with previously acquired dcd bool found; for (int i = 0 ; !error && i < map_->getDlSubframe()->getPdu()->getNbBurst() ; i++) { int diuc = map_->getDlSubframe()->getPdu()->getBurst(i)->getIUC(); if (diuc == DIUC_END_OF_MAP) continue; found = false; for (u_int32_t j = 0 ; !found && j < dcd->nb_prof; j++) { found = dcd->profiles[j].diuc==diuc; } error = !found; } if (!error) process_dcd (dcd); } else { debug2 ("No DCD information found\n"); } } } else { //maintain synchronization assert (lostDLMAPtimer_->busy()); lostDLMAPtimer_->stop(); //printf ("update dlmap timer\n"); lostDLMAPtimer_->start (mac_->macmib_.lost_dlmap_interval); if (mac_->getMacState()!= MAC802_16_WAIT_DL_SYNCH_DCD && mac_->getMacState()!=MAC802_16_UL_PARAM) { //since the map may have changed, we need to adjust the timer //for the DLSubframe double stime = map_->getStarttime(); stime += map_->getDlSubframe()->getPdu()->getBurst(1)->getStarttime()*mac_->getPhy()->getSymbolTime(); //printf ("received dl..needs to update expiration to %f, %f,%f\n", stime, NOW,map_->getStarttime()); map_->getDlSubframe()->getTimer()->resched (stime-NOW); dl_timer_->resched (map_->getStarttime()+mac_->getFrameDuration()-NOW); } }}/** * Process a DCD message * @param frame The dcd information */void SSscheduler::process_dcd (mac802_16_dcd_frame *frame){ if (mac_->getMacState()==MAC802_16_WAIT_DL_SYNCH) { //we are waiting for DL_MAP, ignore this message return; } map_->parseDCDframe (frame); if (mac_->getMacState()==MAC802_16_WAIT_DL_SYNCH_DCD) { mac_->debug ("At %f in %d, received DCD for synch\n", NOW, mac_->addr()); //now I have all information such as frame duration //adjust timing in case the frame we received the DL_MAP //and the DCD is different while (NOW - map_->getStarttime () > mac_->getFrameDuration()) { map_->setStarttime (map_->getStarttime()+mac_->getFrameDuration()); } //store information to be used during potential handoff if (scan_info_->substate == SCANNING) { mac802_16_dcd_frame *tmp = (mac802_16_dcd_frame *) malloc (sizeof (mac802_16_dcd_frame)); memcpy (tmp, frame, sizeof (mac802_16_dcd_frame)); mac802_16_dcd_frame *old = scan_info_->nbr->getDCD(); if (frame == old) frame = tmp; if (old) free (old); //free previous entry scan_info_->nbr->setDCD(tmp); //set new one } mac_->setMacState(MAC802_16_UL_PARAM); //we can schedule next frame //printf ("SS schedule next frame at %f\n", map_->getStarttime()+mac_->getFrameDuration()); //dl_timer_->sched (map_->getStarttime()+mac_->getFrameDuration()-NOW); } if (t1timer_->busy()!=0) { //we were waiting for this packet t1timer_->stop(); t1timer_->start (mac_->macmib_.t1_timeout); }}/** * Process a UCD message * @param frame The ucd information */void SSscheduler::process_ucd (mac802_16_ucd_frame *frame){ if (mac_->getMacState()==MAC802_16_WAIT_DL_SYNCH ||mac_->getMacState()==MAC802_16_WAIT_DL_SYNCH_DCD) { //discard the packet return; } assert (t12timer_->busy()!=0); //we are waiting for this packet if (mac_->getMacState()==MAC802_16_UL_PARAM) { //check if uplink channel usable mac_->debug ("At %f in %d, received UL(UCD) parameters\n", NOW, mac_->addr()); //start T2: ranging t2timer_->start (mac_->macmib_.t2_timeout); //start Lost UL-MAP lostULMAPtimer_->start (mac_->macmib_.lost_ulmap_interval); //store information to be used during potential handoff if (scan_info_->substate == SCANNING) { mac802_16_ucd_frame *tmp = (mac802_16_ucd_frame *) malloc (sizeof (mac802_16_ucd_frame)); memcpy (tmp, frame, sizeof (mac802_16_ucd_frame)); mac802_16_ucd_frame *old = scan_info_->nbr->getUCD(); if (frame == old) frame = tmp; if (old) free (old); //free previous entry scan_info_->nbr->setUCD(tmp); //set new one } //change state mac_->setMacState (MAC802_16_RANGING); } //reset T12 t12timer_->stop(); t12timer_->start (mac_->macmib_.t12_timeout); map_->parseUCDframe (frame);}/** * Process a UL_MAP message * @param frame The ul_map information */void SSscheduler::process_ul_map (mac802_16_ul_map_frame *frame){ if (mac_->getMacState()==MAC802_16_WAIT_DL_SYNCH || mac_->getMacState()==MAC802_16_WAIT_DL_SYNCH_DCD) { //discard the packet return; } if (mac_->getMacState()==MAC802_16_UL_PARAM) { if (scan_info_->substate == HANDOVER || scan_info_->substate==SCANNING) { FrameMap *tmpMap = new FrameMap (mac_); tmpMap->parseULMAPframe (frame); //printf ("Checking if we can read UL_MAP\n"); bool error = false; //we check if we can read the UL_MAP mac802_16_ucd_frame *ucd = scan_info_->nbr->getUCD(); if (ucd!=NULL) { //check if we can decode ul_map with previously acquired ucd bool found; for (int i = 0 ; !error && i < tmpMap->getUlSubframe()->getNbPdu() ; i++) { UlBurst *b = (UlBurst*)tmpMap->getUlSubframe()->getPhyPdu(i)->getBurst(0); int uiuc = b->getIUC(); if (uiuc == UIUC_END_OF_MAP) continue; if (uiuc == UIUC_EXT_UIUC && b->getExtendedUIUC ()== UIUC_FAST_RANGING) uiuc = b->getFastRangingUIUC(); found = false; for (u_int32_t j = 0 ; !found && j < ucd->nb_prof; j++) { //printf ("\t prof=%d, search=%d\n", ucd->profiles[j].uiuc, uiuc); found = ucd->profiles[j].uiuc==uiuc; } error = !found; } if (!error) process_ucd (ucd); } delete (tmpMap); if (error) { //we cannot read message return; } } else return; } if (scan_info_->substate == SCANNING) { //TBD: add checking scanning type for the given station u_char scanning_type = 0; for (int i = 0 ; i < scan_info_->rsp->n_recommended_bs_full ; i++) { if (scan_info_->rsp->rec_bs_full[i].recommended_bs_id == scan_info_->nbr->getID()) { scanning_type = scan_info_->rsp->rec_bs_full[i].scanning_type; break; } } if (scanning_type == 0) { //store information about possible base station and keep scanning scan_info_->nbr->getState()->state_info= mac_->backup_state(); mac_->debug ("At %f in Mac %d bs %d detected during scanning\n", NOW, mac_->addr(), scan_info_->nbr->getID()); scan_info_->nbr->setDetected (true); mac_->nextChannel(); lost_synch (); return; } } map_->parseULMAPframe (frame); if (mac_->getMacState()==MAC802_16_RANGING) { //execute ranging assert (t2timer_->busy()!=0); //we are waiting for this packet init_ranging (); } //schedule when to take care of outgoing packets double start = map_->getStarttime(); start += map_->getUlSubframe()->getStarttime()*mac_->getPhy()->getPS(); //offset for ul subframe start -= NOW; //works with relative time not absolute debug2 ("Uplink starts in %f (framestate=%f) %f %f\n", start, map_->getStarttime(), mac_->getFrameDuration()/mac_->getPhy()->getPS(), mac_->getFrameDuration()/mac_->getPhy()->getSymbolTime()); ul_timer_->resched (start); //reset Lost UL-Map lostULMAPtimer_->stop(); lostULMAPtimer_->start (mac_->macmib_.lost_ulmap_interval);}/** * Process a ranging response message * @param frame The ranging response frame */void SSscheduler::process_ranging_rsp (mac802_16_rng_rsp_frame *frame){ //check the destination if (frame->ss_mac_address != mac_->addr()) return; Connection *basic, *primary; PeerNode *peer;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -