⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bsscheduler.cc

📁 Ns2下Wimax的代码
💻 CC
📖 第 1 页 / 共 2 页
字号:
    ch->txtime() = txtime;    txtime_s = (int) ceil(txtime/phy->getSymbolTime ()); //in units of symbol    assert ((dlduration+db->getDuration()+txtime_s) <= maxdlduration); //if this occurs, increase dlratio    db->setDuration (db->getDuration()+txtime_s);  }    //check if we have additional packets in the broadcast queue  if (mac_->getCManager()->get_connection (BROADCAST_CID, OUT_CONNECTION)->queueByteLength()>0) {    //printf ("Additional %d packet(s) in Broadcast\n", mac_->getCManager()->get_connection (BROADCAST_CID, OUT_CONNECTION)->queueLength());    //other packets to send, increase the broadcast duration    txtime = phy->getTrxSymbolTime (mac_->getCManager()->get_connection (BROADCAST_CID, OUT_CONNECTION)->queueByteLength(), map->getDlSubframe()->getProfile (db->getIUC())->getEncoding());    txtime_s = (int) round(txtime/phy->getSymbolTime ()); //in units of symbol. We add one to create a small gap between bursts    if (txtime_s <= maxdlduration-dlduration-db->getDuration()) {      db->setDuration (db->getDuration()+txtime_s);    } else {      //fill up the rest      db->setDuration (maxdlduration-dlduration);    }  }  dlduration += db->getDuration ()+1; //add 1 OFDM symbol between padding (to avoid collisions)  //First implementation, return the CIDs in a RR fashion  peer = mac_->getPeerNode (nextDL_);  if (peer == NULL) //if the node is not here, lets start from the beginning    peer = mac_->getPeerNode_head();  if (peer) {    for (int i=0; i<mac_->getNbPeerNodes() && dlduration < maxdlduration ;i++) {      //for each node, the order is as follows:      //basic, primary, secondary, data      if (peer->getBasic(OUT_CONNECTION) && peer->getBasic(OUT_CONNECTION)->queueByteLength()>0) {	dlduration = addDlBurst (nbdlbursts++, peer->getBasic(OUT_CONNECTION), peer->getDIUC(), dlduration, maxdlduration);      }      if (peer->getPrimary(OUT_CONNECTION) && peer->getPrimary(OUT_CONNECTION)->queueByteLength()>0 && dlduration < maxdlduration) {	dlduration = addDlBurst (nbdlbursts++, peer->getPrimary(OUT_CONNECTION), peer->getDIUC(), dlduration, maxdlduration);      }      if (peer->getSecondary(OUT_CONNECTION) && peer->getSecondary(OUT_CONNECTION)->queueByteLength()>0 && dlduration < maxdlduration) {	dlduration = addDlBurst (nbdlbursts++, peer->getSecondary(OUT_CONNECTION), peer->getDIUC(), dlduration, maxdlduration);      }      if (peer->getOutData() && peer->getOutData()->queueByteLength()>0 && dlduration < maxdlduration) {	dlduration = addDlBurst (nbdlbursts++, peer->getOutData(), peer->getDIUC(), dlduration, maxdlduration);      }      peer = peer->next_entry();      if (peer == NULL)        peer = mac_->getPeerNode_head();      if (peer)	nextDL_ = peer->getAddr(); //go to next one      else	nextDL_ = -1; //will go the the beginning of the list    }  }  assert (dlduration <= maxdlduration);  //3-Add the End of map element  db = (DlBurst*) map->getDlSubframe()->getPdu ()->addBurst (nbdlbursts);  db->setIUC (DIUC_END_OF_MAP);  db->setStarttime (maxdlduration);  //Start the Uplink allocation  //4-Set start time for uplink subframe and clean previous allocation  mac_->getMap()->getUlSubframe()->setStarttime (maxdlduration*phy->getSymbolPS()+mac_->phymib_.rtg);  while (mac_->getMap()->getUlSubframe()->getNbPdu()>0) {    PhyPdu *pdu = mac_->getMap()->getUlSubframe()->getPhyPdu(0);    pdu->removeAllBursts();    mac_->getMap()->getUlSubframe()->removePhyPdu(pdu);    delete (pdu);  }  //5-Set contention slots for initial ranging  int rangingduration =(int) ceil(((mac_->getPhy()->getPS()*contention_size_*getInitRangingopportunity())/mac_->getPhy()->getSymbolTime()));  assert (rangingduration < maxulduration-ulduration); //check there is enough space  UlBurst *ub = (UlBurst*)mac_->getMap()->getUlSubframe()->addPhyPdu (nbulpdus++,0)->addBurst (0);  ub->setIUC (UIUC_INITIAL_RANGING);  ub->setDuration (rangingduration);  ub->setStarttime (ulduration); //we put the contention at the begining  ulduration += ub->getDuration()+1;  //5-Set contention slots for bandwidth request  int bwduration =(int) ceil(((mac_->getPhy()->getPS()*contention_size_*getBWopportunity())/mac_->getPhy()->getSymbolTime()));  assert (bwduration < maxulduration-ulduration);  ub = (UlBurst*)mac_->getMap()->getUlSubframe()->addPhyPdu (nbulpdus++,0)->addBurst (0);  ub->setIUC (UIUC_REQ_REGION_FULL);  ub->setDuration (bwduration);  ub->setStarttime (ulduration); //we put the contention at the begining  ulduration += ub->getDuration()+1;  //check if there is Fast Ranging allocation to do  FastRangingInfo *next_info = NULL;  for (FastRangingInfo *info = getMac()->fast_ranging_head_.lh_first ; info ; info=next_info) {    //get next info before the entry is removed from list    next_info = info->next_entry();    if (info->frame() == mac_->getFrameNumber()) {      //we need to include a fast ranging allocation      ub = (UlBurst*)mac_->getMap()->getUlSubframe()->addPhyPdu (nbulpdus++,0)->addBurst (0);      int tmp =(int) ceil(((mac_->getPhy()->getPS()*getInitRangingopportunity())/mac_->getPhy()->getSymbolTime()));      ub->setIUC (UIUC_EXT_UIUC);      ub->setDuration (tmp);      ub->setStarttime (ulduration); //start after previous slot      ub->setFastRangingParam (info->macAddr(), UIUC_INITIAL_RANGING);      ulduration += ub->getDuration()+1;      mac_->debug ("At %f in Mac %d adding fast ranging for %d\n", NOW, mac_->addr(), info->macAddr());      info->remove_entry();    }  }  //First implementation, return the CIDs in a RR fashion  peer = mac_->getPeerNode (nextUL_);  if (peer == NULL) //if the node is not here, lets start from the beginning    peer = mac_->getPeerNode_head();  if (peer) {    //printf ("We have %d macs\n", mac_->getNbPeerNodes());    for (int i=0; i<mac_->getNbPeerNodes() && ulduration < maxulduration ;i++) {      //The following code uses BW information to allocate data      if (peer->getReqBw()>0 && !getMac()->isPeerScanning (peer->getAddr())) {	mac_->debug ("At %f Allocating UL burst for Node %d:", NOW, peer->getAddr());	//add a pdu and burst for this node	ub = (UlBurst*) mac_->getMap()->getUlSubframe()->addPhyPdu (nbulpdus++,0)->addBurst (0);	ub->setCid (peer->getBasic(IN_CONNECTION)->get_cid());	//get the profile (we do a simple translation so that DL_PROFILE_1 = UL_PROFILE_1	//printf ("DIUC_1=%d UIUC_1=%d, DIUCreq=%d, UIUC=%d\n", DIUC_PROFILE_1, UIUC_PROFILE_1, peer->getDIUC(), DIUC_PROFILE_1+UIUC_PROFILE_1-peer->getDIUC());	ub->setIUC (mac_->getMap()->getUlSubframe()->getProfile (peer->getDIUC()-DIUC_PROFILE_1+UIUC_PROFILE_1)->getIUC());	ub->setStarttime (ulduration);		txtime = phy->getTrxSymbolTime (peer->getReqBw(), mac_->getMap()->getUlSubframe()->getProfile (ub->getIUC())->getEncoding());	txtime_s = (int) round(txtime/phy->getSymbolTime ()); //in units of symbol	if (txtime_s <= maxulduration-ulduration) {	  ub->setDuration (txtime_s);	  ulduration += ub->getDuration()+1; //add 1 OFDM symbol between bursts	} else {	  //fill up the rest	  ub->setDuration (maxulduration-ulduration);	  ulduration = maxulduration;	}	mac_->debug ("duration= %d\n", ub->getDuration());      }            //The following allocates all the bandwidth to 1 node.      /*      ub = (UlBurst*) mac_->getMap()->getUlSubframe()->addPhyPdu (nbulpdus++,0)->addBurst (0);      ub->setCid (peer->getBasic(IN_CONNECTION)->get_cid());      //get the profile (we do a simple translation so that DL_PROFILE_1 = UL_PROFILE_1      //printf ("DIUC_1=%d UIUC_1=%d, DIUCreq=%d, UIUC=%d\n", DIUC_PROFILE_1, UIUC_PROFILE_1, peer->getDIUC(), DIUC_PROFILE_1+UIUC_PROFILE_1-peer->getDIUC());      ub->setIUC (mac_->getMap()->getUlSubframe()->getProfile (peer->getDIUC()-DIUC_PROFILE_1+UIUC_PROFILE_1)->getIUC());      ub->setStarttime (ulduration);      ub->setDuration (maxulduration-ulduration);      ulduration = maxulduration;      */      peer = peer->next_entry();      if (peer == NULL)        peer = mac_->getPeerNode_head();      if (peer)        nextUL_ = peer->getAddr(); //go to next one      else        nextUL_ = -1; //will go the the beginning of the list    }        }     //end of map  ub = (UlBurst*)mac_->getMap()->getUlSubframe()->addPhyPdu (nbulpdus,0)->addBurst (0);  ub->setIUC (UIUC_END_OF_MAP);  ub->setStarttime (maxulduration);  assert (mac_->getFrameDuration() > map->getUlSubframe()->getStarttime()*phy->getPS()+maxulduration*phy->getSymbolTime ());  //printf ("Start %f end=%f\n",NOW+map->getUlSubframe()->getStarttime()*phy->getPS(), NOW+map->getUlSubframe()->getStarttime()*phy->getPS()+maxulduration*phy->getSymbolTime ());  //printf ("End2=%f\n", NOW+map->getUlSubframe()->getStarttime()*phy->getPS()+ub->getStarttime()*mac_->getPhy()->getSymbolTime());  //now transfert the packets to the bursts starting with broadcast messages  Burst *b = map->getDlSubframe()->getPdu ()->getBurst (0);  int b_data = 0;  int max_data = phy->getMaxPktSize (b->getDuration(), mac_->getMap()->getDlSubframe()->getProfile (b->getIUC())->getEncoding())-b_data;  p = map->getDL_MAP();  ch = HDR_CMN(p);  txtime = phy->getTrxTime (ch->size(), map->getDlSubframe()->getProfile (b->getIUC())->getEncoding());  ch->txtime() = txtime;  assert (b_data+ch->size() <= max_data);  ch->timestamp() = NOW; //add timestamp since it bypasses the queue  b->enqueue(p);      //enqueue into burst  b_data += ch->size();  p = map->getUL_MAP();  ch = HDR_CMN(p);  txtime = phy->getTrxTime (ch->size(), map->getDlSubframe()->getProfile (b->getIUC())->getEncoding());  ch->txtime() = txtime;  assert (b_data+ch->size() <= max_data);  ch->timestamp() = NOW; //add timestamp since it bypasses the queue  b->enqueue(p);      //enqueue into burst  b_data += ch->size();  if (getMac()->sendDCD || map->getDlSubframe()->getCCC()!= getMac()->dlccc_) {    p = map->getDCD();    ch = HDR_CMN(p);    txtime = phy->getTrxTime (ch->size(), map->getDlSubframe()->getProfile (b->getIUC())->getEncoding());    ch->txtime() = txtime;    assert (b_data+ch->size() <= max_data);    ch->timestamp() = NOW; //add timestamp since it bypasses the queue    b->enqueue(p);      //enqueue into burst    b_data += ch->size();  }  if (getMac()->sendUCD || map->getUlSubframe()->getCCC()!= getMac()->ulccc_) {    p = map->getUCD();    ch = HDR_CMN(p);    txtime = phy->getTrxTime (ch->size(), map->getDlSubframe()->getProfile (b->getIUC())->getEncoding());    ch->txtime() = txtime;    assert (b_data+ch->size() <= max_data);    ch->timestamp() = NOW; //add timestamp since it bypasses the queue    b->enqueue(p);      //enqueue into burst    b_data += ch->size();  }  //Get other broadcast messages  Connection *c=mac_->getCManager ()->get_connection (b->getCid(),OUT_CONNECTION);  b_data = transfer_packets (c, b, b_data);  //Now get the other bursts  for (int index = 1 ; index < map->getDlSubframe()->getPdu ()->getNbBurst() -1 ; index++) {    Burst *b = map->getDlSubframe()->getPdu ()->getBurst (index);    int b_data = 0;    Connection *c=mac_->getCManager ()->get_connection (b->getCid(),OUT_CONNECTION);    assert (c);    //printf ("Transferring data to burst %d\n", b->getCid());    b_data = transfer_packets (c, b, b_data);  }}/** * Add a downlink burst with the given information * @param burstid The burst number * @param c The connection to add * @param iuc The profile to use * @param dlduration current allocation status * @param the new allocation status */int BSScheduler::addDlBurst (int burstid, Connection *c, int iuc, int dlduration, int maxdlduration){  double txtime; //tx time for some data (in second)  int txtime_s;  //number of symbols used to transmit the data  OFDMPhy *phy = mac_->getPhy();  //add a burst for this node  DlBurst *db = (DlBurst*) mac_->getMap()->getDlSubframe()->getPdu ()->addBurst (burstid);  db->setCid (c->get_cid());  db->setIUC (iuc);  db->setStarttime (dlduration);  txtime = phy->getTrxSymbolTime (c->queueByteLength(), mac_->getMap()->getDlSubframe()->getProfile (db->getIUC())->getEncoding());  txtime += c->queueLength() * TX_GAP; //add small gaps between packets to send  txtime_s = (int) ceil(txtime/phy->getSymbolTime ()); //in units of symbol  if (txtime_s < maxdlduration-dlduration) {    db->setDuration (txtime_s);    dlduration += db->getDuration ()+1; //add 1 OFDM symbol between bursts  } else {    //fill up the rest    db->setDuration (maxdlduration-dlduration);    dlduration = maxdlduration;  }  return dlduration;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -