IP address selection is one of the most important functions. A simple process for IP layer processing. Optional data packets can be generated by the local host or another host. In the latter case, the host must be configured as a router; otherwise, the datagram received through the network interface will be discarded If the destination address is not the local machine. Steps for searching a route table by IP Address: 1) Search for a required host address; 2) Search for a matched network address; 3) search for the default table items (generally specified as a network Table item in the routing table, and its network number is 0). For a given vro, you can print out five different flags (FLAG ): u. G. This route is to a gateway (router ). If this flag is not set, the destination is directly connected. H. The route is to a host, that is, the destination address is a complete host address. If this flag is not set, it indicates that the route is to a network, and the destination address is a network address: a network number, or a combination of the network number and subnet number. D. The route is created by the redirection message. M The route has been modified by the redirection message. Flag is very important because it distinguishes indirect routing from direct routing (for direct routing, flag is not set ). The difference is that the Group sent to the direct route not only has the IP address of the specified destination, but also has its link layer address. When a group is sent to an indirect route, the IP address specifies the final destination, but the link layer address specifies the gateway (that is, the next stop router) the complexity of the host route table depends on the network topology of the host. 1) The simplest (and least interesting) situation is that the host is not connected to any network at all. The TCP/IP protocol can still be used for such a host, but it can only communicate with itself! In this case, the route table contains only one loop interface. 2) Next, the host is connected to a LAN and can only access hosts on the LAN. At this time, the route table contains two items: one is the loopback interface and the other is the LAN (such as Ethernet ). 3) if the host can access other networks (such as the Internet) through a single router, proceed to the next step. Generally, add a default table to point to the vro. 4) if you want to add other specific hosts or network routes, the last step is required. When an interface is initialized (usually the interface address is set using the ifconfig command), a direct route is automatically created for the interface. For point-to-point links and loop interfaces, routes are routed to the host (for example, set the H flag ). For broadcast interfaces, such as Ethernet, routes are routed to the network. If an IP datagram does not have the default and matching items of the route, it depends on whether the IP datagram is generated by the host or forwarded (for example, we act as a router ). If a datagram is generated by a local host, an error is returned for the application that sends the datagram, the host is not reachable, or the network is not reachable ". If the packet is forwarded, an error message that is inaccessible to the ICMP Host is sent to the original sender. When an IP datagram is sent to another router, the router that receives the datagram sends an ICMP redirect error message to the sender of the IP datagram. 1) assume that the host sends an IP datagram to R1. This routing decision often happens because R1 is the default route of the host. 2) R1 receives the datagram and checks its route table. R2 is the next stop to send the datagram. When it sends a datagram to R2, R1 detects that the interface it is sending is the same as the interface for reaching the datagram (that is, the LAN of the host and the two routers ). In this way, the router is sent with a redirection packet to provide clues to the original sender. 3) R1 sends an ICMP redirection packet to the host, telling it to send the datagram to r2. ICMP redirection packets: Rules for ICMP redirection packets with different code values: first, the redirection packets can only be generated by the router, but not by the host. In addition, redirect packets are used for the host rather than for the router. Assuming that the router and some other routers participate in a routing protocol, the protocol can eliminate the need for redirection. New Method for initializing a route table: use ICMP routers to advertise and request packets. Generally, the host needs to broadcast or multicast a router request packet after the boot. One or more routers respond to a router notification message. In addition, routers regularly broadcast or multicast Their router notification packets, allowing each host being monitored to update their route tables accordingly. Rfc1256 [deering1991] identifies the two ICMP message formats. Router operation for ICMP Router packet discovery: When the router is started, it regularly sends announcement packets on all broadcast or Multicast Transmission interfaces. To be accurate, these announcement messages are not sent on a regular basis, but randomly transmitted to reduce the probability of conflict with other routers on the subnet. Generally, the interval between two announcements is 450 seconds and 600 seconds. The default life cycle of a given notification message is 30 minutes. Another time to use the lifecycle domain is when an interface on the vro is disabled. In this case, the router can send the last advertised message on this interface and set the lifecycle value to 0. In addition to regularly sending notification packets, the router also needs to listen to request packets from the host and send the notification packets to respond to these request packets. If multiple routers exist on the subnet, the system administrator sets a priority level for each router. Host operation of ICMP Router discovery packets: Generally, the host sends three router request packets every three seconds during the boot process. Once a valid notification message is received, the request message is stopped. The host also monitors request packets from neighboring routers. These advertised messages can change the default router of the host. In addition, if the notification message from the current default router is not received, the default router times out. As long as there is a general default vro, The vro will send a notification packet every 10 minutes, the packet's life cycle is 30 minutes. This indicates that the default table items of the host will not time out, even if one or two notification packets are missed. The realization of ICMP Router discovery packets vro discovery packets are generally created and processed by the user process (Daemon.