首先,执行ipconfig确认自己电脑的ip地址

可以得到我的电脑的ip地址为192.168.43.15,网关地址为192.168.43.1
打开wireshark抓包工具,ping网关,看看会发生什么


命令行中,我们发送了4个具有32B的数据,从抓包工具中,我们可以看出该命令采用的是icmp协议

第1帧

该帧序号为1,发生在第0.00s,源地址为192.168.43.15(本机),目标地址为192.168.43.1(网关),协议为ICMP协议,长度为74B,信息: Echo (ping) request id=0x0001, seq=11/2816, ttl=128 (reply in 2)

从图中可以看出,该层一共40B,其中控制信息8B,数据信息32B,
第一个控制信息

Type字段占1B,表示类型,8代表请求类型,0代表回复类型

Code字段占1B,暂不清楚作用。

Checksum字段,占2B,用来校验该层数据是否正确,该帧中Checksum Status为good,表示该帧未发生错误,为正常帧。

标识符字段,占2B,该帧为0x0001(0x0100是什么?)

sequence序列号字段,占2B,该帧为0x000b(0x0b00是什么?)

接下来为32B的数据字段,字段内容为a-w 23B,接着a-i 9B,共32B
总结:ICMP层,全称Internet Control Message Protocol,网络控制信息协议,共40B,包括8B的头部和32B的内容部分,8B = Type字段(1B) + Code字段(1B) + Checksum字段(2B) + Identifier标识符字段(2B) + Sequence序列号字段(2B),32B = a-w 23B + a-i 9B。
IP层

IP层共20B,作用是表明该帧的源IP和目标IP,

该字节的前4位表示IP版本,后4位表示IP层的长度
在该帧中,前4位0x0100表示IP版本为IP 4版本,后4位0x0101表示该IP层头部长度为20B(数字*4,1个单位表示4B,5个单位表示20B)

该字段占1B,不清楚作用

Total Length字段占2B,表示IP层的总长度(IP头+IP内容部),该帧中,为60,表示60B,由20BIP头部和40BIP数据部分组成

标识符字段,占2B

共2B,其中flag占前3位,offset偏移占13位

TTL字段,占1B

内容部分采用协议,占1B,该帧中,0x01表示内容部分为ICMP协议

Header Checksum,占2B,

源IP地址,占4B

目的地IP,占4B
总结,IP层头部共20B,20B = Version(0.5B) + Header Length(0.5B) + 不同服务器属性(1B) + 总长度(2B) + 标识符(2B) +
Flag(3位) + 偏移(13位) + TTL (1B) + Procotol(1B) + Header Checksum(2B) + Source IP(4B) + destination IP(4B)
数据链路层

数据链路层共14B,

目的MAC地址,占6B

源MAC地址,占6B

网络层协议,Type字段,占2B,其中0x0800表示IPv4协议
总结,数据链路层共14B,其中14B = 目的地MAC(6B) + 源MAC(6B) + 网络层协议(2B)
ping回复信息

这个帧基本和上一个一样,我这里记录一下不一样的地方。
共同点:基本都一样,比如帧长度都是74B = 14B(数据链路层) + 20B(网络层) + 40B(ICMP层)
不同点:
ICMP层

ICMP层的type字段不一样,该type为0,之前请求的为8
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |