计算机网络Lab1

发布时间 2023-11-24 16:10:37作者: Kouun

计算机网络Lab1

实验课程:计算机网络 年级:大二 实验成绩
实验名称:Lab1 Protocol Layer 姓名:沈铭远
实验编号 学号:10225101496 实验日期:2023-11-24
指导教师:王廷 组号 实验时间:1.5h

一、实验目的

  • 学习协议和分层如何在数据包中表示
  • 理解构建网络的关键理念和具体实现
  • 学会使用WireShark抓取、分析数据包

二、实验内容与实验步骤

  • 安装实验工具WireShark

  • 接受数据包、抓取数据包

  • 绘制数据包结构

  • 分析协议开销

  • 分析解复用键

三、实验环境

Mac|WireShark

四、实验过程与分析

  1. curl命令简单获取网站作为流量

    截屏2023-11-24 14.02.52
  2. 用WireShark抓取包:
    ![截屏2023-11-24 14.03.13](/Users/ad/Desktop/计网实验/Lab1 Protocol Layer/截屏2023-11-24 14.03.13.png)

    找到协议为HTTP的包,查看具体内容:![截屏2023-11-24 14.01.23](/Users/ad/Desktop/计网实验/Lab1 Protocol Layer/截屏2023-11-24 14.01.23.png)

  3. 依据协议层次分析

    image-20231124105416275

    使用GET方法的HTTP的图

    Ethernet IP TCP HTTP
    14bytes 20bytes 20bytes 79byes
    合计 133bytes
    • Frame :
      133 bytes![截屏2023-11-24 14.01.09](/Users/ad/Desktop/计网实验/Lab1 Protocol Layer/截屏2023-11-24 14.01.09.png)

    • Ethernet
      14 bytes

      ![截屏2023-11-24 14.01.13](/Users/ad/Desktop/计网实验/Lab1 Protocol Layer/截屏2023-11-24 14.01.13.png)

      Destination Source Type
      6 bytes 4 bytes 2 bytes
    • IP:
      20 bytes (IPv4)
      ![截屏2023-11-24 14.01.17](/Users/ad/Desktop/计网实验/Lab1 Protocol Layer/截屏2023-11-24 14.01.17.png)

      Version Header DSCP Length
      0.5 byte 0.5 byte 1 byte 2 bytes
      Identification Flag Fragment offset Time to live
      2 bytes 1 byte 2 bytes 1 byte
      Protocol Header Checksum Source address Des address
      1 byte 2 bytes 4 bytes 4 bytes
    • TCP

      ![截屏2023-11-24 14.01.23](/Users/ad/Desktop/计网实验/Lab1 Protocol Layer/截屏2023-11-24 14.01.23.png)

      Source Port Des Port Sequence number Ack number
      2 bytes 2 bytes 4 bytes 4 bytes
      Header lenth Flag Window CheckSum
      0.5 byte 1.5 bytes 2 bytes 2 bytes
      Urgent
      2 bytes
    • HTTP:
      79 bytes

      1_HTTP
  4. 估算开销:

    从SYN和ACK开始,到HTTP的TCP后结束,是一整个完整的报文
    ![截屏2023-11-24 15.07.41](/Users/ad/Desktop/计网实验/Lab1 Protocol Layer/截屏2023-11-24 15.07.41.png)
    四个包大小和为:$78+54+133+54=319\text{bytes}$

    其中HTTP的有效数据大小为:$79\text{bytes}$
    所以,开销占比为:$75.2%$,可见开销确实很大,但是这种开销是必要的,而且非常重要

  5. 分析协议复用键/多路分解密钥:

    • Ethernet:
      以太网中的多路分解密钥是其中的Type字段,告知他的高层是IP层
      ![截屏2023-11-24 14.01.13](/Users/ad/Desktop/计网实验/Lab1 Protocol Layer/截屏2023-11-24 14.01.13.png)
      可以从图中看出 Type的值为0x0800,类型为IPv4

    • IP

      IP中的Protocol指向了他的高层:TCP,值为6

      ![截屏2023-11-24 14.01.17](/Users/ad/Desktop/计网实验/Lab1 Protocol Layer/截屏2023-11-24 14.01.17.png)

五、实验结果总结

思考题:

1、Look at a short TCP packet that carries no higher-layer data. To what entity is this packet destined? After all, if it carries no higher-layer data then it does not seem very useful to a higher layer protocol such as HTTP!

答:数据包的目的地是接收计算机的 TCP 协议实体,而不是实现 HTTP 的应用 程序。它是 TCP 对等点 之间交换的控制包,用于管理其连接状态。

2、In a classic layered model, one message from a higher layer has a header appended by the lower layer and becomes one new message. But this is not always the case. Above, we saw a trace in which the web response (one HTTP message comprised of an HTTP header and an HTTP payload) was converted into multiple lower layer messages (being multiple TCP packets). Imagine that you have drawn the packet structure (as in step 2) for the first and last TCP packet carrying the web response. How will the drawings differ?

答:只有第一张结构图有HTTP头部,第二章Tcp的结构图虽然有HTTP负载数据,但是是没有HTTP头部。

3、In the classic layered model described above, lower layers append headers to the messages passed down from higher layers. How will this model change if a lower layer adds encryption?

答:下层加密并添加头部之后,接收方对应的下层将看不到上层的数据,直到数据到对应的加密层解析 后,上层的协议和数据才会显示出来。

4、In the classic layered model described above, lower layers append headers to the messages passed down from higher layers. How will this model change if a lower layer adds compression?

答:压缩类似于加密,压缩之后下层是看不到上层的具体数据信息的,到对应的压缩层才会显示上层数 据 不过不同于加密,因为是压缩的,所以有效载荷也将比压缩之前的有效载荷更短。

总结

  • 利用WireSharp工具分析了TCP/IP协议下的文件包
  • 分析了协议开销
  • 分析了多路分解密钥