Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A request and reply of ARP

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

ARP:

We know that the IP address is used at the network layer and above, but when transmitting data frames on the actual network link, the data packets are first received by the NIC and then processed by the upper protocol, so the hardware address of the network must be used in the end. However, there is no simple mapping relationship between IP addresses and hardware addresses of the following networks due to different formats (for example, IP addresses have 32 bits, while hardware addresses of local area network are 48 bits). In addition, new hosts may often be added or removed from a network. Replacing the network adapter also changes the hardware address of the host. ARP solves this problem by storing a mapping table from IP addresses to hardware addresses in the host ARP cache, and this mapping table is frequently updated dynamically (new or deleted over time).

Each host has an ARP cache containing a mapping table of IP addresses to hardware addresses of hosts and routers on its local area network, which are currently known to the host.

Ethernet Frame (RFC 894) Format:

The source address and destination address refer to the hardware address of the network card (also known as MAC address), the length is 48 bits, and it is solidified when the network card is shipped. Using ifcong, the "HWaddr 00:0C:28:0F:35:E3 " section is the hardware address. frame protocol class

The type field has three values, corresponding to IP, ARP and RARP respectively. At the end of the frame is a CRC check code.

The minimum data length in Ethernet frames is 46 bytes and the maximum is 1500 bytes. If the length of ARP and RARP packets is not enough 46 bytes, padding bits should be added at the back. The maximum value of 1500 is called Ethernet's maximum transmission unit (MTU). Different network types have different MTUs. If a packet is routed from Ethernet to a dial-up link, the packet length is greater than the MTU of the dial-up link, and the packet needs to be fragmented. The output of ifcong command also has "MTU:1500", which refers to the maximum length of payload in a data frame, excluding the length of frame header.

ARP datagrams are formatted as follows:

The source MAC address and the destination MAC address appear once in the Ethernet header and once in the ARP request, which is redundant for Ethernet at the link layer, but may be necessary for other types of networks at the link layer.

Hardware type refers to the link layer network type, 1 is Ethernet, protocol type refers to the type of address to be converted, 0x0800 is IP address, the last two address lengths for Ethernet address and IP address are 6 and 4(bytes) respectively,op field is 1 indicates ARP request,op field is 2 indicates ARP reply.

Example: The request frame is as follows (byte counts are added to the front of each line for clarity, and each line is 16 bytes):

Ethernet header (14 bytes)

0000: ff ff ff ff ff ff 00 05 5d 61 58 a8 08 06

ARP frame (28 bytes)

0000: 00 01

0010: 08 00 06 04 00 01 00 05 5d 61 58 a8 c0 a8 00 37

0020: 00 00 00 00 00 00 c0 a8 00 02

Padding bits (18 bytes)

0020: 00 77 31 d2 50 10

0030: fd 78 41 d3 00 00 00 00 00 00 00 00

Ethernet header: the destination host uses the broadcast address, the MAC address of the source host is 00:05:5d:61:58:a8, the upper protocol class

Type 0x0806 indicates ARP.

ARP frame: Hardware type 0x0001 indicates Ethernet, protocol type 0x0800 indicates IP protocol, hardware address (MAC address) length is 6, protocol address (IP address) length is 4,op is 0x0001 indicates MAC address (arp) of request destination host, MAC address of source host is 00:05:5d:61:58:a8, IP address of source host is c 0a8 00 37(192.168.0.55), MAC address of destination host is all 0 to be filled in, IP address of destination host is c 0a8 00 02(192.168.0.2).

For example, if the current link layer network type is Ethernet and the network layer protocol is IP,

Ethernet source address is MAC1, source IP address is IP1,

Ethernet destination address is MAC2, destination IP address is IP2.

ARP request frame should be: ARP reply frame:

Ethernet destination address: ff Ethernet destination address: MAC1

Ethernet Source Address:MAC1 Ethernet Source Address:MAC2

Frame Type:0806 Frame Type: 0806

Hardware type: Ethernet (0001) Hardware type: Ethernet (0001)

Protocol type: IP protocol (0800) Protocol type: IP protocol (0800)

Hardware address length: 6 bytes Hardware address length: 6 bytes

Protocol address length: 4 bytes Protocol address length: 4 bytes

op: 1 op:2

Ethernet address at the sending end:MAC1 Ethernet address at the sending end: MAC2

IP address of sender: IP1 IP address of sender: IP2

Destination Ethernet Address: 00 00 00 00 00 Destination Ethernet Address: MAC1

Destination IP address: IP2 Destination IP address: IP1

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report