欧美色欧美亚洲高清在线观看,国产特黄特色a级在线视频,国产一区视频一区欧美,亚洲成a 人在线观看中文

  1. <ul id="fwlom"></ul>

    <object id="fwlom"></object>

    <span id="fwlom"></span><dfn id="fwlom"></dfn>

      <object id="fwlom"></object>

      計算機網絡實驗報告(路由算法、Socket編程)

      時間:2019-05-12 06:42:22下載本文作者:會員上傳
      簡介:寫寫幫文庫小編為你整理了多篇相關的《計算機網絡實驗報告(路由算法、Socket編程)》,但愿對你工作學習有幫助,當然你在寫寫幫文庫還可以找到更多《計算機網絡實驗報告(路由算法、Socket編程)》。

      第一篇:計算機網絡實驗報告(路由算法、Socket編程)

      計算機網絡實驗報告

      班級: 姓名: 學號:

      實驗一

      一. 實驗目的及要求

      編寫程序,模擬距離矢量路由算法的路由表交換過程,演示交換后的路由表的變化。

      二. 實驗原理

      距離矢量路由算法是這樣工作的:每個路由器維護一張路由表(即一個矢量),它以網絡中的每個路由器為索引,表中列出了當前已知的路由器到每個目標路由器的最佳距離,以及所使用的線路。通過在鄰居之間相互交換信息,路由器不斷地更新他們的內部路由表。

      舉例來說,假定使用延遲作為“距離”的度量標準,并且該路由器發(fā)送一個列表,其中包含了他到每一個目標路由器的延時估計值;同時,他也從每個鄰居路由器接收到一個類似的列表。假設一個路由器接收到來自鄰居x的一個列表,其中x(i)表示x估計的到達路由器i所需要的時間。如果該路由器知道他到x的延時為m毫秒,那么他也知道在x(i)+m毫秒之間內經過x可以到達路由器i。一個路由器針對每個鄰居都執(zhí)行這樣的計算,就可以發(fā)現(xiàn)最佳的估計值,然后在新的路由器表中使用這個最佳的估計值以及對應的輸出路線。

      三.源程序:

      #include “stdio.h” #include “stdlib.h” #include “malloc.h” #include “graphics.h” #include “dos.h” #define VERNUM 7

      typedef struct {

      int dis;

      int flag;

      int flag2;}RoutNode;

      char tmp[10];RoutNode data[VERNUM][VERNUM];

      void welcome();

      void InitRoutData(FILE* pfile);

      void PrintRoutData();

      void SendInf(int recv, int send);

      void Exchange();

      int main(){

      int start, end, i, j, m, n;

      FILE *pfile;

      welcome();

      pfile = fopen(“1.txt”, “r”);

      if(pfile == NULL)

      {

      printf(“the file wrong,press any key to come back.n”);

      getch();

      return;

      }

      else

      InitRoutData(pfile);

      fclose(pfile);

      printf(“nthe original route table:n”);

      for(i = 0;i

      {

      printf(“%c||”, i + 65);

      for(j = 0;j < VERNUM;j++)

      if(data[i][j].dis > 0)

      printf(“<%c %d> ”, j + 65, data[i][j].dis);

      printf(“n”);

      }

      PrintRoutData();

      getch();

      for(i = 0;i < VERNUM;i++)

      {

      for(m = 0;m < VERNUM;m++)

      for(n = 0;n < VERNUM;n++)

      data[m][n].flag = 0;

      Exchange();

      PrintRoutData();

      getch();

      }

      printf(“nexchange the route table:n”);

      return 0;}

      void welcome(){

      int gdriver=DETECT,gmode;

      registerbgidriver(EGAVGA_driver);

      initgraph(&gdriver, &gmode,“C:Win-TC”);

      cleardevice();

      setbkcolor(CYAN);

      setviewport(0,0,639,479,1);

      clearviewport();

      setbkcolor(BLUE);

      setcolor(14);

      rectangle(200,200,440,280);

      setfillstyle(1,5);

      floodfill(300,240,14);

      settextstyle(0,0,2);

      outtextxy(50,30,“Distance Vector Routing Algorithm”);

      setcolor(15);

      settextstyle(1,0,4);

      outtextxy(260,214,“Welcome to use!”);

      line(0,80,640,80);

      getch();

      delay(300);

      cleardevice();} void InitRoutData(FILE* pfile){

      char num[10];

      int i = 0;

      char c;

      int m, n;

      fseek(pfile, 0, 0);

      for(m = 0;!feof(pfile)&& m < 7;m++)

      {

      for(n = 0;!feof(pfile)&& n < 7;n++)

      {

      while(!feof(pfile))

      {

      c = fgetc(pfile);

      if(c == ',')

      {

      num[i] = '