TCP/IP-03-IP 3.1 Introduction IP is the most core protocol in the TCP/IP protocol family. All TCP, UDP, ICMP, and IGMP data are transmitted in IP datagram format. Many people who are new to TCP/IP provide unreliable, connectionless datagram transmission services, especially those with X. 2 5 or s n a background knowledge. Unreliable (u n r e l I a B l e) means that it cannot guarantee that IP datagram can successfully reach the destination. IP addresses only provide the best transmission service. If an error occurs, for example, if a vro has used up the buffer temporarily, the IP address has a simple error processing algorithm: discard the datagram and then send an ICMP message to the source. Any required reliability must be provided by the upper layer (such as TCP ). The term "c o n e c t I o n l e s" means that IP does not maintain any status information about subsequent datagram. The processing of each datagram is independent of each other. This also indicates that IP datagram can be received without sending order. If A Source sends two consecutive data packets (A and B) to the same sink, each data packet is selected independently, and different routes may be selected, therefore, B may arrive before A arrives. We will briefly introduce each field in the IP address header and discuss the selection of IP routes and subnet content. Two useful commands are also introduced: ipconfig and netstat. The details of some fields in the IP header will be discussed later when these fields are used. RFC 791 [Postel 1981a] is a formal specification file for IP addresses. 3.2 The length of the common IP address header is 2 0 bytes, unless it contains an option field. The highest bit is on the left, marked as 0 bit; the lowest bit is on the right, marked as 31 bit. The 32-bit values of four bytes are transmitted in the following order: the first is 0 ~ 7 bit, followed by 8 ~ 15 bit, then 1 6 ~ 23 bit, last 24 ~ 31 bit. This transmission order is called the big endian byte order. Because all the binary integers in the TCP/IP Header must be transmitted in this order, it is also called the network byte order. Machines that store binary integers in other forms, such as the little endian format, must convert the header to the network byte before data transmission. The current Protocol version is 4, so IP is also called IPv4. Section 3. 1 0 will discuss a new version of the IP protocol. The Header Length refers to the number of 32-bit characters in the header, including any options. Because it is a 4-bit field, the header is up to 6 0 bytes. Te l n e t and R l o g I n interaction applications require the minimum transmission latency because they are mainly used to transmit a small amount of interactive data. On the other hand, FTP file transmission requires the maximum throughput. The maximum reliability is specified for network management (s n m p) and routing selection protocols. Usenet news (NNTP) is the only application that requires the minimum cost. Currently, most TCP/IP implementations do not support the to s feature, but new versions of the system since the 4.3BSD Reno are configured. In addition, new routing protocols such as o s p f and I s-I S can make routing decisions based on the values of these fields. In order to calculate the IP address check of a datagram, the test field is set to 0. Then, calculate the binary inverse sum of each 16 bit in the header (the whole header is regarded as composed of a string of 16 bit characters), and the result is included in the test field. After receiving an IP datagram, the system also sums each 16 bit in the header with a binary inverse code. Because the receiver contains a checksum in the sender's header during the computation process, if the header has no errors during transmission, the receiver's computation result should be 1 in total. If the result is not all 1 (namely, check and error), the IP address discards the received datagram. However, no error messages are generated. The upper layer discovers the lost data packets and re-transmits them. ICMP, IGMP, UDP, and TCP both adopt the same test algorithm, although TCP and UDP contain different fields in the IP header in addition to their own header and data. The RFC 1071 [Braden, Borman and Patridge 1988] section describes how to calculate Internet verification. Because the router often only modifies the t l field (minus 1), when the router forwards a packet, it can add its test, instead of re-computing the entire IP header. R f C1141 [Mallory and Kullberg 1990] provides a very effective method. 3.3 IP Route Selection in terms of concept, IP route selection is simple, especially for hosts. If the target host is directly connected to the source host (such as a point-to-point link) or both are on a shared network (Ethernet or a licensing Ring Network), IP datagram is directly sent to the target host. Otherwise, the host sends the datagram to a default vro and the vro forwards it. Most hosts use this simple mechanism. That is, the IP layer can be configured as either a router or a host. Most of today's multi-user systems, including almost all U n I x systems, can be configured as a router. We can specify a simple routing algorithm that can be used by both the host and the router. Essentially, the difference is that a host never forwards data packets from one interface to another, while a router forwards data packets. A host with the vro function should never forward data packets unless it is set as that. The IP address can receive and send data packets from TCP, UDP, ICMP, and IGMP, or receive and send data packets from a network interface. The IP layer has a route table in the memory. When you receive and send a data packet, it searches for the table once. When a datagram comes from a network interface, the IP address first checks whether the destination IP address is one of the local IP addresses or the IP broadcast address. If so, the datagram is sent to the protocol module specified by the IP header protocol field for processing. If the destination of the datagram is not these addresses, (1) If the IP layer is set as the router function, the datagram is forwarded; otherwise (2) the datagram is discarded. Each item in the route table contains the following information:. Destination IP address. It can be either a complete host address or a network address, which is specified by the flag field in the table .. The IP address of the next (or next hop) router (next-hop router) or the IP address of the directly connected network .? Flag. One flag indicates whether the destination IP address is the network address or host address, and the other indicates whether the next stop router is a real next stop router or a directly connected interface. specify a network interface for data transmission. IP route selection is based on hop-by-hop. The route table information shows that the IP address does not know the complete path to any destination. All IP routes provide only the IP address of the next router for datagram transmission. It assumes that the next-Stop router is closer to the destination than the host that sends the datagram, And the next-Stop router is directly connected to the host. 3.4 subnet addressing all hosts now require support for subnet addressing (RFC 950 [Mogul and Postel 1985]). The IP address is not simply composed of a network number and a host number. Instead, the host number is divided into a sub-network number and a host number. The reason for this is that Class A and Class B addresses allocate too much space for the master host number, and the number of hosts can be 22 4-2 and 21 6-2 respectively. Because all the host numbers 0 or 1 are invalid, we subtract 2 from the total number. It is assigned by the local system administrator to determine whether a subnet is established and how many bits are allocated to the subnet number and host number. For example, there is a Class B network address (140. 252). In the remaining 16 bits, 8 bits are used for subnet numbers, and 8 bits are used for host numbers. In this way, two, five, and four subnets are allowed. Each subnet can have 254 hosts. Many administrators use the natural division method, that is, the first 8 bits in the 16 bits left to the host in the Class B address are used as the subnet address, and the last 8 B I t is used as the host number. In this way, it is easier to determine the subnet number for IP addresses expressed in dotted-decimal notation. However, it is not required that the subnet division of Class A or Class B addresses should be based on bytes. Most of the subnet examples are Class B addresses. In fact, the subnet can also be used for Class C addresses, but it only has a small number of available bits. A subnet with A Class A address is rarely used. 3.5 subnet mask Class B IP Address: 16-bit network number, 8-seat network number, 8-bit host number: indicates the range: 192. x. x. part of the x-255.255.255.0 that any host performs during boot is to specify the Host IP address. Most systems store IP addresses in a disk file for reading during boot. In addition to IP addresses, the host also needs to know how many bits are used for subnet numbers and how many bits are used for host numbers. This is determined by the subnet mask during the boot process. 3.8 ifconfig command so far, we have discussed the link layer and IP layer. Now we can introduce the TCP/IP command for configuring and querying network interfaces. The ipconfig (8) command is generally run at boot to configure each interface on the host. Since the dial-up interface may be frequently connected and hung up (such as the s l ip link), ipconfig must run in some way each time the line is connected and hung up. How this process is completed depends on the s l ip software used. The following figure shows the win32 platform windows-> cmd-> ipconfigWindows 2000 IP ConfigurationEthernet adapter: Connection-specific DNS Suffix.: IP Address ............: 192.168.1.216 Subnet Mask ...........: 255.255.255.0 Default Gateway .........: 192.168.1.13.9 the netstat command also provides interface information on the system. It has different system parameters and commands. The-I parameter prints the interface information, and the-n parameter prints the IP address instead of the host name. Windows> cmd> netstat /? D:/> netstat /? Displays protocol statistics and current TCP/IP network connections. NETSTAT [-a] [-e] [-n] [-s] [-p proto] [-r] [interval]-a Displays all connections and listening ports. -e Displays Ethernet statistics. this may be combined with the-s option. -n Displays addresses and port numbers in numerical form. -p proto Shows connections for the protocol specified by proto; proto may be TCP or UDP. if used With the-s option to display per-protocol statistics, proto may be TCP, UDP, or IP. -r Displays the routing table. -s Displays per-protocol statistics. by default, statistics are shown for TCP, UDP and IP; the-p option may be used to specify a subset of the default. interval Redisplays selected statistics, pausing interval seconds between each display. press CTRL + C to stop redisplaying statistic S. If omitted, netstat will print the current configuration information once.3.10 IP future IP address there are three main problems. This is the result of the rapid growth of the Internet over the past few years. 1) more than half of Class B addresses have been allocated. It is estimated that they will run out in 5 years. 2) 32-bit IP addresses are generally not enough in terms of long-term Internet growth. 3) The current routing structure does not have a hierarchical structure and belongs to a plane (f l a t) structure. Each network needs a route table. As the number of networks increases, a website with multiple networks must allocate multiple Class C addresses instead of Class B addresses. Therefore, the number of Route tables will grow. 3.11 The format of the IP header is described in summary, and various fields in the header are briefly discussed. We also introduced the IP Route Selection, and pointed out that the host's route selection can be very simple: if the target host is directly connected to the network, then the datagram is directly transmitted to the target host, otherwise, it is sent to the default vro. Both the host and vro use the route table for route selection. There are three types of routes in the Table: specific host type, specific network type, and default route type. A table in a route table has a certain priority. When selecting a route, the host route takes precedence over the network route, and the default route is selected only when no other routes are available. The IP route selection is implemented step by step. The destination IP address remains unchanged during the transmission of data packets on different sites, but the encapsulation and destination link layer addresses can be changed on each site. Most hosts and many routers use the default next-Stop router for non-local network datagram. Generally, both Class A and Class B addresses must be divided into subnets. The number of bits used for subnet numbers is specified by the subnet mask. We provide an example to describe in detail, that is, the author's subnet, and introduce the concept of a variable-length subnet. The division of subnets reduces the size of the Internet route table, because many networks can be accessed through a single table. The interface and network information can be obtained through the ipconfig and netstat commands, including the interface IP address, subnet mask, broadcast address, and m t u.