Chapter 3 _ IP Internet Protocol IP header IP protocol is the most core protocol in the TCP/IP protocol family. All TCP, UDP, ICMP, and IGMP data are transmitted in IP datagram format. The IP address provides unreliable and connectionless services. Unreliable: IP datagram cannot be successfully delivered to the destination. Reliability is provided by upper layers (such as TCP. No connection: the IP address does not maintain any status information about subsequent datagram. The processing of each datagram is independent of each other. IP datagram can be received without sending order. IP datagram format: IP datagram is transmitted in byte sequence using bit endian. (1) 4-bit version: indicates the version number (2) 4-bit Header Length: the number of 32-bit characters in the header. The maximum value is 15*32/8 = 60 bytes. The value of a common IP datagram field is 5, that is, the header is 5*32/8 = 20 bytes. (3) TOS: 3bit priority field (ignored), 4bitTOS subfield, minimum latency (Telnet, Rlogin), maximum throughput (FTP), maximum reliability (SNMP ), minimum fee (NNTP, User Network News ). Only 1bit can be set in 4bit. If the 4bit value is 0, it indicates a general service. (4) 16-bit total length field: the length of the entire IP datagram, in bytes. It can be up to 65535 bytes, but most links will fragment it. (5) 16-bit identifier: uniquely identifies each datagram sent by the host. Each sent packet is added with a value of 1 because the IP address is connectionless, therefore, this value should be used for data reaggregation. (6) TTL: sets the maximum number of routers that a datagram can pass. Each time a router passes through a route, 1 is subtracted and 0 is discarded. (7) First, set the test field to 0, and then perform a binary inverse sum for the first 16bit of China and the United States. The result is included in the test field. When a data report is received, the sum of 16 bits in the header is also obtained. If the calculation result is 1, the result is correct. Otherwise, the packet is discarded. ICMP, IGMP, UDP, and TCP adopt the same test algorithm. In terms of IP route selection, the IP reason is simple. If the source host is directly connected to the target host or on a shared network, IP datagram is directly sent to the target host, otherwise, it is sent to the default vro and forwarded by the vro. Most user systems can be configured as routers. The IP layer has a route table in the memory. When receiving a datagram and sending it, you need to search for the table. When a datagram comes from a network interface, the IP address checks whether the destination address is one of the local addresses or a broadcast address. If so, the datagram is sent to the protocol module specified by the IP header protocol field for processing. If not, if the IP address layer of the host is set to vro, data packets are forwarded; otherwise, data is discarded. Each entry in the IP route table includes the destination IP address, the next route address, and the identifier. This completes the function (in order) for the IP router of the specified network interface for datagram transmission. search the route table to find the table that exactly matches the destination address. 2. Search the route table and find the table wood that matches the destination network number. 3. Search for the default table in the route table. If none of the above steps are successful, the system returns "host inaccessible" or "Network inaccessible error ". Specify a vro for a network without specifying a vro for each host. This reduces the number of Route tables. The destination IP address of the datagram never changes. Each link layer may have different data frame headers, And the destination address of the Link Layer always refers to the link layer address of the next stop. Subnet addressing because Class a B addresses allocate too much space to the host, the host number is then divided into A subnetwork number and A host number, and the subnet mask is used to indicate which is the network number, which is the host number. The mask is a 32-bit value. 1 indicates the network number, and 0 indicates the host number.