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

📄 mac-802_16-ss.cc

📁 OPNET 中的Wimax模块, 主要用于wimax 无线网络仿真,以及普通无线网络仿真.
💻 CC
📖 第 1 页 / 共 5 页
字号:
      UpFlowTable[tbindex].frag_data = 0;      UpFlowTable[tbindex].curr_gsize = 0;      UpFlowTable[tbindex].bs_addr = 0;      UpFlowTable[tbindex].num_pkt_snt= 0;      UpFlowTable[tbindex].avg_queuing_delay= 0;      UpFlowTable[tbindex].queuing_samples= 0;      UpFlowTable[tbindex].avg_req_stime= 0;      UpFlowTable[tbindex].enque_time= 0;      UpFlowTable[tbindex].num_delay_samples= 0;      UpFlowTable[tbindex].total_piggyreq= 0;      //$A2      UpFlowTable[tbindex].totalACKs= 0;      UpFlowTable[tbindex].totalACKsFiltered= 0;            UpFlowTable[tbindex].total_creq= 0;      UpFlowTable[tbindex].total_fcoll= 0;      UpFlowTable[tbindex].avg_fcont= 0;      UpFlowTable[tbindex].fcont_count= 0;      UpFlowTable[tbindex].total_collision_drops= 0;      UpFlowTable[tbindex].total_queue_drops= 0;      UpFlowTable[tbindex].avg_slotspermap= 0;      UpFlowTable[tbindex].avg_pkts= 0;      UpFlowTable[tbindex].avg_bytes= 0;      UpFlowTable[tbindex].num_bytes= 0;      UpFlowTable[tbindex].num_pkts= 0;          /* STATISTICS */      UpFlowTable[tbindex].SID_num_sent_bytes= 0;      UpFlowTable[tbindex].SID_num_sent_pkts= 0;            UpFlowTable[tbindex].last_mfrtime= 0;      UpFlowTable[tbindex].drop_count= 0;          //UpFlowTable[tbindex].max_qsize= QUEUE_THRESHOLD;            UpFlowTable[tbindex].ugsjitter = 0.0;      //$A12      UpFlowTable[tbindex].jitterSamples = 0;      UpFlowTable[tbindex].last_granttime = 0.0;      UpFlowTable[tbindex].nominal_alloctime = 0.004;      UpFlowTable[tbindex].last_jittercaltime = 0.0;            //$A5      UpFlowTable[tbindex].acceptance_rate = 0.0;      UpFlowTable[tbindex].prev_acceptance_rate = 0.0;      UpFlowTable[tbindex].wt_factor = 0.15;      UpFlowTable[tbindex].num_slots_req = 1;      UpFlowTable[tbindex].tokens_ = 0.0;//$A5      UpFlowTable[tbindex].bucket_ = 24448;      UpFlowTable[tbindex].init_ = 0;      UpFlowTable[tbindex].ratecontrol = 0;      UpFlowTable[tbindex].rate_ = 128000.0;      reqFlag = 0;      reqFlagCounter = 0;//$A6      UpFlowTable[tbindex].totalConcatFrames = 0;      UpFlowTable[tbindex].totalPacketsInConcatFrames = 0;      break;          case 1:      DownFlowTable[tbindex].downstream_record.classifier.src_ip = 0;      DownFlowTable[tbindex].downstream_record.classifier.dst_ip = 0;      DownFlowTable[tbindex].downstream_record.classifier.pkt_type = (packet_t)0;      DownFlowTable[tbindex].downstream_record.flow_id = 0;      DownFlowTable[tbindex].downstream_record.PHS_profile = (PhsType)4;      DownFlowTable[tbindex].downstream_record.sched_type = BEST_EFFORT;;       DownFlowTable[tbindex].downstream_record.gsize = 0;       DownFlowTable[tbindex].downstream_record.ginterval = 0;       DownFlowTable[tbindex].downstream_record.max_qsize = 0;      DownFlowTable[tbindex].downstream_record.ratecontrol = 0;      DownFlowTable[tbindex].downstream_record.rate_ = 0;       DownFlowTable[tbindex].downstream_record.tokenqlen_ = 0;       DownFlowTable[tbindex].downstream_record.bucket_ = 0; 	        DownFlowTable[tbindex].downstream_record.pkt = 0;      break;    }  return;  }/*************************************************************************So a packet has been received by the PHY, and we want to send it up to the 802_16 link...*************************************************************************//*! So a packet has been received by the PHY, and we want to send it up to the 802_16 link... */void Mac802_16SS::sendUp(Packet* p) {  struct hdr_cmn *ch = HDR_CMN(p);      if (debug_ss)    printf("SS%d :sendUp(%lf):packet received by PHY,  packet size:  %d \n",	   ss_id,	   Scheduler::instance().clock(), 	   ch->size());    /* Detect if there is any collision happened. should not happen...?*/  if (rx_state_ == MAC_IDLE)     {      SET_RX_STATE(MAC_RECV);     /* Change the state to recv. */      pktRx_ = p;                 /* Save the packet for timer reference.*/            /* Schedule the reception of this packet, 	 since we just see the packet header. */      double rtime = TX_Time(p,DOWNSTREAM);      assert(rtime >= 0);            if (debug_ss)	printf("SS%d :sendUp(%lf):  Schedule the receive event in this much time:  %lf \n",	       ss_id,	       Scheduler::instance().clock(), 	       rtime);            /* Start the timer for receiving, will end when receiving finishes. */      mhRxPkt_.start(p, rtime);    }   else     {      /* 	 Note: we don't take the channel status into account, ie. no collision,	 as collision should not happen...      */      if (debug_ss)	printf("SS%d :sendUp(%lf):  receiving, but the channel is not idle ?? \n", 	       ss_id,Scheduler::instance().clock());            Packet::free(p);    }}/*************************************************************************Send packets passed by LLC to physical layer..So, NO MAC level ManagementMessages will be sent via this fucntion*************************************************************************//*! Send packets passed by LLC to physical layer..So, NO MAC level ManagementMessages will be sent via this fucntion */void Mac802_16SS::sendDown(Packet* p) {  char tbindex;  struct hdr_mac* mh = HDR_MAC(p);  struct hdr_cmn* ch = HDR_CMN(p);  struct hdr_mac802_16extd* eh = HDR_MAC802_16EXTD(p);    eh->num_hdr = 0;    if (debug_ss)    printf("SS%d :sendDown(%lf):  Entered with packet size:  %d from higher layers  \n",	   ss_id,	   Scheduler::instance().clock(), 	   ch->size());    /* Unlock IFQ */  if(callback_)     {      Handler *h = callback_;      callback_ = 0;      h->handle((Event*) 0);    }     tbindex = classify(p, UPSTREAM);    if (UpFlowTable[tbindex].debug)    {      printf("SS%d(flow-id %d) :sendDown(%lf): Received an upper layer pkt of size %d and sched_type:%d (cur state:%d) \n",	     ss_id, UpFlowTable[tbindex].upstream_record.flow_id,	     Scheduler::instance().clock(), ch->size(), UpFlowTable[tbindex].upstream_record.sched_type,UpFlowTable[tbindex].state);            dump_pkt(p);    }    total_num_appbytesUS += ch->size();   ApplyPhs(p, tbindex);  HandleOutData(p,tbindex); }/************************************************************************* Packet enters the SM for respective flow from this function *************************************************************************//*!  Packet enters the SM for respective flow from this function */void Mac802_16SS::HandleOutData(Packet* p, char tbindex){  struct hdr_cmn* ch = HDR_CMN(p);  struct hdr_mac802_16* dh = HDR_MAC802_16(p);  struct hdr_mac* mh = HDR_MAC(p);    /* Make 802_16  & ethernet header */  /*      Ethernet header has to be properly updated as SS node is also     simulating the end-host   */  mh->set(MF_DATA,index_); /* To set the MAC src-addr and type */  ch->size() += ETHER_HDR_LEN;      dh->dshdr_.fc_type = 0;  dh->dshdr_.fc_parm = 0;  dh->dshdr_.ehdr_on = 0;  dh->dshdr_.mac_param = 0;  dh->dshdr_.len = ch->size();  ch->size() += MAC802_16_HDR_LEN;  if (UpFlowTable[tbindex].debug)     printf("SS%d :HandleOutData(%lf): Packet arrived,  Sending frame of size %d Upstream \n", 	       ss_id,Scheduler::instance().clock(),ch->size());      /* Pass the packet to state-machine */    if (UpFlowTable[tbindex].upstream_record.sched_type == UGS)    {      (this->*UGSswitch[UpFlowTable[tbindex].state])(tbindex, PKT_ARRIVAL , p);    }  else if (UpFlowTable[tbindex].upstream_record.sched_type == RT_POLL)    {      (this->*RTPOLLswitch[UpFlowTable[tbindex].state])(tbindex, PKT_ARRIVAL, p);    }  //$A22  else if (UpFlowTable[tbindex].upstream_record.sched_type == ERT_POLL)    {      (this->*ERTPOLLswitch[UpFlowTable[tbindex].state])(tbindex, PKT_ARRIVAL, p);    }  //$A15  else if (UpFlowTable[tbindex].upstream_record.sched_type == NRT_POLL)    {      (this->*NRTPOLLswitch[UpFlowTable[tbindex].state])(tbindex, PKT_ARRIVAL, p);    }  else if (UpFlowTable[tbindex].upstream_record.sched_type == BEST_EFFORT)    {      (this->*BEFFORTswitch[UpFlowTable[tbindex].state])(tbindex, PKT_ARRIVAL, p);    }  return;}/**************************************************************************************************************************************************/void Mac802_16SS::HandleOutMgmt(Packet* p, char tbindex){  if (UpFlowTable[tbindex].upstream_record.sched_type == UGS)    {      (this->*UGSswitch[UpFlowTable[tbindex].state])(tbindex, PKT_ARRIVAL, p);    }  else if (UpFlowTable[tbindex].upstream_record.sched_type == RT_POLL)    {      (this->*RTPOLLswitch[UpFlowTable[tbindex].state])(tbindex, PKT_ARRIVAL, p);    }  //$A22  else if (UpFlowTable[tbindex].upstream_record.sched_type == ERT_POLL)    {      (this->*ERTPOLLswitch[UpFlowTable[tbindex].state])(tbindex, PKT_ARRIVAL, p);    }  //$A15  else if (UpFlowTable[tbindex].upstream_record.sched_type == NRT_POLL)    {      (this->*NRTPOLLswitch[UpFlowTable[tbindex].state])(tbindex, PKT_ARRIVAL, p);    }  else if (UpFlowTable[tbindex].upstream_record.sched_type == BEST_EFFORT)    {      (this->*BEFFORTswitch[UpFlowTable[tbindex].state])(tbindex, PKT_ARRIVAL, p);    }  return;}/**************************************************************************************************************************************************/void Mac802_16SS::SendData(Packet *p, char tbindex){  Packet* q;  int concat_req = 0;  double stime;  double current_time;  q = UpFlowTable[tbindex].pkt;    UpFlowTable[tbindex].avg_req_stime += (Scheduler::instance().clock() - UpFlowTable[tbindex].enque_time);  UpFlowTable[tbindex].num_delay_samples++;    struct hdr_cmn* ch = HDR_CMN(q);    switch(UpFlowTable[tbindex].upstream_record.sched_type)     {    //$A22    case ERT_POLL:      //TESTE      current_time = Scheduler::instance().clock();      //printf("%f: teste sendData: gsize > pktsize = %d > %d\n",current_time,UpFlowTable[tbindex].upstream_record.gsize,ch->size());      /*if grant size > packet size, send a piggyback req with the new packet size        (since the grant size includes overhead bytes added by the BS (and the SS         do not know exactly the size of this overhead), we compare the packet size          to the last requested grant size, which is in gsize. The current grant size          is equal to gsize + the overhead added by the BS) */      if (UpFlowTable[tbindex].upstream_record.gsize > ch->size())	{	  FillErtPSPiggyReq(tbindex, q);	}      //then send the packet just as in the UGS case    case UGS:      if (UpFlowTable[tbindex].debug)	printf("SS%d(flow-id %d) :sendData: sending a packet at %lf \n",	       ss_id,	       UpFlowTable[tbindex].upstream_record.flow_id,	       Scheduler::instance().clock());#ifdef PACKET_TRACE      packetTrace(q,1);#endif      ch->size() += upchannel.overhead_bytes;      stime = TX_Time(q,UPSTREAM);      SET_TX_STATE(MAC_SEND);             /* STATISTICS*/      UpFlowTable[tbindex].num_pkts++ ;      UpFlowTable[tbindex].num_bytes += ch->size();      total_num_sent_pkts++;      total_num_sent_bytes += ch->size();       total_num_BW_bytesUP += ch->size();             //#ifdef TRACE_SS_UP_DATA //----------------------------------------------      if (debug_ss)        printf("SS%dup(flow-id: %d) %lf %f %d \n",	       ss_id,UpFlowTable[tbindex].upstream_record.flow_id,	       Scheduler::instance().clock(), 	       total_num_sent_bytes,	       ch->size());      //#endif //---------------------------------------------------------------            /* Start a timer that expires when the packet transmission is complete. *///$A5#ifdef US_RATE_CONTROL      if (UpFlowTable[tbindex].ratecontrol == 1)        USRateMeasure(tbindex,q);#endif      mhTxPkt_.start(q->copy(), stime);      downtarget_->recv(q, this);              break;    //$A19    case RT_POLL://$A15 A$19    case NRT_POLL:      /*      if (UpFlowTable[tbindex].debug)	printf("SS%d(flow-id %d) :sendData: sending a packet at %lf \n",	       ss_id,	       UpFlowTable[tbindex].upstream_record.flow_id,	       Scheduler::instance().clock());#ifdef PACKET_TRACE      packetTrace(q,1);#endif      ch->size() += upchannel.overhead_bytes;      stime = TX_Time(q,UPSTREAM);      SET_TX_STATE(MAC_SEND);             /* STATISTICS      UpFlowTable[tbindex].num_pkts++ ;      UpFlowTable[tbindex].num_bytes += ch->size();      total_num_sent_pkts++;      total_num_sent_bytes += ch->size();       total_num_BW_bytesUP += ch->size();             //#ifdef TRACE_SS_UP_DATA //----------------------------------------------      if (debug_ss)

⌨️ 快捷键说明

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