Mac frame format, IP datagram format, and ARP datagram format

Source: Internet
Author: User

Mac frame Format:

650) this.width=650; "Width=" 791 "height=" 349 "title=" 0ktxmlwlnkp3y5n{ah6 ' 14a.png "style=" WIDTH:529PX;HEIGHT:207PX; " Src= "Http://s4.51cto.com/wyfs02/M00/80/1C/wKioL1c4SkyxlPO_AACeAAFC2xs838.png" alt= "Wkiol1c4skyxlpo_ Aaceaafc2xs838.png "/>

The Ethernet frame format consists of 5 fields, the first two fields are 6 bytes long destination address and Source Address field, which refers to the hardware address (MAC address) of the network card. The third field is a 2-byte type field that identifies what protocol was used on the previous layer in order to hand over the received Mac frame data to the previous layer of this Protocol. For example, when the value of a Type field is 0x0800, it means that the upper layer is using an IP datagram. The fourth field is a data field with a length between 46~1500 bytes. The last field is a 4-byte frame test sequence FCS (CRC test). The maximum value of 1500 is called the Maximum Transmission Unit (MTU) of the Ethernet, and if the datagram length is greater than this length, the datagram needs to be fragmented. The MTU refers to the maximum length of the payload in the data frame, excluding the length of the frame header.

We can see that in MAC frame format, there is no frame length field, how does the Mac sub-layer know how many bytes of data are taken from the received Ethernet frame to deliver the previous layer? We know that the data sent by Ethernet use Manchester encoded signal, there must be a voltage conversion in the middle of every code in Manchester code, when the sender sends an Ethernet frame, it is not sent other code elements, so the transmitter network adapter interface voltage is no longer changed. This allows the receiver to know the end position of the Ethernet frame.

ARP Datagram format:

650) this.width=650, "title=" D4} @IC%) j5$n~e) $L [z9_~p.png "src=" http://s1.51cto.com/wyfs02/M01/80/1C/ Wkiol1c4vtkxxymaaace1iq9zs8239.png "alt=" Wkiol1c4vtkxxymaaace1iq9zs8239.png "/>

Let's explain some of the fields in the datagram format:

Frame type: ARP protocol type

Hardware type: Refers to the link layer network type, 1 is Ethernet;

Protocol type: Refers to the type of address to be converted, example 0x0800 is an IP address;

Back two address Lengths: 6 bytes and 4 bytes respectively relative to Ethernet address and IP address;

Op Field: OP is 1 for ARP request, OP is 2 for answer;


We actually know the IP address of a machine (host or router), need to find its corresponding hardware address, Address Resolution Protocol ARP is to help us solve this problem. It is to resolve the hardware address used at the data link layer from the IP address used by the network layer. Each host maintains an ARP cache table with the IP address of each host and router on the local area network to the Hardware address mapping table.

When host a sends an IP datagram to a host B on the local area network, it first looks at the IP address of Host B in its ARP cache. If so, the corresponding hardware address is detected in the ARP cache, then the hardware address is written to the Mac frame, then the Mac frame is sent to this hardware address through the LAN. When the IP address of Host B is not found, host a automatically runs ARP, and then finds the hardware address of Host B as follows:

The 1.ARP process broadcasts a packet of ARP requests on the local area network;

2. The ARP process that runs on all hosts on the local area network can receive this ARP request packet;

3. The IP address of Host B is consistent with the IP address to be queried in the ARP Request packet, the ARP Request packet is received, and the ARP response packet is sent to host a, and the address of the ARP response is written in the packet. All other host IP addresses do not correspond to the IP addresses queried in the request group and do not respond to this ARP request grouping.

4. When host a receives a packet of ARP responses from Host B, it writes the IP address of Host B to the mapping of the hardware address in its ARP cache.

Note: ARP is a mapping problem that resolves the IP address and hardware address of a host or router on the same LAN .


IP datagram Format:

650) this.width=650; "title=" uwym]~ $M 7n]4 ' RG@%I6T1LI.png "src=" http://s1.51cto.com/wyfs02/M02/80/1C/ Wkiol1c4w-mqypd9aadpfh1snxk363.png "alt=" Wkiol1c4w-mqypd9aadpfh1snxk363.png "/>

The IP datagram format can describe what the IP protocol does. An IP datagram consists of a header and a data component. The first part of the header is fixed length, a total of 20 bytes. The following are some optional fields whose lengths are variable. Below we say the meanings of the following fields:

4-bit version: for the ipv4,4 bit version field is 4;

Header length: 4 bits, the first length field represents the number of units is 32. Therefore, the minimum value for the header Length field is 5. That is, the minimum length of the header is 20 bytes, and the maximum value 4 bits can represent is 15, that is, the first ministerial degree is the maximum of 60 bytes.

8-bit service type: There are 3 bits to specify the priority of the IP datagram, and 4 bits to indicate the optional service type, and one bit always 0.

16-bit total length: Is the number of bytes in the entire datagram.

16-bit ID: The counter is incremented by 1 for each datagram sent

3-bit identification and 13-bit chip shift for sharding

Time to Live: TTL that indicates the lifetime of the datagram in the network. This field is set by the origin of the emitted datagram. Its purpose is to prevent the inability to deliver the datagram without the unrestricted access to the Internet and to consume network resources in vain;

The 8-bit Protocol field indicates what protocol this packet carries, so that the destination host IP layer knows that the data part should be handed over to that process

16-Bit Header checksum: This field only examines the header of the datagram, but does not include the data section. This is because the router has to recalculate the first checksum for every router that passes through the datagram. The validation of the data is the responsibility of the higher level protocol.
















Mac frame format, IP datagram format, and ARP datagram format

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.