TCP/Socket learning ---- ARP datagram format

Source: Internet
Author: User

TCP/Socket learning-ARP datagram format ARP function: During network communication, the application of the source host knows the IP address and port number of the target host, but do not know the hardware address of the target host. The packet is first received by the network adapter and then processed by the upper-layer protocol. If the hardware address of the received data packet does not match that of the local host, it is discarded directly. Therefore, you must obtain the hardware address of the target host before communication. ARP plays a role in obtaining the hardware address of the target host before communication ??? How ARP works: the source host sends an ARP request and asks "what is the hardware address of the host whose IP address is 192.168.0.1", and broadcast the request to the listen network segment (the hardware address of the Ethernet frame header is FF: FF indicates broadcast). The target host receives the broadcast ARP request, if the IP address matches the IP address of the local host, an ARP response packet is sent to the source host and the hardware address is entered in the response packet. ARP cache table: each host maintains an ARP cache table, which can be viewed using the arp-a command. The table items in the cache table have an expiration time (generally 20 minutes). If a table item is not used again within 20 minutes, the table item becomes invalid and the next request ARP will be sent. Figure 36.7ARP datagram format: Ethernet header: consists of three parts: Ethernet Destination Address, 6byte Ethernet source address, 6byte frame type, 2 byte datagram body: 28 bytes of ARP request/response composition: hardware 2 byte Protocol 2 byte hardware address length 1 byte Protocol address length 1 byteop 2 byte (what is op ???) Sending end ethernet address 6 byte (sending end MAC address) sending end IP address 4 byte destination ethernet address 6 byte (destination MAC address to be obtained) Destination IP address 4 byte note: the hardware type refers to the link layer network type. 1 indicates the Ethernet protocol type refers to the address type of the yo conversion. 0 X indicates the IP address. The op field is 1, indicating the ARP request, and 2 indicates the ARP response example: the following is a specific example. The request frame is as follows (16 bytes are added to the front of each line for clarity): Ethernet header (14 bytes) 0000: ff 00 05 5d 61 58 a8 08 06ARP frame (28 bytes) 0000: 00 010010: 08 00 06 04 00 01 00 05 5d 61 58 a8 c0 a8 00 370020: 00 00 00 00 00 c0 a8 00 02 fill bits (18 bytes) 0020: 00 77 31 d2 50 100030: fd 78 41 d3 00 00 00 00 00 00 Ethernet header: the destination host uses a broadcast address, and the MAC address of the source host is 00: 05: 5d: 61: 58: a8. The upper-layer protocol type 0x0806 indicates ARP. ARP frame: the hardware type 0x0001 indicates Ethernet, the protocol type 0x0800 indicates IP, the hardware address (MAC address) is 6, and the Protocol address (IP address) the length is 4 (the two are 1 byte in length), and the op is 0x0001, which indicates the MAC address of the target host, the MAC address of the source host is 00: 05: 5d: 61: 58: a8, And the IP address of the source host is c0 a8 00 37 (192.168.0.55). The MAC address of the target host is 0, the IP address of the target host is c0 a8 00 02 (192.168.0.2 ). Because Ethernet requires a minimum Data Length of 46 bytes and a ARP frame length of only 28 bytes, there is an 18-byte fill bit. The content of the fill bit is not defined and is related to the specific implementation. Response frame: Ethernet header 0000: 00 05 5d 61 58 a8 00 05 5d a1 b8 40 08 06ARP frame 0000: 00 010010: 08 00 06 04 00 02 00 05 5d a1 b8 40 c0 a8 00 020020: 00 05 5d 61 58 a8 c0 a8 00 37 fill position 0020: 00 77 31 d2 50 100030: fd 78 41 d3 00 00 00 00 00 00 00 Ethernet header: destination host MAC address: 00: 05: 5d: 61: 58: a8, the MAC address of the source host is 00: 05: 5d: a1: b8: 40. The upper-layer protocol type 0x0806 indicates ARP. ARP frame: the hardware type 0x0001 indicates Ethernet, the protocol type 0x0800 indicates IP protocol, the hardware address (MAC address) is 6, the Protocol address (IP address) is 4, and the op is 0x0002 indicates a response, the MAC address of the source host is 00: 05: 5d: a1: b8: 40, the IP address of the source host is c0 a8 00 02 (192.168.0.2), and the MAC address of the target host is 00: 05: 5d: 61: 58: a8. The destination host IP address is c0 a8 00 37 (192.168.0.55)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.