亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? worker.c

?? ARQ協(xié)議的實現(xiàn) 從單工停等到滑動窗口協(xié)議的實現(xiàn)
?? C
?? 第 1 頁 / 共 2 頁
字號:

void to_network_layer(packet *p)
{
/* Deliver information from an inbound frame to the network layer. A check is
 * made to see if the packet is in sequence.  If it is not, the simulation
 * is terminated with a "protocol error" message.
 */

  unsigned int num;

  num = pktnum(p);
  if (num != last_pkt_given + 1) {
	printf("Tick %u. Proc %d got protocol error.  Packet delivered out of order.\n", tick/DELTA, id); 
	printf("Expected payload %d but got payload %d\n",last_pkt_given+1,num);
	exit(0);
  }
  last_pkt_given = num;
  payloads_accepted++;
}

  
void from_physical_layer (frame *r)
{
/* Copy the newly-arrived frame to the user. */
 *r = last_frame;
}


void to_physical_layer(frame *s)
{
/* Pass the frame to the physical layer for writing on pipe 1 or 2. 
 * However, this is where bad packets are discarded: they never get written.
 */

  int fd, got, k;

  /* Fill in fields that that the simulator expects but some protocols do
   * not fill in or use.  This filling is not strictly needed, but makes the
   * simulation trace look better, showing unused fields as zeros.
   */
  switch(protocol) {
    case 2:
	s->seq = 0;

    case 3:
	s->kind = (id == 0 ? data : ack);
	if (s->kind == ack) {
		s->seq = 0;
		s->info.data[0] = 0;
		s->info.data[1] = 0;
		s->info.data[2] = 0;
		s->info.data[3] = 0;
	}
        break;

     case 4:
     case 5:
 	s->kind = data;
	break;

     case 6:
	if (s->kind == nak) {
		s->info.data[0] = 0;
		s->info.data[1] = 0;
		s->info.data[2] = 0;
		s->info.data[3] = 0;
	}

	/* The following statement is essential to protocol 6.  In that
	 * protocol, oldest_frame is automagically set properly to the
	 * sequence number of the frame that has timed out.  Keeping track of
	 * this information is a bit tricky, since the call to start_timer()
	 * does not tell what the sequence number is, just the buffer.  The
	 * simulator keeps track of sequence numbers using the array seqs[],
	 * which records the sequence number of each data frame sent, so on a
	 * timeout, knowing the buffer number makes it possible to determine
	 * the sequence number.
	 */
	if (s->kind==data) seqs[s->seq % (nseqs/2)] = s->seq; /* save seq # */
  }

  if (s->kind == data) data_sent++;
  if (s->kind == ack) acks_sent++;
  if (retransmitting) data_retransmitted++;

  /* Bad transmissions (checksum errors) are simulated here. */
  k = rand() & 01777;		/* 0 <= k <= about 1000 (really 1023) */
  if (k < pkt_loss) {	/* simulate packet loss */
	if (debug_flags & SENDS) {
		printf("Tick %u. Proc %d sent frame that got lost: ",
							    tick/DELTA, id);
		fr(s);
	}
	if (s->kind == data) data_lost++;	/* statistics gathering */
	if (s->kind == ack) acks_lost++;	/* ditto */
	return;

  }
  if (s->kind == data) data_not_lost++;		/* statistics gathering */
  if (s->kind == ack) acks_not_lost++;		/* ditto */
  fd = (id == 0 ? w1 : w2);

  got = write(fd, s, FRAME_SIZE);
  if (got != FRAME_SIZE) print_statistics();	/* must be done */

  if (debug_flags & SENDS) {
	printf("Tick %u. Proc %d sent frame: ", tick/DELTA, id);
	fr(s);
  }
}


void start_timer(seq_nr k)
{
/* Start a timer for a data frame. */

  ack_timer[k] = tick + timeout_interval + offset;
  offset++;
  recalc_timers();		/* figure out which timer is now lowest */
}


void stop_timer(seq_nr k)
{
/* Stop a data frame timer. */

  ack_timer[k] = 0;
  recalc_timers();		/* figure out which timer is now lowest */
}


void start_ack_timer(void)
{
/* Start the auxiliary timer for sending separate acks. The length of the
 * auxiliary timer is arbitrarily set to half the main timer.  This could
 * have been another simulation parameter, but that is unlikely to have
 * provided much extra insight.
 */

  aux_timer = tick + timeout_interval/AUX;
  offset++;
}


void stop_ack_timer(void)
{
/* Stop the ack timer. */

  aux_timer = 0;
}


void enable_network_layer(void)
{
/* Allow network_layer_ready events to occur. */

  network_layer_status = 1;
}


void disable_network_layer(void)
{
/* Prevent network_layer_ready events from occuring. */

  network_layer_status = 0;
}


int check_timers(void)
{
/* Check for possible timeout.  If found, reset the timer. */

  int i;

  /* See if a timeout event is even possible now. */
  if (lowest_timer == 0 || tick < lowest_timer) return(-1);

  /* A timeout event is possible.  Find the lowest timer. Note that it is
   * impossible for two frame timers to have the same value, so that when a
   * hit is found, it is the only possibility.  The use of the offset variable
   * guarantees that each successive timer set gets a higher value than the
   * previous one.
   */
  for (i = 0; i < NR_TIMERS; i++) {
	if (ack_timer[i] == lowest_timer) {
		ack_timer[i] = 0;	/* turn the timer off */
		recalc_timers();	/* find new lowest timer */
                oldest_frame = seqs[i];	/* for protocol 6 */
		return(i);
	}
  }
  printf("Impossible.  check_timers failed at %d\n", lowest_timer);
  exit(1);
}


int check_ack_timer()
{
/* See if the ack timer has expired. */

  if (aux_timer > 0 && tick >= aux_timer) {
	aux_timer = 0;
	return(1);
  } else {
	return(0);
  }
}


unsigned int pktnum(packet *p)
{
/* Extract packet number from packet. */

  unsigned int num, b0, b1, b2, b3;

  b0 = p->data[0] & BYTE;
  b1 = p->data[1] & BYTE;
  b2 = p->data[2] & BYTE;
  b3 = p->data[3] & BYTE;
  num = (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
  return(num);
}


void fr(frame *f)
{
/* Print frame information for tracing. */

  printf("type=%s  seq=%d  ack=%d  payload=%d\n",
	tag[f->kind], f->seq, f->ack, pktnum(&f->info));
}

void recalc_timers(void)
{
/* Find the lowest timer */

  int i;
  bigint t = UINT_MAX;

  for (i = 0; i < NR_TIMERS; i++) {
	if (ack_timer[i] > 0 && ack_timer[i] < t) t = ack_timer[i];
  }
  lowest_timer = t;
}


void print_statistics(void)
{
/* Display statistics. */

  int word[3];

  sleep(1);
  printf("\nProcess %d:\n", id);
  printf("\tTotal data frames sent:  %9d\n", data_sent);
  printf("\tData frames lost:        %9d\n", data_lost);
  printf("\tData frames not lost:    %9d\n", data_not_lost);
  printf("\tFrames retransmitted:    %9d\n", data_retransmitted);
  printf("\tGood ack frames rec'd:   %9d\n", good_acks_recd);
  printf("\tBad ack frames rec'd:    %9d\n\n", cksum_acks_recd);

  printf("\tGood data frames rec'd:  %9d\n", good_data_recd);
  printf("\tBad data frames rec'd:   %9d\n", cksum_data_recd);
  printf("\tPayloads accepted:       %9d\n", payloads_accepted);
  printf("\tTotal ack frames sent:   %9d\n", acks_sent);
  printf("\tAck frames lost:         %9d\n", acks_lost);
  printf("\tAck frames not lost:     %9d\n", acks_not_lost);

  printf("\tTimeouts:                %9d\n", timeouts);
  printf("\tAck timeouts:            %9d\n", ack_timeouts);
  fflush(stdin);

  word[0] = 0;
  word[1] = payloads_accepted;
  word[2] = data_sent;
  write(mwfd, word, 3*sizeof(int));	/* tell main we are done printing */
  sleep(1);
  exit(0);
}


void sim_error(char *s)
{
/* A simulator error has occurred. */

  int fd;

  printf("%s\n", s);
  fd = (id == 0 ? w4 : w6);
  write(fd, &zero, TICK_SIZE);
  exit(1);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线国偷精品产拍免费yy| 亚洲精品一二三四区| 捆绑变态av一区二区三区| 久久一区二区视频| 日本午夜一本久久久综合| 精品99一区二区三区| 自拍偷拍欧美精品| 天堂精品中文字幕在线| 国产99精品国产| 欧美tickle裸体挠脚心vk| 亚洲精品你懂的| 国产高清无密码一区二区三区| 欧美日韩一区小说| 国产精品久久久久久妇女6080| 免费在线观看精品| 欧美午夜电影网| 亚洲欧美影音先锋| 国产成人亚洲综合a∨婷婷图片 | 精品中文字幕一区二区| 色婷婷久久久亚洲一区二区三区| 久久精品亚洲一区二区三区浴池| 亚洲成人av一区二区三区| 色婷婷综合五月| 欧美国产乱子伦| 国产一区二区三区最好精华液| 欧美日韩国产综合久久| 夜夜亚洲天天久久| 91丨九色丨黑人外教| 国产精品免费av| 高潮精品一区videoshd| 国产视频一区在线播放| 3d成人动漫网站| 欧美男女性生活在线直播观看| 国产九色sp调教91| 色域天天综合网| 综合激情网...| 97久久超碰国产精品电影| 国产精品人成在线观看免费 | 亚洲欧美怡红院| 国产成a人无v码亚洲福利| 亚洲国产精品激情在线观看| 国产乱人伦偷精品视频免下载| 亚洲精品一线二线三线| 国产麻豆成人传媒免费观看| 久久久精品人体av艺术| 国产成人免费av在线| 国产精品久久久久四虎| 91麻豆国产在线观看| 亚洲国产精品一区二区www在线| 91国偷自产一区二区开放时间| 亚洲精品久久7777| 欧美二区在线观看| 精品午夜久久福利影院| 国产精品入口麻豆原神| 色婷婷国产精品久久包臀| 亚洲一区在线观看免费| 91精品国产综合久久久久久漫画| 精品一区二区在线观看| 欧美激情综合五月色丁香小说| 97se亚洲国产综合在线| 日韩综合小视频| 久久精品一区二区三区不卡牛牛 | 国产成人精品在线看| 亚洲另类在线视频| 欧美一三区三区四区免费在线看 | 在线观看一区二区精品视频| 日本人妖一区二区| 欧美经典一区二区三区| 日本道在线观看一区二区| 麻豆成人av在线| 自拍偷拍国产亚洲| 精品奇米国产一区二区三区| 99精品视频在线观看| 日韩国产欧美在线播放| 国产日韩精品一区二区浪潮av| 欧美图区在线视频| 成人午夜激情视频| 蜜桃91丨九色丨蝌蚪91桃色| 亚洲精品老司机| 久久久久久一二三区| 欧美群妇大交群的观看方式 | 狠狠色2019综合网| 亚洲午夜久久久久久久久电影网| 精品国产伦一区二区三区免费 | 99久久久精品免费观看国产蜜| 亚洲成av人片| 中文字幕综合网| 久久久久久久久久看片| 欧美欧美欧美欧美首页| 91在线观看一区二区| 久久国产精品色婷婷| 亚洲成人精品一区| 最新热久久免费视频| 国产亚洲精品aa| 欧美电影免费观看高清完整版在线观看| a在线播放不卡| 国产乱码字幕精品高清av | 美女国产一区二区| 亚洲韩国精品一区| 樱花影视一区二区| 国产精品理伦片| 国产欧美在线观看一区| 久久色在线观看| 欧美变态tickle挠乳网站| 欧美肥大bbwbbw高潮| 在线亚洲精品福利网址导航| av资源站一区| 成人免费高清在线观看| 国产不卡视频一区| 国产精品一二三四| 国产福利精品一区二区| 国产成人综合自拍| 国产成人在线视频网站| 成人性生交大片| 在线观看日韩国产| 99免费精品视频| 不卡的av中国片| www.激情成人| 一本大道av伊人久久综合| 91浏览器入口在线观看| 色哟哟国产精品免费观看| 欧美中文字幕亚洲一区二区va在线 | 欧美视频中文字幕| 欧美亚洲免费在线一区| 欧美日韩亚州综合| 欧美日韩不卡在线| 91精品国产色综合久久久蜜香臀| 在线播放/欧美激情| 日韩欧美一区二区在线视频| 欧美大肚乱孕交hd孕妇| 精品国产一区二区三区不卡| 久久婷婷成人综合色| 日本一区二区免费在线| 亚洲精品视频在线观看免费| 亚洲午夜电影在线观看| 日韩精品五月天| 国产一区二区在线观看免费 | 欧美一a一片一级一片| 欧美日韩国产在线播放网站| 精品少妇一区二区三区日产乱码 | 95精品视频在线| 欧美日本不卡视频| 久久久99久久| 亚洲一区二区在线观看视频| 蜜桃视频一区二区| av动漫一区二区| 91精品国产色综合久久ai换脸| 久久久高清一区二区三区| 日韩理论片在线| 欧美bbbbb| av电影在线观看完整版一区二区| 欧美亚洲国产一区二区三区 | 亚洲伊人色欲综合网| 麻豆精品一区二区综合av| 99视频精品全部免费在线| 欧美日本一道本| 国产人久久人人人人爽| 亚洲成av人片在线观看| 国产麻豆精品theporn| 欧美探花视频资源| 久久免费视频一区| 亚洲成人一区二区在线观看| 国产电影一区二区三区| 欧美日韩亚洲综合在线| 中文字幕av资源一区| 午夜成人免费视频| fc2成人免费人成在线观看播放 | 欧美高清精品3d| 国产蜜臀97一区二区三区| 亚洲成人1区2区| 97久久精品人人做人人爽50路| 日韩欧美精品在线| 亚洲一二三四区不卡| 成人精品免费看| 欧美精品一区二区三区一线天视频| 亚洲精品亚洲人成人网在线播放| 久久丁香综合五月国产三级网站| 欧美性色黄大片| 亚洲视频一区在线| 国产黄色精品网站| 精品国产第一区二区三区观看体验| 亚洲自拍与偷拍| 在线观看视频一区二区欧美日韩| 久久精品日产第一区二区三区高清版 | 国产成人综合网站| 欧美精品一二三| 亚洲黄色录像片| 不卡电影一区二区三区| 久久综合av免费| 另类小说一区二区三区| 欧美色综合影院| 亚洲影院理伦片| 久久久精品影视| 欧美精品一区二区在线观看| 日韩精品午夜视频| 91国偷自产一区二区三区观看 | 色哟哟国产精品免费观看| 日本一二三不卡| 99久久国产综合精品色伊| 日韩一区二区精品在线观看|