< see the first volume of TCP/IP > About Network layer and protocol details---IP protocol

Source: Internet
Author: User

When it comes to IP protocols, you must first say the two features of the IP protocol:

(i) unreliability (unreliable)

Unreliability means that it does not guarantee that the IP datagram can successfully reach the destination, IP can only do to provide the best transport services, IP has a simple error handling algorithm: Discard the data, and then send an ICMP message to the source end, Any reliability must be provided by the Protocol on the previous layer.

(ii) no connectivity (connectionless)

Non-connectivity means that IP does not maintain any status information about subsequent datagrams (datagram), that the datagram is parallel to each other, and thatIP does not maintain subsequent state information .

The format of the IP datagram is as follows:

The transmission of IP datagram uses the big tail way, the big tail way is the normal way that people write data, but in the computer it seems that it is not normal, if you touch some machine language or some binary code rewrite will know the computer is generally stored in the way the data is a small tail way, Small tail way in layman's terms, from right to left to read/write bytes, more information on their own Baidu.

The TOS field is divided into two parts with a 3bit priority subfield and a 4bit service Type field and a 1bit unused bit but the TOS that must be 0,4bit are represented: 1. Minimum delay 2. Maximum throughput 3. Maximum reliability and minimum cost. Only 1bit can be placed in the 4bit. If all 4bit is 0 then it means a General service.

The total Length field refers to the length of the entire IP datagram, in bytes, using the header Length field and the total Length field, to know the exact location and length of the contents of the package in the entire IP datagram. Because the total number of bits in this field is 16, the IP datagram can be up to 65535 bytes long, and the value of the field changes when the IP datagram is fragmented by the MTU. Identifier fields are related to shards and are discussed in detail later.

The necessity of the total Length field: Although the minimum frame length of the Ethernet is 46 bytes, the IP data may be shorter to fill some data to achieve the minimum length, if there is no total Length field, the IP layer will not know how many bytes in 46 bytes are the contents of the IP datagram.

TTL is the maximum number of routers a datagram can pass, he specifies the lifetime of the datagram, theinitial value of the TTL is usually set by the host , once the number of a route it will be subtracted 1, when the field equals 0 o'clock, the datagram will be discarded, and send an ICMP message to notify the source host, This is also a simple algorithm for IP protocol error checking.

The first Test and field is the test and code calculated based on the IP header and does not calculate the subsequent data.

Selection of IP routing

If the destination host and the source host are directly connected or on a shared network (Ethernet or Token Ring network) then the IP datagram is sent directly to the destination host, otherwise the host sends the datagram to the default router, which is forwarded by the router, most of the hosts are using this simple mechanism. Most of today's user systems, including almost all UNIX systems, are configured as a single router, and we can specify a host or a simple routing algorithm for it. essentially the difference is that the host never forwards the datagram from one interface to another, while the router forwards the datagram. The host that contains the router function should never forward datagrams unless it is set to that.

In a general system, IP can accept datagrams from tcp,udp,icmp and IGMP (i.e. locally generated datagrams) and send them, or accept datagrams from a network interface and send them, and the IP layer has a routing table in memory. When a datagram is received and continues to be sent, it is searched for the table once, and when the data comes from a certain network interface, the IP first checks whether the destination address is one of the native IP addresses or the IP broadcast address. If this is true, the datagram is sent to the Protocol module specified by the IP Header Protocol field for processing. If the destination address of the datagram is not the address, then: (1) When the IP layer is set as the function of the router, then the datagram is forwarded (2) Otherwise the packet is discarded directly.

Each item in the routing table contains the following information:

(1) The destination IP address, which can be either a network address or a full host address.

(2) IP address of Next station router

(3) flag, where a flag indicates whether the IP address is a network address or a host address, and another flag indicates if the next station router is the true next-station router.

The choice of IP routing is done over and over, as can be seen from this routing table information. IP does not know the full path to any destination. All IP routing provides the IP address of the next router only for datagram transmission, it assumes that the next router is closer to the destination than the host sending the datagram, and that the next station router is directly connected to the host.

IP routing mainly accomplishes these functions:

(1) Search the routing table, look for a table that can match the destination IP address exactly, if found, send the message to the next station specified in the table or directly connected network interface.

(2) Search the routing table, look for a table that can match the destination network number exactly, if found, send the message to the next station router specified in the table or directly connected network interface. All the hosts on the destination network can find the path through this table.

(3) Search the route, look for the table labeled "Default", if found, send the message to the next router specified in the table.

(4) If the above steps are unsuccessful, then the datagram cannot be transmitted, and the application that generates the datagram returns an unreachable host or a network unreachable error.

< see the first volume of TCP/IP > About Network layer and protocol details---IP 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.