TCP/IP Detailed learning notes (3)-IP Protocol, ARP protocol, RARP protocol

Source: Internet
Author: User

Put these three protocols together because the three protocols are on the same level, the ARP protocol is used to locate the target host's Ethernet NIC MAC address, and the IP hosts the message to be sent. The data link layer can get the data transfer information from ARP, and the data to be transmitted from IP.

1.IP protocol

The IP protocol is the core of the IP protocol, and all TCP,UDP,IMCP,IGCP data is transmitted in the IP data format. It is important to note that IP is not a reliable protocol, which is to say that the IP protocol does not provide a way for the data not to convey a later processing mechanism-this is considered to be the upper-level protocol--tcp or UDP things to do. So that's where it comes in. TCP is a reliable protocol, and UDP is not as reliable as the difference. This is something, not to mention

1.1.IP Protocol Header

To explain it as a textbook work, I'm interested in the eight-bit TTL field, remember what this field does? This field specifies how many routes the packet will pass through before it is discarded (this shows the unreliability of the IP Protocol packet, which does not guarantee that the data will be delivered), the TTL value of the packet is reduced by 1 per router, and when the TTL of that packet becomes 0, it is automatically discarded. The maximum value of this field is 255, that is, a protocol package is also in the router through 255 times will be discarded, depending on the system, this number is not the same, generally 32 or 64,tracerouter this tool is to work with this principle, The Tranceroute-m option requires a maximum value of 255, which is because the TTL is only 8bit in the IP protocol.

The IP version number is now 4, so it is also called IPV4. Now there are IPv6, and the use is more and more extensive.

1.2.IP Route Selection

When an IP packet is ready, how does the IP packet (or router) send the packet to the destination? How does it choose a suitable path to "deliver"?

The most special case is the destination host and host direct connection, then the host does not have to look for routes, the data can be transmitted directly in the past. As for how to pass directly, this depends on the ARP protocol, which will be discussed later.

In a slightly more general case, the host is connected through several routers (router) and the destination host. Then the router will pass the IP packet information to find an appropriate target for the IP packet, such as the appropriate host, or the appropriate route. The router or host will handle an IP packet in the following way

    1. If the IP Packet's TTL (life cycle) is reached, then the IP packet is discarded.
    2. Search the routing table, prioritize the search for a matching host, and if you can find a target host that exactly matches the IP address, send the packet to the target host
    3. Search the routing table, if the matching host fails, matches the same subnet as the router, which requires "subnet mask (1.3.)" 's assistance. If the router is found, the packet is sent to the router.
    4. Search the routing table, if matching the same subnet router fails, then match the same network number (explained in the first chapter) of the router, if the router is found, the packet is sent to the router.
    5. Search for Lu, if none of the above have failed, search the default route, and if the default route exists, the contract
    6. If all fails, throw away the bag.

This proves once again that IP packets are unreliable. Because it does not guarantee delivery.

1.3. Subnet addressing

The IP address is defined as the network number + host number. But now all the host requires subnet addressing, that is, the host number is subdivided into sub-network number + host number. Finally, an IP address becomes the network number + subnet number + host number. For example, a class Baddress:. . 109. 134. In general, the red part of this IP address is the network number, and the blue part is the subnet number, the green part is the host number. As to how many people represent the subnet number on this issue, this does not have a hard rule, instead of the subnet mask , the campus network is believed that most people have used, in the campus network settings There is a 255.255.255.0 thing, this is the subnet mask. The subnet mask is a binary number sequence of 32bit, in the form of a series of 1 and a series of 0, for example: 255.255.255.0 (binary is 11111111.11111111.11111111.00000000) for the B-class address just now, Because 210.30 is the network number, then the next 109.134 is the subnet number and host number combination, and because the subnet mask only the last eight bit is 0, so the host number is the IP address after eight bit, is 134, and the rest is the subnet number--109.

2. ARP protocol

Remember the Ethernet protocol of the Data link layer, each packet has a MAC address header? We know that every Ethernet card has a MAC address, this address is unique, then how does IP packet know this MAC address? This is the work of the ARP protocol.

ARP (Address Resolution) protocol is a kind of resolution Protocol, originally the host is completely do not know which IP corresponds to which host of which interface, when the host to send an IP packet, will first check their own ARP cache (is a IP-MAC Address table cache), If the Ip-mac value of the query does not exist, then the host sends an ARP protocol broadcast packet to the network, the broadcast packet inside the IP address to be queried, and directly received the broadcast packet of all hosts will query their IP address, if a host received a broadcast packet found themselves eligible, Then a ARP packet containing its own MAC address is prepared to be routed to the host that sent the ARP broadcast, and the broadcast host will update its ARP cache (the place where the Ip-mac table is stored) after it has received the ARP packet. The host sending the broadcast will use the new ARP cache data to prepare the data link layer for the packet to send work.

A typical ARP cache information is as follows, in any system with the "arp-a" command:

will get the result.

Such caches are time-bound, typically 20 minutes (the Berkeley system's derivative system).

3.RARP Protocol (abbreviated)

TCP/IP Detailed learning notes (3)-IP Protocol, ARP protocol, RARP protocol

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.