The Role and Message Format of ARP in TCP/IP

Image course, development board –> Taobao store: Wolf FPGA

ConsultationWeChat: MyWork666888

QQ group: 543928922

Recently, Wolf published an article on 100G networking titled “FPGA Project: 100G Network Development Sharing”. It is impressive that it can communicate, but the downside is that it only reaches the MAC layer, and the upper network layers are missing. To interact with computers and other upper-level devices, Wolf has recently delved into ARP, ICMP, and UDP. ICMP mainly implements the ping function, which is often used as a testing tool. The following image shows the actual operation screenshot of the ping function implemented by Wolf under the 100G network.The Role and Message Format of ARP in TCP/IPToday, we will mainly discuss a fundamental concept before implementing ping, which is ARP. ARP stands for Address Resolution Protocol, and it is a key protocol used to resolve network layer IP addresses into data link layer MAC addresses. In a Local Area Network (LAN), devices communicate using MAC addresses, while upper-layer applications use IP addresses. The core function of ARP is to convert the target device’s IP address into the corresponding MAC address, ensuring that data can be correctly transmitted over the physical network.Having discussed its function, let’s look at its working principle: When device A needs to communicate with device B (knowing B’s IP but not its MAC), A sends an ARP request broadcast packet asking, “Who has IP B_IP? Please tell A_MAC.” This broadcast will be received by all devices within the same local area network.Only device B (which has B_IP) will reply with an ARP response unicast packet containing its MAC address: “The MAC corresponding to B_IP is B_MAC.” Other devices will ignore this request. At this point, A knows B’s MAC address. After receiving the response, device A will store the mapping of B_IP and B_MAC in its local ARP cache table, and subsequent communications will directly use this mapping.The Role and Message Format of ARP in TCP/IPNow that we understand its function and principle, let’s discuss its specific message format. First, we need to understand the Ethernet frame format. The message format and field explanations are as follows:The Role and Message Format of ARP in TCP/IPLeading code: 7 bytes of 0x55;

Frame Start Delimiter (SFD): Fixed at 0xd5;

Destination MAC Address: The physical MAC address of the receiving end, occupying 6 bytes. Broadcast address: all 48 bits are 1, i.e., FF-FF-FF-FF-FF-FF.

Source MAC Address: The physical MAC address of the sending end, occupying 6 bytes.

Length/Type: When the value of these two bytes is less than 1536 (hexadecimal 0x0600), it represents the length of the data segment in the Ethernet; otherwise, it indicates which upper-layer protocol the data belongs to in the Ethernet, for example, 0x0800 represents the IP protocol (Internet Protocol), 0x0806 represents the ARP protocol (Address Resolution Protocol), etc.

Data: The length of the data segment in the Ethernet is a minimum of 46 bytes and a maximum of 1500 bytes.

Frame Check Sequence (FCS): To ensure the correct transmission of data, a 4-byte cyclic redundancy check code (CRC check) is added to the end of the data to detect whether the data has been transmitted incorrectly. The CRC data check starts from the Ethernet frame header and does not include the leading code and frame start delimiter.

ARP messages are located in the data portion of the Ethernet. The complete Ethernet frame format containing the ARP message is as follows:The Role and Message Format of ARP in TCP/IPThe detailed ARP packet format and field explanations are as follows:The Role and Message Format of ARP in TCP/IP

Hardware Type: The type of hardware address, 1 indicates Ethernet address.

Protocol Type: The type of protocol address to be mapped, the upper-layer protocol of the ARP protocol is the IP protocol, so this protocol type is for IP protocol, with a value of 0x0800.

Hardware Address Length: The length of the hardware address (MAC address) in bytes. For ARP requests or responses over Ethernet IP addresses, this value is 6.

Protocol Address Length: The length of the IP address in bytes. For ARP requests or responses over Ethernet IP addresses, this value is 4.

OP: Operation code, used to indicate whether the packet is an ARP request or ARP response. 1 indicates ARP request, 2 indicates ARP response.

Source MAC Address: The hardware address of the sender.

Source IP Address: The protocol (IP) address of the sender, such as 192.168.1.102.

Destination MAC Address: The hardware address of the receiver. In the ARP request, since the receiver’s MAC address is unknown, this field is the broadcast address, i.e., 48’hff_ff_ff_ff_ff_ff.

Destination IP Address: The protocol (IP) address of the receiver, such as 192.168.1.10.

Since the minimum Ethernet data segment is 46 bytes, and the total length of the ARP packet is 28 bytes, 18 bytes of data need to be padded after the ARP data segment to meet the Ethernet transmission format requirements. This padding process is called Padding, and the padded data can be any value, but is generally 0.

With this information, we can happily frame the packets. That’s all for today’s discussion on ARP. We will talk about ICMP messages next time when we have the opportunity. If you have a collaborative project based on CMAC for UDP communication, feel free to add me on WeChat at the beginning of the article for cooperation discussions.Some images in this article are sourced from the internet. If there is any infringement, please inform us for deletion.

******* Previous Exciting Articles List ********

FPGA-Zynq Basic Course Content

Ways to Get Started with Zynq

FPGA Image Algorithm: Image Overlay “Ghost” Logo

FPGA Image Algorithm: Horizontal Stripe Removal

FPGA Image Algorithm: Vertical Stripe Removal Technique

Image Course Collection: Image Skills Course + Image Project

FPGA Course Content Upgrade [Pure Logic and Image Development]

FPGA Image Canny Four Image Stitching Display Project

FPGA MPSOC VCU Compression and Decompression Demo

FPGA Image Arbitrary Scaling. Demo2FPGA Image Algorithm: Arbitrary ScalingFPGA Image Algorithm: Guided FilteringWolf Board 001PLUS is online, with first launch discounts ongoingFPGA Hardware: FMC-HDMI4K-MIPI Interface BoardClick the link above for detailsThe Role and Message Format of ARP in TCP/IPThe Role and Message Format of ARP in TCP/IPThe Role and Message Format of ARP in TCP/IPThe Role and Message Format of ARP in TCP/IPThe Role and Message Format of ARP in TCP/IPThe Role and Message Format of ARP in TCP/IPThe Role and Message Format of ARP in TCP/IP

Leave a Comment