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

📄 mac-802_16-ss.cc

📁 OPNET 中的Wimax模块, 主要用于wimax 无线网络仿真,以及普通无线网络仿真.
💻 CC
📖 第 1 页 / 共 5 页
字号:
	}      End modification*/    }   else if (argc == 4)     {      if (strcmp(argv[1],"dump-802_16-queue-stats") == 0) 	{	  if (debug_ss)	    printf("SS%d:dump802_16QueueStats: debug_ss flag:%d \n",ss_id,debug_ss);	  (void)dump802_16QueueStats((char *)argv[2], atoi(argv[3]));	  return TCL_OK;	}   }  else  if (argc == 6)     {      if (strcmp(argv[1],"configure-ss") == 0) 	{	  priority = (u_int16_t) atoi(argv[2]);	  rng_freq = atof(argv[3]);	  ss_id= atoi(argv[4]);	  	  debug_ss = atoi(argv[5]);	  if (debug_ss)	    printf("SS%d:configure-ss: debug_ss flag:%d \n",ss_id,debug_ss);	  return TCL_OK;	}    }  else  if (argc == 5)     {      if (strcmp(argv[1],"dump-802_16-util-stats") == 0) 	{	  (void)dump802_16UtilStats((char *)argv[2], atoi(argv[3]), atoi(argv[4]));	  return TCL_OK;	}    }  else if (argc == 17)     {      if (strcmp(argv[1],"insert-downflow") == 0) 	{	  Initialize_entry(1, SizeDownFlowTable);	  f = atoi(argv[2]);	  	  if (f)	    default_dstream_index_ = SizeDownFlowTable;	            //$A16	  DownFlowTable[SizeDownFlowTable].downstream_record.sched_type = (SchedType)atoi(argv[3]); 	  DownFlowTable[SizeDownFlowTable].downstream_record.classifier.src_ip =  atoi(argv[4]); 	  DownFlowTable[SizeDownFlowTable].downstream_record.classifier.dst_ip =  atoi(argv[5]); 	  DownFlowTable[SizeDownFlowTable].downstream_record.classifier.pkt_type = (packet_t) atoi(argv[6]); 	  DownFlowTable[SizeDownFlowTable].downstream_record.PHS_profile = (PhsType) atoi(argv[7]); 	  DownFlowTable[SizeDownFlowTable].downstream_record.gsize = (u_int16_t) atoi(argv[8]); 	  DownFlowTable[SizeDownFlowTable].downstream_record.ginterval = (double) atof(argv[9]);           //$A17          DownFlowTable[SizeDownFlowTable].downstream_record.latency = (double) atof(argv[10]);	  DownFlowTable[SizeDownFlowTable].downstream_record.min_bw = (u_int32_t) atoi(argv[11]);	  DownFlowTable[SizeDownFlowTable].downstream_record.min_bw /= 8; 	  DownFlowTable[SizeDownFlowTable].downstream_record.max_qsize = atoi(argv[12]);	  DownFlowTable[SizeDownFlowTable].downstream_record.ratecontrol = (char) atoi(argv[13]); 	  DownFlowTable[SizeDownFlowTable].downstream_record.rate_ = (double) atof(argv[14]); 	  DownFlowTable[SizeDownFlowTable].downstream_record.tokenqlen_ = (int) atoi(argv[15]); 	  DownFlowTable[SizeDownFlowTable].downstream_record.bucket_ = (int) atoi(argv[16]); 	  DownFlowTable[SizeDownFlowTable].downstream_record.state = 0;	  SizeDownFlowTable++;	  return TCL_OK;	}    }    return Mac802_16::command(argc, argv);}/**************************************************************************************************************************************************/void Mac802_16SS::print_classifiers(){  int i;    printf("UPSTREAM FLOWS \n");    for (i= 0; i < SizeUpFlowTable;i++)    {      printf("tbindex = %d\n",i);      printf("Flow-id = %d\n",UpFlowTable[i].upstream_record.flow_id);      printf("Sched-type = %d\n",UpFlowTable[i].upstream_record.sched_type);            printf("Src-ip = %d\n",UpFlowTable[i].upstream_record.classifier.src_ip);      printf("dst-ip = %d\n",UpFlowTable[i].upstream_record.classifier.dst_ip);      printf("pkt-type = %d\n",UpFlowTable[i].upstream_record.classifier.pkt_type);      printf("Phs-profile = %d\n",UpFlowTable[i].upstream_record.PHS_profile);      printf("Flag = %d\n",UpFlowTable[i].upstream_record.flag);      printf("Gsize = %d\n",UpFlowTable[i].upstream_record.gsize);      printf("Ginterval = %lf\n",UpFlowTable[i].upstream_record.ginterval);      printf("\n");    }    printf("DOWNSTREAM FLOWS \n");    for (i= 0; i < SizeDownFlowTable;i++)    {      printf("tbindex = %d\n",i);      printf("Flow-id = %d\n",DownFlowTable[i].downstream_record.flow_id);      printf("Sched-type = %d\n",DownFlowTable[i].downstream_record.sched_type);      printf("Src-ip = %d\n",DownFlowTable[i].downstream_record.classifier.src_ip);      printf("dst-ip = %d\n",DownFlowTable[i].downstream_record.classifier.dst_ip);      printf("pkt-type = %d\n",DownFlowTable[i].downstream_record.classifier.pkt_type);      printf("Phs-profile = %d\n",DownFlowTable[i].downstream_record.PHS_profile);    }}/************************************************************************* Timer handler functions *************************************************************************//*!  Timer handler function */void Mac802_16SS::SSSndTimerHandler(Event *e){	sptr temp;	char tbindex;		temp = SndList;	if (!temp)	  {	    printf("SS%d :Error in SSSndTimerHandler: Exiting\n",ss_id);	    exit(1);	  }	else	  {	    SndList = SndList->next;	  }		tbindex = temp->tindex;	free(temp);		if (UpFlowTable[tbindex].upstream_record.sched_type == UGS)	  {	    (this->*UGSswitch[UpFlowTable[tbindex].state])(tbindex, SEND_TIMER, UpFlowTable[tbindex].pkt);	  }		else if (UpFlowTable[tbindex].upstream_record.sched_type == RT_POLL)	  {	    (this->*RTPOLLswitch[UpFlowTable[tbindex].state])(tbindex, SEND_TIMER, UpFlowTable[tbindex].pkt);	  }	//$A22	else if (UpFlowTable[tbindex].upstream_record.sched_type == ERT_POLL)	  {	    (this->*ERTPOLLswitch[UpFlowTable[tbindex].state])(tbindex, SEND_TIMER, UpFlowTable[tbindex].pkt);	  }	//$A15	else if (UpFlowTable[tbindex].upstream_record.sched_type == NRT_POLL)	  {	    (this->*NRTPOLLswitch[UpFlowTable[tbindex].state])(tbindex, SEND_TIMER, UpFlowTable[tbindex].pkt);	  }	else if (UpFlowTable[tbindex].upstream_record.sched_type == BEST_EFFORT)	  {	    (this->*BEFFORTswitch[UpFlowTable[tbindex].state])(tbindex, SEND_TIMER, UpFlowTable[tbindex].pkt);	  }	return;}	/**************************************************************************************************************************************************/	void Mac802_16SS::SSRngHandler(Event * e){  Packet * p = Packet::alloc();  char tbindex;  double stime;  hdr_mac802_16   *dh  = hdr_mac802_16::access(p);  hdr_cmn   *ch  = HDR_CMN(p);    double curr_time = Scheduler::instance().clock();    if (debug_ss)    printf("SSRngHandler(%lf):SS%d :Sending a RNG-REQ message \n",curr_time,ss_id);    ch->uid() = 0;  //$A4  //ch->ptype() = PT_MAC;  ch->ptype() = PT_MAC802_16MGMT;  ch->iface() = -2;  ch->error() = 0;      ch->size() = 10 + SIZE_MGMT_HDR;  dh->dshdr_.fc_type = 3;  dh->dshdr_.fc_parm = 1;  dh->dshdr_.ehdr_on = 0;  dh->dshdr_.mac_param = 0;    ch->size() += downchannel.overhead_bytes;  /* Send the packet */  tbindex = classify(p, UPSTREAM);    if (debug_ss)    printf("SS%d :Packet classified on flow-id %d\n",ss_id,UpFlowTable[tbindex].upstream_record.flow_id);    HandleOutMgmt(p,tbindex);     /* $A3 :  add some randomness.  This will reduce the frequency but that's ok */  double random_delay  = Random::uniform(.01,3);  mhSSRng_.start((Packet *) (&rintr), (rng_freq+random_delay));  }/**************************************************************************************************************************************************/void Mac802_16SS::SSReqTimerHandler(Event *e){  rptr temp,prev;  char tbindex;    while (ReqList->expiration_time != e->time_)    {      prev = ReqList;       ReqList = ReqList->next;      free(prev);    }  temp = ReqList;  if (!temp)    {      printf("SS%d :Error in SSReqTimerHandler: Exiting\n",ss_id);      exit(1);    }  else    {      assert (ReqList->expiration_time == e->time_);      ReqList = ReqList->next;    }  tbindex = temp->rindex;  free(temp);   if (UpFlowTable[tbindex].upstream_record.sched_type == UGS)    {      printf("SS%d :Mac802_16SS->SSReqTimerHandler: Error, Req timer was set for UGS flow , Exiting\n",ss_id);      exit(1);    }  else if (UpFlowTable[tbindex].upstream_record.sched_type == RT_POLL)    {      (this->*RTPOLLswitch[UpFlowTable[tbindex].state])(tbindex, REQ_TIMER, UpFlowTable[tbindex].pkt);    }  //$A22  else if (UpFlowTable[tbindex].upstream_record.sched_type == ERT_POLL)    {      (this->*ERTPOLLswitch[UpFlowTable[tbindex].state])(tbindex, REQ_TIMER, UpFlowTable[tbindex].pkt);    }  //$A15  else if (UpFlowTable[tbindex].upstream_record.sched_type == NRT_POLL)    {      (this->*NRTPOLLswitch[UpFlowTable[tbindex].state])(tbindex, REQ_TIMER, UpFlowTable[tbindex].pkt);    }  else if (UpFlowTable[tbindex].upstream_record.sched_type == BEST_EFFORT)    {//$A5      if(reqFlag == 0)         reqFlag = 1;      reqFlagCounter++;      (this->*BEFFORTswitch[UpFlowTable[tbindex].state])(tbindex, REQ_TIMER, UpFlowTable[tbindex].pkt);    }}	/************************************************************************* * Routine:  void Mac802_16SS::HandleMap(Packet * p) * * Explanation: This routine invokes every flow handler (in *   whatever state they are in) to process the map.  *   If a flow sees an opportunity to send- it updates  *   the SS's allocation table. * * Inputs:   *   Packet *p : The packet containing the MAP * * Outputs: * * *************************************************************************//*!  This routine invokes every flow handler (in  whatever state they are in) to process the map.   If a flow sees an opportunity to send- it updates   the SS's allocation table.  \param p The packet containing the MAP*/void Mac802_16SS::HandleMap(Packet * p){  /* The 'data' portion of 'p' will have all the IEs */  int i = 0;    if (debug_ss)    printf("SS%d:HandleMap: received MAP at %lf (sizeUpFlowTable:%d)\n",ss_id,Scheduler::instance().clock(),SizeUpFlowTable);    map_ = p->copy();    //Make sure callers don't free the map_  for (i = 0; i < SizeUpFlowTable; i++)    {      if (UpFlowTable[i].upstream_record.sched_type == UGS)	{           if (debug_ss)             printf("SS%d : received MAP: handle UGS flow %lf\n",ss_id,Scheduler::instance().clock());	  (this->*UGSswitch[UpFlowTable[i].state])(i, MAP_ARRIVAL, UpFlowTable[i].pkt);	}      else if (UpFlowTable[i].upstream_record.sched_type == RT_POLL)	{           if (debug_ss)             printf("SS%d : received MAP: handle rtPS flow %lf\n",ss_id,Scheduler::instance().clock());	  (this->*RTPOLLswitch[UpFlowTable[i].state])(i, MAP_ARRIVAL, UpFlowTable[i].pkt);	}      //$A22      else if (UpFlowTable[i].upstream_record.sched_type == ERT_POLL)	{           if (debug_ss)             printf("SS%d : received MAP: handle ertPS flow %lf\n",ss_id,Scheduler::instance().clock());	  (this->*ERTPOLLswitch[UpFlowTable[i].state])(i, MAP_ARRIVAL, UpFlowTable[i].pkt);	}      //$A15      else if (UpFlowTable[i].upstream_record.sched_type == NRT_POLL)	{           if (debug_ss)             printf("SS%d : received MAP: handle nrtPS flow %lf\n",ss_id,Scheduler::instance().clock());	  (this->*NRTPOLLswitch[UpFlowTable[i].state])(i, MAP_ARRIVAL, UpFlowTable[i].pkt);	}      else if (UpFlowTable[i].upstream_record.sched_type == BEST_EFFORT)	{           if (debug_ss)             printf("SS%d : received MAP: handle BE flow %lf\n",ss_id,Scheduler::instance().clock());	  (this->*BEFFORTswitch[UpFlowTable[i].state])(i, MAP_ARRIVAL, UpFlowTable[i].pkt);	}    }  Packet::free(p);  //$A11  Packet::free(map_);  map_ = 0;}/**************************************************************************************************************************************************/void Mac802_16SS::Initialize_entry(char dir, char tbindex){  switch(dir)     {    case 0:      UpFlowTable[tbindex].upstream_record.sched_type = BEST_EFFORT;      UpFlowTable[tbindex].upstream_record.gsize 	= 0;      UpFlowTable[tbindex].upstream_record.ginterval 	= 0;      UpFlowTable[tbindex].upstream_record.flag 	= 0;      UpFlowTable[tbindex].upstream_record.PHS_profile= (PhsType)4;      UpFlowTable[tbindex].upstream_record.flow_id	= 0;      UpFlowTable[tbindex].upstream_record.classifier.src_ip= 0;      UpFlowTable[tbindex].upstream_record.classifier.dst_ip= 0;      UpFlowTable[tbindex].upstream_record.classifier.pkt_type= (packet_t)0;            UpFlowTable[tbindex].alloc_list= 0;      UpFlowTable[tbindex].state = 0;      UpFlowTable[tbindex].pkt= 0;      UpFlowTable[tbindex].bk_offwin= 0;      UpFlowTable[tbindex].bk_offcounter= 0;      UpFlowTable[tbindex].bk_offend= 0;      UpFlowTable[tbindex].bk_offstart= 0;      UpFlowTable[tbindex].max_retries= MAX_NUM_RETRIES;      UpFlowTable[tbindex].num_retries= 0;      UpFlowTable[tbindex].contention_on= 0;      UpFlowTable[tbindex].pending= 0;      UpFlowTable[tbindex].map_acktime= 0;      UpFlowTable[tbindex].req_time= 0;      UpFlowTable[tbindex].seq_num = 0;      UpFlowTable[tbindex].frag_pkt = 0;

⌨️ 快捷键说明

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