Learning: ARP protocol / packet analysis

The ARP (the Address Resolution Protocol) i.e., ARP , for implementing the IP address to MAC address mapping, i.e., is achieved by the destination IP find the corresponding MAC address .

In network communications, a host and a host communication packets need to be encapsulated according to the OSI model from top to bottom , when the complete package data, and then sent out. Therefore, the communication in the LAN, not only the source and destination IP address encapsulated , also requires the source / destination MAC encapsulation .

Upper layer application concerned more MAC address do not care about the IP address, the need to learn the MAC address of the destination host's ARP protocol to complete the data package .


Question: A within the network when the host sends a message to the communication between the host B is how?

ARP request process:

1、主机A先在ARP缓存表中查找主机B的MAC地址

2、如果在A的ARP缓存表中找到了,那么就继续数据封装通信。如果没有找到主机A会先发送ARP的广播包(里面包括了A的IP地址和MAC地址、主机B的IP地址)

3、既然是广播帧那么内网中的所有存活主机都会收到该ARP的广播包

4、存活主机会进行检查自身IP地址是否与广播包中的目的IP地址一致,如果不一致的话进行丢弃。如果一致那么就会将主机A的IP和MAC地址添加到自己的ARP缓存表里面,然后再将自己的MAC地址和ARP响应包通过单播方式发送给主机A

5、然后主机A就可以给主机B发送消息

ARP packet analysis:

win10: 192.168.1.104

win2008: 192.168.1.101

. 1, the ARP request packet:

Ethernet Destination address: destination host hardware address, destination address ff:ff:ff:ff:ff:ff, it is a broadcast address

Ethernet source address: source host hardware address

Frame Type: ARP: 0x0806, RARP: 0x8035

Hardware type : Hardware type, identifying the link layer protocol

Protocol type: Protocol type, identifies the network layer protocol

Hardware size : Hardware address, MAC address length identifier, where six bytes (48bti)

Protocol size: 协议地址大小,标识IP地址长度,这里是4个字节(32bit)

Opcode: 操作代码,标识ARP数据包类型,1表示请求,2表示回应

Sender MAC address :发送者MAC

Sender IP address :发送者IP

Target MAC address :`目标MAC,此处全0表示在请求

Target IP address: 目标IP


2、ARP响应包:

响应包与请求包大致相同,不同地方为Opcode为2,源/目IP和MAC地址相反,Target MAC address被补充

Guess you like

Origin www.cnblogs.com/zpchcbd/p/12288199.html