"TCP/IP Detailed Volume 1: Protocol"--3rd IP: Internet Protocol (reprint)

Source: Internet
Author: User

1. Introduction

IP is the most central protocol in the family of TCP/IP protocols. All TCP, UDP, ICMP, and IGMP data are transmitted in an IP datagram format. IP provides unreliable, non-connected datagram delivery services.

(1) unreliable

It does not guarantee that IP datagrams will successfully reach their destination. IP only provides the best transport service. In the event of an error, such as a router temporarily running out of buffers, IP has a simple error-handling algorithm: Discards the datagram and sends an ICMP message to the source end. The reliability of any requirement must be provided by the upper layer (for example, TCP).

(2) No connection

IP does not maintain any status information about subsequent datagrams. The processing of each datagram is independent of each other. That is, IP datagrams can not be received in the order they were sent. If a source sends two consecutive datagrams (first A, then B) to the same beacon, each datagram is routed independently and may choose a different route, so B may arrive before a arrives.

2. IP header

The IP datagram is shown in format 3-1.

IP Datagram Description:

(1) The general IP First Minister is 20 bytes unless the option field is included. The highest bit is on the left, which is recorded as 0 bit;

(2)the 4 byte value is transmitted in the following order: first 0~7 bit, second 8~15 bit, then 1 6~23 bit, and finally 24~31 bit. This transmission order is called the big endian byte order . Since all binary integers in the TCP/IP header are transmitted in the network, this order is called the network byte order . Machines that store binary integers in other forms, such as the little endian format, must convert the header into a network byte order before transmitting the data.

(3) the current protocol version number is 4, so IP is sometimes referred to as IPv4.

(4) the service type (TOS) field includes a 3 bit priority subfield (now ignored), 4 bit TOS subfield and 1 bit unused bit, but must be set to 0. The 4 bit TOS represents: Minimum delay, maximum throughput, maximum reliability, and minimum cost. Only 1 bits can be placed in 4 bit. If all 4 bits are 0, then it means General Service. Figure 3-2 Lists the recommended TOS values for different applications.

Note: The TOS feature is not supported by most TCP/IP implementations today.

(5) The total Length field refers to the length of the entire IP datagram, in bytes. Because the word is 16 bits long, the IP datagram can be up to 65535 bytes in length.

Note: Although you can transfer an IP datagram that is up to 65535 bytes long, most of the link layers will fragment it. Also, the host requires that it cannot receive more than 576 bytes of datagrams.

(6) the Identity field uniquely identifies each datagram sent by the host. It usually adds 1 to the value of each message sent.

(7) The TTL time-to-live field sets the maximum number of routers that datagrams can pass through. It specifies the time-to-live of the datagram. The initial value of the TTL is set by the source host (typically 32 or 64), and once it passes through a router that handles it, its value is subtracted by 1. When the value of this field is 0 o'clock, the datagram is discarded and an ICMP packet is sent to notify the source host.

(8) the Protocol field, which can identify which protocol transmits data to the IP.

(9) the first Test and the field is based on the IP header calculation of the test and code.

option, which is a variable-length optional information in the datagram. These options are rarely used, and not all hosts and routers support these options.

3.IP route selection

IP routing is simple, especially for hosts. If the destination host is directly connected to the source host (such as a point-to-point link) or both 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 a default router, which is forwarded by the router to the datagram.

Description: Most multi-user systems can be configured as a single router. We can specify a simple routing algorithm that both the host and the router can use. Essentially the difference is that the host never forwards the datagram from one interface to another, while the router forwards the datagram.

(1) IP Datagram Processing process

IP can receive datagrams from TCP, UDP, ICMP, and IGMP (that is, locally generated datagrams) and send them, or receive datagrams (datagrams to be forwarded) from a network interface and send them. the IP layer has a routing table in memory. When a datagram is received and sent, it is searched once for the table. When the datagram comes from a network interface, IP first checks whether the destination IP address is one of the native IP addresses or the IP broadcast address.

If this is the address: The datagram is sent to the Protocol module specified by the IP Header Protocol field for processing. If this is not the address: If the IP layer is set as the function of the router, the datagram is forwarded; otherwise the datagram is discarded.

(2) information contained in the routing table

Each item in the routing table contains the following information:

1) Destination IP address.

It can be either a full host address or a network address, specified by the Flag field in the table. The host address has a host number other than 0 to specify a specific host, and the host number in the network address is 0 to specify all hosts in the network (such as Ethernet, Token Ring).

2) The IP address of the next-hop router, or a network IP address with a direct connection.

The next-hop router refers to a router on a directly connected network that can forward datagrams. The next-hop router is not the ultimate goal, but it can forward the datagram that is sent to it for the ultimate purpose.

3) logo.

One of the flags indicates whether the destination IP address is a network address or a host address, and the other flag indicates if the next-hop router is a true next-hop router or a directly connected interface.

4) Specify a network interface for the transmission of datagrams.

(3) IP routing features that are primarily accomplished

IP routing is performed on a per-hop basis. IP does not know the full path to any destination (except, of course, those that are directly connected to the host). All IP routing options provide only the IP address of the next-hop router for datagram transmissions. It assumes that the next-hop router is closer to the destination than the host sending the datagram, and that the next-hop router is directly connected to the host.

1) Search the routing table for a table that matches the destination IP address exactly (network number and host number must match). If found, sends the message to the next station router or directly connected network interface specified by the table (depending on the value of the Flag field).

2) Search the routing table to find the table that matches the destination network number. If found, the message is sent to the next station router or directly connected network interface specified in the table.

3) Search the routing table for the table labeled "Default". If found, the message is sent to the next station router specified in the table.

Description

(1) If none of the above steps are successful, then the datagram cannot be transmitted. If datagrams that cannot be delivered come from the native, then it is common to return a "host unreachable" or "Network unreachable" error to the application that generated the datagram.

(2) the full host address match is performed before the network number matches. Select the default route only if they fail.

(3) assigning a router to a network without having to specify a router for each host is a fundamental feature of the IP routing mechanism. Doing so can greatly reduce the size of the routing table, for example, routers on the internet have only thousands of of the tables, and not more than 1 million of the table entries.

4. Subnet addressing

All hosts are required to support subnet addressing. Instead of the IP address as a simple network number and a host number, instead, the host number is divided into a subnet number and a host number . The reason is: Class A and Class B addresses allocate too much space for the host number, the number of hosts that can be accommodated separately is 2^24-2 and 2^16-2, and in one network people don't have so many hosts.

Note: the full 0 or all 1 host numbers are not valid, so the total is minus 2.

For example: There is a Class B network address (140.252), in the remaining 16bit, 8 bit for the subnet number, 8 bit for the host number, so that 254 subnets are allowed, each subnet can have 254 hosts.

Description: The subnet hides the details of an internal network organization (a campus or company) to an external router. The size of the routing table is reduced, but the subnet is opaque to the routers inside the subnet.

5. Subnet mask

The partial configuration of any host at boot time is the specified host IP address. In addition to this, you need to know how many bits are used for the subnet number and how many bits are used for the host number. This is determined by the subnet mask during the boot process. The subnet mask is a value with a value of 1, where a bit with a number of 0 is left to the network and subnet number, and the number of bits left for the hostname.

For example, two different subnet mask formats for a Class B address.

The first example, the subnet number and the host number are 8 bit. The second example, the subnet number is ten bit, the host number is 6 bit.

6. Special Case IP Address

Describes 7 special IP addresses. 0 means that all bits are 0;-1 to indicate that all bits are all 1, and NetID, SubnetID, and HostID respectively represent fields that are not full 0 or all 1. The subnet number column is empty to indicate that the address is not subnetting.

7, ifconfig and Netstat commands

(1) the Ifconfig (8) command is typically run at boot time to configure each interface on the host. Because the dial-up interface may be plugged in and out frequently (such as a slip link), the ifconfig must run in some way each time the line is switched on and off. How this process is done depends on the slip software used.

(2) the Netstat (1) command provides the interface information on the system. The-I parameter prints out the interface information, and the-n parameter prints out the IP address instead of the host name.

This command prints the MTU of each interface, the number of input groupings, input errors, output groupings, output errors, conflicts, and the current output queue length.

"TCP/IP Detailed Volume 1: Protocol"--3rd IP: Internet Protocol (reprint)

Related Article

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.